From ed57c7c32a3642c4512c71a0779bbb6e9780f3ad Mon Sep 17 00:00:00 2001 From: armink Date: Sat, 13 Sep 2014 11:15:48 +0800 Subject: [PATCH 1/6] [Ymodem]When active end the session, It can config send CAN number. --- components/utilities/ymodem/ymodem.c | 7 ++++--- components/utilities/ymodem/ymodem.h | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/utilities/ymodem/ymodem.c b/components/utilities/ymodem/ymodem.c index f5ebeab832..3af1528024 100644 --- a/components/utilities/ymodem/ymodem.c +++ b/components/utilities/ymodem/ymodem.c @@ -197,7 +197,7 @@ static rt_err_t _rym_do_trans(struct rym_ctx *ctx) { rt_err_t err; enum rym_code code; - rt_size_t data_sz; + rt_size_t data_sz, i; code = _rym_read_code(ctx, RYM_WAIT_PKG_TICK); @@ -223,8 +223,9 @@ static rt_err_t _rym_do_trans(struct rym_ctx *ctx) { case RYM_CODE_CAN: /* the spec require multiple CAN */ - _rym_putchar(ctx, RYM_CODE_CAN); - _rym_putchar(ctx, RYM_CODE_CAN); + for (i = 0; i < RYM_END_SESSION_SEND_CAN_NUM; i++) { + _rym_putchar(ctx, RYM_CODE_CAN); + } return -RYM_ERR_CAN; case RYM_CODE_ACK: _rym_putchar(ctx, RYM_CODE_ACK); diff --git a/components/utilities/ymodem/ymodem.h b/components/utilities/ymodem/ymodem.h index 43ee6f5c10..d82e76d936 100644 --- a/components/utilities/ymodem/ymodem.h +++ b/components/utilities/ymodem/ymodem.h @@ -55,6 +55,9 @@ enum rym_code { #define RYM_CHD_INTV_TICK (RT_TICK_PER_SECOND * 3) #endif +/* how many CAN be sent when user active end the session. */ +#define RYM_END_SESSION_SEND_CAN_NUM 0x07 + enum rym_stage { RYM_STAGE_NONE, /* set when C is send */ @@ -129,7 +132,7 @@ struct rym_ctx * second. */ rt_err_t rym_recv_on_device(struct rym_ctx *ctx, rt_device_t dev, - rym_callback on_begin, rym_callback on_data, rym_callback on_end, - int handshake_timeout); + rt_uint16_t oflag, rym_callback on_begin, rym_callback on_data, + rym_callback on_end, int handshake_timeout); #endif From 7121697a71953bf0c7efd4141fc29e29307b3913 Mon Sep 17 00:00:00 2001 From: armink Date: Sat, 13 Sep 2014 11:22:01 +0800 Subject: [PATCH 2/6] [Ymodem]Add device open flag as input parameter to ymodem function. --- components/utilities/ymodem/ymodem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/utilities/ymodem/ymodem.c b/components/utilities/ymodem/ymodem.c index 3af1528024..7e8ad12419 100644 --- a/components/utilities/ymodem/ymodem.c +++ b/components/utilities/ymodem/ymodem.c @@ -311,6 +311,7 @@ static rt_err_t _rym_do_recv( rt_err_t rym_recv_on_device( struct rym_ctx *ctx, rt_device_t dev, + rt_uint16_t oflag, rym_callback on_begin, rym_callback on_data, rym_callback on_end, @@ -341,7 +342,7 @@ rt_err_t rym_recv_on_device( dev->flag &= ~RT_DEVICE_FLAG_STREAM; rt_hw_interrupt_enable(int_lvl); - res = rt_device_open(dev, 0); + res = rt_device_open(dev, oflag); if (res != RT_EOK) goto __exit; @@ -364,4 +365,3 @@ __exit: return res; } - From 04c4e5d9a43db20023bc160998c54efc8f45ce35 Mon Sep 17 00:00:00 2001 From: armink Date: Sat, 13 Sep 2014 11:50:54 +0800 Subject: [PATCH 3/6] [BSP]Fixes two writing mistake for stm32f10x. --- bsp/stm32f10x/drivers/usart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp/stm32f10x/drivers/usart.c b/bsp/stm32f10x/drivers/usart.c index bbaf4ec032..ca39d49b22 100644 --- a/bsp/stm32f10x/drivers/usart.c +++ b/bsp/stm32f10x/drivers/usart.c @@ -204,7 +204,7 @@ void USART2_IRQHandler(void) #endif /* RT_USING_UART2 */ #if defined(RT_USING_UART3) -/* UART1 device driver structure */ +/* UART3 device driver structure */ struct stm32_uart uart3 = { USART3, @@ -282,7 +282,7 @@ static void GPIO_Configuration(void) /* Configure USART Rx/tx PIN */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = UART2_GPIO_RX; - GPIO_Init(UART1_GPIO, &GPIO_InitStructure); + GPIO_Init(UART2_GPIO, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = UART2_GPIO_TX; From 77b214f1bc8cbb9463fda702ac74accf26529684 Mon Sep 17 00:00:00 2001 From: armink Date: Sat, 13 Sep 2014 11:53:21 +0800 Subject: [PATCH 4/6] [BSP]Add serial receive overflow interrupt to stm32f10x ISR. --- bsp/stm32f10x/drivers/usart.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/bsp/stm32f10x/drivers/usart.c b/bsp/stm32f10x/drivers/usart.c index ca39d49b22..4c6f24af30 100644 --- a/bsp/stm32f10x/drivers/usart.c +++ b/bsp/stm32f10x/drivers/usart.c @@ -21,19 +21,19 @@ #include /* USART1 */ -#define UART1_GPIO_TX GPIO_Pin_9 -#define UART1_GPIO_RX GPIO_Pin_10 -#define UART1_GPIO GPIOA +#define UART1_GPIO_TX GPIO_Pin_9 +#define UART1_GPIO_RX GPIO_Pin_10 +#define UART1_GPIO GPIOA /* USART2 */ -#define UART2_GPIO_TX GPIO_Pin_2 -#define UART2_GPIO_RX GPIO_Pin_3 -#define UART2_GPIO GPIOA +#define UART2_GPIO_TX GPIO_Pin_2 +#define UART2_GPIO_RX GPIO_Pin_3 +#define UART2_GPIO GPIOA /* USART3_REMAP[1:0] = 00 */ -#define UART3_GPIO_TX GPIO_Pin_10 -#define UART3_GPIO_RX GPIO_Pin_11 -#define UART3_GPIO GPIOB +#define UART3_GPIO_TX GPIO_Pin_10 +#define UART3_GPIO_RX GPIO_Pin_11 +#define UART3_GPIO GPIOB /* STM32 uart driver */ struct stm32_uart @@ -163,7 +163,10 @@ void USART1_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } - + if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) + { + stm32_getc(&serial1); + } /* leave interrupt */ rt_interrupt_leave(); } @@ -197,6 +200,10 @@ void USART2_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } + if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) + { + stm32_getc(&serial2); + } /* leave interrupt */ rt_interrupt_leave(); @@ -231,6 +238,10 @@ void USART3_IRQHandler(void) /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } + if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) + { + stm32_getc(&serial3); + } /* leave interrupt */ rt_interrupt_leave(); From 987532967ff6261fc6ae6e58c70cc29958215ab6 Mon Sep 17 00:00:00 2001 From: armink Date: Sun, 14 Sep 2014 14:44:48 +0800 Subject: [PATCH 5/6] [Ymodem]Change macro definition and code format. --- components/utilities/ymodem/ymodem.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/utilities/ymodem/ymodem.h b/components/utilities/ymodem/ymodem.h index d82e76d936..15d8c93839 100644 --- a/components/utilities/ymodem/ymodem.h +++ b/components/utilities/ymodem/ymodem.h @@ -56,7 +56,9 @@ enum rym_code { #endif /* how many CAN be sent when user active end the session. */ +#ifndef RYM_END_SESSION_SEND_CAN_NUM #define RYM_END_SESSION_SEND_CAN_NUM 0x07 +#endif enum rym_stage { RYM_STAGE_NONE, @@ -131,8 +133,8 @@ struct rym_ctx * @param handshake_timeout the timeout when hand shaking. The unit is in * second. */ -rt_err_t rym_recv_on_device(struct rym_ctx *ctx, rt_device_t dev, - rt_uint16_t oflag, rym_callback on_begin, rym_callback on_data, - rym_callback on_end, int handshake_timeout); +rt_err_t rym_recv_on_device(struct rym_ctx *ctx, rt_device_t dev, rt_uint16_t oflag, + rym_callback on_begin, rym_callback on_data, rym_callback on_end, + int handshake_timeout); #endif From 762f18d743580b4b8f3a7954d481dcbe1d2ecf30 Mon Sep 17 00:00:00 2001 From: armink Date: Sun, 14 Sep 2014 14:52:00 +0800 Subject: [PATCH 6/6] [Ymodem]Change tabs to space. --- components/utilities/ymodem/ymodem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/utilities/ymodem/ymodem.h b/components/utilities/ymodem/ymodem.h index 15d8c93839..09b5bae791 100644 --- a/components/utilities/ymodem/ymodem.h +++ b/components/utilities/ymodem/ymodem.h @@ -134,7 +134,7 @@ struct rym_ctx * second. */ rt_err_t rym_recv_on_device(struct rym_ctx *ctx, rt_device_t dev, rt_uint16_t oflag, - rym_callback on_begin, rym_callback on_data, rym_callback on_end, - int handshake_timeout); + rym_callback on_begin, rym_callback on_data, rym_callback on_end, + int handshake_timeout); #endif