diff --git a/.gitmodules b/.gitmodules index 0c1a2eedf..4b15013ec 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,4 +28,7 @@ [submodule "APP_Framework/lib/lorawan/lorawan_devicenode"] path = APP_Framework/lib/lorawan/lorawan_devicenode url = https://gitlink.org.cn/IACU/lorawan_devicenode.git - branch = master \ No newline at end of file + branch = master +[submodule "APP_Framework/lib/lorawan/lorawan_gateway_single_channel"] + path = APP_Framework/lib/lorawan/lorawan_gateway_single_channel + url = https://gitlink.org.cn/IACU/lorawan_gateway_single_channel.git diff --git a/APP_Framework/Applications/Makefile b/APP_Framework/Applications/Makefile index 262ae4911..0f0d2a744 100644 --- a/APP_Framework/Applications/Makefile +++ b/APP_Framework/Applications/Makefile @@ -1,13 +1,13 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_DIR := general_functions app_test SRC_FILES := main.c diff --git a/APP_Framework/Applications/app_test/Kconfig b/APP_Framework/Applications/app_test/Kconfig index 45df5f5d5..3a103a6b3 100644 --- a/APP_Framework/Applications/app_test/Kconfig +++ b/APP_Framework/Applications/app_test/Kconfig @@ -8,7 +8,7 @@ menu "test app" bool "Config test adc" default n if USER_TEST_ADC - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config ADC_DEV_DRIVER string "Set ADC dev path" default "/dev/adc1_dev" @@ -19,7 +19,7 @@ menu "test app" bool "Config test dac" default n if USER_TEST_DAC - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config DAC_DEV_DRIVER string "Set DAC dev path" default "/dev/dac_dev" @@ -30,7 +30,7 @@ menu "test app" bool "Config test fs with sd or usb" default n if USER_TEST_FS - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config FPATH string "Set test file path" default "/test_file" @@ -46,7 +46,7 @@ menu "test app" bool "Config test gpio with led and key" default n if USER_TEST_GPIO - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config GPIO_DEV_DRIVER string "Set gpio dev path" default "/dev/pin_dev" @@ -62,7 +62,7 @@ menu "test app" bool "Config test uart(loraE220)" default n if USER_TEST_LORA - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config LORA_UART_DEV_DRIVER string "Set uart dev path" default "/dev/uart2_dev2" @@ -80,7 +80,7 @@ menu "test app" bool "Config test uart(RS485)" default n if USER_TEST_RS485 - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config RS485_UART_DEV_DRIVER string "Set uart dev path" default "/dev/uart1_dev1" @@ -95,7 +95,7 @@ menu "test app" bool "Config test rtc" default n if USER_TEST_RTC - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config RTC_DEV_DRIVER string "Set rtc dev path" default "/dev/rtc_dev" @@ -110,7 +110,7 @@ menu "test app" bool "Config test hwtimer" default n if USER_TEST_HWTIMER - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config HWTIMER_TIMER_DEV_DRIVER string "Set pin dev path" default "/dev/timer0_dev0" @@ -125,7 +125,7 @@ menu "test app" bool "Config test watchdog" default n if USER_TEST_WDT - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config WDT0_DEV_DRIVER string "Set wdt dev path" default "/dev/wdt0_dev0" @@ -137,7 +137,7 @@ menu "test app" bool "Config test lcd in PrivOpen" default n if USER_TEST_LCD_EDU - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config EDU_LCD_DEV_DRIVER string "Set lcd dev path" default "/dev/lcd_dev" @@ -149,7 +149,7 @@ menu "test app" bool "Config test touch" default n if USER_TEST_TOUCH - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config TOUCH_DEV_DRIVER string "Set touch dev path" default "/dev/touch_dev" @@ -164,7 +164,7 @@ menu "test app" bool "Config test i2c" default n if USER_TEST_I2C - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config I2C_DEV_DRIVER string "Set i2c dev path" default "/dev/i2c1_dev0" @@ -176,7 +176,7 @@ menu "test app" bool "Config test can" default n if USER_TEST_CAN - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config CAN_DEV_DRIVER string "Set can dev path" default "/dev/can2_dev1" @@ -189,7 +189,7 @@ menu "test app" bool "Config test camera with lcd" default n if USER_TEST_CAMERA - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config CAMERA_DEV_DRIVER string "Set camera dev path" default "/dev/camera_dev" @@ -211,7 +211,7 @@ menu "test app" bool "Config test ethernet only for edu-riscv64" default n if USER_TEST_ETHERNET - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES choice prompt "set ethernet role as client or server" default ETHERNET_AS_SERVER @@ -229,7 +229,7 @@ menu "test app" bool "Config test w25q128 device" default n if USER_TEST_FLASH - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config FLASH_DEV_DRIVER string "Set flash dev path" default "/dev/qspi_W25Q128" diff --git a/APP_Framework/Applications/app_test/Makefile b/APP_Framework/Applications/app_test/Makefile index 5215f5091..399fe1eca 100644 --- a/APP_Framework/Applications/app_test/Makefile +++ b/APP_Framework/Applications/app_test/Makefile @@ -1,6 +1,5 @@ include $(KERNEL_ROOT)/.config - -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs ifeq ($(CONFIG_USER_TEST_SEMC),y) @@ -23,7 +22,7 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := test_shell.c SRC_FILES += test_hash.c ifeq ($(CONFIG_USER_TEST_ADC),y) diff --git a/APP_Framework/Applications/app_test/test_adc.c b/APP_Framework/Applications/app_test/test_adc.c index c8cb94bfc..ceceec161 100644 --- a/APP_Framework/Applications/app_test/test_adc.c +++ b/APP_Framework/Applications/app_test/test_adc.c @@ -21,7 +21,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES void TestAdc(void) { diff --git a/APP_Framework/Applications/app_test/test_camera.c b/APP_Framework/Applications/app_test/test_camera.c index 5f9c03e65..442bfd615 100644 --- a/APP_Framework/Applications/app_test/test_camera.c +++ b/APP_Framework/Applications/app_test/test_camera.c @@ -21,7 +21,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES static uint16_t image_buff[384000]; diff --git a/APP_Framework/Applications/app_test/test_can.c b/APP_Framework/Applications/app_test/test_can.c index 046503642..c19abecdb 100644 --- a/APP_Framework/Applications/app_test/test_can.c +++ b/APP_Framework/Applications/app_test/test_can.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES void TestCAN(void) diff --git a/APP_Framework/Applications/app_test/test_dac.c b/APP_Framework/Applications/app_test/test_dac.c index 4aa105eb1..37ac2bf1c 100644 --- a/APP_Framework/Applications/app_test/test_dac.c +++ b/APP_Framework/Applications/app_test/test_dac.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES void TestDac(void) { diff --git a/APP_Framework/Applications/app_test/test_ethernet.c b/APP_Framework/Applications/app_test/test_ethernet.c index a94a8c15c..9f4a4ce8f 100644 --- a/APP_Framework/Applications/app_test/test_ethernet.c +++ b/APP_Framework/Applications/app_test/test_ethernet.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #include diff --git a/APP_Framework/Applications/app_test/test_flash.c b/APP_Framework/Applications/app_test/test_flash.c index e2ea3be86..fb12f461a 100644 --- a/APP_Framework/Applications/app_test/test_flash.c +++ b/APP_Framework/Applications/app_test/test_flash.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES void TestFlash(void) { diff --git a/APP_Framework/Applications/app_test/test_fs.c b/APP_Framework/Applications/app_test/test_fs.c index 280d599c8..e0a2c2339 100644 --- a/APP_Framework/Applications/app_test/test_fs.c +++ b/APP_Framework/Applications/app_test/test_fs.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #define MAX_READ_LENGTH 1000 diff --git a/APP_Framework/Applications/app_test/test_gpio.c b/APP_Framework/Applications/app_test/test_gpio.c index ea2262416..16bbfbb89 100644 --- a/APP_Framework/Applications/app_test/test_gpio.c +++ b/APP_Framework/Applications/app_test/test_gpio.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #ifdef BOARD_EDU_RISCV64_EVB #define BSP_LED_PIN 29 diff --git a/APP_Framework/Applications/app_test/test_hwtimer.c b/APP_Framework/Applications/app_test/test_hwtimer.c index c44a63bc3..9e6f7f981 100644 --- a/APP_Framework/Applications/app_test/test_hwtimer.c +++ b/APP_Framework/Applications/app_test/test_hwtimer.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #define BSP_LED_PIN 134 #define NULL_PARAMETER 0 diff --git a/APP_Framework/Applications/app_test/test_i2c.c b/APP_Framework/Applications/app_test/test_i2c.c index 5428d9296..76881b92e 100644 --- a/APP_Framework/Applications/app_test/test_i2c.c +++ b/APP_Framework/Applications/app_test/test_i2c.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #define I2C_SLAVE_ADDRESS 0x0012U diff --git a/APP_Framework/Applications/app_test/test_lcd.c b/APP_Framework/Applications/app_test/test_lcd.c index 0e8b4be28..eee200d7a 100755 --- a/APP_Framework/Applications/app_test/test_lcd.c +++ b/APP_Framework/Applications/app_test/test_lcd.c @@ -20,7 +20,7 @@ #include -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #ifdef CONFIG_K210_LCD void LcdDemo(void) diff --git a/APP_Framework/Applications/app_test/test_lcd_edu.c b/APP_Framework/Applications/app_test/test_lcd_edu.c index edb1ac96c..e1dddbfd2 100644 --- a/APP_Framework/Applications/app_test/test_lcd_edu.c +++ b/APP_Framework/Applications/app_test/test_lcd_edu.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #define GRAPHIC_CTRL_RECT_UPDATE 0x00 #define LCD_STRING_TYPE 0 diff --git a/APP_Framework/Applications/app_test/test_loraE220.c b/APP_Framework/Applications/app_test/test_loraE220.c index 45eddd69b..90682c990 100644 --- a/APP_Framework/Applications/app_test/test_loraE220.c +++ b/APP_Framework/Applications/app_test/test_loraE220.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #define NULL_PARAMETER 0 #define E220_CFG_LENGTH diff --git a/APP_Framework/Applications/app_test/test_musl.c b/APP_Framework/Applications/app_test/test_musl.c index bfa1ba1f7..ce9432b5a 100644 --- a/APP_Framework/Applications/app_test/test_musl.c +++ b/APP_Framework/Applications/app_test/test_musl.c @@ -20,7 +20,7 @@ #include -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #if defined(CONFIG_MUSL_LIBC) && defined(CONFIG_FS_AUTOMOUNTER) diff --git a/APP_Framework/Applications/app_test/test_rs485.c b/APP_Framework/Applications/app_test/test_rs485.c index 1c90a5190..bbe6f1c4d 100644 --- a/APP_Framework/Applications/app_test/test_rs485.c +++ b/APP_Framework/Applications/app_test/test_rs485.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #define BSP_485_DIR_PIN 24 diff --git a/APP_Framework/Applications/app_test/test_rtc.c b/APP_Framework/Applications/app_test/test_rtc.c index cff31edbc..a7f64d393 100644 --- a/APP_Framework/Applications/app_test/test_rtc.c +++ b/APP_Framework/Applications/app_test/test_rtc.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES void TestRTC(int argc,char *argv[]) { diff --git a/APP_Framework/Applications/app_test/test_touch.c b/APP_Framework/Applications/app_test/test_touch.c index e378b9de6..0eb1cdc88 100644 --- a/APP_Framework/Applications/app_test/test_touch.c +++ b/APP_Framework/Applications/app_test/test_touch.c @@ -24,7 +24,7 @@ #include -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #ifdef CONFIG_BSP_USING_TOUCH void TestTouch(void) @@ -48,7 +48,7 @@ void TestTouch(void) #define LCD_DOT_TYPE 1 #define LCD_SIZE 320 -#elif defined ADD_XIZI_FETURES +#elif defined ADD_XIZI_FEATURES void TestTouch(void) { diff --git a/APP_Framework/Applications/app_test/test_wdt.c b/APP_Framework/Applications/app_test/test_wdt.c index 99115c038..cace0a9cd 100644 --- a/APP_Framework/Applications/app_test/test_wdt.c +++ b/APP_Framework/Applications/app_test/test_wdt.c @@ -20,7 +20,7 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES void TestWDT(int argc, char *agrv[]) { diff --git a/APP_Framework/Applications/connection_app/Makefile b/APP_Framework/Applications/connection_app/Makefile index 65d5842e0..2ed5cc480 100755 --- a/APP_Framework/Applications/connection_app/Makefile +++ b/APP_Framework/Applications/connection_app/Makefile @@ -1,11 +1,11 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y) SRC_DIR += 4g_app diff --git a/APP_Framework/Applications/connection_app/modbus_rtu_app/modbus_rtu_app.c b/APP_Framework/Applications/connection_app/modbus_rtu_app/modbus_rtu_app.c new file mode 100644 index 000000000..82d400802 --- /dev/null +++ b/APP_Framework/Applications/connection_app/modbus_rtu_app/modbus_rtu_app.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2022 AIIT XUOS Lab + * XiUOS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +/** + * @file modbus_rtu_app.c + * @brief support get data from and send data to Modbus rtu server + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022.12.12 + */ +#include +#include +#include +#include + +#define ADAPTER_RTU_DATA_LENGTH 112 +#define ADAPTER_RTU_TRANSFER_DATA_LENGTH ADAPTER_RTU_DATA_LENGTH + 16 + +uint8_t client_join_data[ADAPTER_RTU_TRANSFER_DATA_LENGTH]; + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbport.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define REG_INPUT_START 1000 +#define REG_INPUT_NREGS 4 + +/* ----------------------- Static variables ---------------------------------*/ +static USHORT usRegInputStart = REG_INPUT_START; +static USHORT usRegInputBuf[REG_INPUT_NREGS]; + +/* ----------------------- Start implementation -----------------------------*/ + +eMBErrorCode +eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs ) +{ + eMBErrorCode eStatus = MB_ENOERR; + int iRegIndex; + + if( ( usAddress >= REG_INPUT_START ) + && ( usAddress + usNRegs <= REG_INPUT_START + REG_INPUT_NREGS ) ) + { + iRegIndex = ( int )( usAddress - usRegInputStart ); + while( usNRegs > 0 ) + { + *pucRegBuffer++ = + ( unsigned char )( usRegInputBuf[iRegIndex] >> 8 ); + *pucRegBuffer++ = + ( unsigned char )( usRegInputBuf[iRegIndex] & 0xFF ); + iRegIndex++; + usNRegs--; + } + } + else + { + eStatus = MB_ENOREG; + } + + return eStatus; +} + +eMBErrorCode +eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, + eMBRegisterMode eMode ) +{ + return MB_ENOREG; +} + + +eMBErrorCode +eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, + eMBRegisterMode eMode ) +{ + return MB_ENOREG; +} + +eMBErrorCode +eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete ) +{ + return MB_ENOREG; +} + + +/******************Modbus RTU TEST*********************/ +int AdapterModbusRtuTest(void) +{ + const char *send_msg = "Adapter_Modbus_Rtu Test"; + char recv_msg[256] = {0}; + int baud_rate = BAUD_RATE_115200; + + struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_MODBUS_RTU_NAME); + + struct AdapterData priv_rtu_net; + priv_rtu_net.len = ADAPTER_RTU_TRANSFER_DATA_LENGTH; + priv_rtu_net.buffer = client_join_data; + + + AdapterDeviceOpen(adapter); + AdapterDeviceControl(adapter, OPE_INT, &baud_rate); + + AdapterDeviceJoin(adapter,(uint8_t *)&priv_rtu_net); + + + + eMBErrorCode eStatus; + + eStatus = eMBInit( MB_RTU, 0x0A, 0, 38400, MB_PAR_EVEN ); + + /* Enable the Modbus Protocol Stack. */ + eStatus = eMBEnable( ); + + for( ;; ) + { + ( void )eMBPoll( );//判断事件的发生,并执行对应的回调函数 + + /* Here we simply count the number of poll cycles. */ + usRegInputBuf[0]++; + } + + // while (1) { + // AdapterDeviceSend(adapter, send_msg, strlen(send_msg)); + // AdapterDeviceRecv(adapter, recv_msg, 256); + // printf("4G recv msg %s\n", recv_msg); + // memset(recv_msg, 0, 256); + // } + + + return 0; +} +PRIV_SHELL_CMD_FUNCTION(AdapterModbusRtuTest, a Modbus Rtu adpter sample, PRIV_SHELL_CMD_FUNC_ATTR); + diff --git a/APP_Framework/Applications/connection_app/socket_demo/Makefile b/APP_Framework/Applications/connection_app/socket_demo/Makefile index f75bae3ee..c75d0ece7 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/Makefile +++ b/APP_Framework/Applications/connection_app/socket_demo/Makefile @@ -1,10 +1,10 @@ -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := lwip_tcp_socket_demo.c lwip_udp_socket_demo.c include $(KERNEL_ROOT)/compiler.mk endif include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += lwip_tcp_socket_demo.c lwip_udp_socket_demo.c include $(APPDIR)/Application.mk diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c index 48f147fe9..f0d0d6dbc 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c @@ -20,13 +20,13 @@ #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #include #include #include "lwip/sys.h" #endif -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #include #include #include @@ -45,7 +45,7 @@ static char tcp_demo_ipaddr[] = {192, 168, 131, 77}; static char tcp_demo_netmask[] = {255, 255, 254, 0}; static char tcp_demo_gwaddr[] = {192, 168, 131, 1}; -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #define lw_print printf #define lw_notice printf #define lw_error printf @@ -151,7 +151,7 @@ void TcpSocketRecvTest(int argc, char *argv[]) TcpSocketConfigParam(argv[1]); } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr); pthread_attr_t attr; @@ -159,7 +159,7 @@ void TcpSocketRecvTest(int argc, char *argv[]) attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE; #endif -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER; attr.priority = LWIP_TCP_DEMO_TASK_PRIO; attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE; @@ -222,14 +222,14 @@ void TcpSocketSendTest(int argc, char *argv[]) TcpSocketConfigParam(argv[1]); } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr); pthread_attr_t attr; attr.schedparam.sched_priority = LWIP_TCP_DEMO_TASK_PRIO; attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE; #endif -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER; attr.priority = LWIP_TCP_DEMO_TASK_PRIO; attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE; diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c index b6af89ffe..ebb2a06d0 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c @@ -19,12 +19,12 @@ */ #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES #include #include "lwip/sockets.h" #endif -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #include #include #include @@ -133,14 +133,14 @@ void UdpSocketRecvTest(int argc, char *argv[]) UdpSocketConfigParam(argv[1]); } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr); pthread_attr_t attr; attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO; attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE; #endif -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER; attr.priority = LWIP_UDP_DEMO_TASK_PRIO; attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE; @@ -199,14 +199,14 @@ void UdpSocketSendTest(int argc, char *argv[]) UdpSocketConfigParam(argv[1]); } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr); pthread_attr_t attr; attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO; attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE; #endif -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER; attr.priority = LWIP_UDP_DEMO_TASK_PRIO; attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE; diff --git a/APP_Framework/Applications/control_app/plc_demo/Makefile b/APP_Framework/Applications/control_app/plc_demo/Makefile index e6f45b376..747b6d28b 100755 --- a/APP_Framework/Applications/control_app/plc_demo/Makefile +++ b/APP_Framework/Applications/control_app/plc_demo/Makefile @@ -1,3 +1,3 @@ -SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance +SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile b/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile index 5b7f58eef..8e129e1af 100644 --- a/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile +++ b/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := inovance_am401_cpu1608tn_ethernet.c +SRC_FILES := inovance_am401_cpu1608tn_ethernet.c inovance_am401_cpu1608tn_uart.c include $(KERNEL_ROOT)/compiler.mk \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/inovance/inovance_am401_cpu1608tn_uart.c b/APP_Framework/Applications/control_app/plc_demo/inovance/inovance_am401_cpu1608tn_uart.c new file mode 100644 index 000000000..b7b26d14c --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/inovance/inovance_am401_cpu1608tn_uart.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 AIIT XUOS Lab + * XiUOS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +/** + * @file inovance_am401_cpu1608tn_ethernet.c + * @brief PLC inovance am401 app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2023.5.15 + */ + +#include + +extern int Adapter4GActive(void); + +void ControlInovanceam401UartTest(void) +{ + int i, j = 0; + int read_data_length = 0; + uint8_t read_data[128] = {0}; + +#ifdef CONNECTION_ADAPTER_4G + Adapter4GActive(); +#endif + + ControlProtocolType modbus_rtu_protocol = ControlProtocolFind(); + if (NULL == modbus_rtu_protocol) { + printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol); + return; + } + + printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol); + + if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) { + ControlProtocolOpen(modbus_rtu_protocol); + + for (;;) { + read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data)); + printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length); + if (read_data_length) { + for (j = 0; j < read_data_length; j ++) { + printf("j %d data 0x%x\n", j, read_data[j]); + } + } + i++; + memset(read_data, 0, sizeof(read_data)); + PrivTaskDelay(10000); + } + + //ControlProtocolClose(modbus_rtu_protocol); + } +} +PRIV_SHELL_CMD_FUNCTION(ControlInovanceam401UartTest, inovance am401 uart Demo, PRIV_SHELL_CMD_MAIN_ATTR); + + diff --git a/APP_Framework/Applications/control_app/plc_demo/inovance/test_recipe_inovance_am401_uart.json b/APP_Framework/Applications/control_app/plc_demo/inovance/test_recipe_inovance_am401_uart.json new file mode 100644 index 000000000..04595c49a --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/inovance/test_recipe_inovance_am401_uart.json @@ -0,0 +1,80 @@ +{ + "device_id": 1, + "device_name": "INOVANCE_am401_RTU", + "communication_type": 1, + "serial_config": { + "station": 1, + "baud_rate": 9600, + "data_bits": 8, + "stop_bits": 1, + "check_mode":3 + }, + "protocol_type": 3, + "read_period": 2000, + "read_item_list": [ + { + "value_name": "q00", + "value_type": 1, + "function_code": 1, + "start_address": 0, + "quantity": 1 + }, + { + "value_name": "q01", + "value_type": 1, + "function_code": 1, + "start_address":1, + "quantity": 1 + }, + { + "value_name": "q10", + "value_type": 1, + "function_code": 1, + "start_address": 8, + "quantity": 1 + }, + { + "value_name": "mw100", + "value_type": 3, + "function_code": 3, + "start_address": 100, + "quantity": 1 + }, + { + "value_name": "mw101", + "value_type": 3, + "function_code": 3, + "start_address": 101, + "quantity": 1 + }, + { + "value_name": "md200", + "value_type": 4, + "function_code": 3, + "start_address": 400, + "quantity": 2 + }, + { + "value_name": "md201", + "value_type": 4, + "function_code": 3, + "start_address": 402, + "quantity": 2 + }, + { + "value_name": "md300", + "value_type": 9, + "function_code": 3, + "start_address": 600, + "quantity": 2 + }, + { + "value_name": "md301", + "value_type": 9, + "function_code": 3, + "start_address": 602, + "quantity": 2 + } + + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/Makefile b/APP_Framework/Applications/control_app/plc_demo/keyence/Makefile new file mode 100755 index 000000000..6c12e6405 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/Makefile @@ -0,0 +1,3 @@ +SRC_FILES := kv_8000.c + +include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/README.md b/APP_Framework/Applications/control_app/plc_demo/keyence/README.md new file mode 100644 index 000000000..547da53c4 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/README.md @@ -0,0 +1,22 @@ +# KEYENCE 通信测试 + +[TOC] + +## 通信接线及参数设置 + +* 网口 + + *Mosbus TCP协议,IP:192.168.250.40,Port:502 + +## 存储区 + +- 存储区ZF区。 + +## 通信测试 + +(1)共测试INT16类型数据。 + +(2)测试ZF区数据。 + +(3)D区数据测试,用功能码03和06,以字为单位读写。如读写ZF1,则配方文件中起始地址则直接写1即可。 + diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/kv_8000.c b/APP_Framework/Applications/control_app/plc_demo/keyence/kv_8000.c new file mode 100644 index 000000000..f4e633f05 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/kv_8000.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 AIIT XUOS Lab + * XiUOS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +/** + * @file kv_8000.c + * @brief PLC KEYENCE KV-8000 app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2023.4.12 + */ + +#include +void ControlKV8000Test(void) +{ + int i, j = 0; + int read_data_length = 0; + uint8_t read_data[128] = {0}; + ControlProtocolType modbus_tcp_protocol = ControlProtocolFind(); + if (NULL == modbus_tcp_protocol) { + printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol); + return; + } + printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol); + + if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) { + ControlProtocolOpen(modbus_tcp_protocol); + for (;;) { + read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data)); + printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length); + if (read_data_length) { + for (j = 0; j < read_data_length; j ++) { + printf("j %d data 0x%x\n", j, read_data[j]); + } + } + i++; + memset(read_data, 0, sizeof(read_data)); + PrivTaskDelay(10000); + } + //ControlProtocolClose(modbus_tcp_protocol); + } +} +PRIV_SHELL_CMD_FUNCTION(ControlKV8000Test, KEYENCE Plc KV_8000 Demo, PRIV_SHELL_CMD_MAIN_ATTR); + + diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/test_recipe_KV_8000.json b/APP_Framework/Applications/control_app/plc_demo/keyence/test_recipe_KV_8000.json new file mode 100644 index 000000000..a308badbb --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/test_recipe_KV_8000.json @@ -0,0 +1,37 @@ +{ + "device_id": 1, + "device_name": "GJ2", + "communication_type": 0, + "socket_config": { + "plc_ip": "192.168.250.40", + "local_ip": "192.168.250.233", + "gateway": "192.168.250.1", + "netmask": "255.255.255.0", + "port": 502 + }, + "protocol_type": 2, + "read_period": 100, + "read_item_list": [ + { + "value_name": "ZF0", + "value_type": 3, + "function_code": 3, + "start_address": 0, + "quantity": 1 + }, + { + "value_name": "ZF1", + "value_type": 3, + "function_code": 3, + "start_address": 1, + "quantity": 1 + }, + { + "value_name": "ZF2", + "value_type": 3, + "function_code": 3, + "start_address": 2, + "quantity": 1 + } + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/schneider/README.md b/APP_Framework/Applications/control_app/plc_demo/schneider/README.md new file mode 100644 index 000000000..46f0558bf --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/schneider/README.md @@ -0,0 +1,21 @@ +# SCHNEIDER M241通信测试 + +[TOC] + +## 通信接线及参数设置 + +* 串口 + * M241支持2路485串口,本次采用的是serial2。波特率:9600,数据位:8位,停止位:1位,校验:偶校验 + +## 存储区 + +- 存储区MW区。 + +## 通信测试 + +(1)共测试INT16共1种类型数据。 + +(2)测试MW区数据。 + +(3)MW区数据测试,用功能码03,以字为单位读取。如读MW100,则配方文件中起始地址则直接写100即可。 + diff --git a/APP_Framework/Applications/control_app/plc_demo/xinje/README.md b/APP_Framework/Applications/control_app/plc_demo/xinje/README.md new file mode 100644 index 000000000..bd9d268a9 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/xinje/README.md @@ -0,0 +1,23 @@ +# XINJIE 通信测试 + +[TOC] + +## 通信接线及参数设置 + +* 网口 + + *Mosbus TCP协议,IP:192.168.250.32,Port:502 + +## 存储区 + +- 存储区M、D区。 + +## 通信测试 + +(1)共测试BOOL,INT16共2种类型数据。 + +(2)测试M区及D区数据。 + +(3)D区数据测试,用功能码03和06,以字为单位读写。如读写D500,则配方文件中起始地址则直接写500即可。 + +(4)M区数据测试,用功能码01和05,以位为单位读写。如读写M19,则配方文件中起始地址则直接写19即可。 diff --git a/APP_Framework/Applications/general_functions/circular_area/Makefile b/APP_Framework/Applications/general_functions/circular_area/Makefile index 30616891b..3a440ecbf 100644 --- a/APP_Framework/Applications/general_functions/circular_area/Makefile +++ b/APP_Framework/Applications/general_functions/circular_area/Makefile @@ -1,11 +1,11 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += circular_area_app.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := circular_area_app.c include $(KERNEL_ROOT)/compiler.mk endif \ No newline at end of file diff --git a/APP_Framework/Applications/general_functions/list/Makefile b/APP_Framework/Applications/general_functions/list/Makefile index acfac595c..cb227275c 100644 --- a/APP_Framework/Applications/general_functions/list/Makefile +++ b/APP_Framework/Applications/general_functions/list/Makefile @@ -1,11 +1,11 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += double_list.c single_list.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := double_list.c single_list.c include $(KERNEL_ROOT)/compiler.mk endif \ No newline at end of file diff --git a/APP_Framework/Applications/knowing_app/k210_fft_test/Makefile b/APP_Framework/Applications/knowing_app/k210_fft_test/Makefile index ff9bc3df8..23476939d 100644 --- a/APP_Framework/Applications/knowing_app/k210_fft_test/Makefile +++ b/APP_Framework/Applications/knowing_app/k210_fft_test/Makefile @@ -1,6 +1,6 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs ifeq ($(CONFIG_K210_FFT_TEST), y) diff --git a/APP_Framework/Applications/knowing_app/k210_fft_test/fft_test.c b/APP_Framework/Applications/knowing_app/k210_fft_test/fft_test.c index 3a54afbb0..5166087f9 100644 --- a/APP_Framework/Applications/knowing_app/k210_fft_test/fft_test.c +++ b/APP_Framework/Applications/knowing_app/k210_fft_test/fft_test.c @@ -155,7 +155,7 @@ void k210_fft_test(void) cycle[FFT_SOFT][FFT_DIR_BACKWARD]/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000)); } -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES void nuttx_k210_fft_test(void) { pthread_t thread; diff --git a/APP_Framework/Applications/knowing_app/nnom_demo/mnist_nnom/main.c b/APP_Framework/Applications/knowing_app/nnom_demo/mnist_nnom/main.c index dcdb6e8f7..4c2f5022e 100644 --- a/APP_Framework/Applications/knowing_app/nnom_demo/mnist_nnom/main.c +++ b/APP_Framework/Applications/knowing_app/nnom_demo/mnist_nnom/main.c @@ -71,7 +71,7 @@ void mnist_nnom(int argc, char **argv) printf("Predicted label: %d\n", predic_label); printf("Probability: %d%%\n", (int)(prob * 100)); } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES PRIV_SHELL_CMD_FUNCTION(mnist_nnom, a mnist_nnom test sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif #ifdef __RT_THREAD_H__ diff --git a/APP_Framework/Applications/sensor_app/Kconfig b/APP_Framework/Applications/sensor_app/Kconfig index fbab69a78..d00f82865 100755 --- a/APP_Framework/Applications/sensor_app/Kconfig +++ b/APP_Framework/Applications/sensor_app/Kconfig @@ -108,7 +108,7 @@ menu "sensor app" bool "Using sensor HS300x apps" default n - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES endif endif @@ -122,7 +122,7 @@ menu "sensor app" bool "Using sensor HS300x apps" default n - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES endif endif diff --git a/APP_Framework/Applications/sensor_app/Makefile b/APP_Framework/Applications/sensor_app/Makefile index 03bc3952a..a67b8fb53 100644 --- a/APP_Framework/Applications/sensor_app/Makefile +++ b/APP_Framework/Applications/sensor_app/Makefile @@ -1,6 +1,6 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y) @@ -64,7 +64,7 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := ifeq ($(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS), y) diff --git a/APP_Framework/Framework/Kconfig b/APP_Framework/Framework/Kconfig index 7934d2006..9be072ceb 100644 --- a/APP_Framework/Framework/Kconfig +++ b/APP_Framework/Framework/Kconfig @@ -5,16 +5,16 @@ menu "Framework" default y choice prompt "select os features" - default ADD_XIZI_FETURES + default ADD_XIZI_FEATURES - config ADD_XIZI_FETURES - bool "add xizi fetures" + config ADD_XIZI_FEATURES + bool "add xizi features" - config ADD_NUTTX_FETURES - bool "add nuttx fetures" + config ADD_NUTTX_FEATURES + bool "add nuttx features" - config ADD_RTTHREAD_FETURES - bool "add rt_thread fetures" + config ADD_RTTHREAD_FEATURES + bool "add rt_thread features" endchoice diff --git a/APP_Framework/Framework/Makefile b/APP_Framework/Framework/Makefile index 32a3a1005..ca4bace06 100644 --- a/APP_Framework/Framework/Makefile +++ b/APP_Framework/Framework/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += framework_init.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := framework_init.c SRC_DIR := transform_layer diff --git a/APP_Framework/Framework/connection/4g/Makefile b/APP_Framework/Framework/connection/4g/Makefile index f5c4a138e..df607fbb6 100644 --- a/APP_Framework/Framework/connection/4g/Makefile +++ b/APP_Framework/Framework/connection/4g/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += adapter_4g.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := adapter_4g.c ifeq ($(CONFIG_ADAPTER_EC200T),y) diff --git a/APP_Framework/Framework/connection/4g/ec200t/Kconfig b/APP_Framework/Framework/connection/4g/ec200t/Kconfig index 01ecea76e..7d3640739 100644 --- a/APP_Framework/Framework/connection/4g/ec200t/Kconfig +++ b/APP_Framework/Framework/connection/4g/ec200t/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_4G_EC200T string "EC200T adapter name" default "ec200t" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_EC200T_USING_PWRKEY bool "EC200T using PWRKEY pin number" default n @@ -37,7 +37,7 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES config ADAPTER_EC200T_USING_PWRKEY bool "EC200T using PWRKEY pin number" default n @@ -72,7 +72,7 @@ if ADD_NUTTX_FETURES endif endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES config ADAPTER_EC200T_PWRKEY int "EC200T PWRKEY pin number" default "97" diff --git a/APP_Framework/Framework/connection/4g/ec200t/Makefile b/APP_Framework/Framework/connection/4g/ec200t/Makefile index 5b2bff1fe..e3bf4efec 100644 --- a/APP_Framework/Framework/connection/4g/ec200t/Makefile +++ b/APP_Framework/Framework/connection/4g/ec200t/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += ec200t.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := ec200t.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/4g/ec200t/ec200t.c b/APP_Framework/Framework/connection/4g/ec200t/ec200t.c index 3e8f38508..67076fe44 100644 --- a/APP_Framework/Framework/connection/4g/ec200t/ec200t.c +++ b/APP_Framework/Framework/connection/4g/ec200t/ec200t.c @@ -142,7 +142,7 @@ out: return ret; } -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args){ return 0;} #else static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args) @@ -163,6 +163,8 @@ static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args) serial_cfg.serial_parity_mode = PARITY_NONE; serial_cfg.serial_bit_order = STOP_BITS_1; serial_cfg.serial_invert_mode = NRZ_NORMAL; + //serial receive timeout 10s + serial_cfg.serial_timeout = 10000; serial_cfg.is_ext_uart = 0; #ifdef ADAPTER_EC200T_DRIVER_EXT_PORT serial_cfg.is_ext_uart = 1; diff --git a/APP_Framework/Framework/connection/Makefile b/APP_Framework/Framework/connection/Makefile index cc71769af..0a33bf95f 100644 --- a/APP_Framework/Framework/connection/Makefile +++ b/APP_Framework/Framework/connection/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += adapter.c adapter_agent.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := adapter.c adapter_agent.c ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_NETWORK),y) diff --git a/APP_Framework/Framework/connection/adapter.h b/APP_Framework/Framework/connection/adapter.h index 09c15a0f0..d11080fdf 100644 --- a/APP_Framework/Framework/connection/adapter.h +++ b/APP_Framework/Framework/connection/adapter.h @@ -53,6 +53,7 @@ extern "C" { #define ADAPTER_NBIOT_NAME "nbiot" #define ADAPTER_WIFI_NAME "wifi" #define ADAPTER_ZIGBEE_NAME "zigbee" +#define ADAPTER_MODBUS_RTU_NAME "modbus_rtu" struct Adapter; struct AdapterProductInfo; diff --git a/APP_Framework/Framework/connection/adapter_agent.c b/APP_Framework/Framework/connection/adapter_agent.c index 344674bfb..445d83ed5 100755 --- a/APP_Framework/Framework/connection/adapter_agent.c +++ b/APP_Framework/Framework/connection/adapter_agent.c @@ -26,10 +26,10 @@ #include #include #include -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES # include #endif -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES #include #endif #define AT_CMD_MAX_LEN 128 @@ -424,26 +424,26 @@ int DeleteATAgent(ATAgentType agent) PrivClose(agent->fd); } -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES if (agent->lock.sem.semcount > 0) { printf("delete agent lock = %d\n",agent->lock.sem.semcount); PrivMutexDelete(&agent->lock); } -#elif defined ADD_RTTHREAD_FETURES +#elif defined ADD_RTTHREAD_FEATURES #else if (agent->lock) { printf("delete agent lock = %d\n",agent->lock); PrivMutexDelete(&agent->lock); } #endif -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES if (agent->entm_rx_notice) { printf("delete agent entm_rx_notice = %d\n",agent->entm_rx_notice); PrivSemaphoreDelete(&agent->entm_rx_notice); } #else #endif -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES if (agent->rsp_sem) { printf("delete agent rsp_sem = %d\n",agent->rsp_sem); PrivSemaphoreDelete(&agent->rsp_sem); @@ -518,7 +518,7 @@ static int ATAgentInit(ATAgentType agent) agent->receive_mode = DEFAULT_MODE; -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER; attr.priority = 18; attr.stacksize = 8192; diff --git a/APP_Framework/Framework/connection/at_agent.h b/APP_Framework/Framework/connection/at_agent.h index 42d589a0c..d3efd5edb 100755 --- a/APP_Framework/Framework/connection/at_agent.h +++ b/APP_Framework/Framework/connection/at_agent.h @@ -52,7 +52,7 @@ struct ATAgent uint32 maintain_len; uint32 maintain_max; -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES int lock; #else pthread_mutex_t lock; @@ -63,7 +63,7 @@ struct ATAgent char reply_end_last_char; char reply_end_char; uint32 reply_char_num; -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES int rsp_sem; #else sem_t rsp_sem; @@ -74,7 +74,7 @@ struct ATAgent char entm_recv_buf[ENTM_RECV_MAX]; uint32 entm_recv_len; enum ReceiveMode receive_mode; -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES int entm_rx_notice; #else sem_t entm_rx_notice; diff --git a/APP_Framework/Framework/connection/bluetooth/Makefile b/APP_Framework/Framework/connection/bluetooth/Makefile index bc7d736cd..3ee1fcaa7 100644 --- a/APP_Framework/Framework/connection/bluetooth/Makefile +++ b/APP_Framework/Framework/connection/bluetooth/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += adapter_bluetooth.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := adapter_bluetooth.c ifeq ($(CONFIG_ADAPTER_HC08),y) diff --git a/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig b/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig index 042cf75a0..6a6887560 100644 --- a/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig +++ b/APP_Framework/Framework/connection/bluetooth/hc08/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_BLUETOOTH_HC08 string "HC08 adapter name" default "hc08" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_HC08_RECV_BUFFER_SIZE int "HC08 recv data buffer size" default "128" @@ -31,7 +31,7 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES config ADAPTER_HC08_WORK_ROLE string "HC08 work role M(MASTER) or S(SLAVER)" @@ -58,7 +58,7 @@ if ADD_NUTTX_FETURES endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES config ADAPTER_HC08_RECV_BUFFER_SIZE int "HC08 recv data buffer size" default "128" diff --git a/APP_Framework/Framework/connection/bluetooth/hc08/Makefile b/APP_Framework/Framework/connection/bluetooth/hc08/Makefile index e437a114f..f95394e46 100644 --- a/APP_Framework/Framework/connection/bluetooth/hc08/Makefile +++ b/APP_Framework/Framework/connection/bluetooth/hc08/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += hc08.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := hc08.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/bluetooth/hc08/hc08.c b/APP_Framework/Framework/connection/bluetooth/hc08/hc08.c index 1cbf69d44..d04b732b4 100644 --- a/APP_Framework/Framework/connection/bluetooth/hc08/hc08.c +++ b/APP_Framework/Framework/connection/bluetooth/hc08/hc08.c @@ -353,7 +353,7 @@ static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args) } PrivTaskDelay(500); - #ifdef ADD_RTTHREAD_FETURES + #ifdef ADD_RTTHREAD_FEATURES //Step3 : show hc08 device info, hc08_get send "AT+RX" response device info char device_info[HC08_RESP_DEFAULT_SIZE * 2] = {0}; if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_DEVICE_INFO, NULL, device_info) < 0) { @@ -369,7 +369,7 @@ static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args) if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_LUUID, NULL, NULL) < 0) { return -1; } - #ifdef ADD_RTTHREAD_FETURES + #ifdef ADD_RTTHREAD_FEATURES uint32_t suuid=1234; if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_SET_SUUID, &luuid, NULL) < 0) { return -1; diff --git a/APP_Framework/Framework/connection/ethernet/hfa21_ethernet/Kconfig b/APP_Framework/Framework/connection/ethernet/hfa21_ethernet/Kconfig index 808272cfa..2083a127d 100644 --- a/APP_Framework/Framework/connection/ethernet/hfa21_ethernet/Kconfig +++ b/APP_Framework/Framework/connection/ethernet/hfa21_ethernet/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_ETHERNET_HFA21 string "HFA21 ETHERNET adapter name" default "hfa21_ethernet" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_HFA21_DRIVER_EXTUART bool "Using extra uart to support ethernet" @@ -24,11 +24,11 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES config ADAPTER_HFA21_DRIVER string "HFA21 device uart driver path" default "/dev/uart3" diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/demo.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/demo.c new file mode 100644 index 000000000..2ae19a65a --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/demo.c @@ -0,0 +1,101 @@ +/* + * FreeModbus Libary: BARE Demo Application + * Copyright (C) 2006 Christian Walter + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * File: $Id$ + */ + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbport.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define REG_INPUT_START 1000 +#define REG_INPUT_NREGS 4 + +/* ----------------------- Static variables ---------------------------------*/ +static USHORT usRegInputStart = REG_INPUT_START; +static USHORT usRegInputBuf[REG_INPUT_NREGS]; + +/* ----------------------- Start implementation -----------------------------*/ +int +main( void ) +{ + eMBErrorCode eStatus; + + eStatus = eMBInit( MB_RTU, 0x0A, 0, 38400, MB_PAR_EVEN ); + + /* Enable the Modbus Protocol Stack. */ + eStatus = eMBEnable( ); + + for( ;; ) + { + ( void )eMBPoll( ); + + /* Here we simply count the number of poll cycles. */ + usRegInputBuf[0]++; + } +} + +eMBErrorCode +eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs ) +{ + eMBErrorCode eStatus = MB_ENOERR; + int iRegIndex; + + if( ( usAddress >= REG_INPUT_START ) + && ( usAddress + usNRegs <= REG_INPUT_START + REG_INPUT_NREGS ) ) + { + iRegIndex = ( int )( usAddress - usRegInputStart ); + while( usNRegs > 0 ) + { + *pucRegBuffer++ = + ( unsigned char )( usRegInputBuf[iRegIndex] >> 8 ); + *pucRegBuffer++ = + ( unsigned char )( usRegInputBuf[iRegIndex] & 0xFF ); + iRegIndex++; + usNRegs--; + } + } + else + { + eStatus = MB_ENOREG; + } + + return eStatus; +} + +eMBErrorCode +eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, + eMBRegisterMode eMode ) +{ + return MB_ENOREG; +} + + +eMBErrorCode +eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, + eMBRegisterMode eMode ) +{ + return MB_ENOREG; +} + +eMBErrorCode +eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete ) +{ + return MB_ENOREG; +} diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/ascii/mbascii.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/ascii/mbascii.c new file mode 100644 index 000000000..b29f2bcc0 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/ascii/mbascii.c @@ -0,0 +1,485 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbconfig.h" +#include "mbascii.h" +#include "mbframe.h" + +#include "mbcrc.h" +#include "mbport.h" + +#if MB_ASCII_ENABLED > 0 + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_ASCII_DEFAULT_CR '\r' /*!< Default CR character for Modbus ASCII. */ +#define MB_ASCII_DEFAULT_LF '\n' /*!< Default LF character for Modbus ASCII. */ +#define MB_SER_PDU_SIZE_MIN 3 /*!< Minimum size of a Modbus ASCII frame. */ +#define MB_SER_PDU_SIZE_MAX 256 /*!< Maximum size of a Modbus ASCII frame. */ +#define MB_SER_PDU_SIZE_LRC 1 /*!< Size of LRC field in PDU. */ +#define MB_SER_PDU_ADDR_OFF 0 /*!< Offset of slave address in Ser-PDU. */ +#define MB_SER_PDU_PDU_OFF 1 /*!< Offset of Modbus-PDU in Ser-PDU. */ + +/* ----------------------- Type definitions ---------------------------------*/ +typedef enum +{ + STATE_RX_IDLE, /*!< Receiver is in idle state. */ + STATE_RX_RCV, /*!< Frame is beeing received. */ + STATE_RX_WAIT_EOF /*!< Wait for End of Frame. */ +} eMBRcvState; + +typedef enum +{ + STATE_TX_IDLE, /*!< Transmitter is in idle state. */ + STATE_TX_START, /*!< Starting transmission (':' sent). */ + STATE_TX_DATA, /*!< Sending of data (Address, Data, LRC). */ + STATE_TX_END, /*!< End of transmission. */ + STATE_TX_NOTIFY /*!< Notify sender that the frame has been sent. */ +} eMBSndState; + +typedef enum +{ + BYTE_HIGH_NIBBLE, /*!< Character for high nibble of byte. */ + BYTE_LOW_NIBBLE /*!< Character for low nibble of byte. */ +} eMBBytePos; + +/* ----------------------- Static functions ---------------------------------*/ +static UCHAR prvucMBCHAR2BIN( UCHAR ucCharacter ); + +static UCHAR prvucMBBIN2CHAR( UCHAR ucByte ); + +static UCHAR prvucMBLRC( UCHAR * pucFrame, USHORT usLen ); + +/* ----------------------- Static variables ---------------------------------*/ +static volatile eMBSndState eSndState; +static volatile eMBRcvState eRcvState; + +/* We reuse the Modbus RTU buffer because only one buffer is needed and the + * RTU buffer is bigger. */ +extern volatile UCHAR ucRTUBuf[]; +static volatile UCHAR *ucASCIIBuf = ucRTUBuf; + +static volatile USHORT usRcvBufferPos; +static volatile eMBBytePos eBytePos; + +static volatile UCHAR *pucSndBufferCur; +static volatile USHORT usSndBufferCount; + +static volatile UCHAR ucLRC; +static volatile UCHAR ucMBLFCharacter; + +/* ----------------------- Start implementation -----------------------------*/ +eMBErrorCode +eMBASCIIInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity ) +{ + eMBErrorCode eStatus = MB_ENOERR; + ( void )ucSlaveAddress; + + ENTER_CRITICAL_SECTION( ); + ucMBLFCharacter = MB_ASCII_DEFAULT_LF; + + if( xMBPortSerialInit( ucPort, ulBaudRate, 7, eParity ) != TRUE ) + { + eStatus = MB_EPORTERR; + } + else if( xMBPortTimersInit( MB_ASCII_TIMEOUT_SEC * 20000UL ) != TRUE ) + { + eStatus = MB_EPORTERR; + } + + EXIT_CRITICAL_SECTION( ); + + return eStatus; +} + +void +eMBASCIIStart( void ) +{ + ENTER_CRITICAL_SECTION( ); + vMBPortSerialEnable( TRUE, FALSE ); + eRcvState = STATE_RX_IDLE; + EXIT_CRITICAL_SECTION( ); + + /* No special startup required for ASCII. */ + ( void )xMBPortEventPost( EV_READY ); +} + +void +eMBASCIIStop( void ) +{ + ENTER_CRITICAL_SECTION( ); + vMBPortSerialEnable( FALSE, FALSE ); + vMBPortTimersDisable( ); + EXIT_CRITICAL_SECTION( ); +} + +eMBErrorCode +eMBASCIIReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength ) +{ + eMBErrorCode eStatus = MB_ENOERR; + + ENTER_CRITICAL_SECTION( ); + assert( usRcvBufferPos < MB_SER_PDU_SIZE_MAX ); + + /* Length and CRC check */ + if( ( usRcvBufferPos >= MB_SER_PDU_SIZE_MIN ) + && ( prvucMBLRC( ( UCHAR * ) ucASCIIBuf, usRcvBufferPos ) == 0 ) ) + { + /* Save the address field. All frames are passed to the upper layed + * and the decision if a frame is used is done there. + */ + *pucRcvAddress = ucASCIIBuf[MB_SER_PDU_ADDR_OFF]; + + /* Total length of Modbus-PDU is Modbus-Serial-Line-PDU minus + * size of address field and CRC checksum. + */ + *pusLength = ( USHORT )( usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_LRC ); + + /* Return the start of the Modbus PDU to the caller. */ + *pucFrame = ( UCHAR * ) & ucASCIIBuf[MB_SER_PDU_PDU_OFF]; + } + else + { + eStatus = MB_EIO; + } + EXIT_CRITICAL_SECTION( ); + return eStatus; +} + +eMBErrorCode +eMBASCIISend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength ) +{ + eMBErrorCode eStatus = MB_ENOERR; + UCHAR usLRC; + + ENTER_CRITICAL_SECTION( ); + /* Check if the receiver is still in idle state. If not we where too + * slow with processing the received frame and the master sent another + * frame on the network. We have to abort sending the frame. + */ + if( eRcvState == STATE_RX_IDLE ) + { + /* First byte before the Modbus-PDU is the slave address. */ + pucSndBufferCur = ( UCHAR * ) pucFrame - 1; + usSndBufferCount = 1; + + /* Now copy the Modbus-PDU into the Modbus-Serial-Line-PDU. */ + pucSndBufferCur[MB_SER_PDU_ADDR_OFF] = ucSlaveAddress; + usSndBufferCount += usLength; + + /* Calculate LRC checksum for Modbus-Serial-Line-PDU. */ + usLRC = prvucMBLRC( ( UCHAR * ) pucSndBufferCur, usSndBufferCount ); + ucASCIIBuf[usSndBufferCount++] = usLRC; + + /* Activate the transmitter. */ + eSndState = STATE_TX_START; + vMBPortSerialEnable( FALSE, TRUE ); + } + else + { + eStatus = MB_EIO; + } + EXIT_CRITICAL_SECTION( ); + return eStatus; +} + +BOOL +xMBASCIIReceiveFSM( void ) +{ + BOOL xNeedPoll = FALSE; + UCHAR ucByte; + UCHAR ucResult; + + assert( eSndState == STATE_TX_IDLE ); + + ( void )xMBPortSerialGetByte( ( CHAR * ) & ucByte ); + switch ( eRcvState ) + { + /* A new character is received. If the character is a ':' the input + * buffer is cleared. A CR-character signals the end of the data + * block. Other characters are part of the data block and their + * ASCII value is converted back to a binary representation. + */ + case STATE_RX_RCV: + /* Enable timer for character timeout. */ + vMBPortTimersEnable( ); + if( ucByte == ':' ) + { + /* Empty receive buffer. */ + eBytePos = BYTE_HIGH_NIBBLE; + usRcvBufferPos = 0; + } + else if( ucByte == MB_ASCII_DEFAULT_CR ) + { + eRcvState = STATE_RX_WAIT_EOF; + } + else + { + ucResult = prvucMBCHAR2BIN( ucByte ); + switch ( eBytePos ) + { + /* High nibble of the byte comes first. We check for + * a buffer overflow here. */ + case BYTE_HIGH_NIBBLE: + if( usRcvBufferPos < MB_SER_PDU_SIZE_MAX ) + { + ucASCIIBuf[usRcvBufferPos] = ( UCHAR )( ucResult << 4 ); + eBytePos = BYTE_LOW_NIBBLE; + break; + } + else + { + /* not handled in Modbus specification but seems + * a resonable implementation. */ + eRcvState = STATE_RX_IDLE; + /* Disable previously activated timer because of error state. */ + vMBPortTimersDisable( ); + } + break; + + case BYTE_LOW_NIBBLE: + ucASCIIBuf[usRcvBufferPos] |= ucResult; + usRcvBufferPos++; + eBytePos = BYTE_HIGH_NIBBLE; + break; + } + } + break; + + case STATE_RX_WAIT_EOF: + if( ucByte == ucMBLFCharacter ) + { + /* Disable character timeout timer because all characters are + * received. */ + vMBPortTimersDisable( ); + /* Receiver is again in idle state. */ + eRcvState = STATE_RX_IDLE; + + /* Notify the caller of eMBASCIIReceive that a new frame + * was received. */ + xNeedPoll = xMBPortEventPost( EV_FRAME_RECEIVED ); + } + else if( ucByte == ':' ) + { + /* Empty receive buffer and back to receive state. */ + eBytePos = BYTE_HIGH_NIBBLE; + usRcvBufferPos = 0; + eRcvState = STATE_RX_RCV; + + /* Enable timer for character timeout. */ + vMBPortTimersEnable( ); + } + else + { + /* Frame is not okay. Delete entire frame. */ + eRcvState = STATE_RX_IDLE; + } + break; + + case STATE_RX_IDLE: + if( ucByte == ':' ) + { + /* Enable timer for character timeout. */ + vMBPortTimersEnable( ); + /* Reset the input buffers to store the frame. */ + usRcvBufferPos = 0;; + eBytePos = BYTE_HIGH_NIBBLE; + eRcvState = STATE_RX_RCV; + } + break; + } + + return xNeedPoll; +} + +BOOL +xMBASCIITransmitFSM( void ) +{ + BOOL xNeedPoll = FALSE; + UCHAR ucByte; + + assert( eRcvState == STATE_RX_IDLE ); + switch ( eSndState ) + { + /* Start of transmission. The start of a frame is defined by sending + * the character ':'. */ + case STATE_TX_START: + ucByte = ':'; + xMBPortSerialPutByte( ( CHAR )ucByte ); + eSndState = STATE_TX_DATA; + eBytePos = BYTE_HIGH_NIBBLE; + break; + + /* Send the data block. Each data byte is encoded as a character hex + * stream with the high nibble sent first and the low nibble sent + * last. If all data bytes are exhausted we send a '\r' character + * to end the transmission. */ + case STATE_TX_DATA: + if( usSndBufferCount > 0 ) + { + switch ( eBytePos ) + { + case BYTE_HIGH_NIBBLE: + ucByte = prvucMBBIN2CHAR( ( UCHAR )( *pucSndBufferCur >> 4 ) ); + xMBPortSerialPutByte( ( CHAR ) ucByte ); + eBytePos = BYTE_LOW_NIBBLE; + break; + + case BYTE_LOW_NIBBLE: + ucByte = prvucMBBIN2CHAR( ( UCHAR )( *pucSndBufferCur & 0x0F ) ); + xMBPortSerialPutByte( ( CHAR )ucByte ); + pucSndBufferCur++; + eBytePos = BYTE_HIGH_NIBBLE; + usSndBufferCount--; + break; + } + } + else + { + xMBPortSerialPutByte( MB_ASCII_DEFAULT_CR ); + eSndState = STATE_TX_END; + } + break; + + /* Finish the frame by sending a LF character. */ + case STATE_TX_END: + xMBPortSerialPutByte( ( CHAR )ucMBLFCharacter ); + /* We need another state to make sure that the CR character has + * been sent. */ + eSndState = STATE_TX_NOTIFY; + break; + + /* Notify the task which called eMBASCIISend that the frame has + * been sent. */ + case STATE_TX_NOTIFY: + eSndState = STATE_TX_IDLE; + xNeedPoll = xMBPortEventPost( EV_FRAME_SENT ); + + /* Disable transmitter. This prevents another transmit buffer + * empty interrupt. */ + vMBPortSerialEnable( TRUE, FALSE ); + eSndState = STATE_TX_IDLE; + break; + + /* We should not get a transmitter event if the transmitter is in + * idle state. */ + case STATE_TX_IDLE: + /* enable receiver/disable transmitter. */ + vMBPortSerialEnable( TRUE, FALSE ); + break; + } + + return xNeedPoll; +} + +BOOL +xMBASCIITimerT1SExpired( void ) +{ + switch ( eRcvState ) + { + /* If we have a timeout we go back to the idle state and wait for + * the next frame. + */ + case STATE_RX_RCV: + case STATE_RX_WAIT_EOF: + eRcvState = STATE_RX_IDLE; + break; + + default: + assert( ( eRcvState == STATE_RX_RCV ) || ( eRcvState == STATE_RX_WAIT_EOF ) ); + break; + } + vMBPortTimersDisable( ); + + /* no context switch required. */ + return FALSE; +} + + +static UCHAR +prvucMBCHAR2BIN( UCHAR ucCharacter ) +{ + if( ( ucCharacter >= '0' ) && ( ucCharacter <= '9' ) ) + { + return ( UCHAR )( ucCharacter - '0' ); + } + else if( ( ucCharacter >= 'A' ) && ( ucCharacter <= 'F' ) ) + { + return ( UCHAR )( ucCharacter - 'A' + 0x0A ); + } + else + { + return 0xFF; + } +} + +static UCHAR +prvucMBBIN2CHAR( UCHAR ucByte ) +{ + if( ucByte <= 0x09 ) + { + return ( UCHAR )( '0' + ucByte ); + } + else if( ( ucByte >= 0x0A ) && ( ucByte <= 0x0F ) ) + { + return ( UCHAR )( ucByte - 0x0A + 'A' ); + } + else + { + /* Programming error. */ + assert( 0 ); + } + return '0'; +} + + +static UCHAR +prvucMBLRC( UCHAR * pucFrame, USHORT usLen ) +{ + UCHAR ucLRC = 0; /* LRC char initialized */ + + while( usLen-- ) + { + ucLRC += *pucFrame++; /* Add buffer byte without carry */ + } + + /* Return twos complement */ + ucLRC = ( UCHAR ) ( -( ( CHAR ) ucLRC ) ); + return ucLRC; +} + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/ascii/mbascii.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/ascii/mbascii.h new file mode 100644 index 000000000..20975e29b --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/ascii/mbascii.h @@ -0,0 +1,55 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_ASCII_H +#define _MB_ASCII_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif + +#if MB_ASCII_ENABLED > 0 +eMBErrorCode eMBASCIIInit( UCHAR slaveAddress, UCHAR ucPort, + ULONG ulBaudRate, eMBParity eParity ); +void eMBASCIIStart( void ); +void eMBASCIIStop( void ); + +eMBErrorCode eMBASCIIReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, + USHORT * pusLength ); +eMBErrorCode eMBASCIISend( UCHAR slaveAddress, const UCHAR * pucFrame, + USHORT usLength ); +BOOL xMBASCIIReceiveFSM( void ); +BOOL xMBASCIITransmitFSM( void ); +BOOL xMBASCIITimerT1SExpired( void ); +#endif + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfunccoils.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfunccoils.c new file mode 100644 index 000000000..eb37ed6c0 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfunccoils.c @@ -0,0 +1,269 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbframe.h" +#include "mbproto.h" +#include "mbconfig.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_PDU_FUNC_READ_ADDR_OFF ( MB_PDU_DATA_OFF ) +#define MB_PDU_FUNC_READ_COILCNT_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_READ_SIZE ( 4 ) +#define MB_PDU_FUNC_READ_COILCNT_MAX ( 0x07D0 ) + +#define MB_PDU_FUNC_WRITE_ADDR_OFF ( MB_PDU_DATA_OFF ) +#define MB_PDU_FUNC_WRITE_VALUE_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_WRITE_SIZE ( 4 ) + +#define MB_PDU_FUNC_WRITE_MUL_ADDR_OFF ( MB_PDU_DATA_OFF ) +#define MB_PDU_FUNC_WRITE_MUL_COILCNT_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF ( MB_PDU_DATA_OFF + 4 ) +#define MB_PDU_FUNC_WRITE_MUL_VALUES_OFF ( MB_PDU_DATA_OFF + 5 ) +#define MB_PDU_FUNC_WRITE_MUL_SIZE_MIN ( 5 ) +#define MB_PDU_FUNC_WRITE_MUL_COILCNT_MAX ( 0x07B0 ) + +/* ----------------------- Static functions ---------------------------------*/ +eMBException prveMBError2Exception( eMBErrorCode eErrorCode ); + +/* ----------------------- Start implementation -----------------------------*/ + +#if MB_FUNC_READ_COILS_ENABLED > 0 + +eMBException +eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + USHORT usCoilCount; + UCHAR ucNBytes; + UCHAR *pucFrameCur; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen == ( MB_PDU_FUNC_READ_SIZE + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF + 1] ); + usRegAddress++; + + usCoilCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF] << 8 ); + usCoilCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF + 1] ); + + /* Check if the number of registers to read is valid. If not + * return Modbus illegal data value exception. + */ + if( ( usCoilCount >= 1 ) && + ( usCoilCount < MB_PDU_FUNC_READ_COILCNT_MAX ) ) + { + /* Set the current PDU data pointer to the beginning. */ + pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF]; + *usLen = MB_PDU_FUNC_OFF; + + /* First byte contains the function code. */ + *pucFrameCur++ = MB_FUNC_READ_COILS; + *usLen += 1; + + /* Test if the quantity of coils is a multiple of 8. If not last + * byte is only partially field with unused coils set to zero. */ + if( ( usCoilCount & 0x0007 ) != 0 ) + { + ucNBytes = ( UCHAR )( usCoilCount / 8 + 1 ); + } + else + { + ucNBytes = ( UCHAR )( usCoilCount / 8 ); + } + *pucFrameCur++ = ucNBytes; + *usLen += 1; + + eRegStatus = + eMBRegCoilsCB( pucFrameCur, usRegAddress, usCoilCount, + MB_REG_READ ); + + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + else + { + /* The response contains the function code, the starting address + * and the quantity of registers. We reuse the old values in the + * buffer because they are still valid. */ + *usLen += ucNBytes;; + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + else + { + /* Can't be a valid read coil register request because the length + * is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} + +#if MB_FUNC_WRITE_COIL_ENABLED > 0 +eMBException +eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + UCHAR ucBuf[2]; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen == ( MB_PDU_FUNC_WRITE_SIZE + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF + 1] ); + usRegAddress++; + + if( ( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF + 1] == 0x00 ) && + ( ( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF] == 0xFF ) || + ( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF] == 0x00 ) ) ) + { + ucBuf[1] = 0; + if( pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF] == 0xFF ) + { + ucBuf[0] = 1; + } + else + { + ucBuf[0] = 0; + } + eRegStatus = + eMBRegCoilsCB( &ucBuf[0], usRegAddress, 1, MB_REG_WRITE ); + + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + else + { + /* Can't be a valid write coil register request because the length + * is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} + +#endif + +#if MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED > 0 +eMBException +eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + USHORT usCoilCnt; + UCHAR ucByteCount; + UCHAR ucByteCountVerify; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen > ( MB_PDU_FUNC_WRITE_SIZE + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF + 1] ); + usRegAddress++; + + usCoilCnt = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_COILCNT_OFF] << 8 ); + usCoilCnt |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_COILCNT_OFF + 1] ); + + ucByteCount = pucFrame[MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF]; + + /* Compute the number of expected bytes in the request. */ + if( ( usCoilCnt & 0x0007 ) != 0 ) + { + ucByteCountVerify = ( UCHAR )( usCoilCnt / 8 + 1 ); + } + else + { + ucByteCountVerify = ( UCHAR )( usCoilCnt / 8 ); + } + + if( ( usCoilCnt >= 1 ) && + ( usCoilCnt <= MB_PDU_FUNC_WRITE_MUL_COILCNT_MAX ) && + ( ucByteCountVerify == ucByteCount ) ) + { + eRegStatus = + eMBRegCoilsCB( &pucFrame[MB_PDU_FUNC_WRITE_MUL_VALUES_OFF], + usRegAddress, usCoilCnt, MB_REG_WRITE ); + + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + else + { + /* The response contains the function code, the starting address + * and the quantity of registers. We reuse the old values in the + * buffer because they are still valid. */ + *usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF; + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + else + { + /* Can't be a valid write coil register request because the length + * is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} + +#endif + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncdiag.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncdiag.c new file mode 100644 index 000000000..8c32e85b1 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncdiag.c @@ -0,0 +1,28 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncdisc.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncdisc.c new file mode 100644 index 000000000..1dc10e5c1 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncdisc.c @@ -0,0 +1,133 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbframe.h" +#include "mbproto.h" +#include "mbconfig.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_PDU_FUNC_READ_ADDR_OFF ( MB_PDU_DATA_OFF ) +#define MB_PDU_FUNC_READ_DISCCNT_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_READ_SIZE ( 4 ) +#define MB_PDU_FUNC_READ_DISCCNT_MAX ( 0x07D0 ) + +/* ----------------------- Static functions ---------------------------------*/ +eMBException prveMBError2Exception( eMBErrorCode eErrorCode ); + +/* ----------------------- Start implementation -----------------------------*/ + +#if MB_FUNC_READ_COILS_ENABLED > 0 + +eMBException +eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + USHORT usDiscreteCnt; + UCHAR ucNBytes; + UCHAR *pucFrameCur; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen == ( MB_PDU_FUNC_READ_SIZE + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF + 1] ); + usRegAddress++; + + usDiscreteCnt = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_DISCCNT_OFF] << 8 ); + usDiscreteCnt |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_DISCCNT_OFF + 1] ); + + /* Check if the number of registers to read is valid. If not + * return Modbus illegal data value exception. + */ + if( ( usDiscreteCnt >= 1 ) && + ( usDiscreteCnt < MB_PDU_FUNC_READ_DISCCNT_MAX ) ) + { + /* Set the current PDU data pointer to the beginning. */ + pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF]; + *usLen = MB_PDU_FUNC_OFF; + + /* First byte contains the function code. */ + *pucFrameCur++ = MB_FUNC_READ_DISCRETE_INPUTS; + *usLen += 1; + + /* Test if the quantity of coils is a multiple of 8. If not last + * byte is only partially field with unused coils set to zero. */ + if( ( usDiscreteCnt & 0x0007 ) != 0 ) + { + ucNBytes = ( UCHAR ) ( usDiscreteCnt / 8 + 1 ); + } + else + { + ucNBytes = ( UCHAR ) ( usDiscreteCnt / 8 ); + } + *pucFrameCur++ = ucNBytes; + *usLen += 1; + + eRegStatus = + eMBRegDiscreteCB( pucFrameCur, usRegAddress, usDiscreteCnt ); + + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + else + { + /* The response contains the function code, the starting address + * and the quantity of registers. We reuse the old values in the + * buffer because they are still valid. */ + *usLen += ucNBytes;; + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + else + { + /* Can't be a valid read coil register request because the length + * is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncholding.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncholding.c new file mode 100644 index 000000000..3974b3e68 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncholding.c @@ -0,0 +1,307 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbframe.h" +#include "mbproto.h" +#include "mbconfig.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_PDU_FUNC_READ_ADDR_OFF ( MB_PDU_DATA_OFF + 0) +#define MB_PDU_FUNC_READ_REGCNT_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_READ_SIZE ( 4 ) +#define MB_PDU_FUNC_READ_REGCNT_MAX ( 0x007D ) + +#define MB_PDU_FUNC_WRITE_ADDR_OFF ( MB_PDU_DATA_OFF + 0) +#define MB_PDU_FUNC_WRITE_VALUE_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_WRITE_SIZE ( 4 ) + +#define MB_PDU_FUNC_WRITE_MUL_ADDR_OFF ( MB_PDU_DATA_OFF + 0 ) +#define MB_PDU_FUNC_WRITE_MUL_REGCNT_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF ( MB_PDU_DATA_OFF + 4 ) +#define MB_PDU_FUNC_WRITE_MUL_VALUES_OFF ( MB_PDU_DATA_OFF + 5 ) +#define MB_PDU_FUNC_WRITE_MUL_SIZE_MIN ( 5 ) +#define MB_PDU_FUNC_WRITE_MUL_REGCNT_MAX ( 0x0078 ) + +#define MB_PDU_FUNC_READWRITE_READ_ADDR_OFF ( MB_PDU_DATA_OFF + 0 ) +#define MB_PDU_FUNC_READWRITE_READ_REGCNT_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_READWRITE_WRITE_ADDR_OFF ( MB_PDU_DATA_OFF + 4 ) +#define MB_PDU_FUNC_READWRITE_WRITE_REGCNT_OFF ( MB_PDU_DATA_OFF + 6 ) +#define MB_PDU_FUNC_READWRITE_BYTECNT_OFF ( MB_PDU_DATA_OFF + 8 ) +#define MB_PDU_FUNC_READWRITE_WRITE_VALUES_OFF ( MB_PDU_DATA_OFF + 9 ) +#define MB_PDU_FUNC_READWRITE_SIZE_MIN ( 9 ) + +/* ----------------------- Static functions ---------------------------------*/ +eMBException prveMBError2Exception( eMBErrorCode eErrorCode ); + +/* ----------------------- Start implementation -----------------------------*/ + +#if MB_FUNC_WRITE_HOLDING_ENABLED > 0 + +eMBException +eMBFuncWriteHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen == ( MB_PDU_FUNC_WRITE_SIZE + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_ADDR_OFF + 1] ); + usRegAddress++; + + /* Make callback to update the value. */ + eRegStatus = eMBRegHoldingCB( &pucFrame[MB_PDU_FUNC_WRITE_VALUE_OFF], + usRegAddress, 1, MB_REG_WRITE ); + + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + } + else + { + /* Can't be a valid request because the length is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} +#endif + +#if MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED > 0 +eMBException +eMBFuncWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + USHORT usRegCount; + UCHAR ucRegByteCount; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen >= ( MB_PDU_FUNC_WRITE_MUL_SIZE_MIN + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_ADDR_OFF + 1] ); + usRegAddress++; + + usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_REGCNT_OFF] << 8 ); + usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_WRITE_MUL_REGCNT_OFF + 1] ); + + ucRegByteCount = pucFrame[MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF]; + + if( ( usRegCount >= 1 ) && + ( usRegCount <= MB_PDU_FUNC_WRITE_MUL_REGCNT_MAX ) && + ( ucRegByteCount == ( UCHAR ) ( 2 * usRegCount ) ) ) + { + /* Make callback to update the register values. */ + eRegStatus = + eMBRegHoldingCB( &pucFrame[MB_PDU_FUNC_WRITE_MUL_VALUES_OFF], + usRegAddress, usRegCount, MB_REG_WRITE ); + + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + else + { + /* The response contains the function code, the starting + * address and the quantity of registers. We reuse the + * old values in the buffer because they are still valid. + */ + *usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF; + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + else + { + /* Can't be a valid request because the length is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} +#endif + +#if MB_FUNC_READ_HOLDING_ENABLED > 0 + +eMBException +eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + USHORT usRegCount; + UCHAR *pucFrameCur; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen == ( MB_PDU_FUNC_READ_SIZE + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF + 1] ); + usRegAddress++; + + usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF] << 8 ); + usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); + + /* Check if the number of registers to read is valid. If not + * return Modbus illegal data value exception. + */ + if( ( usRegCount >= 1 ) && ( usRegCount <= MB_PDU_FUNC_READ_REGCNT_MAX ) ) + { + /* Set the current PDU data pointer to the beginning. */ + pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF]; + *usLen = MB_PDU_FUNC_OFF; + + /* First byte contains the function code. */ + *pucFrameCur++ = MB_FUNC_READ_HOLDING_REGISTER; + *usLen += 1; + + /* Second byte in the response contain the number of bytes. */ + *pucFrameCur++ = ( UCHAR ) ( usRegCount * 2 ); + *usLen += 1; + + /* Make callback to fill the buffer. */ + eRegStatus = eMBRegHoldingCB( pucFrameCur, usRegAddress, usRegCount, MB_REG_READ ); + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + else + { + *usLen += usRegCount * 2; + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + else + { + /* Can't be a valid request because the length is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} + +#endif + +#if MB_FUNC_READWRITE_HOLDING_ENABLED > 0 + +eMBException +eMBFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegReadAddress; + USHORT usRegReadCount; + USHORT usRegWriteAddress; + USHORT usRegWriteCount; + UCHAR ucRegWriteByteCount; + UCHAR *pucFrameCur; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen >= ( MB_PDU_FUNC_READWRITE_SIZE_MIN + MB_PDU_SIZE_MIN ) ) + { + usRegReadAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_ADDR_OFF] << 8U ); + usRegReadAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_ADDR_OFF + 1] ); + usRegReadAddress++; + + usRegReadCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_REGCNT_OFF] << 8U ); + usRegReadCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_READ_REGCNT_OFF + 1] ); + + usRegWriteAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_ADDR_OFF] << 8U ); + usRegWriteAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_ADDR_OFF + 1] ); + usRegWriteAddress++; + + usRegWriteCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_REGCNT_OFF] << 8U ); + usRegWriteCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READWRITE_WRITE_REGCNT_OFF + 1] ); + + ucRegWriteByteCount = pucFrame[MB_PDU_FUNC_READWRITE_BYTECNT_OFF]; + + if( ( usRegReadCount >= 1 ) && ( usRegReadCount <= 0x7D ) && + ( usRegWriteCount >= 1 ) && ( usRegWriteCount <= 0x79 ) && + ( ( 2 * usRegWriteCount ) == ucRegWriteByteCount ) ) + { + /* Make callback to update the register values. */ + eRegStatus = eMBRegHoldingCB( &pucFrame[MB_PDU_FUNC_READWRITE_WRITE_VALUES_OFF], + usRegWriteAddress, usRegWriteCount, MB_REG_WRITE ); + + if( eRegStatus == MB_ENOERR ) + { + /* Set the current PDU data pointer to the beginning. */ + pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF]; + *usLen = MB_PDU_FUNC_OFF; + + /* First byte contains the function code. */ + *pucFrameCur++ = MB_FUNC_READWRITE_MULTIPLE_REGISTERS; + *usLen += 1; + + /* Second byte in the response contain the number of bytes. */ + *pucFrameCur++ = ( UCHAR ) ( usRegReadCount * 2 ); + *usLen += 1; + + /* Make the read callback. */ + eRegStatus = + eMBRegHoldingCB( pucFrameCur, usRegReadAddress, usRegReadCount, MB_REG_READ ); + if( eRegStatus == MB_ENOERR ) + { + *usLen += 2 * usRegReadCount; + } + } + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + return eStatus; +} + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncinput.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncinput.c new file mode 100644 index 000000000..2cf1144f1 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncinput.c @@ -0,0 +1,121 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbframe.h" +#include "mbproto.h" +#include "mbconfig.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_PDU_FUNC_READ_ADDR_OFF ( MB_PDU_DATA_OFF ) +#define MB_PDU_FUNC_READ_REGCNT_OFF ( MB_PDU_DATA_OFF + 2 ) +#define MB_PDU_FUNC_READ_SIZE ( 4 ) +#define MB_PDU_FUNC_READ_REGCNT_MAX ( 0x007D ) + +#define MB_PDU_FUNC_READ_RSP_BYTECNT_OFF ( MB_PDU_DATA_OFF ) + +/* ----------------------- Static functions ---------------------------------*/ +eMBException prveMBError2Exception( eMBErrorCode eErrorCode ); + +/* ----------------------- Start implementation -----------------------------*/ +#if MB_FUNC_READ_INPUT_ENABLED > 0 + +eMBException +eMBFuncReadInputRegister( UCHAR * pucFrame, USHORT * usLen ) +{ + USHORT usRegAddress; + USHORT usRegCount; + UCHAR *pucFrameCur; + + eMBException eStatus = MB_EX_NONE; + eMBErrorCode eRegStatus; + + if( *usLen == ( MB_PDU_FUNC_READ_SIZE + MB_PDU_SIZE_MIN ) ) + { + usRegAddress = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF] << 8 ); + usRegAddress |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_ADDR_OFF + 1] ); + usRegAddress++; + + usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF] << 8 ); + usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); + + /* Check if the number of registers to read is valid. If not + * return Modbus illegal data value exception. + */ + if( ( usRegCount >= 1 ) + && ( usRegCount < MB_PDU_FUNC_READ_REGCNT_MAX ) ) + { + /* Set the current PDU data pointer to the beginning. */ + pucFrameCur = &pucFrame[MB_PDU_FUNC_OFF]; + *usLen = MB_PDU_FUNC_OFF; + + /* First byte contains the function code. */ + *pucFrameCur++ = MB_FUNC_READ_INPUT_REGISTER; + *usLen += 1; + + /* Second byte in the response contain the number of bytes. */ + *pucFrameCur++ = ( UCHAR )( usRegCount * 2 ); + *usLen += 1; + + eRegStatus = + eMBRegInputCB( pucFrameCur, usRegAddress, usRegCount ); + + /* If an error occured convert it into a Modbus exception. */ + if( eRegStatus != MB_ENOERR ) + { + eStatus = prveMBError2Exception( eRegStatus ); + } + else + { + *usLen += usRegCount * 2; + } + } + else + { + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + } + else + { + /* Can't be a valid read input register request because the length + * is incorrect. */ + eStatus = MB_EX_ILLEGAL_DATA_VALUE; + } + return eStatus; +} + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncother.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncother.c new file mode 100644 index 000000000..adbc85da9 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbfuncother.c @@ -0,0 +1,87 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbframe.h" +#include "mbproto.h" +#include "mbconfig.h" + +#if MB_FUNC_OTHER_REP_SLAVEID_ENABLED > 0 + +/* ----------------------- Static variables ---------------------------------*/ +static UCHAR ucMBSlaveID[MB_FUNC_OTHER_REP_SLAVEID_BUF]; +static USHORT usMBSlaveIDLen; + +/* ----------------------- Start implementation -----------------------------*/ + +eMBErrorCode +eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning, + UCHAR const *pucAdditional, USHORT usAdditionalLen ) +{ + eMBErrorCode eStatus = MB_ENOERR; + + /* the first byte and second byte in the buffer is reserved for + * the parameter ucSlaveID and the running flag. The rest of + * the buffer is available for additional data. */ + if( usAdditionalLen + 2 < MB_FUNC_OTHER_REP_SLAVEID_BUF ) + { + usMBSlaveIDLen = 0; + ucMBSlaveID[usMBSlaveIDLen++] = ucSlaveID; + ucMBSlaveID[usMBSlaveIDLen++] = ( UCHAR )( xIsRunning ? 0xFF : 0x00 ); + if( usAdditionalLen > 0 ) + { + memcpy( &ucMBSlaveID[usMBSlaveIDLen], pucAdditional, + ( size_t )usAdditionalLen ); + usMBSlaveIDLen += usAdditionalLen; + } + } + else + { + eStatus = MB_ENORES; + } + return eStatus; +} + +eMBException +eMBFuncReportSlaveID( UCHAR * pucFrame, USHORT * usLen ) +{ + memcpy( &pucFrame[MB_PDU_DATA_OFF], &ucMBSlaveID[0], ( size_t )usMBSlaveIDLen ); + *usLen = ( USHORT )( MB_PDU_DATA_OFF + usMBSlaveIDLen ); + return MB_EX_NONE; +} + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbutils.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbutils.c new file mode 100644 index 000000000..be384fc52 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/functions/mbutils.c @@ -0,0 +1,140 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbproto.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define BITS_UCHAR 8U + +/* ----------------------- Start implementation -----------------------------*/ +void +xMBUtilSetBits( UCHAR * ucByteBuf, USHORT usBitOffset, UCHAR ucNBits, + UCHAR ucValue ) +{ + USHORT usWordBuf; + USHORT usMask; + USHORT usByteOffset; + USHORT usNPreBits; + USHORT usValue = ucValue; + + assert( ucNBits <= 8 ); + assert( ( size_t )BITS_UCHAR == sizeof( UCHAR ) * 8 ); + + /* Calculate byte offset for first byte containing the bit values starting + * at usBitOffset. */ + usByteOffset = ( USHORT )( ( usBitOffset ) / BITS_UCHAR ); + + /* How many bits precede our bits to set. */ + usNPreBits = ( USHORT )( usBitOffset - usByteOffset * BITS_UCHAR ); + + /* Move bit field into position over bits to set */ + usValue <<= usNPreBits; + + /* Prepare a mask for setting the new bits. */ + usMask = ( USHORT )( ( 1 << ( USHORT ) ucNBits ) - 1 ); + usMask <<= usBitOffset - usByteOffset * BITS_UCHAR; + + /* copy bits into temporary storage. */ + usWordBuf = ucByteBuf[usByteOffset]; + usWordBuf |= ucByteBuf[usByteOffset + 1] << BITS_UCHAR; + + /* Zero out bit field bits and then or value bits into them. */ + usWordBuf = ( USHORT )( ( usWordBuf & ( ~usMask ) ) | usValue ); + + /* move bits back into storage */ + ucByteBuf[usByteOffset] = ( UCHAR )( usWordBuf & 0xFF ); + ucByteBuf[usByteOffset + 1] = ( UCHAR )( usWordBuf >> BITS_UCHAR ); +} + +UCHAR +xMBUtilGetBits( UCHAR * ucByteBuf, USHORT usBitOffset, UCHAR ucNBits ) +{ + USHORT usWordBuf; + USHORT usMask; + USHORT usByteOffset; + USHORT usNPreBits; + + /* Calculate byte offset for first byte containing the bit values starting + * at usBitOffset. */ + usByteOffset = ( USHORT )( ( usBitOffset ) / BITS_UCHAR ); + + /* How many bits precede our bits to set. */ + usNPreBits = ( USHORT )( usBitOffset - usByteOffset * BITS_UCHAR ); + + /* Prepare a mask for setting the new bits. */ + usMask = ( USHORT )( ( 1 << ( USHORT ) ucNBits ) - 1 ); + + /* copy bits into temporary storage. */ + usWordBuf = ucByteBuf[usByteOffset]; + usWordBuf |= ucByteBuf[usByteOffset + 1] << BITS_UCHAR; + + /* throw away unneeded bits. */ + usWordBuf >>= usNPreBits; + + /* mask away bits above the requested bitfield. */ + usWordBuf &= usMask; + + return ( UCHAR ) usWordBuf; +} + +eMBException +prveMBError2Exception( eMBErrorCode eErrorCode ) +{ + eMBException eStatus; + + switch ( eErrorCode ) + { + case MB_ENOERR: + eStatus = MB_EX_NONE; + break; + + case MB_ENOREG: + eStatus = MB_EX_ILLEGAL_DATA_ADDRESS; + break; + + case MB_ETIMEDOUT: + eStatus = MB_EX_SLAVE_BUSY; + break; + + default: + eStatus = MB_EX_SLAVE_DEVICE_FAILURE; + break; + } + + return eStatus; +} diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mb.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mb.h new file mode 100644 index 000000000..1c09e77f5 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mb.h @@ -0,0 +1,416 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_H +#define _MB_H + +#include "port.h" + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif + +#include "mbport.h" +#include "mbproto.h" + +/*! \defgroup modbus Modbus + * \code #include "mb.h" \endcode + * + * This module defines the interface for the application. It contains + * the basic functions and types required to use the Modbus protocol stack. + * A typical application will want to call eMBInit() first. If the device + * is ready to answer network requests it must then call eMBEnable() to activate + * the protocol stack. In the main loop the function eMBPoll() must be called + * periodically. The time interval between pooling depends on the configured + * Modbus timeout. If an RTOS is available a separate task should be created + * and the task should always call the function eMBPoll(). + * + * \code + * // Initialize protocol stack in RTU mode for a slave with address 10 = 0x0A + * eMBInit( MB_RTU, 0x0A, 38400, MB_PAR_EVEN ); + * // Enable the Modbus Protocol Stack. + * eMBEnable( ); + * for( ;; ) + * { + * // Call the main polling loop of the Modbus protocol stack. + * eMBPoll( ); + * ... + * } + * \endcode + */ + +/* ----------------------- Defines ------------------------------------------*/ + +/*! \ingroup modbus + * \brief Use the default Modbus TCP port (502) + */ +#define MB_TCP_PORT_USE_DEFAULT 0 + +/* ----------------------- Type definitions ---------------------------------*/ + +/*! \ingroup modbus + * \brief Modbus serial transmission modes (RTU/ASCII). + * + * Modbus serial supports two transmission modes. Either ASCII or RTU. RTU + * is faster but has more hardware requirements and requires a network with + * a low jitter. ASCII is slower and more reliable on slower links (E.g. modems) + */ + typedef enum +{ + MB_RTU, /*!< RTU transmission mode. */ + MB_ASCII, /*!< ASCII transmission mode. */ + MB_TCP /*!< TCP mode. */ +} eMBMode; + +/*! \ingroup modbus + * \brief If register should be written or read. + * + * This value is passed to the callback functions which support either + * reading or writing register values. Writing means that the application + * registers should be updated and reading means that the modbus protocol + * stack needs to know the current register values. + * + * \see eMBRegHoldingCB( ), eMBRegCoilsCB( ), eMBRegDiscreteCB( ) and + * eMBRegInputCB( ). + */ +typedef enum +{ + MB_REG_READ, /*!< Read register values and pass to protocol stack. */ + MB_REG_WRITE /*!< Update register values. */ +} eMBRegisterMode; + +/*! \ingroup modbus + * \brief Errorcodes used by all function in the protocol stack. + */ +typedef enum +{ + MB_ENOERR, /*!< no error. */ + MB_ENOREG, /*!< illegal register address. */ + MB_EINVAL, /*!< illegal argument. */ + MB_EPORTERR, /*!< porting layer error. */ + MB_ENORES, /*!< insufficient resources. */ + MB_EIO, /*!< I/O error. */ + MB_EILLSTATE, /*!< protocol stack in illegal state. */ + MB_ETIMEDOUT /*!< timeout error occurred. */ +} eMBErrorCode; + + +/* ----------------------- Function prototypes ------------------------------*/ +/*! \ingroup modbus + * \brief Initialize the Modbus protocol stack. + * + * This functions initializes the ASCII or RTU module and calls the + * init functions of the porting layer to prepare the hardware. Please + * note that the receiver is still disabled and no Modbus frames are + * processed until eMBEnable( ) has been called. + * + * \param eMode If ASCII or RTU mode should be used. + * \param ucSlaveAddress The slave address. Only frames sent to this + * address or to the broadcast address are processed. + * \param ucPort The port to use. E.g. 1 for COM1 on windows. This value + * is platform dependent and some ports simply choose to ignore it. + * \param ulBaudRate The baudrate. E.g. 19200. Supported baudrates depend + * on the porting layer. + * \param eParity Parity used for serial transmission. + * + * \return If no error occurs the function returns eMBErrorCode::MB_ENOERR. + * The protocol is then in the disabled state and ready for activation + * by calling eMBEnable( ). Otherwise one of the following error codes + * is returned: + * - eMBErrorCode::MB_EINVAL If the slave address was not valid. Valid + * slave addresses are in the range 1 - 247. + * - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error. + */ +eMBErrorCode eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, + UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity ); + +/*! \ingroup modbus + * \brief Initialize the Modbus protocol stack for Modbus TCP. + * + * This function initializes the Modbus TCP Module. Please note that + * frame processing is still disabled until eMBEnable( ) is called. + * + * \param usTCPPort The TCP port to listen on. + * \return If the protocol stack has been initialized correctly the function + * returns eMBErrorCode::MB_ENOERR. Otherwise one of the following error + * codes is returned: + * - eMBErrorCode::MB_EINVAL If the slave address was not valid. Valid + * slave addresses are in the range 1 - 247. + * - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error. + */ +eMBErrorCode eMBTCPInit( USHORT usTCPPort ); + +/*! \ingroup modbus + * \brief Release resources used by the protocol stack. + * + * This function disables the Modbus protocol stack and release all + * hardware resources. It must only be called when the protocol stack + * is disabled. + * + * \note Note all ports implement this function. A port which wants to + * get an callback must define the macro MB_PORT_HAS_CLOSE to 1. + * + * \return If the resources where released it return eMBErrorCode::MB_ENOERR. + * If the protocol stack is not in the disabled state it returns + * eMBErrorCode::MB_EILLSTATE. + */ +eMBErrorCode eMBClose( void ); + +/*! \ingroup modbus + * \brief Enable the Modbus protocol stack. + * + * This function enables processing of Modbus frames. Enabling the protocol + * stack is only possible if it is in the disabled state. + * + * \return If the protocol stack is now in the state enabled it returns + * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it + * return eMBErrorCode::MB_EILLSTATE. + */ +eMBErrorCode eMBEnable( void ); + +/*! \ingroup modbus + * \brief Disable the Modbus protocol stack. + * + * This function disables processing of Modbus frames. + * + * \return If the protocol stack has been disabled it returns + * eMBErrorCode::MB_ENOERR. If it was not in the enabled state it returns + * eMBErrorCode::MB_EILLSTATE. + */ +eMBErrorCode eMBDisable( void ); + +/*! \ingroup modbus + * \brief The main pooling loop of the Modbus protocol stack. + * + * This function must be called periodically. The timer interval required + * is given by the application dependent Modbus slave timeout. Internally the + * function calls xMBPortEventGet() and waits for an event from the receiver or + * transmitter state machines. + * + * \return If the protocol stack is not in the enabled state the function + * returns eMBErrorCode::MB_EILLSTATE. Otherwise it returns + * eMBErrorCode::MB_ENOERR. + */ +eMBErrorCode eMBPoll( void ); + +/*! \ingroup modbus + * \brief Configure the slave id of the device. + * + * This function should be called when the Modbus function Report Slave ID + * is enabled ( By defining MB_FUNC_OTHER_REP_SLAVEID_ENABLED in mbconfig.h ). + * + * \param ucSlaveID Values is returned in the Slave ID byte of the + * Report Slave ID response. + * \param xIsRunning If TRUE the Run Indicator Status byte is set to 0xFF. + * otherwise the Run Indicator Status is 0x00. + * \param pucAdditional Values which should be returned in the Additional + * bytes of the Report Slave ID response. + * \param usAdditionalLen Length of the buffer pucAdditonal. + * + * \return If the static buffer defined by MB_FUNC_OTHER_REP_SLAVEID_BUF in + * mbconfig.h is to small it returns eMBErrorCode::MB_ENORES. Otherwise + * it returns eMBErrorCode::MB_ENOERR. + */ +eMBErrorCode eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning, + UCHAR const *pucAdditional, + USHORT usAdditionalLen ); + +/*! \ingroup modbus + * \brief Registers a callback handler for a given function code. + * + * This function registers a new callback handler for a given function code. + * The callback handler supplied is responsible for interpreting the Modbus PDU and + * the creation of an appropriate response. In case of an error it should return + * one of the possible Modbus exceptions which results in a Modbus exception frame + * sent by the protocol stack. + * + * \param ucFunctionCode The Modbus function code for which this handler should + * be registers. Valid function codes are in the range 1 to 127. + * \param pxHandler The function handler which should be called in case + * such a frame is received. If \c NULL a previously registered function handler + * for this function code is removed. + * + * \return eMBErrorCode::MB_ENOERR if the handler has been installed. If no + * more resources are available it returns eMBErrorCode::MB_ENORES. In this + * case the values in mbconfig.h should be adjusted. If the argument was not + * valid it returns eMBErrorCode::MB_EINVAL. + */ +eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode, + pxMBFunctionHandler pxHandler ); + +/* ----------------------- Callback -----------------------------------------*/ + +/*! \defgroup modbus_registers Modbus Registers + * \code #include "mb.h" \endcode + * The protocol stack does not internally allocate any memory for the + * registers. This makes the protocol stack very small and also usable on + * low end targets. In addition the values don't have to be in the memory + * and could for example be stored in a flash.
+ * Whenever the protocol stack requires a value it calls one of the callback + * function with the register address and the number of registers to read + * as an argument. The application should then read the actual register values + * (for example the ADC voltage) and should store the result in the supplied + * buffer.
+ * If the protocol stack wants to update a register value because a write + * register function was received a buffer with the new register values is + * passed to the callback function. The function should then use these values + * to update the application register values. + */ + +/*! \ingroup modbus_registers + * \brief Callback function used if the value of a Input Register + * is required by the protocol stack. The starting register address is given + * by \c usAddress and the last register is given by usAddress + + * usNRegs - 1. + * + * \param pucRegBuffer A buffer where the callback function should write + * the current value of the modbus registers to. + * \param usAddress The starting address of the register. Input registers + * are in the range 1 - 65535. + * \param usNRegs Number of registers the callback function must supply. + * + * \return The function must return one of the following error codes: + * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal + * Modbus response is sent. + * - eMBErrorCode::MB_ENOREG If the application can not supply values + * for registers within this range. In this case a + * ILLEGAL DATA ADDRESS exception frame is sent as a response. + * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is + * currently not available and the application dependent response + * timeout would be violated. In this case a SLAVE DEVICE BUSY + * exception is sent as a response. + * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case + * a SLAVE DEVICE FAILURE exception is sent as a response. + */ +eMBErrorCode eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, + USHORT usNRegs ); + +/*! \ingroup modbus_registers + * \brief Callback function used if a Holding Register value is + * read or written by the protocol stack. The starting register address + * is given by \c usAddress and the last register is given by + * usAddress + usNRegs - 1. + * + * \param pucRegBuffer If the application registers values should be updated the + * buffer points to the new registers values. If the protocol stack needs + * to now the current values the callback function should write them into + * this buffer. + * \param usAddress The starting address of the register. + * \param usNRegs Number of registers to read or write. + * \param eMode If eMBRegisterMode::MB_REG_WRITE the application register + * values should be updated from the values in the buffer. For example + * this would be the case when the Modbus master has issued an + * WRITE SINGLE REGISTER command. + * If the value eMBRegisterMode::MB_REG_READ the application should copy + * the current values into the buffer \c pucRegBuffer. + * + * \return The function must return one of the following error codes: + * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal + * Modbus response is sent. + * - eMBErrorCode::MB_ENOREG If the application can not supply values + * for registers within this range. In this case a + * ILLEGAL DATA ADDRESS exception frame is sent as a response. + * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is + * currently not available and the application dependent response + * timeout would be violated. In this case a SLAVE DEVICE BUSY + * exception is sent as a response. + * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case + * a SLAVE DEVICE FAILURE exception is sent as a response. + */ +eMBErrorCode eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, + USHORT usNRegs, eMBRegisterMode eMode ); + +/*! \ingroup modbus_registers + * \brief Callback function used if a Coil Register value is + * read or written by the protocol stack. If you are going to use + * this function you might use the functions xMBUtilSetBits( ) and + * xMBUtilGetBits( ) for working with bitfields. + * + * \param pucRegBuffer The bits are packed in bytes where the first coil + * starting at address \c usAddress is stored in the LSB of the + * first byte in the buffer pucRegBuffer. + * If the buffer should be written by the callback function unused + * coil values (I.e. if not a multiple of eight coils is used) should be set + * to zero. + * \param usAddress The first coil number. + * \param usNCoils Number of coil values requested. + * \param eMode If eMBRegisterMode::MB_REG_WRITE the application values should + * be updated from the values supplied in the buffer \c pucRegBuffer. + * If eMBRegisterMode::MB_REG_READ the application should store the current + * values in the buffer \c pucRegBuffer. + * + * \return The function must return one of the following error codes: + * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal + * Modbus response is sent. + * - eMBErrorCode::MB_ENOREG If the application does not map an coils + * within the requested address range. In this case a + * ILLEGAL DATA ADDRESS is sent as a response. + * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is + * currently not available and the application dependent response + * timeout would be violated. In this case a SLAVE DEVICE BUSY + * exception is sent as a response. + * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case + * a SLAVE DEVICE FAILURE exception is sent as a response. + */ +eMBErrorCode eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, + USHORT usNCoils, eMBRegisterMode eMode ); + +/*! \ingroup modbus_registers + * \brief Callback function used if a Input Discrete Register value is + * read by the protocol stack. + * + * If you are going to use his function you might use the functions + * xMBUtilSetBits( ) and xMBUtilGetBits( ) for working with bitfields. + * + * \param pucRegBuffer The buffer should be updated with the current + * coil values. The first discrete input starting at \c usAddress must be + * stored at the LSB of the first byte in the buffer. If the requested number + * is not a multiple of eight the remaining bits should be set to zero. + * \param usAddress The starting address of the first discrete input. + * \param usNDiscrete Number of discrete input values. + * \return The function must return one of the following error codes: + * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal + * Modbus response is sent. + * - eMBErrorCode::MB_ENOREG If no such discrete inputs exists. + * In this case a ILLEGAL DATA ADDRESS exception frame is sent + * as a response. + * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is + * currently not available and the application dependent response + * timeout would be violated. In this case a SLAVE DEVICE BUSY + * exception is sent as a response. + * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case + * a SLAVE DEVICE FAILURE exception is sent as a response. + */ +eMBErrorCode eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, + USHORT usNDiscrete ); + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbconfig.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbconfig.h new file mode 100644 index 000000000..26354b435 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbconfig.h @@ -0,0 +1,131 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_CONFIG_H +#define _MB_CONFIG_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif +/* ----------------------- Defines ------------------------------------------*/ +/*! \defgroup modbus_cfg Modbus Configuration + * + * Most modules in the protocol stack are completly optional and can be + * excluded. This is specially important if target resources are very small + * and program memory space should be saved.
+ * + * All of these settings are available in the file mbconfig.h + */ +/*! \addtogroup modbus_cfg + * @{ + */ +/*! \brief If Modbus ASCII support is enabled. */ +#define MB_ASCII_ENABLED ( 0 )//gai + +/*! \brief If Modbus RTU support is enabled. */ +#define MB_RTU_ENABLED ( 1 ) + +/*! \brief If Modbus TCP support is enabled. */ +#define MB_TCP_ENABLED ( 0 ) + +/*! \brief The character timeout value for Modbus ASCII. + * + * The character timeout value is not fixed for Modbus ASCII and is therefore + * a configuration option. It should be set to the maximum expected delay + * time of the network. + */ +#define MB_ASCII_TIMEOUT_SEC ( 1 ) + +/*! \brief Timeout to wait in ASCII prior to enabling transmitter. + * + * If defined the function calls vMBPortSerialDelay with the argument + * MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS to allow for a delay before + * the serial transmitter is enabled. This is required because some + * targets are so fast that there is no time between receiving and + * transmitting the frame. If the master is to slow with enabling its + * receiver then he will not receive the response correctly. + */ +#ifndef MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS +#define MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ( 0 ) +#endif + +/*! \brief Maximum number of Modbus functions codes the protocol stack + * should support. + * + * The maximum number of supported Modbus functions must be greater than + * the sum of all enabled functions in this file and custom function + * handlers. If set to small adding more functions will fail. + */ +#define MB_FUNC_HANDLERS_MAX ( 16 ) + +/*! \brief Number of bytes which should be allocated for the Report Slave ID + * command. + * + * This number limits the maximum size of the additional segment in the + * report slave id function. See eMBSetSlaveID( ) for more information on + * how to set this value. It is only used if MB_FUNC_OTHER_REP_SLAVEID_ENABLED + * is set to 1. + */ +#define MB_FUNC_OTHER_REP_SLAVEID_BUF ( 32 ) + +/*! \brief If the Report Slave ID function should be enabled. */ +#define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( 1 ) + +/*! \brief If the Read Input Registers function should be enabled. */ +#define MB_FUNC_READ_INPUT_ENABLED ( 1 ) + +/*! \brief If the Read Holding Registers function should be enabled. */ +#define MB_FUNC_READ_HOLDING_ENABLED ( 1 ) + +/*! \brief If the Write Single Register function should be enabled. */ +#define MB_FUNC_WRITE_HOLDING_ENABLED ( 1 ) + +/*! \brief If the Write Multiple registers function should be enabled. */ +#define MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED ( 1 ) + +/*! \brief If the Read Coils function should be enabled. */ +#define MB_FUNC_READ_COILS_ENABLED ( 1 ) + +/*! \brief If the Write Coils function should be enabled. */ +#define MB_FUNC_WRITE_COIL_ENABLED ( 1 ) + +/*! \brief If the Write Multiple Coils function should be enabled. */ +#define MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED ( 1 ) + +/*! \brief If the Read Discrete Inputs function should be enabled. */ +#define MB_FUNC_READ_DISCRETE_INPUTS_ENABLED ( 1 ) + +/*! \brief If the Read/Write Multiple Registers function should be enabled. */ +#define MB_FUNC_READWRITE_HOLDING_ENABLED ( 1 ) + +/*! @} */ +#ifdef __cplusplus + PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbframe.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbframe.h new file mode 100644 index 000000000..69a76989a --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbframe.h @@ -0,0 +1,86 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_FRAME_H +#define _MB_FRAME_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif + +/*! + * Constants which defines the format of a modbus frame. The example is + * shown for a Modbus RTU/ASCII frame. Note that the Modbus PDU is not + * dependent on the underlying transport. + * + * + * <------------------------ MODBUS SERIAL LINE PDU (1) -------------------> + * <----------- MODBUS PDU (1') ----------------> + * +-----------+---------------+----------------------------+-------------+ + * | Address | Function Code | Data | CRC/LRC | + * +-----------+---------------+----------------------------+-------------+ + * | | | | + * (2) (3/2') (3') (4) + * + * (1) ... MB_SER_PDU_SIZE_MAX = 256 + * (2) ... MB_SER_PDU_ADDR_OFF = 0 + * (3) ... MB_SER_PDU_PDU_OFF = 1 + * (4) ... MB_SER_PDU_SIZE_CRC = 2 + * + * (1') ... MB_PDU_SIZE_MAX = 253 + * (2') ... MB_PDU_FUNC_OFF = 0 + * (3') ... MB_PDU_DATA_OFF = 1 + * + */ + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_PDU_SIZE_MAX 253 /*!< Maximum size of a PDU. */ +#define MB_PDU_SIZE_MIN 1 /*!< Function Code */ +#define MB_PDU_FUNC_OFF 0 /*!< Offset of function code in PDU. */ +#define MB_PDU_DATA_OFF 1 /*!< Offset for response data in PDU. */ + +/* ----------------------- Prototypes 0-------------------------------------*/ +typedef void ( *pvMBFrameStart ) ( void ); + +typedef void ( *pvMBFrameStop ) ( void ); + +typedef eMBErrorCode( *peMBFrameReceive ) ( UCHAR * pucRcvAddress, + UCHAR ** pucFrame, + USHORT * pusLength ); + +typedef eMBErrorCode( *peMBFrameSend ) ( UCHAR slaveAddress, + const UCHAR * pucFrame, + USHORT usLength ); + +typedef void( *pvMBFrameClose ) ( void ); + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbfunc.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbfunc.h new file mode 100644 index 000000000..ccf54efe2 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbfunc.h @@ -0,0 +1,79 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_FUNC_H +#define _MB_FUNC_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif +#if MB_FUNC_OTHER_REP_SLAVEID_BUF > 0 + eMBException eMBFuncReportSlaveID( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_READ_INPUT_ENABLED > 0 +eMBException eMBFuncReadInputRegister( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_READ_HOLDING_ENABLED > 0 +eMBException eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_WRITE_HOLDING_ENABLED > 0 +eMBException eMBFuncWriteHoldingRegister( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED > 0 +eMBException eMBFuncWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_READ_COILS_ENABLED > 0 +eMBException eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_WRITE_COIL_ENABLED > 0 +eMBException eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED > 0 +eMBException eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_READ_DISCRETE_INPUTS_ENABLED > 0 +eMBException eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#if MB_FUNC_READWRITE_HOLDING_ENABLED > 0 +eMBException eMBFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen ); +#endif + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbport.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbport.h new file mode 100644 index 000000000..3198f1be6 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbport.h @@ -0,0 +1,128 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_PORT_H +#define _MB_PORT_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif + +/* ----------------------- Type definitions ---------------------------------*/ + +typedef enum +{ + EV_READY, /*!< Startup finished. */ + EV_FRAME_RECEIVED, /*!< Frame received. */ + EV_EXECUTE, /*!< Execute function. */ + EV_FRAME_SENT /*!< Frame sent. */ +} eMBEventType; + +/*! \ingroup modbus + * \brief Parity used for characters in serial mode. + * + * The parity which should be applied to the characters sent over the serial + * link. Please note that this values are actually passed to the porting + * layer and therefore not all parity modes might be available. + */ +typedef enum +{ + MB_PAR_NONE, /*!< No parity. */ + MB_PAR_ODD, /*!< Odd parity. */ + MB_PAR_EVEN /*!< Even parity. */ +} eMBParity; + +/* ----------------------- Supporting functions -----------------------------*/ +BOOL xMBPortEventInit( void ); + +BOOL xMBPortEventPost( eMBEventType eEvent ); + +BOOL xMBPortEventGet( /*@out@ */ eMBEventType * eEvent ); + +/* ----------------------- Serial port functions ----------------------------*/ + +BOOL xMBPortSerialInit( UCHAR ucPort, ULONG ulBaudRate, + UCHAR ucDataBits, eMBParity eParity ); + +void vMBPortClose( void ); + +void xMBPortSerialClose( void ); + +void vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable ); + +BOOL xMBPortSerialGetByte( CHAR * pucByte ); + +BOOL xMBPortSerialPutByte( CHAR ucByte ); + +/* ----------------------- Timers functions ---------------------------------*/ +BOOL xMBPortTimersInit( USHORT usTimeOut50us ); + +void xMBPortTimersClose( void ); + +void vMBPortTimersEnable( void ); + +void vMBPortTimersDisable( void ); + +void vMBPortTimersDelay( USHORT usTimeOutMS ); + +/* ----------------------- Callback for the protocol stack ------------------*/ + +/*! + * \brief Callback function for the porting layer when a new byte is + * available. + * + * Depending upon the mode this callback function is used by the RTU or + * ASCII transmission layers. In any case a call to xMBPortSerialGetByte() + * must immediately return a new character. + * + * \return TRUE if a event was posted to the queue because + * a new byte was received. The port implementation should wake up the + * tasks which are currently blocked on the eventqueue. + */ +extern BOOL( *pxMBFrameCBByteReceived ) ( void ); + +extern BOOL( *pxMBFrameCBTransmitterEmpty ) ( void ); + +extern BOOL( *pxMBPortCBTimerExpired ) ( void ); + +/* ----------------------- TCP port functions -------------------------------*/ +BOOL xMBTCPPortInit( USHORT usTCPPort ); + +void vMBTCPPortClose( void ); + +void vMBTCPPortDisable( void ); + +BOOL xMBTCPPortGetRequest( UCHAR **ppucMBTCPFrame, USHORT * usTCPLength ); + +BOOL xMBTCPPortSendResponse( const UCHAR *pucMBTCPFrame, USHORT usTCPLength ); + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbproto.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbproto.h new file mode 100644 index 000000000..e2d14cf05 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbproto.h @@ -0,0 +1,82 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_PROTO_H +#define _MB_PROTO_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif +/* ----------------------- Defines ------------------------------------------*/ +#define MB_ADDRESS_BROADCAST ( 0 ) /*! Modbus broadcast address. */ +#define MB_ADDRESS_MIN ( 1 ) /*! Smallest possible slave address. */ +#define MB_ADDRESS_MAX ( 247 ) /*! Biggest possible slave address. */ +#define MB_FUNC_NONE ( 0 ) +#define MB_FUNC_READ_COILS ( 1 ) +#define MB_FUNC_READ_DISCRETE_INPUTS ( 2 ) +#define MB_FUNC_WRITE_SINGLE_COIL ( 5 ) +#define MB_FUNC_WRITE_MULTIPLE_COILS ( 15 ) +#define MB_FUNC_READ_HOLDING_REGISTER ( 3 ) +#define MB_FUNC_READ_INPUT_REGISTER ( 4 ) +#define MB_FUNC_WRITE_REGISTER ( 6 ) +#define MB_FUNC_WRITE_MULTIPLE_REGISTERS ( 16 ) +#define MB_FUNC_READWRITE_MULTIPLE_REGISTERS ( 23 ) +#define MB_FUNC_DIAG_READ_EXCEPTION ( 7 ) +#define MB_FUNC_DIAG_DIAGNOSTIC ( 8 ) +#define MB_FUNC_DIAG_GET_COM_EVENT_CNT ( 11 ) +#define MB_FUNC_DIAG_GET_COM_EVENT_LOG ( 12 ) +#define MB_FUNC_OTHER_REPORT_SLAVEID ( 17 ) +#define MB_FUNC_ERROR ( 128 ) +/* ----------------------- Type definitions ---------------------------------*/ + typedef enum +{ + MB_EX_NONE = 0x00, + MB_EX_ILLEGAL_FUNCTION = 0x01, + MB_EX_ILLEGAL_DATA_ADDRESS = 0x02, + MB_EX_ILLEGAL_DATA_VALUE = 0x03, + MB_EX_SLAVE_DEVICE_FAILURE = 0x04, + MB_EX_ACKNOWLEDGE = 0x05, + MB_EX_SLAVE_BUSY = 0x06, + MB_EX_MEMORY_PARITY_ERROR = 0x08, + MB_EX_GATEWAY_PATH_FAILED = 0x0A, + MB_EX_GATEWAY_TGT_FAILED = 0x0B +} eMBException; + +typedef eMBException( *pxMBFunctionHandler ) ( UCHAR * pucFrame, USHORT * pusLength ); + +typedef struct +{ + UCHAR ucFunctionCode; + pxMBFunctionHandler pxHandler; +} xMBFunctionHandler; + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbutils.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbutils.h new file mode 100644 index 000000000..385b8c156 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/include/mbutils.h @@ -0,0 +1,107 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_UTILS_H +#define _MB_UTILS_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif +/*! \defgroup modbus_utils Utilities + * + * This module contains some utility functions which can be used by + * the application. It includes some special functions for working with + * bitfields backed by a character array buffer. + * + */ +/*! \addtogroup modbus_utils + * @{ + */ +/*! \brief Function to set bits in a byte buffer. + * + * This function allows the efficient use of an array to implement bitfields. + * The array used for storing the bits must always be a multiple of two + * bytes. Up to eight bits can be set or cleared in one operation. + * + * \param ucByteBuf A buffer where the bit values are stored. Must be a + * multiple of 2 bytes. No length checking is performed and if + * usBitOffset / 8 is greater than the size of the buffer memory contents + * is overwritten. + * \param usBitOffset The starting address of the bits to set. The first + * bit has the offset 0. + * \param ucNBits Number of bits to modify. The value must always be smaller + * than 8. + * \param ucValues Thew new values for the bits. The value for the first bit + * starting at usBitOffset is the LSB of the value + * ucValues + * + * \code + * ucBits[2] = {0, 0}; + * + * // Set bit 4 to 1 (read: set 1 bit starting at bit offset 4 to value 1) + * xMBUtilSetBits( ucBits, 4, 1, 1 ); + * + * // Set bit 7 to 1 and bit 8 to 0. + * xMBUtilSetBits( ucBits, 7, 2, 0x01 ); + * + * // Set bits 8 - 11 to 0x05 and bits 12 - 15 to 0x0A; + * xMBUtilSetBits( ucBits, 8, 8, 0x5A); + * \endcode + */ +void xMBUtilSetBits( UCHAR * ucByteBuf, USHORT usBitOffset, + UCHAR ucNBits, UCHAR ucValues ); + +/*! \brief Function to read bits in a byte buffer. + * + * This function is used to extract up bit values from an array. Up to eight + * bit values can be extracted in one step. + * + * \param ucByteBuf A buffer where the bit values are stored. + * \param usBitOffset The starting address of the bits to set. The first + * bit has the offset 0. + * \param ucNBits Number of bits to modify. The value must always be smaller + * than 8. + * + * \code + * UCHAR ucBits[2] = {0, 0}; + * UCHAR ucResult; + * + * // Extract the bits 3 - 10. + * ucResult = xMBUtilGetBits( ucBits, 3, 8 ); + * \endcode + */ +UCHAR xMBUtilGetBits( UCHAR * ucByteBuf, USHORT usBitOffset, + UCHAR ucNBits ); + +/*! @} */ + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/mb.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/mb.c new file mode 100644 index 000000000..e2450cc79 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/mb.c @@ -0,0 +1,411 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbconfig.h" +#include "mbframe.h" +#include "mbproto.h" +#include "mbfunc.h" + +#include "mbport.h" +#if MB_RTU_ENABLED == 1 +#include "mbrtu.h" +#endif +#if MB_ASCII_ENABLED == 1 +#include "mbascii.h" +#endif +#if MB_TCP_ENABLED == 1 +#include "mbtcp.h" +#endif + +#ifndef MB_PORT_HAS_CLOSE +#define MB_PORT_HAS_CLOSE 0 +#endif + +/* ----------------------- Static variables ---------------------------------*/ + +static UCHAR ucMBAddress; +static eMBMode eMBCurrentMode; + +static enum +{ + STATE_ENABLED, + STATE_DISABLED, + STATE_NOT_INITIALIZED +} eMBState = STATE_NOT_INITIALIZED; + +/* Functions pointer which are initialized in eMBInit( ). Depending on the + * mode (RTU or ASCII) the are set to the correct implementations. + */ +static peMBFrameSend peMBFrameSendCur; +static pvMBFrameStart pvMBFrameStartCur; +static pvMBFrameStop pvMBFrameStopCur; +static peMBFrameReceive peMBFrameReceiveCur; +static pvMBFrameClose pvMBFrameCloseCur; + +/* Callback functions required by the porting layer. They are called when + * an external event has happend which includes a timeout or the reception + * or transmission of a character. + */ +BOOL( *pxMBFrameCBByteReceived ) ( void ); +BOOL( *pxMBFrameCBTransmitterEmpty ) ( void ); +BOOL( *pxMBPortCBTimerExpired ) ( void ); + +BOOL( *pxMBFrameCBReceiveFSMCur ) ( void ); +BOOL( *pxMBFrameCBTransmitFSMCur ) ( void ); + +/* An array of Modbus functions handlers which associates Modbus function + * codes with implementing functions. + */ +static xMBFunctionHandler xFuncHandlers[MB_FUNC_HANDLERS_MAX] = { +#if MB_FUNC_OTHER_REP_SLAVEID_ENABLED > 0 + {MB_FUNC_OTHER_REPORT_SLAVEID, eMBFuncReportSlaveID}, +#endif +#if MB_FUNC_READ_INPUT_ENABLED > 0 + {MB_FUNC_READ_INPUT_REGISTER, eMBFuncReadInputRegister}, +#endif +#if MB_FUNC_READ_HOLDING_ENABLED > 0 + {MB_FUNC_READ_HOLDING_REGISTER, eMBFuncReadHoldingRegister}, +#endif +#if MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED > 0 + {MB_FUNC_WRITE_MULTIPLE_REGISTERS, eMBFuncWriteMultipleHoldingRegister}, +#endif +#if MB_FUNC_WRITE_HOLDING_ENABLED > 0 + {MB_FUNC_WRITE_REGISTER, eMBFuncWriteHoldingRegister}, +#endif +#if MB_FUNC_READWRITE_HOLDING_ENABLED > 0 + {MB_FUNC_READWRITE_MULTIPLE_REGISTERS, eMBFuncReadWriteMultipleHoldingRegister}, +#endif +#if MB_FUNC_READ_COILS_ENABLED > 0 + {MB_FUNC_READ_COILS, eMBFuncReadCoils}, +#endif +#if MB_FUNC_WRITE_COIL_ENABLED > 0 + {MB_FUNC_WRITE_SINGLE_COIL, eMBFuncWriteCoil}, +#endif +#if MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED > 0 + {MB_FUNC_WRITE_MULTIPLE_COILS, eMBFuncWriteMultipleCoils}, +#endif +#if MB_FUNC_READ_DISCRETE_INPUTS_ENABLED > 0 + {MB_FUNC_READ_DISCRETE_INPUTS, eMBFuncReadDiscreteInputs}, +#endif +}; + +/* ----------------------- Start implementation -----------------------------*/ +eMBErrorCode +eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity ) +{ + eMBErrorCode eStatus = MB_ENOERR; + + /* check preconditions */ + if( ( ucSlaveAddress == MB_ADDRESS_BROADCAST ) || + ( ucSlaveAddress < MB_ADDRESS_MIN ) || ( ucSlaveAddress > MB_ADDRESS_MAX ) ) + { + eStatus = MB_EINVAL; + } + else + { + ucMBAddress = ucSlaveAddress; + + switch ( eMode ) + { +#if MB_RTU_ENABLED > 0 + case MB_RTU: + pvMBFrameStartCur = eMBRTUStart;//回调 + pvMBFrameStopCur = eMBRTUStop; + peMBFrameSendCur = eMBRTUSend; + peMBFrameReceiveCur = eMBRTUReceive; + pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL; + pxMBFrameCBByteReceived = xMBRTUReceiveFSM; + pxMBFrameCBTransmitterEmpty = xMBRTUTransmitFSM; + pxMBPortCBTimerExpired = xMBRTUTimerT35Expired; + + eStatus = eMBRTUInit( ucMBAddress, ucPort, ulBaudRate, eParity ); + break; +#endif +#if MB_ASCII_ENABLED > 0 + case MB_ASCII: + pvMBFrameStartCur = eMBASCIIStart; + pvMBFrameStopCur = eMBASCIIStop; + peMBFrameSendCur = eMBASCIISend; + peMBFrameReceiveCur = eMBASCIIReceive; + pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL; + pxMBFrameCBByteReceived = xMBASCIIReceiveFSM; + pxMBFrameCBTransmitterEmpty = xMBASCIITransmitFSM; + pxMBPortCBTimerExpired = xMBASCIITimerT1SExpired; + + eStatus = eMBASCIIInit( ucMBAddress, ucPort, ulBaudRate, eParity ); + break; +#endif + default: + eStatus = MB_EINVAL; + } + + if( eStatus == MB_ENOERR ) + { + if( !xMBPortEventInit( ) ) + { + /* port dependent event module initalization failed. */ + eStatus = MB_EPORTERR; + } + else + { + eMBCurrentMode = eMode; + eMBState = STATE_DISABLED; + } + } + } + return eStatus; +} + +#if MB_TCP_ENABLED > 0 +eMBErrorCode +eMBTCPInit( USHORT ucTCPPort ) +{ + eMBErrorCode eStatus = MB_ENOERR; + + if( ( eStatus = eMBTCPDoInit( ucTCPPort ) ) != MB_ENOERR ) + { + eMBState = STATE_DISABLED; + } + else if( !xMBPortEventInit( ) ) + { + /* Port dependent event module initalization failed. */ + eStatus = MB_EPORTERR; + } + else + { + pvMBFrameStartCur = eMBTCPStart; + pvMBFrameStopCur = eMBTCPStop; + peMBFrameReceiveCur = eMBTCPReceive; + peMBFrameSendCur = eMBTCPSend; + pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBTCPPortClose : NULL; + ucMBAddress = MB_TCP_PSEUDO_ADDRESS; + eMBCurrentMode = MB_TCP; + eMBState = STATE_DISABLED; + } + return eStatus; +} +#endif + +eMBErrorCode +eMBRegisterCB( UCHAR ucFunctionCode, pxMBFunctionHandler pxHandler ) +{ + int i; + eMBErrorCode eStatus; + + if( ( 0 < ucFunctionCode ) && ( ucFunctionCode <= 127 ) ) + { + ENTER_CRITICAL_SECTION( ); + if( pxHandler != NULL ) + { + for( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ ) + { + if( ( xFuncHandlers[i].pxHandler == NULL ) || + ( xFuncHandlers[i].pxHandler == pxHandler ) ) + { + xFuncHandlers[i].ucFunctionCode = ucFunctionCode; + xFuncHandlers[i].pxHandler = pxHandler; + break; + } + } + eStatus = ( i != MB_FUNC_HANDLERS_MAX ) ? MB_ENOERR : MB_ENORES; + } + else + { + for( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ ) + { + if( xFuncHandlers[i].ucFunctionCode == ucFunctionCode ) + { + xFuncHandlers[i].ucFunctionCode = 0; + xFuncHandlers[i].pxHandler = NULL; + break; + } + } + /* Remove can't fail. */ + eStatus = MB_ENOERR; + } + EXIT_CRITICAL_SECTION( ); + } + else + { + eStatus = MB_EINVAL; + } + return eStatus; +} + + +eMBErrorCode +eMBClose( void ) +{ + eMBErrorCode eStatus = MB_ENOERR; + + if( eMBState == STATE_DISABLED ) + { + if( pvMBFrameCloseCur != NULL ) + { + pvMBFrameCloseCur( ); + } + } + else + { + eStatus = MB_EILLSTATE; + } + return eStatus; +} + +eMBErrorCode +eMBEnable( void ) +{ + eMBErrorCode eStatus = MB_ENOERR; + + if( eMBState == STATE_DISABLED )//init完成 + { + /* Activate the protocol stack. */ + pvMBFrameStartCur( );//函数指针,在init中指向了eMBRTUStart + eMBState = STATE_ENABLED; + } + else + { + eStatus = MB_EILLSTATE; + } + return eStatus; +} + +eMBErrorCode +eMBDisable( void ) +{ + eMBErrorCode eStatus; + + if( eMBState == STATE_ENABLED ) + { + pvMBFrameStopCur( ); + eMBState = STATE_DISABLED; + eStatus = MB_ENOERR; + } + else if( eMBState == STATE_DISABLED ) + { + eStatus = MB_ENOERR; + } + else + { + eStatus = MB_EILLSTATE; + } + return eStatus; +} + +eMBErrorCode +eMBPoll( void ) +{ + static UCHAR *ucMBFrame; + static UCHAR ucRcvAddress; + static UCHAR ucFunctionCode; + static USHORT usLength; + static eMBException eException; + + int i; + eMBErrorCode eStatus = MB_ENOERR; + eMBEventType eEvent; + + /* Check if the protocol stack is ready. */ + if( eMBState != STATE_ENABLED ) + { + return MB_EILLSTATE; + } + + /* Check if there is a event available. If not return control to caller. + * Otherwise we will handle the event. */ + if( xMBPortEventGet( &eEvent ) == TRUE ) + { + switch ( eEvent ) + { + case EV_READY: + break; + + case EV_FRAME_RECEIVED: + eStatus = peMBFrameReceiveCur( &ucRcvAddress, &ucMBFrame, &usLength ); + if( eStatus == MB_ENOERR ) + { + /* Check if the frame is for us. If not ignore the frame. */ + if( ( ucRcvAddress == ucMBAddress ) || ( ucRcvAddress == MB_ADDRESS_BROADCAST ) ) + { + ( void )xMBPortEventPost( EV_EXECUTE ); + } + } + break; + + case EV_EXECUTE: + ucFunctionCode = ucMBFrame[MB_PDU_FUNC_OFF]; + eException = MB_EX_ILLEGAL_FUNCTION; + for( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ ) + { + /* No more function handlers registered. Abort. */ + if( xFuncHandlers[i].ucFunctionCode == 0 ) + { + break; + } + else if( xFuncHandlers[i].ucFunctionCode == ucFunctionCode ) + { + eException = xFuncHandlers[i].pxHandler( ucMBFrame, &usLength ); + break; + } + } + + /* If the request was not sent to the broadcast address we + * return a reply. */ + if( ucRcvAddress != MB_ADDRESS_BROADCAST ) + { + if( eException != MB_EX_NONE ) + { + /* An exception occured. Build an error frame. */ + usLength = 0; + ucMBFrame[usLength++] = ( UCHAR )( ucFunctionCode | MB_FUNC_ERROR ); + ucMBFrame[usLength++] = eException; + } + if( ( eMBCurrentMode == MB_ASCII ) && MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ) + { + vMBPortTimersDelay( MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ); + } + eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength ); + } + break; + + case EV_FRAME_SENT: + break; + } + } + return MB_ENOERR; +} diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbcrc.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbcrc.c new file mode 100644 index 000000000..2f8445d12 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbcrc.c @@ -0,0 +1,97 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +static const UCHAR aucCRCHi[] = { + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40 +}; + +static const UCHAR aucCRCLo[] = { + 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, + 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, + 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, + 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, + 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, + 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, + 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, + 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, + 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, + 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, + 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, + 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, + 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, + 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, + 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, + 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, + 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, + 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, + 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, + 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, + 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, + 0x41, 0x81, 0x80, 0x40 +}; + +USHORT +usMBCRC16( UCHAR * pucFrame, USHORT usLen ) +{ + UCHAR ucCRCHi = 0xFF; + UCHAR ucCRCLo = 0xFF; + int iIndex; + + while( usLen-- ) + { + iIndex = ucCRCLo ^ *( pucFrame++ ); + ucCRCLo = ( UCHAR )( ucCRCHi ^ aucCRCHi[iIndex] ); + ucCRCHi = aucCRCLo[iIndex]; + } + return ( USHORT )( ucCRCHi << 8 | ucCRCLo ); +} diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbcrc.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbcrc.h new file mode 100644 index 000000000..b182e69d3 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbcrc.h @@ -0,0 +1,35 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_CRC_H +#define _MB_CRC_H + +USHORT usMBCRC16( UCHAR * pucFrame, USHORT usLen ); + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbrtu.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbrtu.c new file mode 100644 index 000000000..738bdf24f --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbrtu.c @@ -0,0 +1,354 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbrtu.h" +#include "mbframe.h" + +#include "mbcrc.h" +#include "mbport.h" + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_SER_PDU_SIZE_MIN 4 /*!< Minimum size of a Modbus RTU frame. */ +#define MB_SER_PDU_SIZE_MAX 256 /*!< Maximum size of a Modbus RTU frame. */ +#define MB_SER_PDU_SIZE_CRC 2 /*!< Size of CRC field in PDU. */ +#define MB_SER_PDU_ADDR_OFF 0 /*!< Offset of slave address in Ser-PDU. */ +#define MB_SER_PDU_PDU_OFF 1 /*!< Offset of Modbus-PDU in Ser-PDU. */ + +/* ----------------------- Type definitions ---------------------------------*/ +typedef enum +{ + STATE_RX_INIT, /*!< Receiver is in initial state. */ + STATE_RX_IDLE, /*!< Receiver is in idle state. */ + STATE_RX_RCV, /*!< Frame is beeing received. */ + STATE_RX_ERROR /*!< If the frame is invalid. */ +} eMBRcvState; + +typedef enum +{ + STATE_TX_IDLE, /*!< Transmitter is in idle state. */ + STATE_TX_XMIT /*!< Transmitter is in transfer state. */ +} eMBSndState; + +/* ----------------------- Static variables ---------------------------------*/ +static volatile eMBSndState eSndState; +static volatile eMBRcvState eRcvState; + +volatile UCHAR ucRTUBuf[MB_SER_PDU_SIZE_MAX]; + +static volatile UCHAR *pucSndBufferCur; +static volatile USHORT usSndBufferCount; + +static volatile USHORT usRcvBufferPos; + +/* ----------------------- Start implementation -----------------------------*/ +eMBErrorCode +eMBRTUInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity ) +{ + eMBErrorCode eStatus = MB_ENOERR; + ULONG usTimerT35_50us; + + ( void )ucSlaveAddress; + ENTER_CRITICAL_SECTION( ); + + /* Modbus RTU uses 8 Databits. */ + if( xMBPortSerialInit( ucPort, ulBaudRate, 8, eParity ) != TRUE ) + { + eStatus = MB_EPORTERR; + } + else + { + /* If baudrate > 19200 then we should use the fixed timer values + * t35 = 1750us. Otherwise t35 must be 3.5 times the character time. + */ + if( ulBaudRate > 19200 ) + { + usTimerT35_50us = 35; /* 1800us. */ + } + else + { + /* The timer reload value for a character is given by: + * + * ChTimeValue = Ticks_per_1s / ( Baudrate / 11 ) + * = 11 * Ticks_per_1s / Baudrate + * = 220000 / Baudrate + * The reload for t3.5 is 1.5 times this value and similary + * for t3.5. + */ + usTimerT35_50us = ( 7UL * 220000UL ) / ( 2UL * ulBaudRate ); + } + if( xMBPortTimersInit( ( USHORT ) usTimerT35_50us ) != TRUE ) + { + eStatus = MB_EPORTERR; + } + } + EXIT_CRITICAL_SECTION( ); + + return eStatus; +} + +void +eMBRTUStart( void ) +{ + ENTER_CRITICAL_SECTION( ); + /* Initially the receiver is in the state STATE_RX_INIT. we start + * the timer and if no character is received within t3.5 we change + * to STATE_RX_IDLE. This makes sure that we delay startup of the + * modbus protocol stack until the bus is free. + */ + eRcvState = STATE_RX_INIT;//初始化状态 + vMBPortSerialEnable( TRUE, FALSE );//使能接收,禁止发送 + vMBPortTimersEnable( );//启动定时器 + + EXIT_CRITICAL_SECTION( ); +} + +void +eMBRTUStop( void ) +{ + ENTER_CRITICAL_SECTION( ); + vMBPortSerialEnable( FALSE, FALSE ); + vMBPortTimersDisable( ); + EXIT_CRITICAL_SECTION( ); +} + +eMBErrorCode +eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength ) +{ + BOOL xFrameReceived = FALSE; + eMBErrorCode eStatus = MB_ENOERR; + + ENTER_CRITICAL_SECTION( ); + assert( usRcvBufferPos < MB_SER_PDU_SIZE_MAX ); + + /* Length and CRC check */ + if( ( usRcvBufferPos >= MB_SER_PDU_SIZE_MIN ) + && ( usMBCRC16( ( UCHAR * ) ucRTUBuf, usRcvBufferPos ) == 0 ) ) + { + /* Save the address field. All frames are passed to the upper layed + * and the decision if a frame is used is done there. + */ + *pucRcvAddress = ucRTUBuf[MB_SER_PDU_ADDR_OFF]; + + /* Total length of Modbus-PDU is Modbus-Serial-Line-PDU minus + * size of address field and CRC checksum. + */ + *pusLength = ( USHORT )( usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_CRC ); + + /* Return the start of the Modbus PDU to the caller. */ + *pucFrame = ( UCHAR * ) & ucRTUBuf[MB_SER_PDU_PDU_OFF]; + xFrameReceived = TRUE; + } + else + { + eStatus = MB_EIO; + } + + EXIT_CRITICAL_SECTION( ); + return eStatus; +} + +eMBErrorCode +eMBRTUSend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength ) +{ + eMBErrorCode eStatus = MB_ENOERR; + USHORT usCRC16; + + ENTER_CRITICAL_SECTION( ); + + /* Check if the receiver is still in idle state. If not we where to + * slow with processing the received frame and the master sent another + * frame on the network. We have to abort sending the frame. + */ + if( eRcvState == STATE_RX_IDLE ) + { + /* First byte before the Modbus-PDU is the slave address. */ + pucSndBufferCur = ( UCHAR * ) pucFrame - 1; + usSndBufferCount = 1; + + /* Now copy the Modbus-PDU into the Modbus-Serial-Line-PDU. */ + pucSndBufferCur[MB_SER_PDU_ADDR_OFF] = ucSlaveAddress; + usSndBufferCount += usLength; + + /* Calculate CRC16 checksum for Modbus-Serial-Line-PDU. */ + usCRC16 = usMBCRC16( ( UCHAR * ) pucSndBufferCur, usSndBufferCount ); + ucRTUBuf[usSndBufferCount++] = ( UCHAR )( usCRC16 & 0xFF ); + ucRTUBuf[usSndBufferCount++] = ( UCHAR )( usCRC16 >> 8 ); + + /* Activate the transmitter. */ + eSndState = STATE_TX_XMIT; + vMBPortSerialEnable( FALSE, TRUE ); + } + else + { + eStatus = MB_EIO; + } + EXIT_CRITICAL_SECTION( ); + return eStatus; +} + +BOOL +xMBRTUReceiveFSM( void ) +{ + BOOL xTaskNeedSwitch = FALSE; + UCHAR ucByte; + + assert( eSndState == STATE_TX_IDLE ); + + /* Always read the character. */ + ( void )xMBPortSerialGetByte( ( CHAR * ) & ucByte ); + + switch ( eRcvState ) + { + /* If we have received a character in the init state we have to + * wait until the frame is finished. + */ + case STATE_RX_INIT: + vMBPortTimersEnable( ); + break; + + /* In the error state we wait until all characters in the + * damaged frame are transmitted. + */ + case STATE_RX_ERROR: + vMBPortTimersEnable( ); + break; + + /* In the idle state we wait for a new character. If a character + * is received the t1.5 and t3.5 timers are started and the + * receiver is in the state STATE_RX_RECEIVCE. + */ + case STATE_RX_IDLE: + usRcvBufferPos = 0; + ucRTUBuf[usRcvBufferPos++] = ucByte; + eRcvState = STATE_RX_RCV; + + /* Enable t3.5 timers. */ + vMBPortTimersEnable( ); + break; + + /* We are currently receiving a frame. Reset the timer after + * every character received. If more than the maximum possible + * number of bytes in a modbus frame is received the frame is + * ignored. + */ + case STATE_RX_RCV: + if( usRcvBufferPos < MB_SER_PDU_SIZE_MAX ) + { + ucRTUBuf[usRcvBufferPos++] = ucByte; + } + else + { + eRcvState = STATE_RX_ERROR; + } + vMBPortTimersEnable( ); + break; + } + return xTaskNeedSwitch; +} + +BOOL +xMBRTUTransmitFSM( void ) +{ + BOOL xNeedPoll = FALSE; + + assert( eRcvState == STATE_RX_IDLE ); + + switch ( eSndState ) + { + /* We should not get a transmitter event if the transmitter is in + * idle state. */ + case STATE_TX_IDLE: + /* enable receiver/disable transmitter. */ + vMBPortSerialEnable( TRUE, FALSE ); + break; + + case STATE_TX_XMIT: + /* check if we are finished. */ + if( usSndBufferCount != 0 ) + { + xMBPortSerialPutByte( ( CHAR )*pucSndBufferCur ); + pucSndBufferCur++; /* next byte in sendbuffer. */ + usSndBufferCount--; + } + else + { + xNeedPoll = xMBPortEventPost( EV_FRAME_SENT ); + /* Disable transmitter. This prevents another transmit buffer + * empty interrupt. */ + vMBPortSerialEnable( TRUE, FALSE ); + eSndState = STATE_TX_IDLE; + } + break; + } + + return xNeedPoll; +} +//定时中断发生,触发的函数 +BOOL +xMBRTUTimerT35Expired( void ) +{ + BOOL xNeedPoll = FALSE; + + switch ( eRcvState ) + { + /* Timer t35 expired. Startup phase is finished. */ + case STATE_RX_INIT: + xNeedPoll = xMBPortEventPost( EV_READY );//事件类型赋值 + break; + + /* A frame was received and t35 expired. Notify the listener that + * a new frame was received. */ + case STATE_RX_RCV: + xNeedPoll = xMBPortEventPost( EV_FRAME_RECEIVED ); + break; + + /* An error occured while receiving the frame. */ + case STATE_RX_ERROR: + break; + + /* Function called in an illegal state. */ + default: + assert( ( eRcvState == STATE_RX_INIT ) || + ( eRcvState == STATE_RX_RCV ) || ( eRcvState == STATE_RX_ERROR ) ); + } + + vMBPortTimersDisable( ); + eRcvState = STATE_RX_IDLE; + + return xNeedPoll; +} diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbrtu.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbrtu.h new file mode 100644 index 000000000..698168712 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/rtu/mbrtu.h @@ -0,0 +1,50 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_RTU_H +#define _MB_RTU_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif + eMBErrorCode eMBRTUInit( UCHAR slaveAddress, UCHAR ucPort, ULONG ulBaudRate, + eMBParity eParity ); +void eMBRTUStart( void ); +void eMBRTUStop( void ); +eMBErrorCode eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength ); +eMBErrorCode eMBRTUSend( UCHAR slaveAddress, const UCHAR * pucFrame, USHORT usLength ); +BOOL xMBRTUReceiveFSM( void ); +BOOL xMBRTUTransmitFSM( void ); +BOOL xMBRTUTimerT15Expired( void ); +BOOL xMBRTUTimerT35Expired( void ); + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/tcp/mbtcp.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/tcp/mbtcp.c new file mode 100644 index 000000000..5a75fda67 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/tcp/mbtcp.c @@ -0,0 +1,157 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* ----------------------- System includes ----------------------------------*/ +#include "stdlib.h" +#include "string.h" + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbconfig.h" +#include "mbtcp.h" +#include "mbframe.h" +#include "mbport.h" + +#if MB_TCP_ENABLED > 0 + +/* ----------------------- Defines ------------------------------------------*/ + +/* ----------------------- MBAP Header --------------------------------------*/ +/* + * + * <------------------------ MODBUS TCP/IP ADU(1) -------------------------> + * <----------- MODBUS PDU (1') ----------------> + * +-----------+---------------+------------------------------------------+ + * | TID | PID | Length | UID |Code | Data | + * +-----------+---------------+------------------------------------------+ + * | | | | | + * (2) (3) (4) (5) (6) + * + * (2) ... MB_TCP_TID = 0 (Transaction Identifier - 2 Byte) + * (3) ... MB_TCP_PID = 2 (Protocol Identifier - 2 Byte) + * (4) ... MB_TCP_LEN = 4 (Number of bytes - 2 Byte) + * (5) ... MB_TCP_UID = 6 (Unit Identifier - 1 Byte) + * (6) ... MB_TCP_FUNC = 7 (Modbus Function Code) + * + * (1) ... Modbus TCP/IP Application Data Unit + * (1') ... Modbus Protocol Data Unit + */ + +#define MB_TCP_TID 0 +#define MB_TCP_PID 2 +#define MB_TCP_LEN 4 +#define MB_TCP_UID 6 +#define MB_TCP_FUNC 7 + +#define MB_TCP_PROTOCOL_ID 0 /* 0 = Modbus Protocol */ + + +/* ----------------------- Start implementation -----------------------------*/ +eMBErrorCode +eMBTCPDoInit( USHORT ucTCPPort ) +{ + eMBErrorCode eStatus = MB_ENOERR; + + if( xMBTCPPortInit( ucTCPPort ) == FALSE ) + { + eStatus = MB_EPORTERR; + } + return eStatus; +} + +void +eMBTCPStart( void ) +{ +} + +void +eMBTCPStop( void ) +{ + /* Make sure that no more clients are connected. */ + vMBTCPPortDisable( ); +} + +eMBErrorCode +eMBTCPReceive( UCHAR * pucRcvAddress, UCHAR ** ppucFrame, USHORT * pusLength ) +{ + eMBErrorCode eStatus = MB_EIO; + UCHAR *pucMBTCPFrame; + USHORT usLength; + USHORT usPID; + + if( xMBTCPPortGetRequest( &pucMBTCPFrame, &usLength ) != FALSE ) + { + usPID = pucMBTCPFrame[MB_TCP_PID] << 8U; + usPID |= pucMBTCPFrame[MB_TCP_PID + 1]; + + if( usPID == MB_TCP_PROTOCOL_ID ) + { + *ppucFrame = &pucMBTCPFrame[MB_TCP_FUNC]; + *pusLength = usLength - MB_TCP_FUNC; + eStatus = MB_ENOERR; + + /* Modbus TCP does not use any addresses. Fake the source address such + * that the processing part deals with this frame. + */ + *pucRcvAddress = MB_TCP_PSEUDO_ADDRESS; + } + } + else + { + eStatus = MB_EIO; + } + return eStatus; +} + +eMBErrorCode +eMBTCPSend( UCHAR _unused, const UCHAR * pucFrame, USHORT usLength ) +{ + eMBErrorCode eStatus = MB_ENOERR; + UCHAR *pucMBTCPFrame = ( UCHAR * ) pucFrame - MB_TCP_FUNC; + USHORT usTCPLength = usLength + MB_TCP_FUNC; + + /* The MBAP header is already initialized because the caller calls this + * function with the buffer returned by the previous call. Therefore we + * only have to update the length in the header. Note that the length + * header includes the size of the Modbus PDU and the UID Byte. Therefore + * the length is usLength plus one. + */ + pucMBTCPFrame[MB_TCP_LEN] = ( usLength + 1 ) >> 8U; + pucMBTCPFrame[MB_TCP_LEN + 1] = ( usLength + 1 ) & 0xFF; + if( xMBTCPPortSendResponse( pucMBTCPFrame, usTCPLength ) == FALSE ) + { + eStatus = MB_EIO; + } + return eStatus; +} + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/tcp/mbtcp.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/tcp/mbtcp.h new file mode 100644 index 000000000..16b651ee5 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/modbus/tcp/mbtcp.h @@ -0,0 +1,52 @@ +/* + * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. + * Copyright (c) 2006-2018 Christian Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MB_TCP_H +#define _MB_TCP_H + +#ifdef __cplusplus +PR_BEGIN_EXTERN_C +#endif + +/* ----------------------- Defines ------------------------------------------*/ +#define MB_TCP_PSEUDO_ADDRESS 255 + +/* ----------------------- Function prototypes ------------------------------*/ + eMBErrorCode eMBTCPDoInit( USHORT ucTCPPort ); +void eMBTCPStart( void ); +void eMBTCPStop( void ); +eMBErrorCode eMBTCPReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, + USHORT * pusLength ); +eMBErrorCode eMBTCPSend( UCHAR _unused, const UCHAR * pucFrame, + USHORT usLength ); + +#ifdef __cplusplus +PR_END_EXTERN_C +#endif +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/port.h b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/port.h new file mode 100644 index 000000000..c2a0f7d4b --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/port.h @@ -0,0 +1,54 @@ +/* + * FreeModbus Libary: BARE Port + * Copyright (C) 2006 Christian Walter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * File: $Id$ + */ + +#ifndef _PORT_H +#define _PORT_H + +#include +#include + +#define INLINE inline +#define PR_BEGIN_EXTERN_C extern "C" { +#define PR_END_EXTERN_C } + +#define ENTER_CRITICAL_SECTION( ) +#define EXIT_CRITICAL_SECTION( ) + +typedef uint8_t BOOL; + +typedef unsigned char UCHAR; +typedef char CHAR; + +typedef uint16_t USHORT; +typedef int16_t SHORT; + +typedef uint32_t ULONG; +typedef int32_t LONG; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#endif diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/portevent.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/portevent.c new file mode 100644 index 000000000..e700a471c --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/portevent.c @@ -0,0 +1,58 @@ +/* + * FreeModbus Libary: BARE Port + * Copyright (C) 2006 Christian Walter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * File: $Id$ + */ + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbport.h" + +/* ----------------------- Variables ----------------------------------------*/ +static eMBEventType eQueuedEvent; +static BOOL xEventInQueue; + +/* ----------------------- Start implementation -----------------------------*/ +BOOL +xMBPortEventInit( void ) +{ + xEventInQueue = FALSE; + return TRUE; +} + +BOOL +xMBPortEventPost( eMBEventType eEvent ) +{ + xEventInQueue = TRUE; + eQueuedEvent = eEvent; + return TRUE; +} + +BOOL +xMBPortEventGet( eMBEventType * eEvent ) +{ + BOOL xEventHappened = FALSE; + + if( xEventInQueue ) + { + *eEvent = eQueuedEvent; + xEventInQueue = FALSE; + xEventHappened = TRUE; + } + return xEventHappened; +} diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/portserial.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/portserial.c new file mode 100644 index 000000000..f21c310b9 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/portserial.c @@ -0,0 +1,152 @@ +/* + * FreeModbus Libary: BARE Port + * Copyright (C) 2006 Christian Walter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * File: $Id$ + */ + + +#include + +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbport.h" + +/* ----------------------- static functions ---------------------------------*/ +static void prvvUARTTxReadyISR( void ); +static void prvvUARTRxISR( void ); + +/* ----------------------- Start implementation -----------------------------*/ +void +vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable ) +{ + /* If xRXEnable enable serial receive interrupts. If xTxENable enable + * transmitter empty interrupts. + */ + + if(xRxEnable && !xTxEnable)//接收数据 + { + Set485Input(); + } + if(!xRxEnable && xTxEnable) + { + Set485Output(); + } + +} + +BOOL +xMBPortSerialInit( UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits, eMBParity eParity ) +{ + struct SerialDataCfg serial_cfg; + memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg)); + serial_cfg.serial_baud_rate = (uint32_t)ulBaudRate; + serial_cfg.serial_data_bits = (uint8_t)ucDataBits; + serial_cfg.serial_stop_bits = STOP_BITS_1; + serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ; + serial_cfg.serial_parity_mode = (uint8_t)eParity; + serial_cfg.serial_bit_order = STOP_BITS_1; + serial_cfg.serial_invert_mode = NRZ_NORMAL; + serial_cfg.is_ext_uart = 0; + + + + return FALSE; +} + +BOOL +xMBPortSerialPutByte( CHAR ucByte ) +{ + /* Put a byte in the UARTs transmit buffer. This function is called + * by the protocol stack if pxMBFrameCBTransmitterEmpty( ) has been + * called. */ + Set485Output(); + PrivTaskDelay(20); + + PrivWrite(uart_fd, ucByte, 1); + + PrivTaskDelay(15); + Set485Input(); + return TRUE; +} + +BOOL +xMBPortSerialGetByte( CHAR * pucByte ) +{ + /* Return the byte in the UARTs receive buffer. This function is called + * by the protocol stack after pxMBFrameCBByteReceived( ) has been called. + */ + + + + PrivRead(uart_fd, pucByte, 1);// + + //need to wait 30ms , make sure write cmd again and receive data successfully + PrivTaskDelay(30); + + return TRUE; +} + +/* Create an interrupt handler for the transmit buffer empty interrupt + * (or an equivalent) for your target processor. This function should then + * call pxMBFrameCBTransmitterEmpty( ) which tells the protocol stack that + * a new character can be sent. The protocol stack will then call + * xMBPortSerialPutByte( ) to send the character. + */ +static void prvvUARTTxReadyISR( void ) +{ + pxMBFrameCBTransmitterEmpty( ); +} + +/* Create an interrupt handler for the receive interrupt for your target + * processor. This function should then call pxMBFrameCBByteReceived( ). The + * protocol stack will then call xMBPortSerialGetByte( ) to retrieve the + * character. + */ +static void prvvUARTRxISR( void ) +{ + pxMBFrameCBByteReceived( ); +} + +static int pin_fd = 0; +static int uart_fd = 0; + +/** + * @description: Set Uart 485 Input + * @return + */ +static void Set485Input(void) +{ + struct PinStat pin_stat; + pin_stat.pin = 2;//CONTROL_FRAMEWORK_UART_485_DIR + pin_stat.val = GPIO_LOW; + PrivWrite(pin_fd, &pin_stat, 1); +} + +/** + * @description: Set Uart 485 Output + * @return + */ +static void Set485Output(void) +{ + struct PinStat pin_stat; + pin_stat.pin = 2;//CONTROL_FRAMEWORK_UART_485_DIR + pin_stat.val = GPIO_HIGH; + PrivWrite(pin_fd, &pin_stat, 1); +} diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/porttimer.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/porttimer.c new file mode 100644 index 000000000..b31fa19e3 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/FreeModbus/port/porttimer.c @@ -0,0 +1,62 @@ +/* + * FreeModbus Libary: BARE Port + * Copyright (C) 2006 Christian Walter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * File: $Id$ + */ + +/* ----------------------- Platform includes --------------------------------*/ +#include "port.h" + +/* ----------------------- Modbus includes ----------------------------------*/ +#include "mb.h" +#include "mbport.h" + +/* ----------------------- static functions ---------------------------------*/ +static void prvvTIMERExpiredISR( void ); + +/* ----------------------- Start implementation -----------------------------*/ +BOOL +xMBPortTimersInit( USHORT usTim1Timerout50us ) +{ + PrivTaskDelay(usTim1Timerout50us); + return FALSE; +} + + +inline void +vMBPortTimersEnable( ) +{ + /* Enable the timer with the timeout passed to xMBPortTimersInit( ) */ + PrivTaskDelay(usTim1Timerout50us); +} + +inline void +vMBPortTimersDisable( ) +{ + /* Disable any pending timers. */ +} + +/* Create an ISR which is called whenever the timer has expired. This function + * must then call pxMBPortCBTimerExpired( ) to notify the protocol stack that + * the timer has expired. + */ +static void prvvTIMERExpiredISR( void ) +{ + ( void )pxMBPortCBTimerExpired( ); +} + diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/adapter_modbus_rtu.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/adapter_modbus_rtu.c new file mode 100644 index 000000000..e0b77d10e --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/adapter_modbus_rtu.c @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file adapter_Modbus_rtu.c + * @brief Implement the connection 4G adapter function + * @version 1.1 + * @author AIIT XIUOS Lab + * @date 2021.06.25 + */ + +#include + + + +static int AdapterModbusRtuRegister(struct Adapter *adapter) +{ + int ret = 0; + + strncpy(adapter->name, ADAPTER_MODBUS_RTU_NAME, NAME_NUM_MAX); + + adapter->net_protocol = PROTOCOL_NONE;//IP层协议类型,串口没有此层 + adapter->net_role = SLAVE; + adapter->adapter_status = UNREGISTERED; + + ret = AdapterDeviceRegister(adapter); + if (ret < 0) { + printf("AdapterModbusRtu register error\n"); + return -1; + } + + return ret; +} + +int AdapterModbusRtuInit(void) +{ + int ret = 0; + + struct Adapter *adapter = PrivMalloc(sizeof(struct Adapter)); + if (!adapter) { + PrivFree(adapter); + return -1; + } + + memset(adapter, 0, sizeof(struct Adapter)); + + ret = AdapterModbusRtuRegister(adapter); + if (ret < 0) { + printf("AdapterModbusRtuInit register ModbusRtu adapter error\n"); + PrivFree(adapter); + return -1; + } + + return ret; +} + diff --git a/APP_Framework/Framework/connection/industrial_fieldbus/modbus/modbus_rtu.c b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/modbus_rtu.c new file mode 100644 index 000000000..13dca9165 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_fieldbus/modbus/modbus_rtu.c @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file modbus_rtu.c + * @brief Implement the connection Modbus RTU adapter function, using Modbus rtu device + * @version 1.1 + * @author AIIT XUOS Lab + * @date 2021.07.08 + */ + +#include +#define PLC_DATA_LENGTH 1024 +struct CircularAreaApp *g_circular_area; +static pthread_t recv_plc_data_task; +/** + * @description: Open modbus rtu function + * @param adapter - Modbus RTU device pointer + * @return success: 0, failure: -1 + */ +static int ModbusRtuOpen(struct Adapter *adapter) +{ + + /* open serial port*/ + adapter->fd = PrivOpen("/dev/tty3", 2);//2 read and write + if (adapter->fd < 0) { + printf("ModbusRtuOpen get serial %s fd error\n", "/dev/tty3"); + return -1; + } + + PrivTaskDelay(2500); + + ADAPTER_DEBUG("Modbus rtu open done\n"); + + return 0; +} + +/** + * @description: Close modbus rtu function + * @param adapter - Modbus RTu device pointer + * @return success: 0, failure: -1 + */ +static int ModbusRtuClose(struct Adapter *adapter) +{ + /*step1: close modbus serial port*/ + int ret; + ret = PrivClose(adapter->fd); + if(ret < 0){ + printf("ModbusRtuOpen close serial %s fd error\n", "/dev/tty3"); + return -1; + } + + ADAPTER_DEBUG("Modbus rtu Close done\n"); + + return 0; +} + +static int ModbusRtuIoctl(struct Adapter *adapter, int cmd) +{ + + // uint32_t baud_rate = *((uint32_t *)args); + + struct SerialDataCfg serial_cfg; + memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg)); + serial_cfg.serial_baud_rate = BAUD_RATE_9600 ; + serial_cfg.serial_data_bits = DATA_BITS_8; + serial_cfg.serial_stop_bits = STOP_BITS_1; + serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ; + serial_cfg.serial_parity_mode = PARITY_EVEN; + serial_cfg.serial_bit_order = STOP_BITS_1; + serial_cfg.serial_invert_mode = NRZ_NORMAL; + serial_cfg.is_ext_uart = 0; + + struct PrivIoctlCfg ioctl_cfg; + ioctl_cfg.ioctl_driver_type = SERIAL_TYPE; + ioctl_cfg.args = &serial_cfg; + PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg); + + return 0; +} + +static int ModbusRtuSend(struct Adapter *adapter, const void *buf, size_t len) +{ + int ret; + ret = PrivWrite(adapter->fd, buf, len); + if(ret < 0){ + printf("send failed %d!\n", ret); + } + + return ret; +} + +static int ModbusRtuRecv(struct Adapter *adapter, void *buf, size_t len) +{ + int recv_len=0, recv_len_continue=0; + + uint8 *recv_buf = PrivMalloc(len); + + recv_len = PrivRead(adapter->fd, recv_buf, len); + if (recv_len) { + while (recv_len < len) { + recv_len_continue = PrivRead(adapter->fd, recv_buf + recv_len, len - recv_len); + if (recv_len_continue) { + recv_len += recv_len_continue; + } else { + recv_len = 0; + break; + } + } + memcpy(buf, recv_buf, len); + } + + PrivFree(recv_buf); + + return recv_len; +} + + +static const struct IpProtocolDone ec200t_done = +{ + .open = ModbusRtuOpen, + .close = ModbusRtuClose, + .ioctl = ModbusRtuIoctl, + .setup = NULL, + .setdown = NULL, + .setaddr = NULL, + .setdns = NULL, + .setdhcp = NULL, + .ping = NULL, + .netstat = NULL, + .connect = NULL, + .send = ModbusRtuSend, + .recv = ModbusRtuRecv, + .disconnect = NULL, +}; \ No newline at end of file diff --git a/APP_Framework/Framework/connection/lora/Makefile b/APP_Framework/Framework/connection/lora/Makefile index e1b055274..d35c25340 100644 --- a/APP_Framework/Framework/connection/lora/Makefile +++ b/APP_Framework/Framework/connection/lora/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += adapter_lora.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := adapter_lora.c ifeq ($(CONFIG_ADAPTER_SX1278),y) diff --git a/APP_Framework/Framework/connection/lora/adapter_lora.c b/APP_Framework/Framework/connection/lora/adapter_lora.c index dbb76bcad..0c44b76bd 100644 --- a/APP_Framework/Framework/connection/lora/adapter_lora.c +++ b/APP_Framework/Framework/connection/lora/adapter_lora.c @@ -930,7 +930,7 @@ int AdapterLoraTest(void) //create lora gateway task #ifdef AS_LORA_GATEWAY_ROLE -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES pthread_attr_t lora_gateway_attr = PTHREAD_ATTR_INITIALIZER; lora_gateway_attr.priority = 20; lora_gateway_attr.stacksize = 2048; @@ -943,7 +943,7 @@ int AdapterLoraTest(void) PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)adapter); PrivTaskStartup(&lora_recv_data_task); -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES lora_gateway_attr.priority = 19; #else lora_gateway_attr.schedparam.sched_priority = 19; @@ -953,7 +953,7 @@ int AdapterLoraTest(void) PrivTaskStartup(&lora_gateway_task); #else //AS_LORA_CLIENT_ROLE -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES pthread_attr_t lora_client_attr = PTHREAD_ATTR_INITIALIZER; lora_client_attr.priority = 20; lora_client_attr.stacksize = 2048; @@ -965,7 +965,7 @@ int AdapterLoraTest(void) PrivTaskCreate(&lora_recv_data_task, &lora_client_attr, &LoraReceiveTask, (void *)adapter); PrivTaskStartup(&lora_recv_data_task); -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES lora_client_attr.priority = 19; #else lora_client_attr.schedparam.sched_priority = 19; diff --git a/APP_Framework/Framework/connection/lora/e22/Kconfig b/APP_Framework/Framework/connection/lora/e22/Kconfig index ec61a8558..81e0cfc53 100644 --- a/APP_Framework/Framework/connection/lora/e22/Kconfig +++ b/APP_Framework/Framework/connection/lora/e22/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_LORA_E22 string "E22-400T30S adapter name" default "e22" -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES config ADAPTER_E22_M0_PATH string "E22 M0 pin device" diff --git a/APP_Framework/Framework/connection/lora/e22/Makefile b/APP_Framework/Framework/connection/lora/e22/Makefile index c0da4046f..aee122136 100644 --- a/APP_Framework/Framework/connection/lora/e22/Makefile +++ b/APP_Framework/Framework/connection/lora/e22/Makefile @@ -1,5 +1,5 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += e22.c include $(APPDIR)/Application.mk diff --git a/APP_Framework/Framework/connection/lora/e220/Kconfig b/APP_Framework/Framework/connection/lora/e220/Kconfig index 9e51b8eda..2ef8c83d4 100644 --- a/APP_Framework/Framework/connection/lora/e220/Kconfig +++ b/APP_Framework/Framework/connection/lora/e220/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_LORA_E220 string "E220-400T22S adapter name" default "e220" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_E220_M0 int "E220 M0 pin number" default "11" @@ -35,7 +35,7 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES config ADAPTER_E220_M0_PATH string "E220 M0 pin device" @@ -66,7 +66,7 @@ if ADD_NUTTX_FETURES endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES config ADAPTER_E220_M0 int "E220 M0 pin number" default "11" diff --git a/APP_Framework/Framework/connection/lora/e220/Makefile b/APP_Framework/Framework/connection/lora/e220/Makefile index 71d5454a0..0b158cdf9 100644 --- a/APP_Framework/Framework/connection/lora/e220/Makefile +++ b/APP_Framework/Framework/connection/lora/e220/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += e220.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := e220.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/lora/e220/e220.c b/APP_Framework/Framework/connection/lora/e220/e220.c index 201e9417f..9a6bbf3c6 100644 --- a/APP_Framework/Framework/connection/lora/e220/e220.c +++ b/APP_Framework/Framework/connection/lora/e220/e220.c @@ -21,7 +21,7 @@ #include #define E220_GATEWAY_ADDRESS 0xFFFF -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES #define E220_CHANNEL 0x02 #else #define E220_CHANNEL 0x05 @@ -35,7 +35,7 @@ #define E220_ADDRESS ADAPTER_LORA_NET_ROLE_ID #endif -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES #define E220_UART_BAUD_RATE 9600 #else #define E220_UART_BAUD_RATE 115200 @@ -54,7 +54,7 @@ enum E220LoraMode * @param mode Lora working mode * @return NULL */ -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES static void E220LoraModeConfig(enum E220LoraMode mode) { int m0_fd, m1_fd; @@ -338,7 +338,7 @@ static int E220GetRegisterParam(uint8 *buf) * @param adapter - Lora device pointer * @return success: 0, failure: -1 */ -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES static int E220Open(struct Adapter *adapter) { /*step1: open e220 uart port*/ @@ -614,7 +614,7 @@ static void LoraOpen(void) E220Open(adapter); } -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES MSH_CMD_EXPORT(LoraOpen,Lora open test sample); static void LoraRead(void *parameter) @@ -692,7 +692,7 @@ static void LoraRead(void *parameter) #endif -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES static void LoraTest(void) { int ret; @@ -727,7 +727,7 @@ static void LoraSend(int argc, char *argv[]) PRIV_SHELL_CMD_FUNCTION(LoraSend, a lora test send sample, PRIV_SHELL_CMD_MAIN_ATTR); #endif -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES void E220LoraReceive(void) { int ret; @@ -763,7 +763,7 @@ void E220LoraSend(int argc, char *argv[]) } #endif -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES static void LoraReadStart(void) { int ret; diff --git a/APP_Framework/Framework/connection/lora/sx1278/Kconfig b/APP_Framework/Framework/connection/lora/sx1278/Kconfig index 9b9cc2b48..b574497b6 100644 --- a/APP_Framework/Framework/connection/lora/sx1278/Kconfig +++ b/APP_Framework/Framework/connection/lora/sx1278/Kconfig @@ -2,20 +2,20 @@ config ADAPTER_LORA_SX1278 string "SX1278 adapter name" default "sx1278" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_SX1278_DRIVER string "SX1278 device spi driver path" default "/dev/spi2_lora" endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES config ADAPTER_SX1278_DRIVER string "SX1278 device spi driver path" default "/dev/spi2_lora" endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES config ADAPTER_SX1278_DRIVER string "SX1278 device spi driver path" default "/dev/sx1278" diff --git a/APP_Framework/Framework/connection/lora/sx1278/Makefile b/APP_Framework/Framework/connection/lora/sx1278/Makefile index 636fa525d..2e4e0e10f 100644 --- a/APP_Framework/Framework/connection/lora/sx1278/Makefile +++ b/APP_Framework/Framework/connection/lora/sx1278/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += sx1278.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := sx1278.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/lora/sx1278/sx1278.c b/APP_Framework/Framework/connection/lora/sx1278/sx1278.c index dda8b54e0..e8d92143c 100644 --- a/APP_Framework/Framework/connection/lora/sx1278/sx1278.c +++ b/APP_Framework/Framework/connection/lora/sx1278/sx1278.c @@ -20,7 +20,7 @@ #include -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES /** * @description: Sx127x_Nuttx_Write function for nuttx * @param fd - file descriptor to write to @@ -104,7 +104,7 @@ static int Sx1278Ioctl(struct Adapter *adapter, int cmd, void *args) * @param priv_net_group - priv_net_group params * @return success: 0, failure: -1 */ -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES static int Sx1278Join(struct Adapter *adapter, unsigned char *priv_net_group) { int ret; @@ -140,7 +140,7 @@ static int Sx1278Join(struct Adapter *adapter, unsigned char *priv_net_group) * @param len - data len * @return success: 0, failure: -1 */ -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES static int Sx1278Send(struct Adapter *adapter, const void *buf, size_t len) { int ret; @@ -170,7 +170,7 @@ static int Sx1278Send(struct Adapter *adapter, const void *buf, size_t len) * @param len - data len * @return success: 0, failure: -1 */ -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES static int Sx1278Recv(struct Adapter *adapter, void *buf, size_t len) { int ret; @@ -196,7 +196,7 @@ static int Sx1278Recv(struct Adapter *adapter, void *buf, size_t len) * @param priv_net_group - priv_net_group params * @return success: 0, failure: -1 */ -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES static int Sx1278Quit(struct Adapter *adapter, unsigned char *priv_net_group) { int ret; diff --git a/APP_Framework/Framework/connection/nbiot/bc28/Kconfig b/APP_Framework/Framework/connection/nbiot/bc28/Kconfig index 6897a6ae2..012901041 100644 --- a/APP_Framework/Framework/connection/nbiot/bc28/Kconfig +++ b/APP_Framework/Framework/connection/nbiot/bc28/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_NBIOT_BC28 string "BC28 adapter name" default "bc28" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_BC28_RESETPIN int "BC28 RESET pin number" default "100" @@ -31,11 +31,11 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES config ADAPTER_BC28_DRIVER string "BC28 device uart driver path" default "/dev/uart2" diff --git a/APP_Framework/Framework/connection/wifi/Makefile b/APP_Framework/Framework/connection/wifi/Makefile index 5e466adc5..c7cb23eae 100644 --- a/APP_Framework/Framework/connection/wifi/Makefile +++ b/APP_Framework/Framework/connection/wifi/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += adapter_wifi.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := adapter_wifi.c ifeq ($(CONFIG_ADAPTER_HFA21_WIFI),y) diff --git a/APP_Framework/Framework/connection/wifi/adapter_wifi.c b/APP_Framework/Framework/connection/wifi/adapter_wifi.c index 6c40f7413..ebea01232 100644 --- a/APP_Framework/Framework/connection/wifi/adapter_wifi.c +++ b/APP_Framework/Framework/connection/wifi/adapter_wifi.c @@ -297,7 +297,7 @@ int WifiRecv(int argc, char *argv[]) } PRIV_SHELL_CMD_FUNCTION(WifiRecv, a WiFi receive sample, PRIV_SHELL_CMD_MAIN_ATTR); -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES enum { diff --git a/APP_Framework/Framework/connection/wifi/esp07s_wifi/Kconfig b/APP_Framework/Framework/connection/wifi/esp07s_wifi/Kconfig index 15fdda3f5..848026276 100755 --- a/APP_Framework/Framework/connection/wifi/esp07s_wifi/Kconfig +++ b/APP_Framework/Framework/connection/wifi/esp07s_wifi/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_WIFI_ESP07S string "ESP07S WIFI adapter name" default "esp07s_wifi" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_ESP07S_DRIVER_EXTUART bool "Using extra uart to support wifi" @@ -24,7 +24,7 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES config ADAPTER_ESP07S_DRIVER_EXTUART bool "Using extra uart to support wifi" default n @@ -45,8 +45,8 @@ if ADD_NUTTX_FETURES endif endif -if ADD_RTTHREAD_FETURES - if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES + if ADD_RTTHREAD_FEATURES config ADAPTER_ESP07S_DRIVER_EXTUART bool "Using extra uart to support wifi" default n diff --git a/APP_Framework/Framework/connection/wifi/esp07s_wifi/Makefile b/APP_Framework/Framework/connection/wifi/esp07s_wifi/Makefile index 53493604e..2a2819d4d 100755 --- a/APP_Framework/Framework/connection/wifi/esp07s_wifi/Makefile +++ b/APP_Framework/Framework/connection/wifi/esp07s_wifi/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += esp07s_wifi.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := esp07s_wifi.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig index 6fea4cc6f..bd83eb4cc 100644 --- a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig +++ b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig @@ -2,13 +2,13 @@ config ADAPTER_WIFI_ESP8285 string "ESP8285 WIFI adapter name" default "esp8285_wifi" -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES config ADAPTER_ESP8285_DRIVER string "ESP8285 device uart driver path" default "/dev/ttyS1" endif -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_ESP8285_DRIVER string "ESP8285 device uart driver path" default "/dev/uart1_dev1" diff --git a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile index 0431e2732..6b9fc3626 100644 --- a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile +++ b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += esp8285_wifi.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := esp8285_wifi.c include $(KERNEL_ROOT)/compiler.mk endif \ No newline at end of file diff --git a/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig index cc248bd79..fe0dc74bd 100755 --- a/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig +++ b/APP_Framework/Framework/connection/wifi/hfa21_wifi/Kconfig @@ -2,7 +2,7 @@ config ADAPTER_WIFI_HFA21 string "HFA21 WIFI adapter name" default "hfa21_wifi" -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_HFA21_DRIVER_EXTUART bool "Using extra uart to support wifi" @@ -24,11 +24,11 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES config ADAPTER_HFA21_DRIVER string "HFA21 device uart driver path" default "/dev/uart3" diff --git a/APP_Framework/Framework/connection/zigbee/Makefile b/APP_Framework/Framework/connection/zigbee/Makefile index cfd9f20c0..d4c2485bf 100644 --- a/APP_Framework/Framework/connection/zigbee/Makefile +++ b/APP_Framework/Framework/connection/zigbee/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += adapter_zigbee.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := adapter_zigbee.c ifeq ($(CONFIG_ADAPTER_E18),y) diff --git a/APP_Framework/Framework/connection/zigbee/e18/Kconfig b/APP_Framework/Framework/connection/zigbee/e18/Kconfig index 0551d4cbf..2b1efac9d 100644 --- a/APP_Framework/Framework/connection/zigbee/e18/Kconfig +++ b/APP_Framework/Framework/connection/zigbee/e18/Kconfig @@ -17,7 +17,7 @@ choice endchoice -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config ADAPTER_E18_MODEPIN int "E18 MODE pin number" default "61" @@ -46,7 +46,7 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES if ARCH_BOARD_XIDATONG_ARM32 config ADAPTER_E18_MODEPIN int "E18 MODE pin number" @@ -84,6 +84,6 @@ endif endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES endif diff --git a/APP_Framework/Framework/connection/zigbee/e18/Makefile b/APP_Framework/Framework/connection/zigbee/e18/Makefile index 1ac35b43f..6f2e1d871 100644 --- a/APP_Framework/Framework/connection/zigbee/e18/Makefile +++ b/APP_Framework/Framework/connection/zigbee/e18/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += e18.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := e18.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/connection/zigbee/e18/e18.c b/APP_Framework/Framework/connection/zigbee/e18/e18.c index b07a4c3ea..4ebc8aed9 100644 --- a/APP_Framework/Framework/connection/zigbee/e18/e18.c +++ b/APP_Framework/Framework/connection/zigbee/e18/e18.c @@ -43,7 +43,7 @@ char *cmd_set_ch = "AT+CH=11"; /*set channel as 11*/ static int E18HardwareModeGet() { -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32 int ret = 0; int pin_fd; @@ -96,7 +96,7 @@ static int E18HardwareModeGet() static int E18HardwareModeSet(void) { -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES #ifdef CONFIG_ARCH_BOARD_XIDATONG_ARM32 int ret = 0; int pin_fd; @@ -227,7 +227,7 @@ static int E18NetworkModeConfig(struct Adapter *adapter) } out: -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES if(E18_AS_HEX_MODE == mode) #else if(E18_AS_AT_MODE == mode) @@ -302,7 +302,7 @@ static int E18NetRoleConfig(struct Adapter *adapter) } out: -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES if(E18_AS_HEX_MODE == mode) #else if(E18_AS_AT_MODE == mode) @@ -449,7 +449,7 @@ static int E18Join(struct Adapter *adapter, unsigned char *priv_net_group) // } if(!ret){ -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES if(E18_AS_HEX_MODE == mode) #else if(E18_AS_AT_MODE == mode) diff --git a/APP_Framework/Framework/control/ipc_protocol/modbus_uart/Kconfig b/APP_Framework/Framework/control/ipc_protocol/modbus_uart/Kconfig index bc6a0cae9..6729481c1 100755 --- a/APP_Framework/Framework/control/ipc_protocol/modbus_uart/Kconfig +++ b/APP_Framework/Framework/control/ipc_protocol/modbus_uart/Kconfig @@ -1,4 +1,4 @@ -if ADD_XIZI_FETURES +if ADD_XIZI_FEATURES config CONTROL_FRAMEWORK_UART_485_DIR int "control framework 485 direction pin number" default "2" @@ -27,11 +27,11 @@ if ADD_XIZI_FETURES endif endif -if ADD_NUTTX_FETURES +if ADD_NUTTX_FEATURES endif -if ADD_RTTHREAD_FETURES +if ADD_RTTHREAD_FEATURES endif diff --git a/APP_Framework/Framework/control/plc_protocol/melsec/Kconfig b/APP_Framework/Framework/control/plc_protocol/melsec/Kconfig index c441642b9..e26812739 100755 --- a/APP_Framework/Framework/control/plc_protocol/melsec/Kconfig +++ b/APP_Framework/Framework/control/plc_protocol/melsec/Kconfig @@ -24,7 +24,7 @@ choice endchoice if CONTROL_USING_SERIAL_485 - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config CONTROL_FRAMEWORK_UART_485_DIR int "control framework 485 direction pin number" default "2" @@ -53,11 +53,11 @@ if CONTROL_USING_SERIAL_485 endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif diff --git a/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c b/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c index aea9b553f..f3b52157e 100644 --- a/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c +++ b/APP_Framework/Framework/knowing/kpu/k210_yolov2_detect_procedure/k210_yolov2_detect.c @@ -48,7 +48,7 @@ void k210_detect(char *json_file_path) return; } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES kpu_fd = PrivOpen(KPU_DEV_DRIVER, O_RDONLY); if (camera_fd < 0) { @@ -154,7 +154,7 @@ void k210_detect(char *json_file_path) } } -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES dvp_set_ai_addr( (uintptr_t)(kpurgbbuffer + detect_params.net_input_size[1] * (detect_params.net_input_size[0] - detect_params.sensor_output_size[0])), @@ -175,7 +175,7 @@ void k210_detect(char *json_file_path) #endif // Load kmodel into kpu task -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES if (kpu_load_kmodel(&detect_task, model_data_align) != 0) { printf("\nmodel init error\n"); @@ -287,7 +287,7 @@ static void *thread_detect_entry(void *parameter) while (shoot_flag == 2) PrivIoctl(camera_fd, FLAG_CHECK, &camera_cfg); -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES if (dmalock_sync_take(&dma_ch, 2000)) { printf("Fail to take DMA channel"); @@ -296,7 +296,7 @@ static void *thread_detect_entry(void *parameter) while (!g_ai_done_flag) ; dmalock_release(dma_ch); -#elif defined ADD_XIZI_FETURES +#elif defined ADD_XIZI_FEATURES struct PrivIoctlCfg kpu_cfg; kpu_cfg.args = kpurgbbuffer; kpu_cfg.ioctl_driver_type = KPU_TYPE; @@ -309,7 +309,7 @@ static void *thread_detect_entry(void *parameter) } #endif -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES float *output; size_t output_size; kpu_get_output(&detect_task, 0, (uint8_t **)&output, &output_size); @@ -335,7 +335,7 @@ static void *thread_detect_entry(void *parameter) } #ifdef BSP_USING_LCD -#ifdef ADD_RTTHREAD_FETURES +#ifdef ADD_RTTHREAD_FEATURES extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr); lcd_draw_picture(0, 0, (uint16_t)detect_params.sensor_output_size[1] - 1, (uint16_t)detect_params.sensor_output_size[0] - 1, (uint32_t *)showbuffer); diff --git a/APP_Framework/Framework/sensor/Makefile b/APP_Framework/Framework/sensor/Makefile index 2ac3900a9..ea1294107 100644 --- a/APP_Framework/Framework/sensor/Makefile +++ b/APP_Framework/Framework/sensor/Makefile @@ -1,18 +1,18 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += sensor.c include $(APPDIR)/Application.mk endif -ifeq ($(ADD_XIZI_FETURES),y) +ifeq ($(ADD_XIZI_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += sensor.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := sensor.c ifeq ($(CONFIG_SENSOR_HCHO),y) diff --git a/APP_Framework/Framework/sensor/altitude/Kconfig b/APP_Framework/Framework/sensor/altitude/Kconfig index afbbef1f7..7e9b13aad 100644 --- a/APP_Framework/Framework/sensor/altitude/Kconfig +++ b/APP_Framework/Framework/sensor/altitude/Kconfig @@ -12,7 +12,7 @@ config SENSOR_BMP180 string "BMP180 quantity name" default "altitude_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_DEVICE_BMP180_DEV string "BMP180 device name" default "/dev/i2c1_dev0" @@ -22,11 +22,11 @@ config SENSOR_BMP180 default 0x77 endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif endif diff --git a/APP_Framework/Framework/sensor/ch4/Kconfig b/APP_Framework/Framework/sensor/ch4/Kconfig index 63011de1d..9bc386da7 100644 --- a/APP_Framework/Framework/sensor/ch4/Kconfig +++ b/APP_Framework/Framework/sensor/ch4/Kconfig @@ -12,7 +12,7 @@ config SENSOR_AS830 string "as830 quantity name" default "ch4_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_AS830_DRIVER_EXTUART bool "Using extra uart to support as830" default y @@ -33,7 +33,7 @@ config SENSOR_AS830 endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_AS830_DEV string "as830 device uart path" default "/dev/ttyS1" @@ -42,7 +42,7 @@ config SENSOR_AS830 endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES config SENSOR_AS830_DRIVER_EXTUART bool "Using extra uart to support as830" default y diff --git a/APP_Framework/Framework/sensor/ch4/as830/Makefile b/APP_Framework/Framework/sensor/ch4/as830/Makefile index 5d661e31b..a8c591811 100644 --- a/APP_Framework/Framework/sensor/ch4/as830/Makefile +++ b/APP_Framework/Framework/sensor/ch4/as830/Makefile @@ -1,11 +1,11 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += as830.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := as830.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/co2/Kconfig b/APP_Framework/Framework/sensor/co2/Kconfig index 78a965e8d..8ae2dcf68 100644 --- a/APP_Framework/Framework/sensor/co2/Kconfig +++ b/APP_Framework/Framework/sensor/co2/Kconfig @@ -12,7 +12,7 @@ config SENSOR_ZG09 string "zg09 quantity name" default "co2_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_ZG09_DRIVER_EXTUART bool "Using extra uart to support zg09" default y @@ -33,7 +33,7 @@ config SENSOR_ZG09 endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_ZG09_DEV string "CO2 device name" default "/dev/ttyS1" @@ -42,7 +42,7 @@ config SENSOR_ZG09 endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES config SENSOR_ZG09_DRIVER_EXTUART bool "Using extra uart to support zg09" default y @@ -78,7 +78,7 @@ config SENSOR_G8S string "g8-s quantity name" default "co2_2" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_G8S_DRIVER_EXTUART bool "Using extra uart to support g8-s" default n @@ -99,7 +99,7 @@ config SENSOR_G8S endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_G8S_DEV string "CO2 device name" default "/dev/ttyS3" @@ -107,7 +107,7 @@ config SENSOR_G8S If USART1 is selected, then fill in /dev/ttyS1 here. endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif endif diff --git a/APP_Framework/Framework/sensor/co2/g8s/Makefile b/APP_Framework/Framework/sensor/co2/g8s/Makefile index e4b77f31a..293a243fb 100644 --- a/APP_Framework/Framework/sensor/co2/g8s/Makefile +++ b/APP_Framework/Framework/sensor/co2/g8s/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += g8s.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := g8s.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/co2/zg09/Makefile b/APP_Framework/Framework/sensor/co2/zg09/Makefile index 1a3e79d52..8ff1c1d27 100644 --- a/APP_Framework/Framework/sensor/co2/zg09/Makefile +++ b/APP_Framework/Framework/sensor/co2/zg09/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += zg09.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := zg09.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/hcho/Kconfig b/APP_Framework/Framework/sensor/hcho/Kconfig index cd87003b6..aad01deb1 100644 --- a/APP_Framework/Framework/sensor/hcho/Kconfig +++ b/APP_Framework/Framework/sensor/hcho/Kconfig @@ -12,7 +12,7 @@ config SENSOR_TB600B_WQ_HCHO1OS string "tb600b wq_hcho1os quantity name" default "hcho_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_TB600B_WQ_HCHO1OS_DRIVER_EXTUART bool "Using extra uart to support tb600b wq_hcho1os" default y @@ -33,7 +33,7 @@ config SENSOR_TB600B_WQ_HCHO1OS endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV string "tb600b wq_hcho1os device uart path" default "/dev/ttyS1" @@ -42,7 +42,7 @@ config SENSOR_TB600B_WQ_HCHO1OS endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES config SENSOR_TB600B_WQ_HCHO1OS_DRIVER_EXTUART bool "Using extra uart to support tb600b wq_hcho1os" default y diff --git a/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile index 9e7dd4863..3049e5223 100644 --- a/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile +++ b/APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += tb600b_wq_hcho1os.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := tb600b_wq_hcho1os.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/humidity/Kconfig b/APP_Framework/Framework/sensor/humidity/Kconfig index a38a74125..8909f03e3 100644 --- a/APP_Framework/Framework/sensor/humidity/Kconfig +++ b/APP_Framework/Framework/sensor/humidity/Kconfig @@ -12,7 +12,7 @@ config SENSOR_HS300X_HUMIDITY string "HS300x quantity name" default "humidity_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_DEVICE_HS300X_DEV string "HS300x device name" default "/dev/i2c1_dev0" @@ -23,7 +23,7 @@ config SENSOR_HS300X_HUMIDITY endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_HS300X_DEV string "HS300x device name" default "/dev/i2c1_dev0" @@ -34,7 +34,7 @@ config SENSOR_HS300X_HUMIDITY endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES config SENSOR_DEVICE_HS300X_DEV string "HS300x device name" default "/dev/i2c1" diff --git a/APP_Framework/Framework/sensor/humidity/hs300x_humi/Makefile b/APP_Framework/Framework/sensor/humidity/hs300x_humi/Makefile index 58f85b1ef..0dc12429d 100644 --- a/APP_Framework/Framework/sensor/humidity/hs300x_humi/Makefile +++ b/APP_Framework/Framework/sensor/humidity/hs300x_humi/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += hs300x_humi.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := hs300x_humi.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/sensor/iaq/Kconfig b/APP_Framework/Framework/sensor/iaq/Kconfig index 6b52c1db1..209911950 100644 --- a/APP_Framework/Framework/sensor/iaq/Kconfig +++ b/APP_Framework/Framework/sensor/iaq/Kconfig @@ -12,7 +12,7 @@ config SENSOR_TB600B_IAQ10 string "tb600b iaq10 quantity name" default "iaq_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_TB600B_IAQ10_DRIVER_EXTUART bool "Using extra uart to support tb600b iaq10" default y @@ -33,7 +33,7 @@ config SENSOR_TB600B_IAQ10 endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_TB600B_IAQ10_DEV string "tb600b iaq10 device uart path" default "/dev/ttyS1" @@ -42,7 +42,7 @@ config SENSOR_TB600B_IAQ10 endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif endif diff --git a/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile index 39da6a6bb..600f7e2fc 100644 --- a/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile +++ b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += tb600b_iaq10.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := tb600b_iaq10.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/pm/Kconfig b/APP_Framework/Framework/sensor/pm/Kconfig index 5c9d7069c..328f06455 100644 --- a/APP_Framework/Framework/sensor/pm/Kconfig +++ b/APP_Framework/Framework/sensor/pm/Kconfig @@ -38,7 +38,7 @@ config SENSOR_PS5308 default "pm10_1" endif - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_PS5308_DRIVER_EXTUART bool "Using extra uart to support PS5308" default y @@ -59,7 +59,7 @@ config SENSOR_PS5308 endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_PS5308_DEV string "PS5308 device name" default "/dev/ttyS1" @@ -68,7 +68,7 @@ config SENSOR_PS5308 endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif endif diff --git a/APP_Framework/Framework/sensor/pm/ps5308/Makefile b/APP_Framework/Framework/sensor/pm/ps5308/Makefile index 960968dd2..96ae6cc99 100644 --- a/APP_Framework/Framework/sensor/pm/ps5308/Makefile +++ b/APP_Framework/Framework/sensor/pm/ps5308/Makefile @@ -1,11 +1,11 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += ps5308.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := ps5308.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/temperature/Kconfig b/APP_Framework/Framework/sensor/temperature/Kconfig index aa170103b..64584f8bf 100644 --- a/APP_Framework/Framework/sensor/temperature/Kconfig +++ b/APP_Framework/Framework/sensor/temperature/Kconfig @@ -12,7 +12,7 @@ config SENSOR_HS300X_TEMPERATURE string "HS300x quantity name" default "temperature_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_DEVICE_HS300X_DEV string "HS300x device name" default "/dev/i2c1_dev0" @@ -22,7 +22,7 @@ config SENSOR_HS300X_TEMPERATURE default 0x44 endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_HS300X_DEV string "HS300x device name" default "/dev/i2c1_dev0" @@ -33,7 +33,7 @@ config SENSOR_HS300X_TEMPERATURE endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES config SENSOR_DEVICE_HS300X_DEV string "HS300x device name" default "/dev/i2c1" diff --git a/APP_Framework/Framework/sensor/temperature/hs300x_temp/Makefile b/APP_Framework/Framework/sensor/temperature/hs300x_temp/Makefile index 047981e4b..dc0382316 100644 --- a/APP_Framework/Framework/sensor/temperature/hs300x_temp/Makefile +++ b/APP_Framework/Framework/sensor/temperature/hs300x_temp/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += hs300x_temp.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := hs300x_temp.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/tvoc/Kconfig b/APP_Framework/Framework/sensor/tvoc/Kconfig index b667e4801..60d062363 100644 --- a/APP_Framework/Framework/sensor/tvoc/Kconfig +++ b/APP_Framework/Framework/sensor/tvoc/Kconfig @@ -12,7 +12,7 @@ config SENSOR_TB600B_TVOC10 string "tb600b tvoc10 quantity name" default "tvoc_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_TB600B_TVOC10_DRIVER_EXTUART bool "Using extra uart to support tb600b tvoc10" default y @@ -33,7 +33,7 @@ config SENSOR_TB600B_TVOC10 endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_TB600B_TVOC10_DEV string "tb600b tvoc10 device uart path" default "/dev/ttyS1" @@ -42,7 +42,7 @@ config SENSOR_TB600B_TVOC10 endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif endif diff --git a/APP_Framework/Framework/sensor/tvoc/tb600b_tvoc10/Makefile b/APP_Framework/Framework/sensor/tvoc/tb600b_tvoc10/Makefile index 7fb2cadbd..b5467d0ad 100644 --- a/APP_Framework/Framework/sensor/tvoc/tb600b_tvoc10/Makefile +++ b/APP_Framework/Framework/sensor/tvoc/tb600b_tvoc10/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += tb600b_tvoc10.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := tb600b_tvoc10.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/voice/Kconfig b/APP_Framework/Framework/sensor/voice/Kconfig index 87a8c213f..e2b56743e 100644 --- a/APP_Framework/Framework/sensor/voice/Kconfig +++ b/APP_Framework/Framework/sensor/voice/Kconfig @@ -12,7 +12,7 @@ config SENSOR_D124 string "D124 quantity voice name" default "voice_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_D124_DRIVER_EXTUART bool "Using extra uart to support D124" default y @@ -33,7 +33,7 @@ config SENSOR_D124 endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_D124_DEV string "D124 device name" default "/dev/ttyS1" @@ -42,7 +42,7 @@ config SENSOR_D124 endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES config SENSOR_D124_DRIVER_EXTUART bool "Using extra uart to support D124" default y diff --git a/APP_Framework/Framework/sensor/voice/d124/Makefile b/APP_Framework/Framework/sensor/voice/d124/Makefile index 18f5d991a..7686ec3ec 100644 --- a/APP_Framework/Framework/sensor/voice/d124/Makefile +++ b/APP_Framework/Framework/sensor/voice/d124/Makefile @@ -1,12 +1,12 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += d124.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := d124.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/voice/d124/d124.c b/APP_Framework/Framework/sensor/voice/d124/d124.c index 1e204806d..232680c21 100644 --- a/APP_Framework/Framework/sensor/voice/d124/d124.c +++ b/APP_Framework/Framework/sensor/voice/d124/d124.c @@ -51,7 +51,7 @@ static void *ReadTask(void *parameter) * @param sdev - sensor device pointer * @return success: 1 , failure: other */ -#ifdef ADD_NUTTX_FETURES +#ifdef ADD_NUTTX_FEATURES static int SensorDeviceOpen(struct SensorDevice *sdev) { int result = 0; diff --git a/APP_Framework/Framework/sensor/winddirection/Kconfig b/APP_Framework/Framework/sensor/winddirection/Kconfig index 7fdbd7bd4..11c59f174 100644 --- a/APP_Framework/Framework/sensor/winddirection/Kconfig +++ b/APP_Framework/Framework/sensor/winddirection/Kconfig @@ -12,7 +12,7 @@ config SENSOR_QS_FX string "qs-fx quantity name" default "winddirection_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_QS_FX_DRIVER_EXTUART bool "Using extra uart to support qs-fx" default y @@ -41,7 +41,7 @@ config SENSOR_QS_FX endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_QS_FX_DEV string "qs-fx device name" default "/dev/ttyS1" @@ -50,7 +50,7 @@ config SENSOR_QS_FX endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif endif diff --git a/APP_Framework/Framework/sensor/winddirection/qs-fx/Makefile b/APP_Framework/Framework/sensor/winddirection/qs-fx/Makefile index e45522588..ff3f83ad6 100644 --- a/APP_Framework/Framework/sensor/winddirection/qs-fx/Makefile +++ b/APP_Framework/Framework/sensor/winddirection/qs-fx/Makefile @@ -1,11 +1,11 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += qs-fx.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := qs-fx.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/winddirection/qs-fx/qs-fx.c b/APP_Framework/Framework/sensor/winddirection/qs-fx/qs-fx.c index 3a9e1eed5..d26c44e80 100644 --- a/APP_Framework/Framework/sensor/winddirection/qs-fx/qs-fx.c +++ b/APP_Framework/Framework/sensor/winddirection/qs-fx/qs-fx.c @@ -69,7 +69,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev) return result; } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES static int PinOpen(void){ int pin_fd = PrivOpen(SENSOR_DEVICE_QS_FX_PIN_DEV, O_RDWR); if (pin_fd < 0) { @@ -106,7 +106,7 @@ static int PinOpen(void){ */ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len) { -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES int pin_fd=PinOpen(); struct PinStat pin_dir; pin_dir.pin = SENSOR_DEVICE_QS_FX_PIN_NUMBER; @@ -120,7 +120,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len) return -1; PrivTaskDelay(20); -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES pin_dir.val = GPIO_LOW; if (PrivWrite(pin_fd,&pin_dir,0) < 0) // pull-down pin to configure as rx mode return -1; diff --git a/APP_Framework/Framework/sensor/windspeed/Kconfig b/APP_Framework/Framework/sensor/windspeed/Kconfig index 96dfabf27..a8247f5e2 100644 --- a/APP_Framework/Framework/sensor/windspeed/Kconfig +++ b/APP_Framework/Framework/sensor/windspeed/Kconfig @@ -12,7 +12,7 @@ config SENSOR_QS_FS string "qs-fs quantity name" default "windspeed_1" - if ADD_XIZI_FETURES + if ADD_XIZI_FEATURES config SENSOR_QS_FS_DRIVER_EXTUART bool "Using extra uart to support qs-fx" default y @@ -41,7 +41,7 @@ config SENSOR_QS_FS endif endif - if ADD_NUTTX_FETURES + if ADD_NUTTX_FEATURES config SENSOR_DEVICE_QS_FS_DEV string "qs-fx device name" default "/dev/ttyS1" @@ -50,7 +50,7 @@ config SENSOR_QS_FS endif - if ADD_RTTHREAD_FETURES + if ADD_RTTHREAD_FEATURES endif endif diff --git a/APP_Framework/Framework/sensor/windspeed/qs-fs/Makefile b/APP_Framework/Framework/sensor/windspeed/qs-fs/Makefile index a6872570e..479e73cc5 100644 --- a/APP_Framework/Framework/sensor/windspeed/qs-fs/Makefile +++ b/APP_Framework/Framework/sensor/windspeed/qs-fs/Makefile @@ -1,11 +1,11 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs CSRCS += qs-fs.c include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_FILES := qs-fs.c include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/sensor/windspeed/qs-fs/qs-fs.c b/APP_Framework/Framework/sensor/windspeed/qs-fs/qs-fs.c index 151e70c91..ff8651fcb 100644 --- a/APP_Framework/Framework/sensor/windspeed/qs-fs/qs-fs.c +++ b/APP_Framework/Framework/sensor/windspeed/qs-fs/qs-fs.c @@ -68,7 +68,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev) return result; } -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES static int PinOpen(void){ int pin_fd = PrivOpen(SENSOR_DEVICE_QS_FS_PIN_DEV, O_RDWR); if (pin_fd < 0) { @@ -106,7 +106,7 @@ static int PinOpen(void){ */ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len) { -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES int pin_fd=PinOpen(); struct PinStat pin_dir; pin_dir.pin = SENSOR_DEVICE_QS_FS_PIN_NUMBER; @@ -121,7 +121,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len) return -1; PrivTaskDelay(20); -#ifdef ADD_XIZI_FETURES +#ifdef ADD_XIZI_FEATURES pin_dir.val = GPIO_LOW; if (PrivWrite(pin_fd,&pin_dir,0) < 0) // pull-down pin to configure as rx mode return -1; diff --git a/APP_Framework/Framework/transform_layer/Makefile b/APP_Framework/Framework/transform_layer/Makefile index 6a6d096f8..46204ebe2 100644 --- a/APP_Framework/Framework/transform_layer/Makefile +++ b/APP_Framework/Framework/transform_layer/Makefile @@ -1,6 +1,6 @@ SRC_DIR := -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_DIR += xizi endif diff --git a/APP_Framework/Makefile b/APP_Framework/Makefile index 3a832911b..2b9d30849 100644 --- a/APP_Framework/Makefile +++ b/APP_Framework/Makefile @@ -1,10 +1,10 @@ include $(KERNEL_ROOT)/.config -ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES),y) include $(APPDIR)/Make.defs include $(APPDIR)/Application.mk endif -ifeq ($(CONFIG_ADD_XIZI_FETURES),y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES),y) SRC_DIR := Applications Framework lib include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/lib/lorawan/Kconfig b/APP_Framework/lib/lorawan/Kconfig index ec6f54332..be88cbf5d 100644 --- a/APP_Framework/lib/lorawan/Kconfig +++ b/APP_Framework/lib/lorawan/Kconfig @@ -5,6 +5,18 @@ menuconfig LIB_USING_LORAWAN default n if LIB_USING_LORAWAN + menuconfig LIB_USING_LORAWAN_GATEWAY_SC + help + Please add "source "$APP_DIR/lib/lorawan/lorawan_gateway_single_channel/Kconfig"" when using lorawan_gateway_single_channel + bool "LoRaWan using lorawan_gateway for single channel(SX126x/SX127x) lib" + default n + select LIB_USING_LORA_RADIO + select BSP_USING_LWIP + + if LIB_USING_LORAWAN_GATEWAY_SC + + endif + menuconfig LIB_USING_LORAWAN_ED_STACK help Please add "source "$APP_DIR/lib/lorawan/lorawan_devicenode/Kconfig"" when using lorawan_devicenode @@ -21,6 +33,7 @@ menuconfig LIB_USING_LORAWAN Please add "source "$APP_DIR/lib/lorawan/lora_radio_driver/Kconfig"" when using lora_radio_driver bool "LoRaWan using lora-radio-driver lib" default n + select BSP_USING_SPI if LIB_USING_LORA_RADIO diff --git a/APP_Framework/lib/lorawan/Makefile b/APP_Framework/lib/lorawan/Makefile index dd6c0721f..98b176f19 100644 --- a/APP_Framework/lib/lorawan/Makefile +++ b/APP_Framework/lib/lorawan/Makefile @@ -8,4 +8,8 @@ ifeq ($(CONFIG_LIB_USING_LORAWAN_ED_STACK),y) SRC_DIR += lorawan_devicenode endif +ifeq ($(CONFIG_LIB_USING_LORAWAN_GATEWAY_SC),y) + SRC_DIR += lorawan_gateway_single_channel +endif + include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/lib/lorawan/README.md b/APP_Framework/lib/lorawan/README.md index 7fb6c76e2..bff82e90b 100644 --- a/APP_Framework/lib/lorawan/README.md +++ b/APP_Framework/lib/lorawan/README.md @@ -1,16 +1,17 @@ # lorawan子模块调试说明 -矽璓工业物联操作系统XiUOS目前支持lorawan相关开源库,通过子模块形式管理,该目录主要内容是包含**lora_radio_driver**、**lorawan_devicenode**等。 +矽璓工业物联操作系统XiUOS目前支持lorawan相关开源库,通过子模块形式管理,该目录主要内容是包含**lora_radio_driver**、**lorawan_devicenode**、**lorawan_gateway_single_channel**等。 ## 目录内容 ``` xiuos/APP_Framework/lib/lorawan ├── README.md - ├── lora_radio_driver lora_radio驱动库 - ├── lorawan_devicenode lorawan节点协议栈 - ├── Kconfig lorawan Kconfig配置 - └── Makefile lorawan Makefile + ├── lora_radio_driver lora_radio驱动库 + ├── lorawan_devicenode lorawan节点协议栈 + ├── lorawan_gateway_single_channel lorawan单通道网关协议栈 + ├── Kconfig lorawan Kconfig配置 + └── Makefile lorawan Makefile ``` ## 使用 @@ -24,7 +25,16 @@ git submodule init git submodule update APP_Framework/lib/lorawan/lora_radio_driver git submodule update APP_Framework/lib/lorawan/lorawan_devicenode -# 进入 APP_Framework/lib/lorawan/Kconfig 配置,增加子模块source路径 +# 进入 APP_Framework/lib/lorawan/Kconfig 配置,增加子模块source路径,从而编译时可找到相应lib的配置 +menuconfig LIB_USING_LORAWAN_GATEWAY_SC + bool "LoRaWan using lorawan_gateway for single channel(SX126x、SX127x) lib" + default n + select LIB_USING_LORA_RADIO + +if LIB_USING_LORAWAN_GATEWAY_SC + source "$APP_DIR/lib/lorawan/lorawan_gateway_single_channel/Kconfig" +endif + menuconfig LIB_USING_LORAWAN_ED_STACK bool "LoRaWan using lorawan_ed_stack lib" default n diff --git a/APP_Framework/lib/lorawan/lora_radio_driver b/APP_Framework/lib/lorawan/lora_radio_driver index bc03d64f4..d21965b1c 160000 --- a/APP_Framework/lib/lorawan/lora_radio_driver +++ b/APP_Framework/lib/lorawan/lora_radio_driver @@ -1 +1 @@ -Subproject commit bc03d64f4b7408f85512735064dc5569431d6c8d +Subproject commit d21965b1cbcfa99b2d36acd029a37f3f2eba612e diff --git a/APP_Framework/lib/lorawan/lorawan_gateway_single_channel b/APP_Framework/lib/lorawan/lorawan_gateway_single_channel new file mode 160000 index 000000000..ac1c6516e --- /dev/null +++ b/APP_Framework/lib/lorawan/lorawan_gateway_single_channel @@ -0,0 +1 @@ +Subproject commit ac1c6516ec9b2998c0c50796a4e5a8b78781dc8c diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-arm32-board/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-arm32-board/configs/nsh/defconfig index 697a70852..06623fbae 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-arm32-board/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-arm32-board/configs/nsh/defconfig @@ -9,7 +9,7 @@ # CONFIG_NSH_ARGCAT is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDPARMS is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="aiit-arm32-board" CONFIG_ARCH_BOARD_STM32F4_AIIT=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-riscv64-board/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-riscv64-board/configs/nsh/defconfig index 641746360..b6214968f 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-riscv64-board/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/aiit-riscv64-board/configs/nsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="aiit-riscv64-board" CONFIG_ARCH_BOARD_AIIT_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/lorae22nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/lorae22nsh/defconfig index 8beb3aa76..18e17f54e 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/lorae22nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/lorae22nsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="edu-riscv64" CONFIG_ARCH_BOARD_EDU_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/loransh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/loransh/defconfig index 882bfd930..b68627f4f 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/loransh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/loransh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="edu-riscv64" CONFIG_ARCH_BOARD_EDU_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/nsh/defconfig index c93933657..4293cb647 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/nsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="edu-riscv64" CONFIG_ARCH_BOARD_EDU_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/usbnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/usbnsh/defconfig index fbe6ee65d..ee5ba82a5 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/usbnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/usbnsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="edu-riscv64" CONFIG_ARCH_BOARD_EDU_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/wifinsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/wifinsh/defconfig index 83a523fcf..dfc7f4901 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/wifinsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/edu-riscv64/configs/wifinsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="edu-riscv64" CONFIG_ARCH_BOARD_EDU_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/hc32f4a0/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/hc32f4a0/configs/nsh/defconfig index 513eca924..85bcadd17 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/hc32f4a0/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/hc32f4a0/configs/nsh/defconfig @@ -9,7 +9,7 @@ # CONFIG_NSH_ARGCAT is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDPARMS is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_ARMV7M=y CONFIG_ARCH_CORTEXM4=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/elf/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/elf/defconfig index b0c8add40..909a58c09 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/elf/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/elf/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="sabre-lite" CONFIG_ARCH_BOARD_SABRE_LITE=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/knsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/knsh/defconfig index 5d1a8916c..3b15c1260 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/knsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/knsh/defconfig @@ -6,7 +6,7 @@ # modifications. # # CONFIG_NSH_CMDOPT_HEXDUMP is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_ADDRENV=y CONFIG_ARCH_BOARD="sabre-lite" diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/nsh/defconfig index 5588f4a47..8624d9db1 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/nsh/defconfig @@ -6,7 +6,7 @@ # modifications. # # CONFIG_NSH_CMDOPT_HEXDUMP is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="sabre-lite" CONFIG_ARCH_BOARD_SABRE_LITE=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/posix_spawn/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/posix_spawn/defconfig index 50f16f7a7..77ffec5f1 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/posix_spawn/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/posix_spawn/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="sabre-lite" CONFIG_ARCH_BOARD_SABRE_LITE=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/smp/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/smp/defconfig index 430c983cc..2fed4ea83 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/smp/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/configs/smp/defconfig @@ -6,7 +6,7 @@ # modifications. # # CONFIG_NSH_CMDOPT_HEXDUMP is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="sabre-lite" CONFIG_ARCH_BOARD_SABRE_LITE=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board.h b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board.h index 405566e68..3693cb79c 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board.h +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board.h @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/include/board.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file board.h + * @brief sabre-lite board.h file + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ #ifndef __BOARDS_ARM_IMX6_SABRE_LITE_INCLUDE_BOARD_H #define __BOARDS_ARM_IMX6_SABRE_LITE_INCLUDE_BOARD_H diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board_memorymap.h b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board_memorymap.h index d49e77662..14fa834cf 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board_memorymap.h +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/include/board_memorymap.h @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/include/board_memorymap.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file board_memorymap.h + * @brief sabre-lite board memorymap + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ #ifndef __BOARDS_ARM_IMX6_SABRE_LITE_INCLUDE_BOARD_MEMORYMAP_H #define __BOARDS_ARM_IMX6_SABRE_LITE_INCLUDE_BOARD_MEMORYMAP_H diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_appinit.c b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_appinit.c index a90b2913a..26c471a34 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_appinit.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_appinit.c @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/src/imx_appinit.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file imx_appinit.c + * @brief sabre-lite imx_appinit.c file + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ /**************************************************************************** * Included Files diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_autoleds.c b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_autoleds.c index ab081c440..cfd34ca69 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_autoleds.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_autoleds.c @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/src/imx_autoleds.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file imx_autoleds.c + * @brief sabre-lite imx_autoleds.c file + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ /* LEDs * diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_boardinit.c b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_boardinit.c index df29c3b07..3f49cef5c 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_boardinit.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_boardinit.c @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/src/imx_boardinit.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file imx_boardinit.c + * @brief sabre-lite imx_boardinit.c file + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ /**************************************************************************** * Included Files diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_bringup.c b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_bringup.c index b26bf4582..71e55b8b2 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_bringup.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_bringup.c @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/src/imx_bringup.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file imx_bringup.c + * @brief sabre-lite imx_bringup.c file + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ /**************************************************************************** * Included Files diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_userleds.c b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_userleds.c index f86268f1c..2261bf165 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_userleds.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/imx_userleds.c @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/src/imx_userleds.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file imx_userleds.c + * @brief sabre-lite imx_userleds.c file + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ /**************************************************************************** * Included Files diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/sabre-lite.h b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/sabre-lite.h index 76568b434..f4b310767 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/sabre-lite.h +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/sabre-lite/src/sabre-lite.h @@ -1,22 +1,22 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-lite/src/sabre-lite.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** + * @file sabre-lite.h + * @brief sabre-lite sabre-lite.h file + * @version 1.0 + * @author AIIT XUOS Lab + * @date 2023.05.15 + */ #ifndef __BOARDS_ARM_IMX6_SABRE_LITE_SRC_SABRE_LITE_H #define __BOARDS_ARM_IMX6_SABRE_LITE_SRC_SABRE_LITE_H diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/4gnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/4gnsh/defconfig index e77bb4385..60de6af8a 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/4gnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/4gnsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/btnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/btnsh/defconfig index 9b7af5b16..a8b10a612 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/btnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/btnsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig index 3219e42d0..463b56ad4 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/lcdnsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/loransh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/loransh/defconfig index b13f681e5..c921ad8b4 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/loransh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/loransh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig index e38a4d7e5..5cd70cefe 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/muslnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/muslnsh/defconfig index 9b1048d9e..0aed0f5c7 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/muslnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/muslnsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig index 18e37d804..f51869369 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/netnsh/defconfig @@ -6,7 +6,7 @@ # modifications. # # CONFIG_ARCH_LEDS is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/nsh/defconfig index 9bbac573a..332888ba3 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/nsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/sdionsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/sdionsh/defconfig index 09b581648..366f58951 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/sdionsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/sdionsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/usbnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/usbnsh/defconfig index fbb2ab1d2..5aadd5c2f 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/usbnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/usbnsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig index 2d1625113..f5de9941f 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/wifinsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/zbnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/zbnsh/defconfig index f2bb2dd5a..3aad755ea 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/zbnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/zbnsh/defconfig @@ -5,7 +5,7 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="xidatong-arm32" CONFIG_ARCH_BOARD_XIDATONG_ARM32=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/4gnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/4gnsh/defconfig index 9f8bf526d..c2764380a 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/4gnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/4gnsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/btnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/btnsh/defconfig index d22793b51..33ce3dd95 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/btnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/btnsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/cannsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/cannsh/defconfig index d0df672e4..8d552684b 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/cannsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/cannsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/ch376nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/ch376nsh/defconfig index b9aefbaa3..25aabdfa7 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/ch376nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/ch376nsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig index 588b67f60..6525d7e4c 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/lcdnsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/loransh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/loransh/defconfig index d86e29dfb..562195c42 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/loransh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/loransh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/nsh/defconfig index aaad9d7a0..6a930ff44 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/nsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/touchnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/touchnsh/defconfig index 09d0c7329..c02b6aaec 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/touchnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/touchnsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/w5500nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/w5500nsh/defconfig index 6075ce1b8..380fef511 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/w5500nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/w5500nsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/wifinsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/wifinsh/defconfig index 327ac8b74..389d01ec1 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/wifinsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/wifinsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/zbnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/zbnsh/defconfig index 2eef08514..94962951a 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/zbnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-riscv64/configs/zbnsh/defconfig @@ -7,7 +7,7 @@ # # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="xidatong-riscv64" CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/iaqnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/iaqnsh/defconfig index 004a0a38b..bccc666e1 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/iaqnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/iaqnsh/defconfig @@ -9,7 +9,7 @@ # CONFIG_NSH_ARGCAT is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDPARMS is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="stm32f4discovery" CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/loransh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/loransh/defconfig index e5288e75b..addd8965e 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/loransh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/loransh/defconfig @@ -9,7 +9,7 @@ # CONFIG_NSH_ARGCAT is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDPARMS is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="stm32f4discovery" CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/nsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/nsh/defconfig index 5ca3887cc..3902a9e1c 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/nsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/nsh/defconfig @@ -9,7 +9,7 @@ # CONFIG_NSH_ARGCAT is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDPARMS is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="stm32f4discovery" CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/tempnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/tempnsh/defconfig index 7522834e8..614fb27a8 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/tempnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/nuttx/boards/arm/stm32/stm32f4discovery/configs/tempnsh/defconfig @@ -9,7 +9,7 @@ # CONFIG_NSH_ARGCAT is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDPARMS is not set -CONFIG_ADD_NUTTX_FETURES=y +CONFIG_ADD_NUTTX_FEATURES=y CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="stm32f4discovery" CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config index aa01305c9..5decf02ef 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/.config @@ -313,9 +313,9 @@ CONFIG_USB_DEVICE_NAME="usb_dev" # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -# CONFIG_ADD_XIZI_FETURES is not set -# CONFIG_ADD_NUTTX_FETURES is not set -CONFIG_ADD_RTTHREAD_FETURES=y +# CONFIG_ADD_XIZI_FEATURES is not set +# CONFIG_ADD_NUTTX_FEATURES is not set +CONFIG_ADD_RTTHREAD_FEATURES=y # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y CONFIG_CONNECTION_FRAMEWORK_DEBUG=y diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h index e71dc1826..b755526d1 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-arm32-board/rtconfig.h @@ -190,7 +190,7 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_RTTHREAD_FETURES +#define ADD_RTTHREAD_FEATURES #define SUPPORT_CONNECTION_FRAMEWORK #define CONNECTION_FRAMEWORK_DEBUG #define ADAPTER_HFA21_DRIVER "/dev/uart3" diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/.config index a35ce48a2..781d0905f 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/.config @@ -327,9 +327,9 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055 # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -# CONFIG_ADD_XIZI_FETURES is not set -# CONFIG_ADD_NUTTX_FETURES is not set -CONFIG_ADD_RTTHREAD_FETURES=y +# CONFIG_ADD_XIZI_FEATURES is not set +# CONFIG_ADD_NUTTX_FEATURES is not set +CONFIG_ADD_RTTHREAD_FEATURES=y CONFIG_SUPPORT_SENSOR_FRAMEWORK=y CONFIG_SENSOR_HCHO=y CONFIG_SENSOR_TB600B_WQ_HCHO1OS=y diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/rtconfig.h index 714ab891e..7377e8ac0 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/aiit-riscv64-board/rtconfig.h @@ -206,7 +206,7 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_RTTHREAD_FETURES +#define ADD_RTTHREAD_FEATURES #define SUPPORT_SENSOR_FRAMEWORK #define SENSOR_HCHO #define SENSOR_TB600B_WQ_HCHO1OS diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/.config index 335c45a54..81e2f5a1f 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/.config @@ -465,9 +465,9 @@ CONFIG_OV2640_Y_IMAGE_WINDOWS_SIZE=400 # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set CONFIG_SUPPORT_KNOWING_FRAMEWORK=y diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/rtconfig.h index 437cca660..bb838bb57 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/k210/rtconfig.h @@ -318,7 +318,7 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_XIZI_FETURES +#define ADD_XIZI_FEATURES #define SUPPORT_KNOWING_FRAMEWORK #define USING_KPU_PROCESSING #define USING_YOLOV2 diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/.config index 80c549734..36a8c9ccd 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/.config @@ -482,9 +482,9 @@ CONFIG_OV2640_Y_IMAGE_WINDOWS_SIZE=400 # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set CONFIG_SUPPORT_SENSOR_FRAMEWORK=y # CONFIG_SENSOR_HCHO is not set # CONFIG_SENSOR_TVOC is not set diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/rtconfig.h index 01651642e..6829561cd 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32f407_core/rtconfig.h @@ -311,7 +311,7 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_XIZI_FETURES +#define ADD_XIZI_FEATURES #define SUPPORT_SENSOR_FRAMEWORK #define SENSOR_VOICE #define SENSOR_D124 diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/.config index 0f63cb237..658492e7a 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/.config @@ -324,9 +324,9 @@ CONFIG_BSP_USING_USBD=y # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/rtconfig.h index 8ebd6580e..1fb0f5228 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/stm32h743_openmv_h7plus/rtconfig.h @@ -193,7 +193,7 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_XIZI_FETURES +#define ADD_XIZI_FEATURES /* Security */ diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/.config index a17f65d9d..6074e05ac 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/.config @@ -389,9 +389,9 @@ CONFIG_PHY_RESET_PIN=3 # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -# CONFIG_ADD_XIZI_FETURES is not set -# CONFIG_ADD_NUTTX_FETURES is not set -CONFIG_ADD_RTTHREAD_FETURES=y +# CONFIG_ADD_XIZI_FEATURES is not set +# CONFIG_ADD_NUTTX_FEATURES is not set +CONFIG_ADD_RTTHREAD_FEATURES=y # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/rtconfig.h index 964d9ebdc..f4203c863 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-arm32/rtconfig.h @@ -248,7 +248,7 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_RTTHREAD_FETURES +#define ADD_RTTHREAD_FEATURES /* Security */ diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/.config b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/.config index e12d40794..561d84c00 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/.config +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/.config @@ -352,9 +352,9 @@ CONFIG_PKG_WIZNET_VER="latest" # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -# CONFIG_ADD_XIZI_FETURES is not set -# CONFIG_ADD_NUTTX_FETURES is not set -CONFIG_ADD_RTTHREAD_FETURES=y +# CONFIG_ADD_XIZI_FEATURES is not set +# CONFIG_ADD_NUTTX_FEATURES is not set +CONFIG_ADD_RTTHREAD_FEATURES=y # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/rtconfig.h b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/rtconfig.h index eee446b17..0c87387ec 100644 --- a/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/rtconfig.h +++ b/Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/rtconfig.h @@ -217,7 +217,7 @@ /* Framework */ #define TRANSFORM_LAYER_ATTRIUBUTE -#define ADD_RTTHREAD_FETURES +#define ADD_RTTHREAD_FEATURES /* Security */ diff --git a/Ubiquitous/XiZi_AIoT/softkernel/task/Makefile b/Ubiquitous/XiZi_AIoT/softkernel/task/Makefile index 4ca20e597..93ec6f896 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/task/Makefile +++ b/Ubiquitous/XiZi_AIoT/softkernel/task/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := task.c schedule.c ipc.c +SRC_FILES := schedule.c ipc.c include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_AIoT/softkernel/task/ipc.c b/Ubiquitous/XiZi_AIoT/softkernel/task/ipc.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/Ubiquitous/XiZi_AIoT/softkernel/task/schedule.c b/Ubiquitous/XiZi_AIoT/softkernel/task/schedule.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/Ubiquitous/XiZi_AIoT/softkernel/task/task.c b/Ubiquitous/XiZi_AIoT/softkernel/task/task.c index e69de29bb..808804462 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/task/task.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/task/task.c @@ -0,0 +1,537 @@ + +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: task.c +* @brief: file task.c +* @version: 1.0 +* @author: AIIT XUOS Lab +* @date: 2023/05/18 +* +*/ + +#include + + +// 全局运行队列和本地运行队列 +tcb_t *global_run_queue_head = NULL; +tcb_t *global_run_queue_tail = NULL; +tcb_t *local_run_queue_head[8] = {NULL}; +tcb_t *local_run_queue_tail[8] = {NULL}; + +// 当前任务的指针 +volatile tcb_t *current_task = NULL; + + +/******************************************************************************* +* 函 数 名: tcb_init +* 功能描述: 初始化任务控制块 +* 形 参: tcb:任务控制块指针,priority:任务优先级,stack_size:栈大小 +* 返 回 值: 无 +*******************************************************************************/ +void tcb_init(tcb_t *tcb, int priority, int stack_size) { + tcb->priority = priority; + tcb->state = TASK_CREATED; + tcb->message_queue = NULL; + tcb->stack = (uint8_t*)malloc(stack_size); + tcb->stack_size = stack_size; + tcb->stack_ptr = tcb->stack + stack_size - sizeof(context_t); + // 将任务的上下文保存在栈中 + context_t *context = (context_t*)tcb->stack_ptr; + context_init(context, (void*)task_entry, tcb->stack_ptr); +} + +/******************************************************************************* +* 函 数 名: tcb_destroy +* 功能描述: 销毁任务控制块 +* 形 参: tcb:任务控制块指针 +* 返 回 值: 无 +*******************************************************************************/ +void tcb_destroy(tcb_t *tcb) { + free(tcb->stack_bottom); + tcb->stack_ptr = NULL; + tcb->stack_bottom = NULL; + tcb->stack_size = 0; + tcb->state = TASK_BLOCKED; + tcb->priority = 0; + tcb->next = NULL; + if (tcb->message_queue != NULL) { + message_queue_destroy(tcb->message_queue); + tcb->message_queue = NULL; + } +} + +/******************************************************************************* +* 函 数 名: get_current_task +* 功能描述: 获取当前任务的指针 +* 形 参: 无 +* 返 回 值: 任务控制块指针 +*******************************************************************************/ +tcb_t *get_current_task() { + return (tcb_t*)current_task; +} + + +/******************************************************************************* +* 函 数 名: get_local_run_queue_head +* 功能描述: 获取本地运行队列的头指针 +* 形 参: cpu_id:当前cpu的id +* 返 回 值: 任务控制块指针 +*******************************************************************************/ +tcb_t *get_local_run_queue_head(int cpu_id) { + return local_run_queue_head[cpu_id]; +} + + +/******************************************************************************* +* 函 数 名: add_to_global_run_queue +* 功能描述: 将任务添加到全局运行队列中 +* 形 参: tcb:任务控制块指针 +* 返 回 值: 无 +*******************************************************************************/ +void add_to_global_run_queue(tcb_t *tcb) { + // 将任务添加到全局运行队列的尾部 + if (global_run_queue_head == NULL) { + global_run_queue_head = tcb; + global_run_queue_tail = tcb; + } else { + global_run_queue_tail->next = tcb; + global_run_queue_tail = tcb; + } +} + + +/******************************************************************************* +* 函 数 名: take_from_global_run_queue +* 功能描述: 从全局运行队列中取出一个任务 +* 形 参: 无 +* 返 回 值: tcb:任务控制块指针 +*******************************************************************************/ +tcb_t *take_from_global_run_queue() { + // 从全局运行队列的头部取出一个任务 + if (global_run_queue_head == NULL) { + return NULL; + } else { + tcb_t *tcb = global_run_queue_head; + global_run_queue_head = tcb->next; + if (global_run_queue_head == NULL) { + global_run_queue_tail = NULL; + } + return tcb; + } +} + + +/******************************************************************************* +* 函 数 名: add_to_local_run_queue +* 功能描述: 将任务添加到本地运行队列中 +* 形 参: tcb:任务控制块指针,cpu_id:任务绑定的CPU id +* 返 回 值: 无 +*******************************************************************************/ +void add_to_local_run_queue(tcb_t *tcb, int cpu_id) { + // 将任务添加到本地运行队列的尾部 + if (local_run_queue_head[cpu_id] == NULL) { + local_run_queue_head[cpu_id] = tcb; + local_run_queue_tail[cpu_id] = tcb; + } else { + local_run_queue_tail[cpu_id]->next = tcb; + local_run_queue_tail[cpu_id] = tcb; + } +} + + +/******************************************************************************* +* 函 数 名: take_from_local_run_queue +* 功能描述: 从本地运行队列中取出一个任务 +* 形 参: cpu_id:CPU id +* 返 回 值: 无 +*******************************************************************************/ +tcb_t *take_from_local_run_queue(int cpu_id) { + // 从本地运行队列的头部取出一个任务 + if (local_run_queue_head[cpu_id] == NULL) { + return NULL; + } else { + tcb_t *tcb = local_run_queue_head[cpu_id]; + local_run_queue_head[cpu_id] = tcb->next; + if (local_run_queue_head[cpu_id] == NULL) { + local_run_queue_tail[cpu_id] = NULL; + } + return tcb; + } +} + + +/******************************************************************************* +* 函 数 名: move_current_task_to_global_run_queue +* 功能描述: 将当前任务从本地运行队列中取出,并添加到全局运行队列中 +* 形 参: 无 +* 返 回 值: 无 +*******************************************************************************/ +void move_current_task_to_global_run_queue() { + int cpu_id = get_cpu_id(); + tcb_t *tcb = (tcb_t*)current_task; + tcb->state = TASK_READY; + add_to_global_run_queue(tcb); + local_run_queue_head[cpu_id] = NULL; + local_run_queue_tail[cpu_id] = NULL; + current_task = NULL; +} + + +/******************************************************************************* +* 函 数 名: switch_to_next_task +* 功能描述: 切换到下一个任务 +* 形 参: 无 +* 返 回 值: 无 +*******************************************************************************/ +void switch_to_next_task() { + int cpu_id = get_cpu_id(); + tcb_t *current_tcb = (tcb_t*)current_task; + tcb_t *next_tcb = take_from_local_run_queue(cpu_id); + if (next_tcb == NULL) { + next_tcb = take_from_global_run_queue(); + } + if (next_tcb == NULL) { + // 如果没有可运行的任务,则将当前任务继续运行 + return; + } + // 保存当前任务的上下文 + if (current_tcb != NULL) { + current_tcb->stack_ptr = get_stack_pointer(); + } + // 切换到下一个任务的上下文 + current_task = next_tcb; + set_stack_pointer(next_tcb->stack_ptr); + // 如果切换到的任务是新的任务,需要执行任务初始化函数 + if (current_tcb != next_tcb) { + next_tcb->state = TASK_RUNNING; + task_init(next_tcb); + } +} + + +/******************************************************************************* +* 函 数 名: task_init +* 功能描述: 任务初始化函数 +* 形 参: tcb:任务控制块指针 +* 返 回 值: 无 +*******************************************************************************/ +void task_init(tcb_t *tcb) { + // 创建消息队列 + message_queue_t mq = (message_queue_t)malloc(sizeof(message_queue_t)); + mq->buffer = (message_t)malloc(sizeof(message_t) * 16); + mq->capacity = 16; + mq->head = 0; + mq->tail = 0; + mq->count = 0; + tcb->message_queue = mq; +} + + +/******************************************************************************* +* 函 数 名: create_task +* 功能描述: 创建任务 +* 形 参: priority:任务优先级,stack_size:栈大小 +* 返 回 值: 无 +*******************************************************************************/ +tcb_t *create_task(int priority, int stack_size) { + tcb_t *tcb = (tcb_t*)malloc(sizeof(tcb_t)); + tcb_init(tcb, priority, stack_size); + add_to_global_run_queue(tcb); + return tcb; +} + + +/******************************************************************************* +* 函 数 名: destroy_task +* 功能描述: 销毁任务 +* 形 参: tcb:任务控制块指针 +* 返 回 值: 无 +*******************************************************************************/ +void destroy_task(tcb_t *tcb) { + tcb_destroy(tcb); + free(tcb); +} + + +/******************************************************************************* +* 函 数 名: send_message +* 功能描述: 发送消息 +* 形 参: dest_tcb:目标任务的控制块指针,type:消息类型,data:消息的具体内容 +* 返 回 值: 无 +*******************************************************************************/ +void send_message(tcb_t *dest_tcb, int type, void *data) { + message_t message; + message.type = type; + message.data = data; + if (dest_tcb->message_queue == NULL) { + // 如果目标任务没有消息队列,则创建一个消息队列 + dest_tcb->message_queue = message_queue_create(16); + } + // 将消息添加到目标任务的消息队列中 + message_queue_push(dest_tcb->message_queue, &message); +} + + +/******************************************************************************* +* 函 数 名: receive_message +* 功能描述: 接收消息 +* 形 参: type:接收的消息类型,data:存储接收到的消息 +* 返 回 值: 无 +*******************************************************************************/ +void receive_message(int type, void *data) { + tcb_t *current_tcb = (tcb_t*)current_task; + message_t message; + // 从当前任务的消息队列中取出消息 + while (message_queue_pop(current_tcb->message_queue, &message) != 0) { + if (message.type == type) { + // 如果消息的类型匹配,则返回消息数据 + memcpy(data, message.data, sizeof(void*)); + return; + } + } + // 如果没有匹配的消息,则当前任务被阻塞,直到有匹配的消息为止 + current_tcb->state = TASK_BLOCKED; + while (message_queue_pop(current_tcb->message_queue, &message) != 0) { + if (message.type == type) { + // 如果有匹配的消息,则返回消息数据,并将当前任务状态设置为就绪 + memcpy(data, message.data, sizeof(void*)); + current_tcb->state = TASK_READY; + return; + } + } + // 如果还是没有匹配的消息,则当前任务一直被阻塞 + while (1) { + wait_for_interrupt(); + } +} + + +/******************************************************************************* +* 函 数 名: message_queue_create +* 功能描述: 创建消息队列 +* 形 参: capacity:消息队列的容量 +* 返 回 值: 生成的消息队列的指针 +*******************************************************************************/ +message_queue_t *message_queue_create(int capacity) { + message_queue_t *mq = (message_queue_t*)malloc(sizeof(message_queue_t)); + mq->buffer = (message_t*)malloc(sizeof(message_t) * capacity); + mq->capacity = capacity; + mq->head = 0; + mq->tail = 0; + mq->count = 0; + return mq; +} + + +/******************************************************************************* +* 函 数 名: message_queue_destroy +* 功能描述: 销毁消息队列 +* 形 参: mq:消息队列的指针 +* 返 回 值: 无 +*******************************************************************************/ +void message_queue_destroy(message_queue_t *mq) { + free(mq->buffer); + free(mq); +} + + +/******************************************************************************* +* 函 数 名: message_queue_push +* 功能描述: 将消息添加到消息队列中 +* 形 参: message_queue_t:消息队列的指针,message_t:存储的消息 +* 返 回 值: 0:成功,-1:失败 +*******************************************************************************/ +int message_queue_push(message_queue_t *mq, message_t *message) { + if (mq->count >= mq->capacity) { + return -1; // 队列已满 + } + mq->buffer[mq->tail] = *message; + mq->tail = (mq->tail + 1) % mq->capacity; + mq->count++; + return 0; +} + + +/******************************************************************************* +* 函 数 名: message_queue_pop +* 功能描述: 从消息队列中取出消息 +* 形 参: message_queue_t:消息队列的指针,message_t:存储的消息 +* 返 回 值: 0:成功,-1:失败 +*******************************************************************************/ +int message_queue_pop(message_queue_t *mq, message_t *message) { + if (mq->count <= 0) { + return -1; // 队列已空 + } + *message = mq->buffer[mq->head]; + mq->head = (mq->head + 1) % mq->capacity; + mq->count--; + return 0; +} + + +/******************************************************************************* +* 函 数 名: context_init +* 功能描述: 初始化上下文 +* 形 参: message_queue_t:消息队列的指针,message_t:存储的消息 +* 返 回 值: 0:成功,-1:失败 +*******************************************************************************/ +void context_init(context_t *context, void (*entry)(void), void *stack_ptr) { + context->cpsr = 0x10; // 设置 CPSR 的初始值 + context->pc = (uint32_t)entry; // 设置 PC 的初始值为任务入口地址 + context->r0 = (uint32_t)stack_ptr; // 设置 R0 的初始值为栈指针 + context->r1 = 0; // 设置 R1 的初始值为 0 + context->r2 = 0; // 设置 R2 的初始值为 0 + context->r3 = 0; // 设置 R3 的初始值为 0 + context->r4 = 0; // 设置 R4 的初始值为 0 + context->r5 = 0; // 设置 R5 的初始值为 0 + context->r6 = 0; // 设置 R6 的初始值为 0 + context->r7 = 0; // 设置 R7 的初始值为 0 + context->r8 = 0; // 设置 R8 的初始值为 0 + context->r9 = 0; // 设置 R9 的初始值为 0 + context->r10 = 0; // 设置 R10 的初始值为 0 + context->r11 = 0; // 设置 R11 的初始值为 0 + context->r12 = 0; // 设置 R12 的初始值为 0 + context->sp = (uint32_t)stack_ptr; // 设置 SP 的初始值为栈指针 + context->lr = (uint32_t)task_exit; // 设置 LR 的初始值为线程退出函数的地址 +} + +/******************************************************************************* +* 函 数 名: wait_for_interrupt +* 功能描述: 等待中断 +* 形 参: 无 +* 返 回 值: 无 +*******************************************************************************/ +void wait_for_interrupt() { + // 在实现中,可以使用 WFI 指令等待中断 + __asm__ volatile("wfi"); +} + +/******************************************************************************* +* 函 数 名: get_cpu_id +* 功能描述: 获取CPU id +* 形 参: 无 +* 返 回 值: 获取的cpu id +*******************************************************************************/ +int get_cpu_id() { + uint32_t mpidr; + __asm__ volatile("mrc p15, 0, %0, c0, c0, 5" : "=r"(mpidr)); + return mpidr & 0xff; +} + + +/******************************************************************************* +* 函 数 名: get_stack_pointer +* 功能描述: 获取栈指针 +* 形 参: 无 +* 返 回 值: 获取到的栈指针 +*******************************************************************************/ +void *get_stack_pointer() { + // 在实现中,可以使用 ARM 的 SP 寄存器获取栈指针 + void *sp; + __asm__ volatile("mov %0, sp" : "=r"(sp)); + return sp; +} + + +/******************************************************************************* +* 函 数 名: set_stack_pointer +* 功能描述: 设置栈指针 +* 形 参: 设置的栈指针 +* 返 回 值: 无 +*******************************************************************************/ +void set_stack_pointer(void *sp) { + // 在实现中,可以使用 ARM 的 SP 寄存器设置栈指针 + __asm__ volatile("mov sp, %0" : : "r"(sp)); +} + +/******************************************************************************* +* 函 数 名: add_interrupt_handler +* 功能描述: 添加中断处理函数 +* 形 参: irq:中断号,handler:中断句柄,priority:中断优先级 +* 返 回 值: 无 +*******************************************************************************/ +void add_interrupt_handler(int irq, void (*handler)(void), int priority) { + uint32_t *vector_table = (uint32_t*)0x0; + + // 将中断处理函数写入中断向量表中 + vector_table[irq + 16] = (uint32_t)handler; + + // 设置中断优先级 + uint8_t priority_shift = 8 - __NVIC_PRIO_BITS; + uint32_t priority_mask = 0xff << priority_shift; + uint32_t priority_value = (priority << priority_shift) & priority_mask; + uint32_t *priority_reg = (uint32_t*)0xE000E400; + int index = irq / 4; + int offset = irq % 4; + priority_reg[index] &= ~(0xff << (offset * 8)); + priority_reg[index] |= (priority_value << (offset * 8)); + + // 使能中断 + uint32_t *enable_reg = (uint32_t*)0xE000E100; + enable_reg[irq / 32] |= 1 << (irq % 32); +} + + +/******************************************************************************* +* 函 数 名: enter_critical +* 功能描述: 进入临界区 +* 形 参: 无 +* 返 回 值: 无 +*******************************************************************************/ +void enter_critical() { + // 在实现中,可以使用 ARM 的 CPSR 寄存器进入临界区 + __asm__ volatile("cpsid i"); +} + +/******************************************************************************* +* 函 数 名: leave_critical +* 功能描述: 离开临界区 +* 形 参: 无 +* 返 回 值: 无 +*******************************************************************************/ +void leave_critical() { + // 在实现中,可以使用 ARM 的 CPSR 寄存器离开临界区 + __asm__ volatile("cpsie i"); +} + + + +/******************************************************************************* +* 函 数 名: task_exit +* 功能描述: 任务退出函数 +* 形 参: 无 +* 返 回 值: 无 +*******************************************************************************/ +void task_exit() { + // 切换到下一个任务 + switch_to_next_task(); + // 在实现中,可以使用 ARM 的 WFE 指令等待下一个中断 + __asm__ volatile("wfe"); +} + + +/******************************************************************************* +* 函 数 名: task_entry +* 功能描述: 任务入口函数 +* 形 参: 无 +* 返 回 值: 无 +*******************************************************************************/ +void task_entry() { + tcb_t *current_tcb = (tcb_t*)current_task; + current_tcb->state = TASK_RUNNING; + task_init(current_tcb); + while (1) { + switch_to_next_task(); + } +} diff --git a/Ubiquitous/XiZi_AIoT/softkernel/task/task.h b/Ubiquitous/XiZi_AIoT/softkernel/task/task.h new file mode 100644 index 000000000..fdcc38fa0 --- /dev/null +++ b/Ubiquitous/XiZi_AIoT/softkernel/task/task.h @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2020 AIIT XUOS Lab +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ + +/** +* @file: task.h +* @brief: file task.h +* @version: 1.0 +* @author: AIIT XUOS Lab +* @date: 2023/05/18 +* +*/ + +#ifndef __TASK_H__ +#define __TASK_H__ + +#include +#include +#include +#include +#include + +// 任务状态枚举类型 +typedef enum { + TASK_CREATED, // 初始状态 + TASK_READY, // 就绪状态 + TASK_RUNNING, // 运行状态 + TASK_BLOCKED, // 阻塞状态 +} task_state_t; + + +// 任务控制块结构体 +typedef struct tcb { + uint32_t *stack_ptr; // 任务堆栈指针 + uint32_t *stack_bottom; // 任务堆栈底部指针 + uint32_t stack_size; // 任务堆栈大小 + task_state_t state; // 任务状态 + int priority; // 任务优先级 + struct tcb *next; // 指向下一个任务控制块的指针 + struct message_queue *message_queue; // 消息队列 +} tcb_t; + + +// 消息结构体 +typedef struct message { + int type; // 消息类型 + void *data; // 消息数据指针 +} message_t; + + +// 消息队列结构体 +typedef struct message_queue { + message_t *buffer; // 消息缓冲区 + int capacity; // 缓冲区容量 + int count; // 当前缓冲区中的消息数量 + int head; // 队头指针 + int tail; // 队尾指针 + semaphore_t *semaphore; // 信号量,用于实现消息队列的同步机制 +} message_queue_t; + + +// 信号量结构体 +typedef struct semaphore { + int count; // 计数器 + tcb_t *wait_list_head; // 指向等待信号量的任务控制块的指针 + mutex_t mutex; // 互斥锁,用于保护信号量和等待队列的访问 +} semaphore_t; + + +// 互斥锁结构体 +typedef struct mutex { + int lock; // 锁标志 +} mutex_t; + + +// 上下文结构体 +typedef struct { + uint32_t cpsr; // 控制寄存器 + uint32_t pc; // 程序计数器 + uint32_t r0; // 寄存器 R0 + uint32_t r1; // 寄存器 R1 + uint32_t r2; // 寄存器 R2 + uint32_t r3; // 寄存器 R3 + uint32_t r4; // 寄存器 R4 + uint32_t r5; // 寄存器 R5 + uint32_t r6; // 寄存器 R6 + uint32_t r7; // 寄存器 R7 + uint32_t r8; // 寄存器 R8 + uint32_t r9; // 寄存器 R9 + uint32_t r10; // 寄存器 R10 + uint32_t r11; // 寄存器 R11 + uint32_t r12; // 寄存器 R12 + uint32_t sp; // 栈指针 + uint32_t lr; // 链接寄存器 +} context_t; + +void tcb_init(tcb_t *tcb, int priority, int stack_size); +void tcb_destroy(tcb_t *tcb); +tcb_t *get_current_task(void); +tcb_t *get_local_run_queue_head(int cpu_id); +void add_to_global_run_queue(tcb_t *tcb); +tcb_t *take_from_global_run_queue(void); +void add_to_local_run_queue(tcb_t *tcb, int cpu_id); +tcb_t *take_from_local_run_queue(int cpu_id); +void move_current_task_to_global_run_queue(void); +void switch_to_next_task(void); +void task_init(tcb_t *tcb); +tcb_t *create_task(int priority, int stack_size); +void destroy_task(tcb_t *tcb); +void send_message(tcb_t *dest_tcb, int type, void *data); +void receive_message(int type, void *data); +message_queue_t *message_queue_create(int capacity); +void message_queue_destroy(message_queue_t *mq); +int message_queue_push(message_queue_t *mq, message_t *message); +int message_queue_pop(message_queue_t *mq, message_t *message); +int message_queue_push(message_queue_t *mq, message_t *message); +void context_init(context_t *context, void (*entry)(void), void *stack_ptr); +void wait_for_interrupt(void); +int get_cpu_id(void); +void *get_stack_pointer(void); +void set_stack_pointer(void *sp); +void add_interrupt_handler(int irq, void (*handler)(void), int priority); +void enter_critical(void); +void leave_critical(void); +void task_exit(void); +void task_entry(void); +#endif diff --git a/Ubiquitous/XiZi_IIoT/arch/risc-v/gap8/gap8.h b/Ubiquitous/XiZi_IIoT/arch/risc-v/gap8/gap8.h index 78bdaed19..8f1d72598 100755 --- a/Ubiquitous/XiZi_IIoT/arch/risc-v/gap8/gap8.h +++ b/Ubiquitous/XiZi_IIoT/arch/risc-v/gap8/gap8.h @@ -37,7 +37,7 @@ /** * @file gap8.h -* @brief support gap8 chip fetures +* @brief support gap8 chip features * @version 1.0 * @author AIIT XUOS Lab * @date 2021-09-02 @@ -45,7 +45,7 @@ /************************************************* File name: gap8.h -Description: support gap8 chip fetures +Description: support gap8 chip features Others: take nuttx/arch/risc-v/src/gap8/gap8.h for references https://github.com/apache/incubator-nuttx.git History: diff --git a/Ubiquitous/XiZi_IIoT/board/cortex-m0-emulator/.defconfig b/Ubiquitous/XiZi_IIoT/board/cortex-m0-emulator/.defconfig index ed725c23c..90e7fce5f 100644 --- a/Ubiquitous/XiZi_IIoT/board/cortex-m0-emulator/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/cortex-m0-emulator/.defconfig @@ -179,9 +179,9 @@ CONFIG_LIB_NEWLIB=y # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig index 7f43c0a50..67bf8db13 100755 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig @@ -11,7 +11,7 @@ menuconfig BSP_USING_SPI bool "Using SPI device" default n select RESOURCES_SPI - select BSP_USING_DMA + select BSP_USING_DMA if BSP_USING_SPI source "$BSP_DIR/third_party_driver/spi/Kconfig" endif @@ -117,6 +117,7 @@ menuconfig BSP_USING_WIZCHIP bool "Using w5500 as network device" default n select RESOURCES_WIZCHIP + select BSP_USING_SPI if BSP_USING_WIZCHIP source "$BSP_DIR/third_party_driver/ethernet/Kconfig" endif diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/Kconfig b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/Kconfig index baf59367c..b374d8fb0 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/Kconfig @@ -1,15 +1,17 @@ # Kconfig file config BSP_USING_W5500 -bool "Using w5500 " -default y + bool "Using w5500" + default y -# if BSP_USING_W5500 - config BSP_WIZ_RST_PIN - int - default 13 +config BSP_WIZ_RST_PIN + int + default 13 - config BSP_WIZ_INT_PIN - int - default 14 -# endif \ No newline at end of file +config BSP_WIZ_INT_PIN + int + default 14 + +config BSP_WIZ_USE_IPERF + bool "Using iperf" + default y diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/wiz_iperf.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/wiz_iperf.c index 09c154347..3b1647c0f 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/wiz_iperf.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/ethernet/wiz_iperf.c @@ -2,6 +2,8 @@ #include "w5500.h" #include "connect_w5500.h" +#ifdef BSP_WIZ_USE_IPERF + #define IPERF_PORT 5001 #define IPERF_BUFSZ (4 * 1024) @@ -459,4 +461,5 @@ __usage: } SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), iperf, iperf, - iperf throughput test); \ No newline at end of file + iperf throughput test); +#endif diff --git a/Ubiquitous/XiZi_IIoT/board/gd32vf103-rvstar/.defconfig b/Ubiquitous/XiZi_IIoT/board/gd32vf103-rvstar/.defconfig index 9d6d6b972..165bf6a29 100644 --- a/Ubiquitous/XiZi_IIoT/board/gd32vf103-rvstar/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/gd32vf103-rvstar/.defconfig @@ -181,9 +181,9 @@ CONFIG_FS_VFS=n # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig index 761c3df3d..aff17c060 100644 --- a/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/hc32f4a0/.defconfig @@ -191,9 +191,9 @@ CONFIG_FS_VFS_FATFS=y # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/Kconfig b/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/Kconfig index 5753d8854..7e37be3cd 100755 --- a/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/Kconfig @@ -6,3 +6,6 @@ config BOARD_NETWORK_USE_1G_ENET_PORT bool "Enable 1000M Enet Port" default y +config LWIP_REASSEMBLY_FRAG + bool + default y \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/enet_ethernetif.c index 641c66436..b7bf34f03 100644 --- a/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/ethernet/enet_ethernetif.c @@ -211,9 +211,10 @@ void ethernetif_phy_init(struct ethernetif *ethernetif, * * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input(struct netif *netif) +void ethernetif_input(void *netif_arg) { struct pbuf *p; + struct netif *netif = (struct netif *)netif_arg; LWIP_ASSERT("netif != NULL", (netif != NULL)); diff --git a/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/include/enet_ethernetif.h b/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/include/enet_ethernetif.h index ca5ade06b..6c552e28c 100644 --- a/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/include/enet_ethernetif.h +++ b/Ubiquitous/XiZi_IIoT/board/imxrt1176-sbc/third_party_driver/include/enet_ethernetif.h @@ -159,7 +159,7 @@ err_t ethernetif1_init(struct netif *netif); * * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input( struct netif *netif); +void ethernetif_input( void *netif_arg); int ETH_BSP_Config(void); void *ethernetif_config_enet_set(uint8_t enet_port); diff --git a/Ubiquitous/XiZi_IIoT/board/ok1052-c/.defconfig b/Ubiquitous/XiZi_IIoT/board/ok1052-c/.defconfig index 555b84bcf..b46ec4679 100644 --- a/Ubiquitous/XiZi_IIoT/board/ok1052-c/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/ok1052-c/.defconfig @@ -223,9 +223,9 @@ CONFIG_FS_VFS_FATFS=y # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c index 764637188..9b8ca475a 100755 --- a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif.c @@ -57,16 +57,12 @@ #include "netif/ppp/pppoe.h" #include "lwip/igmp.h" #include "lwip/mld6.h" +#include "lwip/sys.h" -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) -//#include "FreeRTOS.h" -//#include "event_groups.h" -#endif -#include #include "netif/ethernet.h" #include "enet_ethernetif.h" #include "enet_ethernetif_priv.h" - +#include #include "fsl_enet.h" #include "fsl_phy.h" #include "fsl_gpio.h" @@ -91,6 +87,7 @@ void enet_delay(uint32 ms) void Time_Update_LwIP(void) { } + ethernetif_config_t enet_cfg = { .phyAddress = BOARD_ENET0_PHY_ADDRESS, .clockName = kCLOCK_CoreSysClk, @@ -109,7 +106,6 @@ void ethernetif_clk_init(void) { const clock_enet_pll_config_t config = {.enableClkOutput = true, .enableClkOutput25M = false, .loopDivider = 1}; CLOCK_InitEnetPll(&config); - SysTick_Config(SystemCoreClock / TICK_PER_SECOND); } void ethernetif_gpio_init(void) @@ -119,13 +115,15 @@ void ethernetif_gpio_init(void) IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, true); GPIO_PinInit(GPIO1, 3, &gpio_config); + GPIO_PinInit(GPIO1, 10, &gpio_config); /* pull up the ENET_INT before RESET. */ + GPIO_WritePinOutput(GPIO1, 10, 1); GPIO_WritePinOutput(GPIO1, 3, 0); enet_delay(30); GPIO_WritePinOutput(GPIO1, 3, 1); } -void ETH_BSP_Config(void) +int ETH_BSP_Config(void) { static int flag = 0; if(flag == 0) @@ -134,6 +132,7 @@ void ETH_BSP_Config(void) ethernetif_gpio_init(); flag = 1; } + return 0; } void ethernetif_phy_init(struct ethernetif *ethernetif, @@ -198,23 +197,27 @@ void ethernetif_phy_init(struct ethernetif *ethernetif, * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input(struct netif *netif) +void ethernetif_input(void *netif_arg) { struct pbuf *p; + struct netif *netif = (struct netif *)netif_arg; err_t ret = 0; LWIP_ASSERT("netif != NULL", (netif != NULL)); - /* move received packet into a new pbuf */ - while ((p = ethernetif_linkinput(netif)) != NULL) - { - /* pass all packets to ethernet_input, which decides what packets it supports */ - if ((ret = netif->input(p, netif)) != ERR_OK) + while (1) { + sys_arch_sem_wait(get_eth_recv_sem(), WAITING_FOREVER); + /* move received packet into a new pbuf */ + while ((p = ethernetif_linkinput(netif)) != NULL) { - LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); - lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); - pbuf_free(p); - p = NULL; + /* pass all packets to ethernet_input, which decides what packets it supports */ + if ((ret = netif->input(p, netif)) != ERR_OK) + { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); + pbuf_free(p); + p = NULL; + } } } } diff --git a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c index 10364a0cb..ae235661c 100755 --- a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c +++ b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/ethernet/enet_ethernetif_kinetis.c @@ -58,22 +58,9 @@ #include "netif/ppp/pppoe.h" #include "lwip/igmp.h" #include "lwip/mld6.h" +#include "lwip/sys.h" -#ifdef FSL_RTOS_XIUOS -#define USE_RTOS 1 -#define FSL_RTOS_FREE_RTOS -#endif - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) - -#ifdef FSL_RTOS_XIUOS -#include "xs_sem.h" - -#else -#include "FreeRTOS.h" -#include "event_groups.h" -#include "list.h" -#endif +#include typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL @@ -91,27 +78,6 @@ typedef unsigned long UBaseType_t; #define pdPASS ( pdTRUE ) #define pdFAIL ( pdFALSE ) -#ifndef FSL_RTOS_XIUOS -typedef struct EventGroupDef_t -{ - EventBits_t uxEventBits; - List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */ - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxEventGroupNumber; - #endif - - #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */ - #endif -} EventGroup_t; - -struct EventGroupDef_t; -typedef struct EventGroupDef_t * EventGroupHandle_t; -#endif - -#endif - #include "enet_ethernetif.h" #include "enet_ethernetif_priv.h" @@ -130,19 +96,13 @@ typedef struct EventGroupDef_t * EventGroupHandle_t; struct ethernetif { ENET_Type *base; -#if (defined(FSL_FEATURE_SOC_ENET_COUNT) && (FSL_FEATURE_SOC_ENET_COUNT > 0)) || \ - (USE_RTOS && defined(FSL_RTOS_FREE_RTOS)) +#if (defined(FSL_FEATURE_SOC_ENET_COUNT) && (FSL_FEATURE_SOC_ENET_COUNT > 0)) enet_handle_t handle; #endif -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) -#ifdef FSL_RTOS_XIUOS int enetSemaphore; -#else - EventGroupHandle_t enetTransmitAccessEvent; -#endif EventBits_t txFlag; -#endif + enet_rx_bd_struct_t *RxBuffDescrip; enet_tx_bd_struct_t *TxBuffDescrip; rx_buffer_t *RxDataBuff; @@ -153,14 +113,6 @@ struct ethernetif /******************************************************************************* * Code ******************************************************************************/ -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) - -int32 lwip_obtain_semaphore(struct netif *netif) -{ - struct ethernetif *ethernetif = netif->state; - return (KSemaphoreObtain(ethernetif->enetSemaphore, WAITING_FOREVER) == EOK); -} - #if FSL_FEATURE_ENET_QUEUE > 1 static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, uint32_t ringId, enet_event_t event, void *param) #else @@ -169,44 +121,19 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event { struct netif *netif = (struct netif *)param; struct ethernetif *ethernetif = netif->state; - BaseType_t xResult; switch (event) { case kENET_RxEvent: - ethernetif_input(netif); + ENET_DisableInterrupts(ethernetif->base, kENET_RxFrameInterrupt); + sys_sem_signal(get_eth_recv_sem()); break; case kENET_TxEvent: -#ifndef FSL_RTOS_XIUOS - { - portBASE_TYPE taskToWake = pdFALSE; - -#ifdef __CA7_REV - if (SystemGetIRQNestingLevel()) -#else - if (__get_IPSR()) -#endif - { - xResult = xEventGroupSetBitsFromISR(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, &taskToWake); - if ((pdPASS == xResult) && (pdTRUE == taskToWake)) - { - portYIELD_FROM_ISR(taskToWake); - } - } - else - { - xEventGroupSetBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag); - } - } -#endif - break; + break; default: break; } - - KSemaphoreAbandon(ethernetif->enetSemaphore); } -#endif #if LWIP_IPV4 && LWIP_IGMP err_t ethernetif_igmp_mac_filter(struct netif *netif, const ip4_addr_t *group, @@ -312,11 +239,9 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, ENET_GetDefaultConfig(&config); config.ringNum = ENET_RING_NUM; - config.macSpecialConfig |= kENET_ControlPromiscuousEnable; ethernetif_phy_init(ethernetif, ethernetifConfig, &config); -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) uint32_t instance; static ENET_Type *const enetBases[] = ENET_BASE_PTRS; static const IRQn_Type enetTxIrqId[] = ENET_Transmit_IRQS; @@ -328,51 +253,37 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ /* Create the Event for transmit busy release trigger. */ -#ifdef FSL_RTOS_XIUOS if(ethernetif->enetSemaphore < 0) { ethernetif->enetSemaphore = KSemaphoreCreate(0); } -#else - ethernetif->enetTransmitAccessEvent = xEventGroupCreate(); -#endif ethernetif->txFlag = 0x1; + sys_sem_new(get_eth_recv_sem(), 0); config.interrupt |= kENET_RxFrameInterrupt | kENET_TxFrameInterrupt | kENET_TxBufferInterrupt; for (instance = 0; instance < ARRAY_SIZE(enetBases); instance++) { if (enetBases[instance] == ethernetif->base) { -#ifdef __CA7_REV - GIC_SetPriority(enetRxIrqId[instance], ENET_PRIORITY); - GIC_SetPriority(enetTxIrqId[instance], ENET_PRIORITY); -#if defined(ENET_ENHANCEDBUFFERDESCRIPTOR_MODE) && ENET_ENHANCEDBUFFERDESCRIPTOR_MODE - GIC_SetPriority(enetTsIrqId[instance], ENET_1588_PRIORITY); -#endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ -#else NVIC_SetPriority(enetRxIrqId[instance], ENET_PRIORITY); NVIC_SetPriority(enetTxIrqId[instance], ENET_PRIORITY); #if defined(ENET_ENHANCEDBUFFERDESCRIPTOR_MODE) && ENET_ENHANCEDBUFFERDESCRIPTOR_MODE NVIC_SetPriority(enetTsIrqId[instance], ENET_1588_PRIORITY); #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ -#endif /* __CA7_REV */ break; } } LWIP_ASSERT("Input Ethernet base error!", (instance != ARRAY_SIZE(enetBases))); -#endif /* USE_RTOS */ + + config.txAccelerConfig = kENET_TxAccelIpCheckEnabled | kENET_TxAccelProtoCheckEnabled; /* Initialize the ENET module.*/ ENET_Init(ethernetif->base, ðernetif->handle, &config, &buffCfg[0], netif->hwaddr, sysClock); - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) ENET_SetCallback(ðernetif->handle, ethernet_callback, netif); -#endif ENET_ActiveRead(ethernetif->base); -// low_level_init(); } ENET_Type **ethernetif_enet_ptr(struct ethernetif *ethernetif) @@ -395,45 +306,17 @@ static unsigned char *enet_get_tx_buffer(struct ethernetif *ethernetif) */ static err_t enet_send_frame(struct ethernetif *ethernetif, unsigned char *data, const uint32_t length) { -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) + uint32_t counter; + + for (counter = ENET_TIMEOUT; counter != 0U; counter--) { - status_t result; - - lw_print("lw: [%s] len %d\n", __func__, length); - - do + if (ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length) != kStatus_ENET_TxFrameBusy) { - result = ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length); - - if (result == kStatus_ENET_TxFrameBusy) - { -#ifdef FSL_RTOS_XIUOS - KSemaphoreObtain(ethernetif->enetSemaphore, portMAX_DELAY); -#else - xEventGroupWaitBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, pdTRUE, (BaseType_t) false, - portMAX_DELAY); -#endif - } - - } while (result == kStatus_ENET_TxFrameBusy); - - return ERR_OK; - } -#else - { - uint32_t counter; - - for (counter = ENET_TIMEOUT; counter != 0U; counter--) - { - if (ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length) != kStatus_ENET_TxFrameBusy) - { - return ERR_OK; - } + return ERR_OK; } - - return ERR_TIMEOUT; } -#endif + + return ERR_TIMEOUT; } struct pbuf *ethernetif_linkinput(struct netif *netif) @@ -538,6 +421,7 @@ struct pbuf *ethernetif_linkinput(struct netif *netif) } } + ENET_EnableInterrupts(ethernetif->base, kENET_RxFrameInterrupt); return p; } diff --git a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/include/enet_ethernetif.h b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/include/enet_ethernetif.h index 1a8abf2ab..7b8c20c95 100755 --- a/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/include/enet_ethernetif.h +++ b/Ubiquitous/XiZi_IIoT/board/ok1052-c/third_party_driver/include/enet_ethernetif.h @@ -179,7 +179,7 @@ err_t ethernetif1_init(struct netif *netif); * * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input( struct netif *netif); +void ethernetif_input( void *netif_arg); void ETH_BSP_Config(void); void *ethernetif_config_enet_set(uint8_t enet_port); diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/.defconfig b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/.defconfig index ad4f5b2b4..fd991b36b 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/.defconfig @@ -223,9 +223,9 @@ CONFIG_FS_VFS_FATFS=y # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/pin_mux.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/pin_mux.c index 0aa7d67f6..f39545239 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/pin_mux.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/pin_mux.c @@ -47,6 +47,652 @@ void BOARD_InitBootPins(void) { BOARD_InitPins(); } +void SDHCPinmuxConfig(void) +{ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_14_USDHC1_VSELECT, /* GPIO_B1_14 is configured as USDHC1_VSELECT */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B0_00_USDHC1_CMD, /* GPIO_SD_B0_00 is configured as USDHC1_CMD */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B0_01_USDHC1_CLK, /* GPIO_SD_B0_01 is configured as USDHC1_CLK */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B0_02_USDHC1_DATA0, /* GPIO_SD_B0_02 is configured as USDHC1_DATA0 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B0_03_USDHC1_DATA1, /* GPIO_SD_B0_03 is configured as USDHC1_DATA1 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B0_04_USDHC1_DATA2, /* GPIO_SD_B0_04 is configured as USDHC1_DATA2 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B0_05_USDHC1_DATA3, /* GPIO_SD_B0_05 is configured as USDHC1_DATA3 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_14_USDHC1_VSELECT, /* GPIO_B1_14 PAD functional properties : */ + 0x0170A1u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/4 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 47K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B0_00_USDHC1_CMD, /* GPIO_SD_B0_00 PAD functional properties : */ + 0x017089u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V) + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 47K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B0_01_USDHC1_CLK, /* GPIO_SD_B0_01 PAD functional properties : */ + 0x014089u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V) + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Disabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 47K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B0_02_USDHC1_DATA0, /* GPIO_SD_B0_02 PAD functional properties : */ + 0x017089u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V) + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 47K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B0_03_USDHC1_DATA1, /* GPIO_SD_B0_03 PAD functional properties : */ + 0x017089u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V) + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 47K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B0_04_USDHC1_DATA2, /* GPIO_SD_B0_04 PAD functional properties : */ + 0x017089u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V) + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 47K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B0_05_USDHC1_DATA3, /* GPIO_SD_B0_05 PAD functional properties : */ + 0x017089u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0(150 Ohm @ 3.3V, 260 Ohm@1.8V) + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 47K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ +} + +void SemcPinmuxConfig(void) +{ + + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_00_SEMC_DATA00, /* GPIO_EMC_00 is configured as SEMC_DATA00 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_01_SEMC_DATA01, /* GPIO_EMC_01 is configured as SEMC_DATA01 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_02_SEMC_DATA02, /* GPIO_EMC_02 is configured as SEMC_DATA02 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_03_SEMC_DATA03, /* GPIO_EMC_03 is configured as SEMC_DATA03 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_04_SEMC_DATA04, /* GPIO_EMC_04 is configured as SEMC_DATA04 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_05_SEMC_DATA05, /* GPIO_EMC_05 is configured as SEMC_DATA05 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_06_SEMC_DATA06, /* GPIO_EMC_06 is configured as SEMC_DATA06 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_07_SEMC_DATA07, /* GPIO_EMC_07 is configured as SEMC_DATA07 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_08_SEMC_DM00, /* GPIO_EMC_08 is configured as SEMC_DM00 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_09_SEMC_ADDR00, /* GPIO_EMC_09 is configured as SEMC_ADDR00 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_10_SEMC_ADDR01, /* GPIO_EMC_10 is configured as SEMC_ADDR01 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_11_SEMC_ADDR02, /* GPIO_EMC_11 is configured as SEMC_ADDR02 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_12_SEMC_ADDR03, /* GPIO_EMC_12 is configured as SEMC_ADDR03 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_13_SEMC_ADDR04, /* GPIO_EMC_13 is configured as SEMC_ADDR04 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_14_SEMC_ADDR05, /* GPIO_EMC_14 is configured as SEMC_ADDR05 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_15_SEMC_ADDR06, /* GPIO_EMC_15 is configured as SEMC_ADDR06 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_16_SEMC_ADDR07, /* GPIO_EMC_16 is configured as SEMC_ADDR07 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_17_SEMC_ADDR08, /* GPIO_EMC_17 is configured as SEMC_ADDR08 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_18_SEMC_ADDR09, /* GPIO_EMC_18 is configured as SEMC_ADDR09 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_19_SEMC_ADDR11, /* GPIO_EMC_19 is configured as SEMC_ADDR11 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_20_SEMC_ADDR12, /* GPIO_EMC_20 is configured as SEMC_ADDR12 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_21_SEMC_BA0, /* GPIO_EMC_21 is configured as SEMC_BA0 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_22_SEMC_BA1, /* GPIO_EMC_22 is configured as SEMC_BA1 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_23_SEMC_ADDR10, /* GPIO_EMC_23 is configured as SEMC_ADDR10 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_24_SEMC_CAS, /* GPIO_EMC_24 is configured as SEMC_CAS */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_25_SEMC_RAS, /* GPIO_EMC_25 is configured as SEMC_RAS */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_26_SEMC_CLK, /* GPIO_EMC_26 is configured as SEMC_CLK */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_27_SEMC_CKE, /* GPIO_EMC_27 is configured as SEMC_CKE */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_28_SEMC_WE, /* GPIO_EMC_28 is configured as SEMC_WE */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_29_SEMC_CS0, /* GPIO_EMC_29 is configured as SEMC_CS0 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_30_SEMC_DATA08, /* GPIO_EMC_30 is configured as SEMC_DATA08 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_31_SEMC_DATA09, /* GPIO_EMC_31 is configured as SEMC_DATA09 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_32_SEMC_DATA10, /* GPIO_EMC_32 is configured as SEMC_DATA10 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_33_SEMC_DATA11, /* GPIO_EMC_33 is configured as SEMC_DATA11 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_34_SEMC_DATA12, /* GPIO_EMC_34 is configured as SEMC_DATA12 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_35_SEMC_DATA13, /* GPIO_EMC_35 is configured as SEMC_DATA13 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_36_SEMC_DATA14, /* GPIO_EMC_36 is configured as SEMC_DATA14 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_37_SEMC_DATA15, /* GPIO_EMC_37 is configured as SEMC_DATA15 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_38_SEMC_DM01, /* GPIO_EMC_38 is configured as SEMC_DM01 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_39_SEMC_DQS, /* GPIO_EMC_39 is configured as SEMC_DQS */ + 1U); /* Software Input On Field: Force input path of pad GPIO_EMC_39 */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_40_SEMC_RDY, /* GPIO_EMC_40 is configured as SEMC_RDY */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_41_SEMC_CSX00, /* GPIO_EMC_41 is configured as SEMC_CSX00 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_00_SEMC_DATA00, /* GPIO_EMC_00 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_01_SEMC_DATA01, /* GPIO_EMC_01 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_02_SEMC_DATA02, /* GPIO_EMC_02 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_03_SEMC_DATA03, /* GPIO_EMC_03 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_04_SEMC_DATA04, /* GPIO_EMC_04 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_05_SEMC_DATA05, /* GPIO_EMC_05 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_06_SEMC_DATA06, /* GPIO_EMC_06 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_07_SEMC_DATA07, /* GPIO_EMC_07 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_08_SEMC_DM00, /* GPIO_EMC_08 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_09_SEMC_ADDR00, /* GPIO_EMC_09 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_10_SEMC_ADDR01, /* GPIO_EMC_10 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_11_SEMC_ADDR02, /* GPIO_EMC_11 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_12_SEMC_ADDR03, /* GPIO_EMC_12 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_13_SEMC_ADDR04, /* GPIO_EMC_13 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_14_SEMC_ADDR05, /* GPIO_EMC_14 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_15_SEMC_ADDR06, /* GPIO_EMC_15 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_16_SEMC_ADDR07, /* GPIO_EMC_16 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_17_SEMC_ADDR08, /* GPIO_EMC_17 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_18_SEMC_ADDR09, /* GPIO_EMC_18 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_19_SEMC_ADDR11, /* GPIO_EMC_19 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_20_SEMC_ADDR12, /* GPIO_EMC_20 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_21_SEMC_BA0, /* GPIO_EMC_21 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_22_SEMC_BA1, /* GPIO_EMC_22 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_23_SEMC_ADDR10, /* GPIO_EMC_23 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_24_SEMC_CAS, /* GPIO_EMC_24 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_25_SEMC_RAS, /* GPIO_EMC_25 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_26_SEMC_CLK, /* GPIO_EMC_26 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_27_SEMC_CKE, /* GPIO_EMC_27 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_28_SEMC_WE, /* GPIO_EMC_28 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_29_SEMC_CS0, /* GPIO_EMC_29 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_30_SEMC_DATA08, /* GPIO_EMC_30 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_31_SEMC_DATA09, /* GPIO_EMC_31 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_32_SEMC_DATA10, /* GPIO_EMC_32 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_33_SEMC_DATA11, /* GPIO_EMC_33 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_34_SEMC_DATA12, /* GPIO_EMC_34 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_35_SEMC_DATA13, /* GPIO_EMC_35 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_36_SEMC_DATA14, /* GPIO_EMC_36 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_37_SEMC_DATA15, /* GPIO_EMC_37 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_38_SEMC_DM01, /* GPIO_EMC_38 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_39_SEMC_DQS, /* GPIO_EMC_39 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_40_SEMC_RDY, /* GPIO_EMC_40 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_41_SEMC_CSX00, /* GPIO_EMC_41 PAD functional properties : */ + 0x0110F9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/7 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Enabled */ +} /* * TEXT BELOW IS USED AS SETTING FOR TOOLS ************************************* BOARD_InitPins: @@ -56,51 +702,313 @@ BOARD_InitPins: pull_keeper_select: Keeper, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0_6, slew_rate: Slow} - {pin_num: K14, peripheral: LPUART1, signal: TX, pin_signal: GPIO_AD_B0_12, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Down_100K_Ohm, pull_keeper_select: Keeper, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0_6, slew_rate: Slow} - - {pin_num: F14, peripheral: GPIO1, signal: 'gpio_io, 09', pin_signal: GPIO_AD_B0_09, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Down_100K_Ohm, - pull_keeper_select: Keeper, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0_6, slew_rate: Slow} + - {pin_num: A7, peripheral: ENET, signal: enet_mdc, pin_signal: GPIO_EMC_40, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: C7, peripheral: ENET, signal: enet_mdio, pin_signal: GPIO_EMC_41, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Enable, speed: MHZ_50, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: B13, peripheral: ENET, signal: enet_ref_clk, pin_signal: GPIO_B1_10, software_input_on: Enable, hysteresis_enable: Disable, pull_up_down_config: Pull_Down_100K_Ohm, + pull_keeper_select: Keeper, pull_keeper_enable: Disable, open_drain: Disable, speed: MHZ_50, drive_strength: R0_6, slew_rate: Fast} + - {pin_num: E12, peripheral: ENET, signal: 'enet_rx_data, 0', pin_signal: GPIO_B1_04, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: D12, peripheral: ENET, signal: 'enet_rx_data, 1', pin_signal: GPIO_B1_05, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: C12, peripheral: ENET, signal: enet_rx_en, pin_signal: GPIO_B1_06, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: C13, peripheral: ENET, signal: enet_rx_er, pin_signal: GPIO_B1_11, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: B12, peripheral: ENET, signal: 'enet_tx_data, 0', pin_signal: GPIO_B1_07, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: A12, peripheral: ENET, signal: 'enet_tx_data, 1', pin_signal: GPIO_B1_08, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: A13, peripheral: ENET, signal: enet_tx_en, pin_signal: GPIO_B1_09, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_200, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: F14, peripheral: GPIO1, signal: 'gpio_io, 09', pin_signal: GPIO_AD_B0_09, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: G13, peripheral: GPIO1, signal: 'gpio_io, 10', pin_signal: GPIO_AD_B0_10, software_input_on: Disable, hysteresis_enable: Disable, pull_up_down_config: Pull_Up_100K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0_5, slew_rate: Fast} + - {pin_num: J3, peripheral: USDHC1, signal: usdhc_clk, pin_signal: GPIO_SD_B0_01, software_input_on: Disable, hysteresis_enable: Enable, pull_up_down_config: Pull_Up_47K_Ohm, + pull_keeper_select: Keeper, pull_keeper_enable: Disable, open_drain: Disable, speed: MHZ_100, drive_strength: R0, slew_rate: Fast} + - {pin_num: J4, peripheral: USDHC1, signal: usdhc_cmd, pin_signal: GPIO_SD_B0_00, software_input_on: Disable, hysteresis_enable: Enable, pull_up_down_config: Pull_Up_47K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0, slew_rate: Fast} + - {pin_num: J1, peripheral: USDHC1, signal: 'usdhc_data, 0', pin_signal: GPIO_SD_B0_02, software_input_on: Disable, hysteresis_enable: Enable, pull_up_down_config: Pull_Up_47K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0, slew_rate: Fast} + - {pin_num: K1, peripheral: USDHC1, signal: 'usdhc_data, 1', pin_signal: GPIO_SD_B0_03, software_input_on: Disable, hysteresis_enable: Enable, pull_up_down_config: Pull_Up_47K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0, slew_rate: Fast} + - {pin_num: H2, peripheral: USDHC1, signal: 'usdhc_data, 2', pin_signal: GPIO_SD_B0_04, software_input_on: Disable, hysteresis_enable: Enable, pull_up_down_config: Pull_Up_47K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0, slew_rate: Fast} + - {pin_num: J2, peripheral: USDHC1, signal: 'usdhc_data, 3', pin_signal: GPIO_SD_B0_05, software_input_on: Disable, hysteresis_enable: Enable, pull_up_down_config: Pull_Up_47K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0, slew_rate: Fast} + - {pin_num: C14, peripheral: USDHC1, signal: usdhc_vselect, pin_signal: GPIO_B1_14, software_input_on: Disable, hysteresis_enable: Enable, pull_up_down_config: Pull_Up_47K_Ohm, + pull_keeper_select: Pull, pull_keeper_enable: Enable, open_drain: Disable, speed: MHZ_100, drive_strength: R0_4, slew_rate: Fast} * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS *********** */ - -/* FUNCTION ************************************************************************************************************ - * - * Function Name : BOARD_InitPins - * Description : Configures pin routing and optionally pin electrical features. - * - * END ****************************************************************************************************************/ -void BOARD_InitPins(void) { - CLOCK_EnableClock(kCLOCK_Iomuxc); /* iomuxc clock (iomuxc_clk_enable): 0x03u */ - - IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 is configured as GPIO1_IO09 */ +void Lcd_InitPins(void) +{ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_00_LCD_CLK, /* GPIO_B0_00 is configured as LCD_CLK */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 is configured as LPUART1_TX */ + IOMUXC_GPIO_B0_01_LCD_ENABLE, /* GPIO_B0_01 is configured as LCD_ENABLE */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( - IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 is configured as LPUART1_RX */ + IOMUXC_GPIO_B0_02_LCD_HSYNC, /* GPIO_B0_02 is configured as LCD_HSYNC */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_03_LCD_VSYNC, /* GPIO_B0_03 is configured as LCD_VSYNC */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_04_LCD_DATA00, /* GPIO_B0_04 is configured as LCD_DATA00 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_05_LCD_DATA01, /* GPIO_B0_05 is configured as LCD_DATA01 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_06_LCD_DATA02, /* GPIO_B0_06 is configured as LCD_DATA02 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_07_LCD_DATA03, /* GPIO_B0_07 is configured as LCD_DATA03 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_08_LCD_DATA04, /* GPIO_B0_08 is configured as LCD_DATA04 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_09_LCD_DATA05, /* GPIO_B0_09 is configured as LCD_DATA05 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_10_LCD_DATA06, /* GPIO_B0_10 is configured as LCD_DATA06 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_11_LCD_DATA07, /* GPIO_B0_11 is configured as LCD_DATA07 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_12_LCD_DATA08, /* GPIO_B0_12 is configured as LCD_DATA08 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_13_LCD_DATA09, /* GPIO_B0_13 is configured as LCD_DATA09 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_14_LCD_DATA10, /* GPIO_B0_14 is configured as LCD_DATA10 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B0_15_LCD_DATA11, /* GPIO_B0_15 is configured as LCD_DATA11 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_00_LCD_DATA12, /* GPIO_B1_00 is configured as LCD_DATA12 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_01_LCD_DATA13, /* GPIO_B1_01 is configured as LCD_DATA13 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_02_LCD_DATA14, /* GPIO_B1_02 is configured as LCD_DATA14 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_03_LCD_DATA15, /* GPIO_B1_03 is configured as LCD_DATA15 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_15_GPIO2_IO31, /* GPIO_B1_15 is configured as GPIO2_IO31 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinConfig( - IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 PAD functional properties : */ - 0x10B0u); /* Slew Rate Field: Slow Slew Rate + IOMUXC_GPIO_B0_00_LCD_CLK, /* GPIO_B0_00 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate Drive Strength Field: R0/6 Speed Field: medium(100MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled - Pull / Keep Select Field: Keeper - Pull Up / Down Config. Field: 100K Ohm Pull Down - Hyst. Enable Field: Hysteresis Disabled */ + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ IOMUXC_SetPinConfig( - IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 PAD functional properties : */ - 0x10B0u); /* Slew Rate Field: Slow Slew Rate + IOMUXC_GPIO_B0_01_LCD_ENABLE, /* GPIO_B0_01 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate Drive Strength Field: R0/6 Speed Field: medium(100MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled - Pull / Keep Select Field: Keeper - Pull Up / Down Config. Field: 100K Ohm Pull Down - Hyst. Enable Field: Hysteresis Disabled */ + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ IOMUXC_SetPinConfig( - IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 PAD functional properties : */ + IOMUXC_GPIO_B0_02_LCD_HSYNC, /* GPIO_B0_02 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_03_LCD_VSYNC, /* GPIO_B0_03 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_04_LCD_DATA00, /* GPIO_B0_04 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_05_LCD_DATA01, /* GPIO_B0_05 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_06_LCD_DATA02, /* GPIO_B0_06 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_07_LCD_DATA03, /* GPIO_B0_07 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_08_LCD_DATA04, /* GPIO_B0_08 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_09_LCD_DATA05, /* GPIO_B0_09 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_10_LCD_DATA06, /* GPIO_B0_10 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_11_LCD_DATA07, /* GPIO_B0_11 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_12_LCD_DATA08, /* GPIO_B0_12 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_13_LCD_DATA09, /* GPIO_B0_13 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_14_LCD_DATA10, /* GPIO_B0_14 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B0_15_LCD_DATA11, /* GPIO_B0_15 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_00_LCD_DATA12, /* GPIO_B1_00 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_01_LCD_DATA13, /* GPIO_B1_01 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_02_LCD_DATA14, /* GPIO_B1_02 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_03_LCD_DATA15, /* GPIO_B1_03 PAD functional properties : */ + 0x01B0B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Enabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_15_GPIO2_IO31, /* GPIO_B1_15 PAD functional properties : */ 0x10B0u); /* Slew Rate Field: Slow Slew Rate Drive Strength Field: R0/6 Speed Field: medium(100MHz) @@ -111,6 +1019,334 @@ void BOARD_InitPins(void) { Hyst. Enable Field: Hysteresis Disabled */ } +void BOARD_InitI2C1Pins(void) { + CLOCK_EnableClock(kCLOCK_Iomuxc); /* iomuxc clock (iomuxc_clk_enable): 0x03u */ + + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_00_LPI2C1_SCL, /* GPIO_AD_B1_00 is configured as LPI2C1_SCL */ + 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_00 */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_01_LPI2C1_SDA, /* GPIO_AD_B1_01 is configured as LPI2C1_SDA */ + 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_01 */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_00_LPI2C1_SCL, /* GPIO_AD_B1_00 PAD functional properties : */ + 0xD8B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Enabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 22K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_01_LPI2C1_SDA, /* GPIO_AD_B1_01 PAD functional properties : */ + 0xD8B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Enabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 22K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ +} + +void BOARD_InitUartPins(void) +{ +#ifdef BSP_USING_LPUART1 + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 is configured as LPUART1_TX */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 is configured as LPUART1_RX */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 PAD functional properties : */ + 0x10B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 PAD functional properties : */ + 0x10B0u); /* Slew Rate Field: Slow Slew Rate + Drive Strength Field: R0/6 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Disabled */ +#endif +#ifdef BSP_USING_LPUART2 + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_02_LPUART2_TX, + 0U); + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_03_LPUART2_RX, + 0U); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_02_LPUART2_TX, + 0x10B0u); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_03_LPUART2_RX, + 0x10B0u); +#endif + +#ifdef BSP_USING_LPUART3 + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_06_LPUART3_TX, + 0U); + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_07_LPUART3_RX, + 0U); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_06_LPUART3_TX, + 0x10B0u); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_07_LPUART3_RX, + 0x10B0u); +#endif + + +#ifdef BSP_USING_LPUART4 + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B1_00_LPUART4_TX, + 0U); + IOMUXC_SetPinMux( + IOMUXC_GPIO_SD_B1_01_LPUART4_RX, + 0U); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B1_00_LPUART4_TX, + 0x10B0u); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_SD_B1_01_LPUART4_RX, + 0x10B0u); +#endif + +#ifdef BSP_USING_LPUART8 + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_10_LPUART8_TX, + 0U); + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B1_11_LPUART8_RX, + 0U); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_10_LPUART8_TX, + 0x10B0u); + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B1_11_LPUART8_RX, + 0x10B0u); +#endif +} + +/* FUNCTION ************************************************************************************************************ + * + * Function Name : BOARD_InitPins + * Description : Configures pin routing and optionally pin electrical features. + * + * END ****************************************************************************************************************/ +void BOARD_InitPins(void) +{ + CLOCK_EnableClock(kCLOCK_Iomuxc); /* iomuxc clock (iomuxc_clk_enable): 0x03u */ + /* Software Input On Field: Input Path is determined by functionality */ + SemcPinmuxConfig(); + +#ifdef BSP_USING_LPUART + BOARD_InitUartPins(); +#endif + +#ifdef BSP_USING_LCD + Lcd_InitPins(); +#endif + +#ifdef BSP_USING_I2C + BOARD_InitI2C1Pins(); +#endif + + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B0_03_GPIO1_IO03, /* GPIO_AD_B0_09 is configured as GPIO1_IO09 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 is configured as GPIO1_IO10 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B0_12_LPUART1_TX, /* GPIO_AD_B0_12 is configured as LPUART1_TX */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B0_13_LPUART1_RX, /* GPIO_AD_B0_13 is configured as LPUART1_RX */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + + + IOMUXC_SetPinMux( + IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 is configured as GPIO1_IO09 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 PAD functional properties : */ + 0x10B0u); /* Slew Rate Field: Slow Slew Rate */ + +#ifdef BSP_USING_SDIO + SDHCPinmuxConfig(); +#endif + + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_04_ENET_RX_DATA00, /* GPIO_B1_04 is configured as ENET_RX_DATA00 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_05_ENET_RX_DATA01, /* GPIO_B1_05 is configured as ENET_RX_DATA01 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_06_ENET_RX_EN, /* GPIO_B1_06 is configured as ENET_RX_EN */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_07_ENET_TX_DATA00, /* GPIO_B1_07 is configured as ENET_TX_DATA00 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_08_ENET_TX_DATA01, /* GPIO_B1_08 is configured as ENET_TX_DATA01 */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_09_ENET_TX_EN, /* GPIO_B1_09 is configured as ENET_TX_EN */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_10_ENET_REF_CLK, /* GPIO_B1_10 is configured as ENET_REF_CLK */ + 1U); /* Software Input On Field: Force input path of pad GPIO_B1_10 */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_B1_11_ENET_RX_ER, /* GPIO_B1_11 is configured as ENET_RX_ER */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_40_ENET_MDC, /* GPIO_EMC_40 is configured as ENET_MDC */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + IOMUXC_SetPinMux( + IOMUXC_GPIO_EMC_41_ENET_MDIO, /* GPIO_EMC_41 is configured as ENET_MDIO */ + 0U); /* Software Input On Field: Input Path is determined by functionality */ + + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B0_03_GPIO1_IO03, /* GPIO_AD_B0_09 PAD functional properties : */ + 0xB0A9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + + IOMUXC_SetPinConfig( + IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 PAD functional properties : */ + 0xB0A9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: medium(100MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_04_ENET_RX_DATA00, /* GPIO_B1_04 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_05_ENET_RX_DATA01, /* GPIO_B1_05 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_06_ENET_RX_EN, /* GPIO_B1_06 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_07_ENET_TX_DATA00, /* GPIO_B1_07 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_08_ENET_TX_DATA01, /* GPIO_B1_08 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_09_ENET_TX_EN, /* GPIO_B1_09 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_10_ENET_REF_CLK, /* GPIO_B1_10 PAD functional properties : */ + 0x31u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/6 + Speed Field: low(50MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Disabled + Pull / Keep Select Field: Keeper + Pull Up / Down Config. Field: 100K Ohm Pull Down + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_B1_11_ENET_RX_ER, /* GPIO_B1_11 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_40_ENET_MDC, /* GPIO_EMC_40 PAD functional properties : */ + 0xB0E9u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: max(200MHz) + Open Drain Enable Field: Open Drain Disabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ + IOMUXC_SetPinConfig( + IOMUXC_GPIO_EMC_41_ENET_MDIO, /* GPIO_EMC_41 PAD functional properties : */ + 0xB829u); /* Slew Rate Field: Fast Slew Rate + Drive Strength Field: R0/5 + Speed Field: low(50MHz) + Open Drain Enable Field: Open Drain Enabled + Pull / Keep Enable Field: Pull/Keeper Enabled + Pull / Keep Select Field: Pull + Pull Up / Down Config. Field: 100K Ohm Pull Up + Hyst. Enable Field: Hysteresis Disabled */ +} + /*********************************************************************************************************************** * EOF **********************************************************************************************************************/ diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c index 1b32163dd..9b8ca475a 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c @@ -57,11 +57,7 @@ #include "netif/ppp/pppoe.h" #include "lwip/igmp.h" #include "lwip/mld6.h" - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) -//#include "FreeRTOS.h" -//#include "event_groups.h" -#endif +#include "lwip/sys.h" #include "netif/ethernet.h" #include "enet_ethernetif.h" @@ -201,23 +197,27 @@ void ethernetif_phy_init(struct ethernetif *ethernetif, * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input(struct netif *netif) +void ethernetif_input(void *netif_arg) { struct pbuf *p; + struct netif *netif = (struct netif *)netif_arg; err_t ret = 0; LWIP_ASSERT("netif != NULL", (netif != NULL)); - /* move received packet into a new pbuf */ - while ((p = ethernetif_linkinput(netif)) != NULL) - { - /* pass all packets to ethernet_input, which decides what packets it supports */ - if ((ret = netif->input(p, netif)) != ERR_OK) + while (1) { + sys_arch_sem_wait(get_eth_recv_sem(), WAITING_FOREVER); + /* move received packet into a new pbuf */ + while ((p = ethernetif_linkinput(netif)) != NULL) { - LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); - lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); - pbuf_free(p); - p = NULL; + /* pass all packets to ethernet_input, which decides what packets it supports */ + if ((ret = netif->input(p, netif)) != ERR_OK) + { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); + pbuf_free(p); + p = NULL; + } } } } diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c index fe8f7c3d1..ae235661c 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c @@ -58,22 +58,9 @@ #include "netif/ppp/pppoe.h" #include "lwip/igmp.h" #include "lwip/mld6.h" +#include "lwip/sys.h" -#ifdef FSL_RTOS_XIUOS -#define USE_RTOS 1 -#define FSL_RTOS_FREE_RTOS -#endif - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) - -#ifdef FSL_RTOS_XIUOS -#include "xs_sem.h" - -#else -#include "FreeRTOS.h" -#include "event_groups.h" -#include "list.h" -#endif +#include typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL @@ -91,27 +78,6 @@ typedef unsigned long UBaseType_t; #define pdPASS ( pdTRUE ) #define pdFAIL ( pdFALSE ) -#ifndef FSL_RTOS_XIUOS -typedef struct EventGroupDef_t -{ - EventBits_t uxEventBits; - List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */ - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxEventGroupNumber; - #endif - - #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */ - #endif -} EventGroup_t; - -struct EventGroupDef_t; -typedef struct EventGroupDef_t * EventGroupHandle_t; -#endif - -#endif - #include "enet_ethernetif.h" #include "enet_ethernetif_priv.h" @@ -130,19 +96,13 @@ typedef struct EventGroupDef_t * EventGroupHandle_t; struct ethernetif { ENET_Type *base; -#if (defined(FSL_FEATURE_SOC_ENET_COUNT) && (FSL_FEATURE_SOC_ENET_COUNT > 0)) || \ - (USE_RTOS && defined(FSL_RTOS_FREE_RTOS)) +#if (defined(FSL_FEATURE_SOC_ENET_COUNT) && (FSL_FEATURE_SOC_ENET_COUNT > 0)) enet_handle_t handle; #endif -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) -#ifdef FSL_RTOS_XIUOS int enetSemaphore; -#else - EventGroupHandle_t enetTransmitAccessEvent; -#endif EventBits_t txFlag; -#endif + enet_rx_bd_struct_t *RxBuffDescrip; enet_tx_bd_struct_t *TxBuffDescrip; rx_buffer_t *RxDataBuff; @@ -153,14 +113,6 @@ struct ethernetif /******************************************************************************* * Code ******************************************************************************/ -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) - -int32 lwip_obtain_semaphore(struct netif *netif) -{ - struct ethernetif *ethernetif = netif->state; - return (KSemaphoreObtain(ethernetif->enetSemaphore, WAITING_FOREVER) == EOK); -} - #if FSL_FEATURE_ENET_QUEUE > 1 static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, uint32_t ringId, enet_event_t event, void *param) #else @@ -169,44 +121,19 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event { struct netif *netif = (struct netif *)param; struct ethernetif *ethernetif = netif->state; - BaseType_t xResult; switch (event) { case kENET_RxEvent: - ethernetif_input(netif); + ENET_DisableInterrupts(ethernetif->base, kENET_RxFrameInterrupt); + sys_sem_signal(get_eth_recv_sem()); break; case kENET_TxEvent: -#ifndef FSL_RTOS_XIUOS - { - portBASE_TYPE taskToWake = pdFALSE; - -#ifdef __CA7_REV - if (SystemGetIRQNestingLevel()) -#else - if (__get_IPSR()) -#endif - { - xResult = xEventGroupSetBitsFromISR(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, &taskToWake); - if ((pdPASS == xResult) && (pdTRUE == taskToWake)) - { - portYIELD_FROM_ISR(taskToWake); - } - } - else - { - xEventGroupSetBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag); - } - } -#endif - break; + break; default: break; } - - KSemaphoreAbandon(ethernetif->enetSemaphore); } -#endif #if LWIP_IPV4 && LWIP_IGMP err_t ethernetif_igmp_mac_filter(struct netif *netif, const ip4_addr_t *group, @@ -315,7 +242,6 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, ethernetif_phy_init(ethernetif, ethernetifConfig, &config); -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) uint32_t instance; static ENET_Type *const enetBases[] = ENET_BASE_PTRS; static const IRQn_Type enetTxIrqId[] = ENET_Transmit_IRQS; @@ -327,51 +253,37 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ /* Create the Event for transmit busy release trigger. */ -#ifdef FSL_RTOS_XIUOS if(ethernetif->enetSemaphore < 0) { ethernetif->enetSemaphore = KSemaphoreCreate(0); } -#else - ethernetif->enetTransmitAccessEvent = xEventGroupCreate(); -#endif ethernetif->txFlag = 0x1; + sys_sem_new(get_eth_recv_sem(), 0); config.interrupt |= kENET_RxFrameInterrupt | kENET_TxFrameInterrupt | kENET_TxBufferInterrupt; for (instance = 0; instance < ARRAY_SIZE(enetBases); instance++) { if (enetBases[instance] == ethernetif->base) { -#ifdef __CA7_REV - GIC_SetPriority(enetRxIrqId[instance], ENET_PRIORITY); - GIC_SetPriority(enetTxIrqId[instance], ENET_PRIORITY); -#if defined(ENET_ENHANCEDBUFFERDESCRIPTOR_MODE) && ENET_ENHANCEDBUFFERDESCRIPTOR_MODE - GIC_SetPriority(enetTsIrqId[instance], ENET_1588_PRIORITY); -#endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ -#else NVIC_SetPriority(enetRxIrqId[instance], ENET_PRIORITY); NVIC_SetPriority(enetTxIrqId[instance], ENET_PRIORITY); #if defined(ENET_ENHANCEDBUFFERDESCRIPTOR_MODE) && ENET_ENHANCEDBUFFERDESCRIPTOR_MODE NVIC_SetPriority(enetTsIrqId[instance], ENET_1588_PRIORITY); #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ -#endif /* __CA7_REV */ break; } } LWIP_ASSERT("Input Ethernet base error!", (instance != ARRAY_SIZE(enetBases))); -#endif /* USE_RTOS */ + + config.txAccelerConfig = kENET_TxAccelIpCheckEnabled | kENET_TxAccelProtoCheckEnabled; /* Initialize the ENET module.*/ ENET_Init(ethernetif->base, ðernetif->handle, &config, &buffCfg[0], netif->hwaddr, sysClock); - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) ENET_SetCallback(ðernetif->handle, ethernet_callback, netif); -#endif ENET_ActiveRead(ethernetif->base); -// low_level_init(); } ENET_Type **ethernetif_enet_ptr(struct ethernetif *ethernetif) @@ -394,45 +306,17 @@ static unsigned char *enet_get_tx_buffer(struct ethernetif *ethernetif) */ static err_t enet_send_frame(struct ethernetif *ethernetif, unsigned char *data, const uint32_t length) { -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) + uint32_t counter; + + for (counter = ENET_TIMEOUT; counter != 0U; counter--) { - status_t result; - - lw_print("lw: [%s] len %d\n", __func__, length); - - do + if (ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length) != kStatus_ENET_TxFrameBusy) { - result = ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length); - - if (result == kStatus_ENET_TxFrameBusy) - { -#ifdef FSL_RTOS_XIUOS - KSemaphoreObtain(ethernetif->enetSemaphore, portMAX_DELAY); -#else - xEventGroupWaitBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, pdTRUE, (BaseType_t) false, - portMAX_DELAY); -#endif - } - - } while (result == kStatus_ENET_TxFrameBusy); - - return ERR_OK; - } -#else - { - uint32_t counter; - - for (counter = ENET_TIMEOUT; counter != 0U; counter--) - { - if (ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length) != kStatus_ENET_TxFrameBusy) - { - return ERR_OK; - } + return ERR_OK; } - - return ERR_TIMEOUT; } -#endif + + return ERR_TIMEOUT; } struct pbuf *ethernetif_linkinput(struct netif *netif) @@ -537,6 +421,7 @@ struct pbuf *ethernetif_linkinput(struct netif *netif) } } + ENET_EnableInterrupts(ethernetif->base, kENET_RxFrameInterrupt); return p; } diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/enet_ethernetif.h b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/enet_ethernetif.h index fc96b93a2..7978b36b6 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/enet_ethernetif.h +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/enet_ethernetif.h @@ -179,7 +179,7 @@ err_t ethernetif1_init(struct netif *netif); * * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input( struct netif *netif); +void ethernetif_input( void *netif_arg); int ETH_BSP_Config(void); void *ethernetif_config_enet_set(uint8_t enet_port); diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/.defconfig b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/.defconfig index 3c7407613..fb21f4d68 100644 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/.defconfig @@ -223,9 +223,9 @@ CONFIG_FS_VFS_FATFS=y # Framework # CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y -CONFIG_ADD_XIZI_FETURES=y -# CONFIG_ADD_NUTTX_FETURES is not set -# CONFIG_ADD_RTTHREAD_FETURES is not set +CONFIG_ADD_XIZI_FEATURES=y +# CONFIG_ADD_NUTTX_FEATURES is not set +# CONFIG_ADD_RTTHREAD_FEATURES is not set # CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set # CONFIG_SUPPORT_CONNECTION_FRAMEWORK is not set # CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/config.mk b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/config.mk index 53f596df6..a9bcb3314 100644 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/config.mk +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/config.mk @@ -5,15 +5,29 @@ export AFLAGS := -c -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections ### if use USB function, use special lds file because USB uses ITCM -ifeq ($(CONFIG_BSP_USING_USB),y) -export LFLAGS := -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi_xidatong.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link-usb.lds +ifeq ($(CONFIG_LIB_MUSLLIB), y) +export LFLAGS += -nostdlib -nostdinc # -fno-builtin -nodefaultlibs +export LIBCC := -lgcc +export LINK_MUSLLIB := $(KERNEL_ROOT)/lib/musllib/libmusl.a +endif + +ifeq ($(CONFIG_RESOURCES_LWIP), y) +export LINK_LWIP := $(KERNEL_ROOT)/resources/ethernet/LwIP/liblwip.a +endif + +ifeq ($(CONFIG_MCUBOOT_BOOTLOADER),y) +export LFLAGS += -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-xiwangtong-arm32-boot.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link-bootloader.lds +else ifeq ($(CONFIG_MCUBOOT_APPLICATION),y) +export LFLAGS += -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-xiwangtong-arm32-app.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link-application.lds +else ifeq ($(CONFIG_BSP_USING_USB),y) +export LFLAGS += -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-xiwangtong-arm32.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link-usb.lds else -export LFLAGS := -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi_xidatong.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds +export LFLAGS += -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-xiwangtong-arm32.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds endif export CXXFLAGS := -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -export APPLFLAGS := -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi_app.map,-cref,-u, -T $(BSP_ROOT)/link_userspace.lds +export APPLFLAGS := -mcpu=cortex-m7 -mthumb -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-app.map,-cref,-u, -T $(BSP_ROOT)/link_userspace.lds export DEFINES := -DHAVE_CCONFIG_H -DCPU_MIMXRT1052CVL5B -DSKIP_SYSCLK_INIT -DEVK_MCIMXRM -DFSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1 -DXIP_EXTERNAL_FLASH=1 -D__STARTUP_INITIALIZE_NONCACHEDATA -D__STARTUP_CLEAR_BSS diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/include/board.h b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/include/board.h index 9e9e12d44..99deb8f14 100755 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/include/board.h +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/include/board.h @@ -51,6 +51,8 @@ void InitBoardHardware(void); /*! @brief The board name */ #define BOARD_NAME "IMXRT1050" +#define configMAC_ADDR {0x02, 0x12, 0x13, 0x10, 0x15, 0x11} + #define NVIC_PRIORITYGROUP_0 0x00000007U /*!< 0 bits for pre-emption priority 4 bits for subpriority */ #define NVIC_PRIORITYGROUP_1 0x00000006U /*!< 1 bits for pre-emption priority diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c index 31d211a37..9b8ca475a 100755 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif.c @@ -57,16 +57,12 @@ #include "netif/ppp/pppoe.h" #include "lwip/igmp.h" #include "lwip/mld6.h" - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) -//#include "FreeRTOS.h" -//#include "event_groups.h" -#endif +#include "lwip/sys.h" #include "netif/ethernet.h" #include "enet_ethernetif.h" #include "enet_ethernetif_priv.h" - +#include #include "fsl_enet.h" #include "fsl_phy.h" #include "fsl_gpio.h" @@ -92,6 +88,20 @@ void Time_Update_LwIP(void) { } +ethernetif_config_t enet_cfg = { + .phyAddress = BOARD_ENET0_PHY_ADDRESS, + .clockName = kCLOCK_CoreSysClk, + .macAddress = configMAC_ADDR, +#if defined(FSL_FEATURE_SOC_LPC_ENET_COUNT) && (FSL_FEATURE_SOC_LPC_ENET_COUNT > 0) + .non_dma_memory = non_dma_memory, +#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */ +}; + +void *ethernetif_config_enet_set(uint8_t enet_port) +{ + return (void *)&enet_cfg; +} + void ethernetif_clk_init(void) { const clock_enet_pll_config_t config = {.enableClkOutput = true, .enableClkOutput25M = false, .loopDivider = 1}; @@ -113,7 +123,7 @@ void ethernetif_gpio_init(void) GPIO_WritePinOutput(GPIO1, 3, 1); } -void ETH_BSP_Config(void) +int ETH_BSP_Config(void) { static int flag = 0; if(flag == 0) @@ -122,6 +132,7 @@ void ETH_BSP_Config(void) ethernetif_gpio_init(); flag = 1; } + return 0; } void ethernetif_phy_init(struct ethernetif *ethernetif, @@ -186,23 +197,27 @@ void ethernetif_phy_init(struct ethernetif *ethernetif, * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input(struct netif *netif) +void ethernetif_input(void *netif_arg) { struct pbuf *p; + struct netif *netif = (struct netif *)netif_arg; err_t ret = 0; LWIP_ASSERT("netif != NULL", (netif != NULL)); - /* move received packet into a new pbuf */ - while ((p = ethernetif_linkinput(netif)) != NULL) - { - /* pass all packets to ethernet_input, which decides what packets it supports */ - if ((ret = netif->input(p, netif)) != ERR_OK) + while (1) { + sys_arch_sem_wait(get_eth_recv_sem(), WAITING_FOREVER); + /* move received packet into a new pbuf */ + while ((p = ethernetif_linkinput(netif)) != NULL) { - LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); - lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); - pbuf_free(p); - p = NULL; + /* pass all packets to ethernet_input, which decides what packets it supports */ + if ((ret = netif->input(p, netif)) != ERR_OK) + { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p); + pbuf_free(p); + p = NULL; + } } } } diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c index fe8f7c3d1..ae235661c 100755 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/ethernet/enet_ethernetif_kinetis.c @@ -58,22 +58,9 @@ #include "netif/ppp/pppoe.h" #include "lwip/igmp.h" #include "lwip/mld6.h" +#include "lwip/sys.h" -#ifdef FSL_RTOS_XIUOS -#define USE_RTOS 1 -#define FSL_RTOS_FREE_RTOS -#endif - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) - -#ifdef FSL_RTOS_XIUOS -#include "xs_sem.h" - -#else -#include "FreeRTOS.h" -#include "event_groups.h" -#include "list.h" -#endif +#include typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL @@ -91,27 +78,6 @@ typedef unsigned long UBaseType_t; #define pdPASS ( pdTRUE ) #define pdFAIL ( pdFALSE ) -#ifndef FSL_RTOS_XIUOS -typedef struct EventGroupDef_t -{ - EventBits_t uxEventBits; - List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */ - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxEventGroupNumber; - #endif - - #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */ - #endif -} EventGroup_t; - -struct EventGroupDef_t; -typedef struct EventGroupDef_t * EventGroupHandle_t; -#endif - -#endif - #include "enet_ethernetif.h" #include "enet_ethernetif_priv.h" @@ -130,19 +96,13 @@ typedef struct EventGroupDef_t * EventGroupHandle_t; struct ethernetif { ENET_Type *base; -#if (defined(FSL_FEATURE_SOC_ENET_COUNT) && (FSL_FEATURE_SOC_ENET_COUNT > 0)) || \ - (USE_RTOS && defined(FSL_RTOS_FREE_RTOS)) +#if (defined(FSL_FEATURE_SOC_ENET_COUNT) && (FSL_FEATURE_SOC_ENET_COUNT > 0)) enet_handle_t handle; #endif -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) -#ifdef FSL_RTOS_XIUOS int enetSemaphore; -#else - EventGroupHandle_t enetTransmitAccessEvent; -#endif EventBits_t txFlag; -#endif + enet_rx_bd_struct_t *RxBuffDescrip; enet_tx_bd_struct_t *TxBuffDescrip; rx_buffer_t *RxDataBuff; @@ -153,14 +113,6 @@ struct ethernetif /******************************************************************************* * Code ******************************************************************************/ -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) - -int32 lwip_obtain_semaphore(struct netif *netif) -{ - struct ethernetif *ethernetif = netif->state; - return (KSemaphoreObtain(ethernetif->enetSemaphore, WAITING_FOREVER) == EOK); -} - #if FSL_FEATURE_ENET_QUEUE > 1 static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, uint32_t ringId, enet_event_t event, void *param) #else @@ -169,44 +121,19 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event { struct netif *netif = (struct netif *)param; struct ethernetif *ethernetif = netif->state; - BaseType_t xResult; switch (event) { case kENET_RxEvent: - ethernetif_input(netif); + ENET_DisableInterrupts(ethernetif->base, kENET_RxFrameInterrupt); + sys_sem_signal(get_eth_recv_sem()); break; case kENET_TxEvent: -#ifndef FSL_RTOS_XIUOS - { - portBASE_TYPE taskToWake = pdFALSE; - -#ifdef __CA7_REV - if (SystemGetIRQNestingLevel()) -#else - if (__get_IPSR()) -#endif - { - xResult = xEventGroupSetBitsFromISR(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, &taskToWake); - if ((pdPASS == xResult) && (pdTRUE == taskToWake)) - { - portYIELD_FROM_ISR(taskToWake); - } - } - else - { - xEventGroupSetBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag); - } - } -#endif - break; + break; default: break; } - - KSemaphoreAbandon(ethernetif->enetSemaphore); } -#endif #if LWIP_IPV4 && LWIP_IGMP err_t ethernetif_igmp_mac_filter(struct netif *netif, const ip4_addr_t *group, @@ -315,7 +242,6 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, ethernetif_phy_init(ethernetif, ethernetifConfig, &config); -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) uint32_t instance; static ENET_Type *const enetBases[] = ENET_BASE_PTRS; static const IRQn_Type enetTxIrqId[] = ENET_Transmit_IRQS; @@ -327,51 +253,37 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif, #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ /* Create the Event for transmit busy release trigger. */ -#ifdef FSL_RTOS_XIUOS if(ethernetif->enetSemaphore < 0) { ethernetif->enetSemaphore = KSemaphoreCreate(0); } -#else - ethernetif->enetTransmitAccessEvent = xEventGroupCreate(); -#endif ethernetif->txFlag = 0x1; + sys_sem_new(get_eth_recv_sem(), 0); config.interrupt |= kENET_RxFrameInterrupt | kENET_TxFrameInterrupt | kENET_TxBufferInterrupt; for (instance = 0; instance < ARRAY_SIZE(enetBases); instance++) { if (enetBases[instance] == ethernetif->base) { -#ifdef __CA7_REV - GIC_SetPriority(enetRxIrqId[instance], ENET_PRIORITY); - GIC_SetPriority(enetTxIrqId[instance], ENET_PRIORITY); -#if defined(ENET_ENHANCEDBUFFERDESCRIPTOR_MODE) && ENET_ENHANCEDBUFFERDESCRIPTOR_MODE - GIC_SetPriority(enetTsIrqId[instance], ENET_1588_PRIORITY); -#endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ -#else NVIC_SetPriority(enetRxIrqId[instance], ENET_PRIORITY); NVIC_SetPriority(enetTxIrqId[instance], ENET_PRIORITY); #if defined(ENET_ENHANCEDBUFFERDESCRIPTOR_MODE) && ENET_ENHANCEDBUFFERDESCRIPTOR_MODE NVIC_SetPriority(enetTsIrqId[instance], ENET_1588_PRIORITY); #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ -#endif /* __CA7_REV */ break; } } LWIP_ASSERT("Input Ethernet base error!", (instance != ARRAY_SIZE(enetBases))); -#endif /* USE_RTOS */ + + config.txAccelerConfig = kENET_TxAccelIpCheckEnabled | kENET_TxAccelProtoCheckEnabled; /* Initialize the ENET module.*/ ENET_Init(ethernetif->base, ðernetif->handle, &config, &buffCfg[0], netif->hwaddr, sysClock); - -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) ENET_SetCallback(ðernetif->handle, ethernet_callback, netif); -#endif ENET_ActiveRead(ethernetif->base); -// low_level_init(); } ENET_Type **ethernetif_enet_ptr(struct ethernetif *ethernetif) @@ -394,45 +306,17 @@ static unsigned char *enet_get_tx_buffer(struct ethernetif *ethernetif) */ static err_t enet_send_frame(struct ethernetif *ethernetif, unsigned char *data, const uint32_t length) { -#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) + uint32_t counter; + + for (counter = ENET_TIMEOUT; counter != 0U; counter--) { - status_t result; - - lw_print("lw: [%s] len %d\n", __func__, length); - - do + if (ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length) != kStatus_ENET_TxFrameBusy) { - result = ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length); - - if (result == kStatus_ENET_TxFrameBusy) - { -#ifdef FSL_RTOS_XIUOS - KSemaphoreObtain(ethernetif->enetSemaphore, portMAX_DELAY); -#else - xEventGroupWaitBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, pdTRUE, (BaseType_t) false, - portMAX_DELAY); -#endif - } - - } while (result == kStatus_ENET_TxFrameBusy); - - return ERR_OK; - } -#else - { - uint32_t counter; - - for (counter = ENET_TIMEOUT; counter != 0U; counter--) - { - if (ENET_SendFrame(ethernetif->base, ðernetif->handle, data, length) != kStatus_ENET_TxFrameBusy) - { - return ERR_OK; - } + return ERR_OK; } - - return ERR_TIMEOUT; } -#endif + + return ERR_TIMEOUT; } struct pbuf *ethernetif_linkinput(struct netif *netif) @@ -537,6 +421,7 @@ struct pbuf *ethernetif_linkinput(struct netif *netif) } } + ENET_EnableInterrupts(ethernetif->base, kENET_RxFrameInterrupt); return p; } diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/connect_ethernet.h b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/connect_ethernet.h index 376c004fe..49f92d4c8 100755 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/connect_ethernet.h +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/connect_ethernet.h @@ -21,11 +21,13 @@ #ifndef __CONNECT_ETHERNET_H_ #define __CONNECT_ETHERNET_H_ +#include "enet_ethernetif.h" +#include "enet_ethernetif_priv.h" + #ifdef __cplusplus extern "C" { #endif - #ifndef sourceClock #define sourceClock CLOCK_GetFreq(kCLOCK_CoreSysClk) #endif diff --git a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/enet_ethernetif.h b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/enet_ethernetif.h index 8416d75bc..7978b36b6 100755 --- a/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/enet_ethernetif.h +++ b/Ubiquitous/XiZi_IIoT/board/xiwangtong-arm32/third_party_driver/include/enet_ethernetif.h @@ -179,12 +179,14 @@ err_t ethernetif1_init(struct netif *netif); * * @param netif the lwip network interface structure for this ethernetif */ -void ethernetif_input( struct netif *netif); - -void ETH_BSP_Config(void); +void ethernetif_input( void *netif_arg); +int ETH_BSP_Config(void); +void *ethernetif_config_enet_set(uint8_t enet_port); int32 lwip_obtain_semaphore(struct netif *netif); +#define NETIF_ENET0_INIT_FUNC ethernetif0_init + #if defined(__cplusplus) } #endif /* __cplusplus */ diff --git a/Ubiquitous/XiZi_IIoT/path_app.mk b/Ubiquitous/XiZi_IIoT/path_app.mk index 131191ffb..78427f764 100644 --- a/Ubiquitous/XiZi_IIoT/path_app.mk +++ b/Ubiquitous/XiZi_IIoT/path_app.mk @@ -9,7 +9,7 @@ ifeq ($(CONFIG_APP_SELECT_NEWLIB), y) endif -ifeq ($(CONFIG_ADD_XIZI_FETURES), y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES), y) APPPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xizi \ -I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xizi/user_api/switch_api \ -I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/include # diff --git a/Ubiquitous/XiZi_IIoT/path_kernel.mk b/Ubiquitous/XiZi_IIoT/path_kernel.mk index 6736938db..d97b59204 100755 --- a/Ubiquitous/XiZi_IIoT/path_kernel.mk +++ b/Ubiquitous/XiZi_IIoT/path_kernel.mk @@ -436,18 +436,18 @@ KERNELPATHS +=-I$(KERNEL_ROOT)/fs/compatibility_ch376 # endif ifeq ($(CONFIG_TRANSFORM_LAYER_ATTRIUBUTE), y) -ifeq ($(CONFIG_ADD_XIZI_FETURES), y) +ifeq ($(CONFIG_ADD_XIZI_FEATURES), y) ifeq ($(CONFIG_LIB_MUSLLIB), ) KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/include # endif KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/transform_layer/xizi # endif -ifeq ($(CONFIG_ADD_NUTTX_FETURES), y) +ifeq ($(CONFIG_ADD_NUTTX_FEATURES), y) # endif -ifeq ($(CONFIG_ADD_RTTHREAD_FETURES), y) +ifeq ($(CONFIG_ADD_RTTHREAD_FEATURES), y) # endif @@ -533,6 +533,10 @@ KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/lib/lorawan/lorawan_deviceno KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/lib/lorawan/lorawan_devicenode/lorawan-ed-stack/Mac/Crypto # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/lib/lorawan/lorawan_devicenode/lorawan-ed-stack/Phy/region # endif + +ifeq ($(CONFIG_LIB_USING_LORAWAN_GATEWAY_SC),y) +KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/lib/lorawan/lorawan_gateway_single_channel/inc # +endif endif ifeq ($(CONFIG_CRYPTO), y) diff --git a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h index 0aed7120a..57be89c52 100644 --- a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h +++ b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h @@ -30,6 +30,8 @@ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H__ +#include + /* ---------- Debug options ---------- */ #ifndef LWIP_DEBUG #define LWIP_DEBUG 1 @@ -535,10 +537,10 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums #define DEFAULT_ACCEPTMBOX_SIZE 10 #define DEFAULT_THREAD_PRIO 20 -#define DEFAULT_THREAD_STACKSIZE 1024 +#define DEFAULT_THREAD_STACKSIZE 2048 #define TCPIP_THREAD_NAME "tcp" -#define TCPIP_THREAD_STACKSIZE 4096 +#define TCPIP_THREAD_STACKSIZE 2048 #define TCPIP_MBOX_SIZE 16 #define TCPIP_THREAD_PRIO 20 diff --git a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.c b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.c index 281ad1f56..e491c5cb1 100644 --- a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.c +++ b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/sys_arch.c @@ -318,7 +318,6 @@ ip4_addr_t gw; void lwip_config_input(struct netif *net) { sys_thread_t th_id = 0; - extern void ethernetif_input(void *netif_arg); th_id = sys_thread_new("eth_input", ethernetif_input, net, LWIP_TASK_STACK_SIZE, 20); if (th_id >= 0) { diff --git a/Ubiquitous/XiZi_IIoT/resources/ethernet/cmd_lwip/lwip_tcp_demo.c b/Ubiquitous/XiZi_IIoT/resources/ethernet/cmd_lwip/lwip_tcp_demo.c index 6f1c8d2b9..e1ad56550 100755 --- a/Ubiquitous/XiZi_IIoT/resources/ethernet/cmd_lwip/lwip_tcp_demo.c +++ b/Ubiquitous/XiZi_IIoT/resources/ethernet/cmd_lwip/lwip_tcp_demo.c @@ -28,7 +28,7 @@ #include "tcpecho_raw.h" char tcp_demo_msg[LWIP_TEST_MSG_SIZE] = { 0 }; char tcp_demo_ip[] = {192, 168, 250, 252}; -u16_t tcp_demo_port = LWIP_TARGET_PORT; +u16_t tcp_demo_port = 80; int tcp_send_num = 0; int tcp_send_task_on = 0; uint32 tcp_interval = 50;