mbed
Fork of mbed-dev by
Diff: targets/TARGET_STM/TARGET_STM32F4/serial_device.c
- Revision:
- 168:9672193075cf
- Parent:
- 167:e84263d55307
- Child:
- 171:19eb464bc2be
--- a/targets/TARGET_STM/TARGET_STM32F4/serial_device.c Wed Jun 21 17:46:44 2017 +0100 +++ b/targets/TARGET_STM/TARGET_STM32F4/serial_device.c Thu Jul 06 15:42:05 2017 +0100 @@ -40,7 +40,7 @@ #include "PeripheralPins.h" #include "mbed_error.h" -#define UART_NUM (8) +#define UART_NUM (10) static uint32_t serial_irq_ids[UART_NUM] = {0}; UART_HandleTypeDef uart_handlers[UART_NUM]; @@ -124,6 +124,22 @@ obj_s->index = 7; break; #endif +#if defined(UART9_BASE) + case UART_9: + __HAL_RCC_UART9_FORCE_RESET(); + __HAL_RCC_UART9_RELEASE_RESET(); + __HAL_RCC_UART9_CLK_ENABLE(); + obj_s->index = 8; + break; +#endif +#if defined(UART10_BASE) + case UART_10: + __HAL_RCC_UART10_FORCE_RESET(); + __HAL_RCC_UART10_RELEASE_RESET(); + __HAL_RCC_UART10_CLK_ENABLE(); + obj_s->index = 9; + break; +#endif } // Configure the UART pins @@ -217,6 +233,20 @@ __HAL_RCC_UART8_CLK_DISABLE(); break; #endif +#if defined(UART9_BASE) + case 8: + __HAL_RCC_UART9_FORCE_RESET(); + __HAL_RCC_UART9_RELEASE_RESET(); + __HAL_RCC_UART9_CLK_DISABLE(); + break; +#endif +#if defined(UART10_BASE) + case 9: + __HAL_RCC_UART10_FORCE_RESET(); + __HAL_RCC_UART10_RELEASE_RESET(); + __HAL_RCC_UART10_CLK_DISABLE(); + break; +#endif } // Configure GPIOs @@ -315,6 +345,20 @@ } #endif +#if defined(UART9_BASE) +static void uart9_irq(void) +{ + uart_irq(8); +} +#endif + +#if defined(UART10_BASE) +static void uart10_irq(void) +{ + uart_irq(9); +} +#endif + void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) { struct serial_s *obj_s = SERIAL_S(obj); @@ -376,6 +420,18 @@ vector = (uint32_t)&uart8_irq; break; #endif +#if defined(UART9_BASE) + case 8: + irq_n = UART9_IRQn; + vector = (uint32_t)&uart9_irq; + break; +#endif +#if defined(UART10_BASE) + case 9: + irq_n = UART10_IRQn; + vector = (uint32_t)&uart10_irq; + break; +#endif } if (enable) { @@ -568,6 +624,16 @@ irq_n = UART8_IRQn; break; #endif +#if defined(UART9_BASE) + case 8: + irq_n = UART9_IRQn; + break; +#endif +#if defined(UART10_BASE) + case 9: + irq_n = UART10_IRQn; + break; +#endif default: irq_n = (IRQn_Type)0; }