EFM32 Wonder Gecko Software Documentation  efm32wg-doc-5.1.2
bsp_dk_mcuboard.c
Go to the documentation of this file.
1 /***************************************************************************/
18 #include <stdbool.h>
19 #include "bsp.h"
20 #include "em_gpio.h"
21 #include "em_cmu.h"
22 
23 /***************************************************************************/
28 /***************************************************************************/
33 /**************************************************************************/
38 {
39 #ifdef BSP_MCUBOARD_USB
40  /* Disable GPIO port pin mode. */
41  GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModeDisabled, 0 );
42  GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeDisabled, 0 );
43  GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModeDisabled, 0 );
44 #endif
45 
46  return BSP_STATUS_OK;
47 }
48 
49 /**************************************************************************/
53 int BSP_McuBoard_Init( void )
54 {
55 #ifdef BSP_MCUBOARD_USB
56  /* Make sure that the CMU clock to the GPIO peripheral is enabled */
58 
59  /* USB status LED - configure PE1 as push pull */
60  GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModePushPull, 0 );
61 
62  /* USB PHY overcurrent status input */
63  GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeInput, 0 );
64 
65  /* USB VBUS switch - configure PF5 as push pull - Default OFF */
66  GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, 0 );
67 #endif
68 
69  return BSP_STATUS_OK;
70 }
71 
72 /**************************************************************************/
79 {
80 #ifdef BSP_MCUBOARD_USB
81  if ( enable )
82  {
83  GPIO_PinOutSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
84  }
85  else
86  {
87  GPIO_PinOutClear( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
88  }
89 
90  return BSP_STATUS_OK;
91 #else
92 
93  (void)enable;
95 #endif
96 }
97 
98 /**************************************************************************/
103 {
104 #ifdef BSP_MCUBOARD_USB
105  bool flag;
106 
107  if ( !GPIO_PinInGet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN ) )
108  {
109  flag = true;
110  }
111  else
112  {
113  flag = false;
114  }
115 
116  return flag;
117 #else
118 
119  return false;
120 #endif
121 }
122 
123 /**************************************************************************/
130 {
131 #ifdef BSP_MCUBOARD_USB
132  GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, enable );
133 
134  return BSP_STATUS_OK;
135 #else
136 
137  (void)enable;
139 #endif
140 }
141 
Clock management unit (CMU) API.
int BSP_McuBoard_Init(void)
Enable MCU plugin board peripherals.
Board support package API definitions.
int BSP_McuBoard_UsbVbusPowerEnable(bool enable)
Enable MCU plugin board VBUS power switch.
#define BSP_STATUS_OK
Definition: bsp.h:45
bool BSP_McuBoard_UsbVbusOcFlagGet(void)
Get state MCU plugin board VBUS overcurrent flag.
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 BSP_STATUS_NOT_IMPLEMENTED
Definition: bsp.h:47
General Purpose IO (GPIO) peripheral API.
int BSP_McuBoard_DeInit(void)
Disable MCU plugin board peripherals.
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out register to 1.
Definition: em_gpio.h:856
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
Definition: em_cmu.c:1453
__STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out port register to 0.
Definition: em_gpio.h:811
__STATIC_INLINE unsigned int GPIO_PinInGet(GPIO_Port_TypeDef port, unsigned int pin)
Read the pad value for a single pin in a GPIO port.
Definition: em_gpio.h:781
int BSP_McuBoard_UsbStatusLedEnable(bool enable)
Set state of MCU plugin board USB status LED.