EFM32 Zero Gecko Software Documentation  efm32zg-doc-4.2.1
cdc.c
Go to the documentation of this file.
1 /**************************************************************************/
15 #include "em_device.h"
16 #include "em_common.h"
17 #include "em_cmu.h"
18 #include "em_dma.h"
19 #include "em_gpio.h"
20 #include "em_usart.h"
21 #include "em_usb.h"
22 #include "bsp.h"
23 #include "dmactrl.h"
24 #include "cdc.h"
25 
26 /**************************************************************************/
93 /*** Typedef's and defines. ***/
94 
95 #define CDC_BULK_EP_SIZE (USB_FS_BULK_EP_MAXSIZE) /* This is the max. ep size. */
96 #define CDC_USB_RX_BUF_SIZ CDC_BULK_EP_SIZE /* Packet size when receiving on USB. */
97 #define CDC_USB_TX_BUF_SIZ 127 /* Packet size when transmitting on USB. */
98 
99 /* Calculate a timeout in ms corresponding to 5 char times on current */
100 /* baudrate. Minimum timeout is set to 10 ms. */
101 #define CDC_RX_TIMEOUT EFM32_MAX(10U, 50000 / (cdcLineCoding.dwDTERate))
102 
103 /* The serial port LINE CODING data structure, used to carry information */
104 /* about serial port baudrate, parity etc. between host and device. */
106 typedef struct
107 {
108  uint32_t dwDTERate;
109  uint8_t bCharFormat;
110  uint8_t bParityType;
111  uint8_t bDataBits;
112  uint8_t dummy;
113 } __attribute__ ((packed)) cdcLineCoding_TypeDef;
115 
116 
117 /*** Function prototypes. ***/
118 
119 static int UsbDataReceived(USB_Status_TypeDef status, uint32_t xferred,
120  uint32_t remaining);
121 static void DmaSetup(void);
122 static int LineCodingReceived(USB_Status_TypeDef status,
123  uint32_t xferred,
124  uint32_t remaining);
125 static void SerialPortInit(void);
126 static void UartRxTimeout(void);
127 
128 /*** Variables ***/
129 
130 /*
131  * The LineCoding variable must be 4-byte aligned as it is used as USB
132  * transmit and receive buffer.
133  */
134 EFM32_ALIGN(4)
136 static cdcLineCoding_TypeDef __attribute__ ((aligned(4))) cdcLineCoding =
137 {
138  115200, 0, 0, 8, 0
139 };
141 
142 STATIC_UBUF(usbRxBuffer0, CDC_USB_RX_BUF_SIZ); /* USB receive buffers. */
143 STATIC_UBUF(usbRxBuffer1, CDC_USB_RX_BUF_SIZ);
144 STATIC_UBUF(uartRxBuffer0, CDC_USB_TX_BUF_SIZ); /* UART receive buffers. */
145 STATIC_UBUF(uartRxBuffer1, CDC_USB_TX_BUF_SIZ);
146 
147 static const uint8_t *usbRxBuffer[ 2 ] = { usbRxBuffer0, usbRxBuffer1 };
148 static const uint8_t *uartRxBuffer[ 2 ] = { uartRxBuffer0, uartRxBuffer1 };
149 
150 static int usbRxIndex, usbBytesReceived;
151 static int uartRxIndex, uartRxCount;
152 static int LastUsbTxCnt;
153 
154 static bool dmaRxCompleted;
155 static bool usbRxActive, dmaTxActive;
156 static bool usbTxActive, dmaRxActive;
157 
158 static DMA_CB_TypeDef DmaTxCallBack;
159 static DMA_CB_TypeDef DmaRxCallBack;
160 
163 /**************************************************************************/
166 void CDC_Init( void )
167 {
168  SerialPortInit();
169  DmaSetup();
170 }
171 
172 /**************************************************************************/
182 int CDC_SetupCmd(const USB_Setup_TypeDef *setup)
183 {
184  int retVal = USB_STATUS_REQ_UNHANDLED;
185 
186  if ( ( setup->Type == USB_SETUP_TYPE_CLASS ) &&
187  ( setup->Recipient == USB_SETUP_RECIPIENT_INTERFACE ) )
188  {
189  switch (setup->bRequest)
190  {
191  case USB_CDC_GETLINECODING:
192  /********************/
193  if ( ( setup->wValue == 0 ) &&
194  ( setup->wIndex == CDC_CTRL_INTERFACE_NO ) && /* Interface no. */
195  ( setup->wLength == 7 ) && /* Length of cdcLineCoding. */
196  ( setup->Direction == USB_SETUP_DIR_IN ) )
197  {
198  /* Send current settings to USB host. */
199  USBD_Write(0, (void*) &cdcLineCoding, 7, NULL);
200  retVal = USB_STATUS_OK;
201  }
202  break;
203 
204  case USB_CDC_SETLINECODING:
205  /********************/
206  if ( ( setup->wValue == 0 ) &&
207  ( setup->wIndex == CDC_CTRL_INTERFACE_NO ) && /* Interface no. */
208  ( setup->wLength == 7 ) && /* Length of cdcLineCoding. */
209  ( setup->Direction != USB_SETUP_DIR_IN ) )
210  {
211  /* Get new settings from USB host. */
212  USBD_Read(0, (void*) &cdcLineCoding, 7, LineCodingReceived);
213  retVal = USB_STATUS_OK;
214  }
215  break;
216 
217  case USB_CDC_SETCTRLLINESTATE:
218  /********************/
219  if ( ( setup->wIndex == CDC_CTRL_INTERFACE_NO ) && /* Interface no. */
220  ( setup->wLength == 0 ) ) /* No data. */
221  {
222  /* Do nothing ( Non compliant behaviour !! ) */
223  retVal = USB_STATUS_OK;
224  }
225  break;
226  }
227  }
228 
229  return retVal;
230 }
231 
232 /**************************************************************************/
240 void CDC_StateChangeEvent( USBD_State_TypeDef oldState,
241  USBD_State_TypeDef newState)
242 {
243  if (newState == USBD_STATE_CONFIGURED)
244  {
245  /* We have been configured, start CDC functionality ! */
246 
247  if (oldState == USBD_STATE_SUSPENDED) /* Resume ? */
248  {
249  }
250 
251  /* Start receiving data from USB host. */
252  usbRxIndex = 0;
253  usbRxActive = true;
254  dmaTxActive = false;
255  USBD_Read(CDC_EP_DATA_OUT, (void*) usbRxBuffer[ usbRxIndex ],
256  CDC_USB_RX_BUF_SIZ, UsbDataReceived);
257 
258  /* Start receiving data on UART. */
259  uartRxIndex = 0;
260  LastUsbTxCnt = 0;
261  uartRxCount = 0;
262  dmaRxActive = true;
263  usbTxActive = false;
264  dmaRxCompleted = true;
265  DMA_ActivateBasic(CDC_UART_RX_DMA_CHANNEL, true, false,
266  (void *) uartRxBuffer[ uartRxIndex ],
267  (void *) &(CDC_UART->RXDATA),
268  CDC_USB_TX_BUF_SIZ - 1);
269  USBTIMER_Start(CDC_TIMER_ID, CDC_RX_TIMEOUT, UartRxTimeout);
270  }
271 
272  else if ((oldState == USBD_STATE_CONFIGURED) &&
273  (newState != USBD_STATE_SUSPENDED))
274  {
275  /* We have been de-configured, stop CDC functionality. */
276  USBTIMER_Stop(CDC_TIMER_ID);
277  /* Stop DMA channels. */
278  DMA->CHENC = ( 1 << CDC_UART_TX_DMA_CHANNEL ) |
279  ( 1 << CDC_UART_RX_DMA_CHANNEL );
280  }
281 
282  else if (newState == USBD_STATE_SUSPENDED)
283  {
284  /* We have been suspended, stop CDC functionality. */
285  /* Reduce current consumption to below 2.5 mA. */
286  USBTIMER_Stop(CDC_TIMER_ID);
287  /* Stop DMA channels. */
288  DMA->CHENC = ( 1 << CDC_UART_TX_DMA_CHANNEL ) |
289  ( 1 << CDC_UART_RX_DMA_CHANNEL );
290  }
291 }
292 
295 /**************************************************************************/
305 static int UsbDataReceived(USB_Status_TypeDef status,
306  uint32_t xferred,
307  uint32_t remaining)
308 {
309  (void) remaining; /* Unused parameter. */
310 
311  if ((status == USB_STATUS_OK) && (xferred > 0))
312  {
313  usbRxIndex ^= 1;
314 
315  if (!dmaTxActive)
316  {
317  /* dmaTxActive = false means that a new UART Tx DMA can be started. */
318  dmaTxActive = true;
319  DMA_ActivateBasic(CDC_UART_TX_DMA_CHANNEL, true, false,
320  (void *) &(CDC_UART->TXDATA),
321  (void *) usbRxBuffer[ usbRxIndex ^ 1 ],
322  xferred - 1);
323 
324  /* Start a new USB receive transfer. */
325  USBD_Read(CDC_EP_DATA_OUT, (void*) usbRxBuffer[ usbRxIndex ],
326  CDC_USB_RX_BUF_SIZ, UsbDataReceived);
327  }
328  else
329  {
330  /* The UART transmit DMA callback function will start a new DMA. */
331  usbRxActive = false;
332  usbBytesReceived = xferred;
333  }
334  }
335  return USB_STATUS_OK;
336 }
337 
338 /**************************************************************************/
345 static void DmaTxComplete(unsigned int channel, bool primary, void *user)
346 {
347  (void) channel; /* Unused parameter. */
348  (void) primary; /* Unused parameter. */
349  (void) user; /* Unused parameter. */
350 
351  /*
352  * As nested interrupts may occur and we rely on variables usbRxActive
353  * and dmaTxActive etc, we must handle this function as a critical region.
354  */
355  INT_Disable();
356 
357  if (!usbRxActive)
358  {
359  /* usbRxActive = false means that an USB receive packet has been received.*/
360  DMA_ActivateBasic(CDC_UART_TX_DMA_CHANNEL, true, false,
361  (void *) &(CDC_UART->TXDATA),
362  (void *) usbRxBuffer[ usbRxIndex ^ 1 ],
363  usbBytesReceived - 1);
364 
365  /* Start a new USB receive transfer. */
366  usbRxActive = true;
367  USBD_Read(CDC_EP_DATA_OUT, (void*) usbRxBuffer[ usbRxIndex ],
368  CDC_USB_RX_BUF_SIZ, UsbDataReceived);
369  }
370  else
371  {
372  /* The USB receive complete callback function will start a new DMA. */
373  dmaTxActive = false;
374  }
375 
376  INT_Enable();
377 }
378 
379 /**************************************************************************/
389 static int UsbDataTransmitted(USB_Status_TypeDef status,
390  uint32_t xferred,
391  uint32_t remaining)
392 {
393  (void) xferred; /* Unused parameter. */
394  (void) remaining; /* Unused parameter. */
395 
396  if (status == USB_STATUS_OK)
397  {
398  if (!dmaRxActive)
399  {
400  /* dmaRxActive = false means that a new UART Rx DMA can be started. */
401 
402  USBD_Write(CDC_EP_DATA_IN, (void*) uartRxBuffer[ uartRxIndex ^ 1],
403  uartRxCount, UsbDataTransmitted);
404  LastUsbTxCnt = uartRxCount;
405 
406  dmaRxActive = true;
407  dmaRxCompleted = true;
408  DMA_ActivateBasic(CDC_UART_RX_DMA_CHANNEL, true, false,
409  (void *) uartRxBuffer[ uartRxIndex ],
410  (void *) &(CDC_UART->RXDATA),
411  CDC_USB_TX_BUF_SIZ - 1);
412  uartRxCount = 0;
413  USBTIMER_Start(CDC_TIMER_ID, CDC_RX_TIMEOUT, UartRxTimeout);
414  }
415  else
416  {
417  /* The UART receive DMA callback function will start a new DMA. */
418  usbTxActive = false;
419  }
420  }
421  return USB_STATUS_OK;
422 }
423 
424 /**************************************************************************/
431 static void DmaRxComplete(unsigned int channel, bool primary, void *user)
432 {
433  (void) channel; /* Unused parameter. */
434  (void) primary; /* Unused parameter. */
435  (void) user; /* Unused parameter. */
436 
437  /*
438  * As nested interrupts may occur and we rely on variables usbTxActive
439  * and dmaRxActive etc, we must handle this function as a critical region.
440  */
441  INT_Disable();
442 
443  uartRxIndex ^= 1;
444 
445  if (dmaRxCompleted)
446  {
447  uartRxCount = CDC_USB_TX_BUF_SIZ;
448  }
449  else
450  {
451  uartRxCount = CDC_USB_TX_BUF_SIZ - 1 -
454  }
455 
456  if (!usbTxActive)
457  {
458  /* usbTxActive = false means that a new USB packet can be transferred. */
459  usbTxActive = true;
460  USBD_Write(CDC_EP_DATA_IN, (void*) uartRxBuffer[ uartRxIndex ^ 1],
461  uartRxCount, UsbDataTransmitted);
462  LastUsbTxCnt = uartRxCount;
463 
464  /* Start a new UART receive DMA. */
465  dmaRxCompleted = true;
466  DMA_ActivateBasic(CDC_UART_RX_DMA_CHANNEL, true, false,
467  (void *) uartRxBuffer[ uartRxIndex ],
468  (void *) &(CDC_UART->RXDATA),
469  CDC_USB_TX_BUF_SIZ - 1);
470  uartRxCount = 0;
471  USBTIMER_Start(CDC_TIMER_ID, CDC_RX_TIMEOUT, UartRxTimeout);
472  }
473  else
474  {
475  /* The USB transmit complete callback function will start a new DMA. */
476  dmaRxActive = false;
477  USBTIMER_Stop(CDC_TIMER_ID);
478  }
479 
480  INT_Enable();
481 }
482 
483 /**************************************************************************/
490 static void UartRxTimeout(void)
491 {
492  int cnt;
493  uint32_t dmaCtrl;
494 
495  dmaCtrl = dmaControlBlock[ 1 ].CTRL;
496 
497  /* Has the DMA just completed ? */
499  {
500  return;
501  }
502 
503  cnt = CDC_USB_TX_BUF_SIZ - 1 -
505 
506  if ((cnt == 0) && (LastUsbTxCnt == CDC_BULK_EP_SIZE))
507  {
508  /*
509  * No activity on UART Rx, send a ZERO length USB package if last USB
510  * USB package sent was CDC_BULK_EP_SIZE (max. EP size) long.
511  */
512  /* Stop Rx DMA channel. */
513  DMA->CHENC = 1 << CDC_UART_RX_DMA_CHANNEL;
514  dmaRxCompleted = false;
515  /* Call DMA completion callback. */
516  DmaRxComplete(CDC_UART_RX_DMA_CHANNEL, true, NULL);
517  return;
518  }
519 
520  if ((cnt > 0) && (cnt == uartRxCount))
521  {
522  /*
523  * There is curently no activity on UART Rx but some chars have been
524  * received. Stop DMA and transmit the chars we have got so far on USB.
525  */
526  /* Stop Rx DMA channel. */
527  DMA->CHENC = 1 << CDC_UART_RX_DMA_CHANNEL;
528  dmaRxCompleted = false;
529  /* Call DMA completion callback. */
530  DmaRxComplete(CDC_UART_RX_DMA_CHANNEL, true, NULL);
531  return;
532  }
533 
534  /* Restart timer to continue monitoring. */
535  uartRxCount = cnt;
536  USBTIMER_Start(CDC_TIMER_ID, CDC_RX_TIMEOUT, UartRxTimeout);
537 }
538 
539 /**************************************************************************/
551 static int LineCodingReceived(USB_Status_TypeDef status,
552  uint32_t xferred,
553  uint32_t remaining)
554 {
555  uint32_t frame = 0;
556  (void) remaining;
557 
558  /* We have received new serial port communication settings from USB host. */
559  if ((status == USB_STATUS_OK) && (xferred == 7))
560  {
561  /* Check bDataBits, valid values are: 5, 6, 7, 8 or 16 bits. */
562  if (cdcLineCoding.bDataBits == 5)
563  frame |= USART_FRAME_DATABITS_FIVE;
564 
565  else if (cdcLineCoding.bDataBits == 6)
566  frame |= USART_FRAME_DATABITS_SIX;
567 
568  else if (cdcLineCoding.bDataBits == 7)
570 
571  else if (cdcLineCoding.bDataBits == 8)
573 
574  else if (cdcLineCoding.bDataBits == 16)
576 
577  else
578  return USB_STATUS_REQ_ERR;
579 
580  /* Check bParityType, valid values are: 0=None 1=Odd 2=Even 3=Mark 4=Space */
581  if (cdcLineCoding.bParityType == 0)
582  frame |= USART_FRAME_PARITY_NONE;
583 
584  else if (cdcLineCoding.bParityType == 1)
585  frame |= USART_FRAME_PARITY_ODD;
586 
587  else if (cdcLineCoding.bParityType == 2)
588  frame |= USART_FRAME_PARITY_EVEN;
589 
590  else if (cdcLineCoding.bParityType == 3)
591  return USB_STATUS_REQ_ERR;
592 
593  else if (cdcLineCoding.bParityType == 4)
594  return USB_STATUS_REQ_ERR;
595 
596  else
597  return USB_STATUS_REQ_ERR;
598 
599  /* Check bCharFormat, valid values are: 0=1 1=1.5 2=2 stop bits */
600  if (cdcLineCoding.bCharFormat == 0)
601  frame |= USART_FRAME_STOPBITS_ONE;
602 
603  else if (cdcLineCoding.bCharFormat == 1)
605 
606  else if (cdcLineCoding.bCharFormat == 2)
607  frame |= USART_FRAME_STOPBITS_TWO;
608 
609  else
610  return USB_STATUS_REQ_ERR;
611 
612  /* Program new UART baudrate etc. */
613  CDC_UART->FRAME = frame;
614  USART_BaudrateAsyncSet(CDC_UART, 0, cdcLineCoding.dwDTERate, usartOVS16);
615 
616  return USB_STATUS_OK;
617  }
618  return USB_STATUS_REQ_ERR;
619 }
620 
621 /**************************************************************************/
624 static void DmaSetup(void)
625 {
626  /* DMA configuration structs. */
627  DMA_Init_TypeDef dmaInit;
628  DMA_CfgChannel_TypeDef chnlCfgTx, chnlCfgRx;
629  DMA_CfgDescr_TypeDef descrCfgTx, descrCfgRx;
630 
631  /* Initialize the DMA. */
632  dmaInit.hprot = 0;
633  dmaInit.controlBlock = dmaControlBlock;
634  DMA_Init(&dmaInit);
635 
636  /*---------- Configure DMA channel for UART Tx. ----------*/
637 
638  /* Setup the interrupt callback routine */
639  DmaTxCallBack.cbFunc = DmaTxComplete;
640  DmaTxCallBack.userPtr = NULL;
641 
642  /* Setup the channel */
643  chnlCfgTx.highPri = false; /* Can't use with peripherals. */
644  chnlCfgTx.enableInt = true; /* Interrupt needed when buffers are used. */
645  chnlCfgTx.select = CDC_TX_DMA_SIGNAL;
646  chnlCfgTx.cb = &DmaTxCallBack;
647  DMA_CfgChannel(CDC_UART_TX_DMA_CHANNEL, &chnlCfgTx);
648 
649  /* Setup channel descriptor. */
650  /* Destination is UART Tx data register and doesn't move. */
651  descrCfgTx.dstInc = dmaDataIncNone;
652  descrCfgTx.srcInc = dmaDataInc1;
653  descrCfgTx.size = dmaDataSize1;
654 
655  /* We have time to arbitrate again for each sample. */
656  descrCfgTx.arbRate = dmaArbitrate1;
657  descrCfgTx.hprot = 0;
658 
659  /* Configure primary descriptor. */
660  DMA_CfgDescr(CDC_UART_TX_DMA_CHANNEL, true, &descrCfgTx);
661 
662  /*---------- Configure DMA channel for UART Rx. ----------*/
663 
664  /* Setup the interrupt callback routine. */
665  DmaRxCallBack.cbFunc = DmaRxComplete;
666  DmaRxCallBack.userPtr = NULL;
667 
668  /* Setup the channel */
669  chnlCfgRx.highPri = false; /* Can't use with peripherals. */
670  chnlCfgRx.enableInt = true; /* Interrupt needed when buffers are used. */
671  chnlCfgRx.select = CDC_RX_DMA_SIGNAL;
672  chnlCfgRx.cb = &DmaRxCallBack;
673  DMA_CfgChannel(CDC_UART_RX_DMA_CHANNEL, &chnlCfgRx);
674 
675  /* Setup channel descriptor. */
676  /* Source is UART Rx data register and doesn't move. */
677  descrCfgRx.dstInc = dmaDataInc1;
678  descrCfgRx.srcInc = dmaDataIncNone;
679  descrCfgRx.size = dmaDataSize1;
680 
681  /* We have time to arbitrate again for each sample. */
682  descrCfgRx.arbRate = dmaArbitrate1;
683  descrCfgRx.hprot = 0;
684 
685  /* Configure primary descriptor. */
686  DMA_CfgDescr(CDC_UART_RX_DMA_CHANNEL, true, &descrCfgRx);
687 }
688 
689 /**************************************************************************/
692 static void SerialPortInit(void)
693 {
695 
696  /* Configure GPIO pins. */
698  /* To avoid false start, configure output as high. */
699  GPIO_PinModeSet(CDC_UART_TX_PORT, CDC_UART_TX_PIN, gpioModePushPull, 1);
700  GPIO_PinModeSet(CDC_UART_RX_PORT, CDC_UART_RX_PIN, gpioModeInput, 0);
701 
702  /* Enable DK mainboard RS232/UART switch. */
703  CDC_ENABLE_DK_UART_SWITCH();
704 
705  /* Enable peripheral clocks. */
707  CMU_ClockEnable(CDC_UART_CLOCK, true);
708 
709  /* Configure UART for basic async operation. */
710  init.enable = usartDisable;
711  USART_InitAsync(CDC_UART, &init);
712 
713  /* Enable Tx/Rx pins and set correct UART location. */
714  CDC_UART->ROUTE = CDC_UART_ROUTE;
715 
716  /* Finally enable it */
717  USART_Enable(CDC_UART, usartEnable);
718 }
719 
Clock management unit (CMU) API.
Board support package API definitions.
uint8_t hprot
Definition: em_dma.h:335
#define USART_FRAME_DATABITS_SIX
DMA_ArbiterConfig_TypeDef arbRate
Definition: em_dma.h:231
#define _DMA_CTRL_N_MINUS_1_MASK
#define USART_FRAME_DATABITS_SIXTEEN
#define USART_FRAME_PARITY_ODD
DMA_DataInc_TypeDef dstInc
Definition: em_dma.h:219
Callback structure that can be used to define DMA complete actions.
Definition: em_dma.h:148
void CDC_Init(void)
CDC device initialization.
Definition: cdc.c:166
#define DMA_CTRL_CYCLE_CTRL_INVALID
__STATIC_INLINE uint32_t INT_Enable(void)
Enable interrupts.
Definition: em_int.h:94
#define EFM32_PACK_START(x)
Definition: em_common.h:88
DMA_CB_TypeDef * cb
User definable callback handling configuration.
Definition: em_dma.h:208
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define USART_FRAME_STOPBITS_ONEANDAHALF
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
USART_Enable_TypeDef enable
Definition: em_usart.h:253
Emlib general purpose utilities.
void CDC_StateChangeEvent(USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
Callback function called each time the USB device state is changed. Starts CDC operation when device ...
Definition: cdc.c:240
#define EFM32_PACK_END()
Definition: em_common.h:95
#define USART_FRAME_DATABITS_SEVEN
int CDC_SetupCmd(const USB_Setup_TypeDef *setup)
Handle USB setup commands. Implements CDC class specific commands.
Definition: cdc.c:182
void DMA_ActivateBasic(unsigned int channel, bool primary, bool useBurst, void *dst, void *src, unsigned int nMinus1)
Activate DMA basic cycle (used for memory-peripheral transfers).
Definition: em_dma.c:454
void GPIO_PinModeSet(GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
Set the mode for a GPIO pin.
Definition: em_gpio.c:226
#define _DMA_CTRL_N_MINUS_1_SHIFT
General Purpose IO (GPIO) peripheral API.
void DMA_Init(DMA_Init_TypeDef *init)
Initializes DMA controller.
Definition: em_dma.c:1033
void DMA_CfgChannel(unsigned int channel, DMA_CfgChannel_TypeDef *cfg)
Configure a DMA channel.
Definition: em_dma.c:706
DMA_DESCRIPTOR_TypeDef dmaControlBlock[DMACTRL_CH_CNT *2]
Definition: dmactrl.c:48
DMA_DataSize_TypeDef size
Definition: em_dma.h:225
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
Definition: em_cmu.c:1369
#define DMA
#define USART_FRAME_DATABITS_FIVE
DMA_DataInc_TypeDef srcInc
Definition: em_dma.h:222
#define USART_FRAME_STOPBITS_TWO
DMA_DESCRIPTOR_TypeDef * controlBlock
Definition: em_dma.h:352
void * userPtr
Definition: em_dma.h:158
#define USART_FRAME_PARITY_NONE
#define USART_INITASYNC_DEFAULT
Definition: em_usart.h:331
DMA_FuncPtr_TypeDef cbFunc
Definition: em_dma.h:155
#define EFM32_ALIGN(X)
Definition: em_common.h:103
#define USART_FRAME_DATABITS_EIGHT
USB Communication Device Class (CDC) driver.
__STATIC_INLINE uint32_t INT_Disable(void)
Disable interrupts.
Definition: em_int.h:71
void USART_Enable(USART_TypeDef *usart, USART_Enable_TypeDef enable)
Enable/disable USART/UART receiver and/or transmitter.
Definition: em_usart.c:541
#define USART_FRAME_PARITY_EVEN
#define USART_FRAME_STOPBITS_ONE
void USART_InitAsync(USART_TypeDef *usart, const USART_InitAsync_TypeDef *init)
Init USART/UART for normal asynchronous mode.
Definition: em_usart.c:583
#define _DMA_CTRL_CYCLE_CTRL_MASK
Direct memory access (DMA) API.
DMA control data block.
void DMA_CfgDescr(unsigned int channel, bool primary, DMA_CfgDescr_TypeDef *cfg)
Configure DMA descriptor for auto-request, basic or ping-pong DMA cycles.
Definition: em_dma.c:781
void USART_BaudrateAsyncSet(USART_TypeDef *usart, uint32_t refFreq, uint32_t baudrate, USART_OVS_TypeDef ovs)
Configure USART/UART operating in asynchronous mode to use a given baudrate (or as close as possible ...
Definition: em_usart.c:162