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