Skip to content

Commit 46949d0

Browse files
committed
DISCO_F413ZH: add UART9 and 10 in serial_api.c
1 parent 6426d27 commit 46949d0

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

targets/TARGET_STM/TARGET_STM32F4/serial_device.c

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "PeripheralPins.h"
4141
#include "mbed_error.h"
4242

43-
#define UART_NUM (8)
43+
#define UART_NUM (10)
4444
static uint32_t serial_irq_ids[UART_NUM] = {0};
4545
UART_HandleTypeDef uart_handlers[UART_NUM];
4646

@@ -123,6 +123,22 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
123123
__HAL_RCC_UART8_CLK_ENABLE();
124124
obj_s->index = 7;
125125
break;
126+
#endif
127+
#if defined(UART9_BASE)
128+
case UART_9:
129+
__HAL_RCC_UART9_FORCE_RESET();
130+
__HAL_RCC_UART9_RELEASE_RESET();
131+
__HAL_RCC_UART9_CLK_ENABLE();
132+
obj_s->index = 8;
133+
break;
134+
#endif
135+
#if defined(UART10_BASE)
136+
case UART_10:
137+
__HAL_RCC_UART10_FORCE_RESET();
138+
__HAL_RCC_UART10_RELEASE_RESET();
139+
__HAL_RCC_UART10_CLK_ENABLE();
140+
obj_s->index = 9;
141+
break;
126142
#endif
127143
}
128144

@@ -216,6 +232,20 @@ void serial_free(serial_t *obj)
216232
__HAL_RCC_UART8_RELEASE_RESET();
217233
__HAL_RCC_UART8_CLK_DISABLE();
218234
break;
235+
#endif
236+
#if defined(UART9_BASE)
237+
case 8:
238+
__HAL_RCC_UART9_FORCE_RESET();
239+
__HAL_RCC_UART9_RELEASE_RESET();
240+
__HAL_RCC_UART9_CLK_DISABLE();
241+
break;
242+
#endif
243+
#if defined(UART10_BASE)
244+
case 9:
245+
__HAL_RCC_UART10_FORCE_RESET();
246+
__HAL_RCC_UART10_RELEASE_RESET();
247+
__HAL_RCC_UART10_CLK_DISABLE();
248+
break;
219249
#endif
220250
}
221251

@@ -315,6 +345,20 @@ static void uart8_irq(void)
315345
}
316346
#endif
317347

348+
#if defined(UART9_BASE)
349+
static void uart9_irq(void)
350+
{
351+
uart_irq(8);
352+
}
353+
#endif
354+
355+
#if defined(UART10_BASE)
356+
static void uart10_irq(void)
357+
{
358+
uart_irq(9);
359+
}
360+
#endif
361+
318362
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
319363
{
320364
struct serial_s *obj_s = SERIAL_S(obj);
@@ -375,6 +419,18 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
375419
irq_n = UART8_IRQn;
376420
vector = (uint32_t)&uart8_irq;
377421
break;
422+
#endif
423+
#if defined(UART9_BASE)
424+
case 8:
425+
irq_n = UART9_IRQn;
426+
vector = (uint32_t)&uart9_irq;
427+
break;
428+
#endif
429+
#if defined(UART10_BASE)
430+
case 9:
431+
irq_n = UART10_IRQn;
432+
vector = (uint32_t)&uart10_irq;
433+
break;
378434
#endif
379435
}
380436

@@ -567,6 +623,16 @@ static IRQn_Type serial_get_irq_n(serial_t *obj)
567623
case 7:
568624
irq_n = UART8_IRQn;
569625
break;
626+
#endif
627+
#if defined(UART9_BASE)
628+
case 8:
629+
irq_n = UART9_IRQn;
630+
break;
631+
#endif
632+
#if defined(UART10_BASE)
633+
case 9:
634+
irq_n = UART10_IRQn;
635+
break;
570636
#endif
571637
default:
572638
irq_n = (IRQn_Type)0;

0 commit comments

Comments
 (0)