From 7b4d3c52abc8184429da22820ae8eb79277fbca2 Mon Sep 17 00:00:00 2001 From: armink Date: Sat, 31 Jan 2015 16:47:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91S?= =?UTF-8?q?TM32=E7=9A=84=E4=B8=B2=E5=8F=A3=E5=BA=95=E5=B1=82=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=EF=BC=8C=E6=8F=90=E5=8D=87=E5=8F=AF=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- BSP/src/usart.c | 112 +- EWARM/FreeModbus_Slave&Master+RTT+STM32.ewp | 4270 ++++++++--------- ...FreeModbus_Slave&Master+RTT+STM32.cspy.bat | 48 +- FreeModbus/port/rtt/portserial.c | 8 - FreeModbus/port/rtt/portserial_m.c | 10 +- .../drivers/include/drivers/serial.h | 5 +- RVMDK/JLinkSettings.ini | 34 +- 7 files changed, 2200 insertions(+), 2287 deletions(-) diff --git a/BSP/src/usart.c b/BSP/src/usart.c index 3770e5e..2fbc7fc 100644 --- a/BSP/src/usart.c +++ b/BSP/src/usart.c @@ -12,6 +12,7 @@ * 2009-01-05 Bernard the first version * 2010-03-29 Bernard remove interrupt Tx and DMA Rx mode * 2013-05-13 aozima update for kehong-lingtai. + * 2015-01-31 armink make sure the serial transmit complete in putc() */ #include "stm32f10x.h" @@ -44,8 +45,6 @@ struct stm32_uart { USART_TypeDef* uart_device; IRQn_Type irq; - /* transmit interrupt type */ - rt_uint32_t tx_irq_type; }; static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg) @@ -93,7 +92,6 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg) { struct stm32_uart* uart; - rt_uint32_t irq_type = (rt_uint32_t)(arg); RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; @@ -102,75 +100,20 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar { /* disable interrupt */ case RT_DEVICE_CTRL_CLR_INT: - - if (irq_type == RT_DEVICE_FLAG_INT_RX) - { - /* disable rx irq */ - USART_ITConfig(uart->uart_device, USART_IT_RXNE, DISABLE); - } - else if (irq_type == RT_DEVICE_FLAG_INT_TX) - { - /* disable tx irq */ - USART_ITConfig(uart->uart_device, uart->tx_irq_type, DISABLE); - } - else if (irq_type == RT_NULL) - { - /* disable irq */ - UART_DISABLE_IRQ(uart->irq); - } + /* disable rx irq */ + UART_DISABLE_IRQ(uart->irq); + /* disable interrupt */ + USART_ITConfig(uart->uart_device, USART_IT_RXNE, DISABLE); break; /* enable interrupt */ case RT_DEVICE_CTRL_SET_INT: - if (irq_type == RT_DEVICE_FLAG_INT_RX) - { - /* enable rx irq */ - USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE); - } - else if (irq_type == RT_DEVICE_FLAG_INT_TX) - { - /* enable tx irq */ - USART_ITConfig(uart->uart_device, uart->tx_irq_type, ENABLE); - } - else if (irq_type == RT_NULL) - { - /* enable irq */ - UART_ENABLE_IRQ(uart->irq); - } - break; - /* get interrupt flag */ - case RT_DEVICE_CTRL_GET_INT: - if (irq_type == RT_DEVICE_FLAG_INT_RX) - { - /* return rx irq flag */ - return USART_GetITStatus(uart->uart_device, USART_IT_RXNE); - } - else if (irq_type == RT_DEVICE_FLAG_INT_TX) - { - /* return tx irq flag */ - return USART_GetITStatus(uart->uart_device, uart->tx_irq_type); - } - break; - /* get USART flag */ - case RT_DEVICE_CTRL_GET_FLAG: - if (irq_type == RT_DEVICE_FLAG_INT_RX) - { - /* return rx irq flag */ - return USART_GetFlagStatus(uart->uart_device, USART_FLAG_RXNE); - } - else if (irq_type == RT_DEVICE_FLAG_INT_TX) - { - /* return tx flag */ - if (uart->tx_irq_type == USART_IT_TC) - { - return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TC); - } - else if (uart->tx_irq_type == USART_IT_TXE) - { - return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TXE); - } - } + /* enable rx irq */ + UART_ENABLE_IRQ(uart->irq); + /* enable interrupt */ + USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE); break; } + return RT_EOK; } @@ -181,8 +124,8 @@ static int stm32_putc(struct rt_serial_device *serial, char c) RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; - while (!(uart->uart_device->SR & USART_FLAG_TXE)); uart->uart_device->DR = c; + while (!(uart->uart_device->SR & USART_FLAG_TC)); return 1; } @@ -218,7 +161,6 @@ struct stm32_uart uart1 = { USART1, USART1_IRQn, - USART_IT_TC, }; struct rt_serial_device serial1; @@ -237,14 +179,10 @@ void USART1_IRQHandler(void) USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE); } - if (USART_GetITStatus(uart->uart_device, uart->tx_irq_type) != RESET) + if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET) { /* clear interrupt */ - rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_TX_DONE); - if (uart->tx_irq_type == USART_IT_TC) - { - USART_ClearITPendingBit(uart->uart_device, uart->tx_irq_type); - } + USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) { @@ -261,7 +199,6 @@ struct stm32_uart uart2 = { USART2, USART2_IRQn, - USART_IT_TC, }; struct rt_serial_device serial2; @@ -279,13 +216,10 @@ void USART2_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE); } - if (USART_GetITStatus(uart->uart_device, uart->tx_irq_type) != RESET) + if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET) { /* clear interrupt */ - if (uart->tx_irq_type == USART_IT_TC) - { - USART_ClearITPendingBit(uart->uart_device, uart->tx_irq_type); - } + USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) { @@ -303,7 +237,6 @@ struct stm32_uart uart3 = { USART3, USART3_IRQn, - USART_IT_TC, }; struct rt_serial_device serial3; @@ -321,13 +254,10 @@ void USART3_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE); } - if (USART_GetITStatus(uart->uart_device, uart->tx_irq_type) != RESET) + if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET) { /* clear interrupt */ - if (uart->tx_irq_type == USART_IT_TC) - { - USART_ClearITPendingBit(uart->uart_device, uart->tx_irq_type); - } + USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) { @@ -395,7 +325,7 @@ static void GPIO_Configuration(void) GPIO_Init(UART1_GPIO_REMAP, &GPIO_InitStructure); #endif /* RT_USING_UART1 */ -#ifdef RT_USING_UART2 +#if defined(RT_USING_UART2) /* Configure USART Rx/tx PIN */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = UART2_GPIO_RX; @@ -406,7 +336,7 @@ static void GPIO_Configuration(void) GPIO_Init(UART2_GPIO, &GPIO_InitStructure); #endif /* RT_USING_UART2 */ -#ifdef RT_USING_UART3 +#if defined(RT_USING_UART3) /* Configure USART Rx/tx PIN */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = UART3_GPIO_RX; @@ -453,7 +383,7 @@ void rt_hw_usart_init(void) uart); #endif /* RT_USING_UART1 */ -#ifdef RT_USING_UART2 +#if defined(RT_USING_UART2) uart = &uart2; config.baud_rate = BAUD_RATE_115200; @@ -468,7 +398,7 @@ void rt_hw_usart_init(void) uart); #endif /* RT_USING_UART2 */ -#ifdef RT_USING_UART3 +#if defined(RT_USING_UART3) uart = &uart3; config.baud_rate = BAUD_RATE_115200; diff --git a/EWARM/FreeModbus_Slave&Master+RTT+STM32.ewp b/EWARM/FreeModbus_Slave&Master+RTT+STM32.ewp index 762fe6e..2b084a5 100644 --- a/EWARM/FreeModbus_Slave&Master+RTT+STM32.ewp +++ b/EWARM/FreeModbus_Slave&Master+RTT+STM32.ewp @@ -1,2135 +1,2135 @@ - - - - 2 - - Debug - - ARM - - 1 - - General - 3 - - 21 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 28 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 8 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 1 - - - - - - - - - CUSTOM - 3 - - - - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 15 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 1 - - - - - - - BILINK - 0 - - - - - Release - - ARM - - 0 - - General - 3 - - 21 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 28 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 8 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 15 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - - - APP - - $PROJ_DIR$\..\APP\src\app.c - - - $PROJ_DIR$\..\APP\src\app_task.c - - - $PROJ_DIR$\..\APP\inc\stm32f10x_conf.h - - - $PROJ_DIR$\..\APP\src\stm32f10x_it.c - - - - BSP - - $PROJ_DIR$\..\BSP\src\bsp.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\libcpu\arm\cortex-m3\context_iar.S - - - $PROJ_DIR$\..\RT-Thread-1.2.2\libcpu\arm\cortex-m3\cpuport.c - - - $PROJ_DIR$\..\BSP\src\usart.c - - - - CMSIS - - $PROJ_DIR$\..\Libaries\CMSIS_EWARM\CM3\DeviceSupport\ST\STM32F10x\system_stm32f10x.c - - - - FreeModbusMaster - - Modbus - - $PROJ_DIR$\..\FreeModbus\modbus\mb_m.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfunccoils_m.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncdisc_m.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncholding_m.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncinput_m.c - - - $PROJ_DIR$\..\FreeModbus\modbus\rtu\mbrtu_m.c - - - - Port - - $PROJ_DIR$\..\FreeModbus\port\rtt\portevent_m.c - - - $PROJ_DIR$\..\FreeModbus\port\rtt\portserial_m.c - - - $PROJ_DIR$\..\FreeModbus\port\rtt\porttimer_m.c - - - $PROJ_DIR$\..\FreeModbus\port\user_mb_app_m.c - - - - - FreeModbusSlave - - Modbus - - $PROJ_DIR$\..\FreeModbus\modbus\mb.c - - - $PROJ_DIR$\..\FreeModbus\modbus\rtu\mbcrc.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfunccoils.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncdiag.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncdisc.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncholding.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncinput.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncother.c - - - $PROJ_DIR$\..\FreeModbus\modbus\rtu\mbrtu.c - - - $PROJ_DIR$\..\FreeModbus\modbus\functions\mbutils.c - - - - Port - - $PROJ_DIR$\..\FreeModbus\port\port.c - - - $PROJ_DIR$\..\FreeModbus\port\rtt\portevent.c - - - $PROJ_DIR$\..\FreeModbus\port\rtt\portserial.c - - - $PROJ_DIR$\..\FreeModbus\port\rtt\porttimer.c - - - $PROJ_DIR$\..\FreeModbus\port\user_mb_app.c - - - - - RT-Thread - - Drivers - - $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\completion.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\dataqueue.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\pipe.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\portal.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\ringbuffer.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\serial\serial.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\wrokqueue.c - - - - Kernel - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\clock.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\cpuusage.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\device.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\idle.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\ipc.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\irq.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\kservice.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\mem.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\memheap.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\mempool.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\module.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\module.h - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\object.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\scheduler.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\slab.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\thread.c - - - $PROJ_DIR$\..\RT-Thread-1.2.2\src\timer.c - - - - - StdPeriph_Driver - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\misc.c - - - $PROJ_DIR$\..\Libaries\CMSIS_EWARM\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_md.s - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_adc.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_bkp.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_can.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_cec.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_crc.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_dac.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_dbgmcu.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_dma.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_exti.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_flash.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_fsmc.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_gpio.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_i2c.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_iwdg.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_pwr.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_rcc.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_rtc.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_sdio.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_spi.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_tim.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_usart.c - - - $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_wwdg.c - - - - - + + + + 2 + + Debug + + ARM + + 1 + + General + 3 + + 21 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 15 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + ARM + + 0 + + General + 3 + + 21 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 15 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + APP + + $PROJ_DIR$\..\APP\src\app.c + + + $PROJ_DIR$\..\APP\src\app_task.c + + + $PROJ_DIR$\..\APP\inc\stm32f10x_conf.h + + + $PROJ_DIR$\..\APP\src\stm32f10x_it.c + + + + BSP + + $PROJ_DIR$\..\BSP\src\bsp.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\libcpu\arm\cortex-m3\context_iar.S + + + $PROJ_DIR$\..\RT-Thread-1.2.2\libcpu\arm\cortex-m3\cpuport.c + + + $PROJ_DIR$\..\BSP\src\usart.c + + + + CMSIS + + $PROJ_DIR$\..\Libaries\CMSIS_EWARM\CM3\DeviceSupport\ST\STM32F10x\system_stm32f10x.c + + + + FreeModbusMaster + + Modbus + + $PROJ_DIR$\..\FreeModbus\modbus\mb_m.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfunccoils_m.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncdisc_m.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncholding_m.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncinput_m.c + + + $PROJ_DIR$\..\FreeModbus\modbus\rtu\mbrtu_m.c + + + + Port + + $PROJ_DIR$\..\FreeModbus\port\rtt\portevent_m.c + + + $PROJ_DIR$\..\FreeModbus\port\rtt\portserial_m.c + + + $PROJ_DIR$\..\FreeModbus\port\rtt\porttimer_m.c + + + $PROJ_DIR$\..\FreeModbus\port\user_mb_app_m.c + + + + + FreeModbusSlave + + Modbus + + $PROJ_DIR$\..\FreeModbus\modbus\mb.c + + + $PROJ_DIR$\..\FreeModbus\modbus\rtu\mbcrc.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfunccoils.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncdiag.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncdisc.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncholding.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncinput.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbfuncother.c + + + $PROJ_DIR$\..\FreeModbus\modbus\rtu\mbrtu.c + + + $PROJ_DIR$\..\FreeModbus\modbus\functions\mbutils.c + + + + Port + + $PROJ_DIR$\..\FreeModbus\port\port.c + + + $PROJ_DIR$\..\FreeModbus\port\rtt\portevent.c + + + $PROJ_DIR$\..\FreeModbus\port\rtt\portserial.c + + + $PROJ_DIR$\..\FreeModbus\port\rtt\porttimer.c + + + $PROJ_DIR$\..\FreeModbus\port\user_mb_app.c + + + + + RT-Thread + + Drivers + + $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\completion.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\dataqueue.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\pipe.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\portal.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\ringbuffer.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\serial\serial.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\components\drivers\src\wrokqueue.c + + + + Kernel + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\clock.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\cpuusage.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\device.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\idle.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\ipc.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\irq.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\kservice.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\mem.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\memheap.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\mempool.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\module.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\module.h + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\object.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\scheduler.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\slab.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\thread.c + + + $PROJ_DIR$\..\RT-Thread-1.2.2\src\timer.c + + + + + StdPeriph_Driver + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\misc.c + + + $PROJ_DIR$\..\Libaries\CMSIS_EWARM\CM3\DeviceSupport\ST\STM32F10x\startup\iar\startup_stm32f10x_md.s + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_adc.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_bkp.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_can.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_cec.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_crc.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_dac.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_dbgmcu.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_dma.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_exti.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_flash.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_fsmc.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_gpio.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_i2c.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_iwdg.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_pwr.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_rcc.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_rtc.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_sdio.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_spi.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_tim.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_usart.c + + + $PROJ_DIR$\..\Libaries\STM32F10x_StdPeriph_Driver\src\stm32f10x_wwdg.c + + + + + diff --git a/EWARM/settings/FreeModbus_Slave&Master+RTT+STM32.cspy.bat b/EWARM/settings/FreeModbus_Slave&Master+RTT+STM32.cspy.bat index 18624a9..9e60b95 100644 --- a/EWARM/settings/FreeModbus_Slave&Master+RTT+STM32.cspy.bat +++ b/EWARM/settings/FreeModbus_Slave&Master+RTT+STM32.cspy.bat @@ -1,24 +1,24 @@ -@REM This batch file has been generated by the IAR Embedded Workbench -@REM C-SPY Debugger, as an aid to preparing a command line for running -@REM the cspybat command line utility using the appropriate settings. -@REM -@REM Note that this file is generated every time a new debug session -@REM is initialized, so you may want to move or rename the file before -@REM making changes. -@REM -@REM You can launch cspybat by typing the name of this batch file followed -@REM by the name of the debug file (usually an ELF/DWARF or UBROF file). -@REM -@REM Read about available command line parameters in the C-SPY Debugging -@REM Guide. Hints about additional command line parameters that may be -@REM useful in specific cases: -@REM --download_only Downloads a code image without starting a debug -@REM session afterwards. -@REM --silent Omits the sign-on message. -@REM --timeout Limits the maximum allowed execution time. -@REM - - -"C:\Program Files\IAR Systems\Embedded Workbench 6.5\common\bin\cspybat" "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\bin\armproc.dll" "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\bin\armjlink.dll" %1 --plugin "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\bin\armbat.dll" --macro "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\config\debugger\ST\Trace_STM32F1xx.dmac" --backend -B "--endian=little" "--cpu=Cortex-M3" "--fpu=None" "-p" "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\CONFIG\debugger\ST\STM32F103xB.ddf" "--semihosting" "--device=STM32F103xB" "--drv_communication=USB0" "--jlink_speed=auto" "--jlink_initial_speed=32" "--jlink_reset_strategy=0,0" "--drv_catch_exceptions=0x000" "--drv_swo_clock_setup=72000000,0,2000000" - - +@REM This batch file has been generated by the IAR Embedded Workbench +@REM C-SPY Debugger, as an aid to preparing a command line for running +@REM the cspybat command line utility using the appropriate settings. +@REM +@REM Note that this file is generated every time a new debug session +@REM is initialized, so you may want to move or rename the file before +@REM making changes. +@REM +@REM You can launch cspybat by typing the name of this batch file followed +@REM by the name of the debug file (usually an ELF/DWARF or UBROF file). +@REM +@REM Read about available command line parameters in the C-SPY Debugging +@REM Guide. Hints about additional command line parameters that may be +@REM useful in specific cases: +@REM --download_only Downloads a code image without starting a debug +@REM session afterwards. +@REM --silent Omits the sign-on message. +@REM --timeout Limits the maximum allowed execution time. +@REM + + +"C:\Program Files\IAR Systems\Embedded Workbench 6.5\common\bin\cspybat" "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\bin\armproc.dll" "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\bin\armjlink.dll" %1 --plugin "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\bin\armbat.dll" --macro "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\config\debugger\ST\Trace_STM32F1xx.dmac" --backend -B "--endian=little" "--cpu=Cortex-M3" "--fpu=None" "-p" "C:\Program Files\IAR Systems\Embedded Workbench 6.5\arm\CONFIG\debugger\ST\STM32F103xB.ddf" "--semihosting" "--device=STM32F103xB" "--drv_communication=USB0" "--jlink_speed=auto" "--jlink_initial_speed=32" "--jlink_reset_strategy=0,0" "--drv_catch_exceptions=0x000" "--drv_swo_clock_setup=72000000,0,2000000" + + diff --git a/FreeModbus/port/rtt/portserial.c b/FreeModbus/port/rtt/portserial.c index e892b56..c2e0836 100644 --- a/FreeModbus/port/rtt/portserial.c +++ b/FreeModbus/port/rtt/portserial.c @@ -131,14 +131,6 @@ void vMBPortSerialEnable(BOOL xRxEnable, BOOL xTxEnable) rt_uint32_t recved_event; if (xRxEnable) { - /* waiting for last transmit complete */ - while (1) - { - if (serial->ops->control(serial, RT_DEVICE_CTRL_GET_FLAG, (void *)RT_DEVICE_FLAG_INT_TX)) - { - break; - } - } /* enable RX interrupt */ serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void *)RT_DEVICE_FLAG_INT_RX); /* switch 485 to receive mode */ diff --git a/FreeModbus/port/rtt/portserial_m.c b/FreeModbus/port/rtt/portserial_m.c index e88701f..836fcb2 100644 --- a/FreeModbus/port/rtt/portserial_m.c +++ b/FreeModbus/port/rtt/portserial_m.c @@ -132,14 +132,6 @@ void vMBMasterPortSerialEnable(BOOL xRxEnable, BOOL xTxEnable) rt_uint32_t recved_event; if (xRxEnable) { - /* waiting for last transmit complete */ - while (1) - { - if (serial->ops->control(serial, RT_DEVICE_CTRL_GET_FLAG, (void *)RT_DEVICE_FLAG_INT_TX)) - { - break; - } - } /* enable RX interrupt */ serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void *)RT_DEVICE_FLAG_INT_RX); /* switch 485 to receive mode */ @@ -173,7 +165,7 @@ void vMBMasterPortClose(void) BOOL xMBMasterPortSerialPutByte(CHAR ucByte) { - serial->parent.write(&(serial->parent), 0, &ucByte, 1); + serial->parent.write(&(serial->parent), 0, &ucByte, 1); return TRUE; } diff --git a/RT-Thread-1.2.2/components/drivers/include/drivers/serial.h b/RT-Thread-1.2.2/components/drivers/include/drivers/serial.h index f9ba505..24b82ef 100644 --- a/RT-Thread-1.2.2/components/drivers/include/drivers/serial.h +++ b/RT-Thread-1.2.2/components/drivers/include/drivers/serial.h @@ -66,10 +66,9 @@ #endif #define RT_DEVICE_CTRL_CONFIG 0x03 /* configure device */ -#define RT_DEVICE_CTRL_SET_INT 0x10 /* enable serial irq */ -#define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable serial irq */ +#define RT_DEVICE_CTRL_SET_INT 0x10 /* enable receive irq */ +#define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable receive irq */ #define RT_DEVICE_CTRL_GET_INT 0x12 -#define RT_DEVICE_CTRL_GET_FLAG 0x13 #define RT_SERIAL_EVENT_RX_IND 0x01 /* Rx indication */ #define RT_SERIAL_EVENT_TX_DONE 0x02 /* Tx complete */ diff --git a/RVMDK/JLinkSettings.ini b/RVMDK/JLinkSettings.ini index 5516360..28de79c 100644 --- a/RVMDK/JLinkSettings.ini +++ b/RVMDK/JLinkSettings.ini @@ -1,17 +1,17 @@ -[FLASH] -SkipProgOnCRCMatch = 1 -VerifyDownload = 1 -AllowCaching = 1 -EnableFlashDL = 2 -Override = 0 -Device="ADUC7020X62" -[BREAKPOINTS] -ShowInfoWin = 1 -EnableFlashBP = 2 -BPDuringExecution = 0 -[CPU] -OverrideMemMap = 0 -AllowSimulation = 1 -ScriptFile="" -[SWO] -SWOLogFile="" +[FLASH] +SkipProgOnCRCMatch = 1 +VerifyDownload = 1 +AllowCaching = 1 +EnableFlashDL = 2 +Override = 0 +Device="ADUC7020X62" +[BREAKPOINTS] +ShowInfoWin = 1 +EnableFlashBP = 2 +BPDuringExecution = 0 +[CPU] +OverrideMemMap = 0 +AllowSimulation = 1 +ScriptFile="" +[SWO] +SWOLogFile=""