Skip to content

Commit 6c6e762

Browse files
committed
Support USARTs up to USART5 in SPI
1 parent 53f88b5 commit 6c6e762

File tree

1 file changed

+84
-0
lines changed
  • targets/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+84
-0
lines changed

targets/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ static inline CMU_Clock_TypeDef spi_get_clock_tree(spi_t *obj)
5959
#ifdef USART2
6060
case SPI_2:
6161
return cmuClock_USART2;
62+
#endif
63+
#ifdef USART3
64+
case SPI_3:
65+
return cmuClock_USART3;
66+
#endif
67+
#ifdef USART4
68+
case SPI_4:
69+
return cmuClock_USART4;
70+
#endif
71+
#ifdef USART5
72+
case SPI_5:
73+
return cmuClock_USART5;
6274
#endif
6375
default:
6476
error("Spi module not available.. Out of bound access.");
@@ -84,6 +96,21 @@ static inline uint8_t spi_get_index(spi_t *obj)
8496
case SPI_2:
8597
index = 2;
8698
break;
99+
#endif
100+
#ifdef USART3
101+
case SPI_3:
102+
index = 3;
103+
break;
104+
#endif
105+
#ifdef USART4
106+
case SPI_4:
107+
index = 4;
108+
break;
109+
#endif
110+
#ifdef USART5
111+
case SPI_5:
112+
index = 5;
113+
break;
87114
#endif
88115
default:
89116
error("Spi module not available.. Out of bound access.");
@@ -286,6 +313,21 @@ void spi_enable_interrupt(spi_t *obj, uint32_t handler, uint8_t enable)
286313
case USART_2:
287314
IRQvector = USART2_RX_IRQn;
288315
break;
316+
#endif
317+
#ifdef USART3
318+
case USART_3:
319+
IRQvector = USART3_RX_IRQn;
320+
break;
321+
#endif
322+
#ifdef USART4
323+
case USART_4:
324+
IRQvector = USART4_RX_IRQn;
325+
break;
326+
#endif
327+
#ifdef USART5
328+
case USART_5:
329+
IRQvector = USART5_RX_IRQn;
330+
break;
289331
#endif
290332
default:
291333
error("Undefined SPI peripheral");
@@ -770,6 +812,24 @@ static void spi_master_dma_channel_setup(spi_t *obj, void* callback)
770812
rxChnlCfg.select = DMAREQ_USART2_RXDATAV;
771813
txChnlCfg.select = DMAREQ_USART2_TXEMPTY;
772814
break;
815+
#endif
816+
#ifdef USART3
817+
case SPI_3:
818+
rxChnlCfg.select = DMAREQ_USART3_RXDATAV;
819+
txChnlCfg.select = DMAREQ_USART3_TXEMPTY;
820+
break;
821+
#endif
822+
#ifdef USART4
823+
case SPI_4:
824+
rxChnlCfg.select = DMAREQ_USART4_RXDATAV;
825+
txChnlCfg.select = DMAREQ_USART4_TXEMPTY;
826+
break;
827+
#endif
828+
#ifdef USART5
829+
case SPI_5:
830+
rxChnlCfg.select = DMAREQ_USART5_RXDATAV;
831+
txChnlCfg.select = DMAREQ_USART5_TXEMPTY;
832+
break;
773833
#endif
774834
default:
775835
error("Spi module not available.. Out of bound access.");
@@ -799,12 +859,36 @@ static void spi_activate_dma(spi_t *obj, void* rxdata, const void* txdata, int t
799859
/* Select RX source address. 9 bit frame length requires to use extended register.
800860
10 bit and larger frame requires to use RXDOUBLE register. */
801861
switch((int)obj->spi.spi) {
862+
#ifdef USART0
802863
case USART_0:
803864
dma_periph = ldmaPeripheralSignal_USART0_RXDATAV;
804865
break;
866+
#endif
867+
#ifdef USART1
805868
case USART_1:
806869
dma_periph = ldmaPeripheralSignal_USART1_RXDATAV;
807870
break;
871+
#endif
872+
#ifdef USART2
873+
case USART_2:
874+
dma_periph = ldmaPeripheralSignal_USART2_RXDATAV;
875+
break;
876+
#endif
877+
#ifdef USART3
878+
case USART_3:
879+
dma_periph = ldmaPeripheralSignal_USART3_RXDATAV;
880+
break;
881+
#endif
882+
#ifdef USART4
883+
case USART_4:
884+
dma_periph = ldmaPeripheralSignal_USART4_RXDATAV;
885+
break;
886+
#endif
887+
#ifdef USART5
888+
case USART_5:
889+
dma_periph = ldmaPeripheralSignal_USART5_RXDATAV;
890+
break;
891+
#endif
808892
default:
809893
EFM_ASSERT(0);
810894
while(1);

0 commit comments

Comments
 (0)