mbed library with additional peripherals for ST F401 board
Fork of mbed-src by
This mbed LIB has additional peripherals for ST F401 board
- UART2 : PA_3 rx, PA_2 tx
- UART3 : PC_7 rx, PC_6 tx
- I2C2 : PB_3 SDA, PB_10 SCL
- I2C3 : PB_4 SDA, PA_8 SCL
Revision 55:3b765ca737a5, committed 2013-12-09
- Comitter:
- mbed_official
- Date:
- Mon Dec 09 11:15:04 2013 +0000
- Parent:
- 54:24d77221bceb
- Child:
- 56:99eb381a3269
- Commit message:
- Synchronized with git revision faee2bf073820222f14e0baf95ec002e8cfec21e
Full URL: https://github.com/mbedmicro/mbed/commit/faee2bf073820222f14e0baf95ec002e8cfec21e/
- use TC flag instead of TXE for TX interrupt
- clear interrupt flags to prevent possible interrupt storm
Changed in this revision
targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c | Show annotated file Show diff for this revision Revisions of this file |
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c Sat Dec 07 12:45:04 2013 +0000 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c Mon Dec 09 11:15:04 2013 +0000 @@ -182,30 +182,21 @@ ******************************************************************************/ // not api -void uart1_irq(void) { - USART_TypeDef *usart = (USART_TypeDef *)UART_1; - if (serial_irq_ids[0] != 0) { - if (USART_GetITStatus(usart, USART_IT_TXE) != RESET) { - irq_handler(serial_irq_ids[0], TxIrq); +static void uart_irq(USART_TypeDef* usart, int id) { + if (serial_irq_ids[id] != 0) { + if (USART_GetITStatus(usart, USART_IT_TC) != RESET) { + irq_handler(serial_irq_ids[id], TxIrq); + USART_ClearITPendingBit(usart, USART_IT_TC); } if (USART_GetITStatus(usart, USART_IT_RXNE) != RESET) { - irq_handler(serial_irq_ids[0], RxIrq); + irq_handler(serial_irq_ids[id], RxIrq); + USART_ClearITPendingBit(usart, USART_IT_RXNE); } } } -// not api -void uart2_irq(void) { - USART_TypeDef *usart = (USART_TypeDef *)UART_2; - if (serial_irq_ids[1] != 0) { - if (USART_GetITStatus(usart, USART_IT_TXE) != RESET) { - irq_handler(serial_irq_ids[1], TxIrq); - } - if (USART_GetITStatus(usart, USART_IT_RXNE) != RESET) { - irq_handler(serial_irq_ids[1], RxIrq); - } - } -} +static void uart1_irq(void) {uart_irq((USART_TypeDef*)UART_1, 0);} +static void uart2_irq(void) {uart_irq((USART_TypeDef*)UART_2, 1);} void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) { irq_handler = handler; @@ -233,7 +224,7 @@ USART_ITConfig(usart, USART_IT_RXNE, ENABLE); } else { // TxIrq - USART_ITConfig(usart, USART_IT_TXE, ENABLE); + USART_ITConfig(usart, USART_IT_TC, ENABLE); } NVIC_SetVector(irq_n, vector);