bsp_dk_mcuboard.c
Go to the documentation of this file.00001
00035 #include <stdbool.h>
00036 #include "bsp.h"
00037 #include "em_gpio.h"
00038 #include "em_cmu.h"
00039
00040
00045
00050
00054 int BSP_McuBoard_DeInit( void )
00055 {
00056 #ifdef BSP_MCUBOARD_USB
00057
00058 GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModeDisabled, 0 );
00059 GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeDisabled, 0 );
00060 GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModeDisabled, 0 );
00061 #endif
00062
00063 return BSP_STATUS_OK;
00064 }
00065
00066
00070 int BSP_McuBoard_Init( void )
00071 {
00072 #ifdef BSP_MCUBOARD_USB
00073
00074 CMU_ClockEnable( cmuClock_GPIO, true );
00075
00076
00077 GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModePushPull, 0 );
00078
00079
00080 GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeInput, 0 );
00081
00082
00083 GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, 0 );
00084 #endif
00085
00086 return BSP_STATUS_OK;
00087 }
00088
00089
00095 int BSP_McuBoard_UsbStatusLedEnable( bool enable )
00096 {
00097 #ifdef BSP_MCUBOARD_USB
00098 if ( enable )
00099 {
00100 GPIO_PinOutSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
00101 }
00102 else
00103 {
00104 GPIO_PinOutClear( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
00105 }
00106
00107 return BSP_STATUS_OK;
00108 #else
00109
00110 (void)enable;
00111 return BSP_STATUS_NOT_IMPLEMENTED;
00112 #endif
00113 }
00114
00115
00119 bool BSP_McuBoard_UsbVbusOcFlagGet( void )
00120 {
00121 #ifdef BSP_MCUBOARD_USB
00122 bool flag;
00123
00124 if ( !GPIO_PinInGet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN ) )
00125 {
00126 flag = true;
00127 }
00128 else
00129 {
00130 flag = false;
00131 }
00132
00133 return flag;
00134 #else
00135
00136 return false;
00137 #endif
00138 }
00139
00140
00146 int BSP_McuBoard_UsbVbusPowerEnable( bool enable )
00147 {
00148 #ifdef BSP_MCUBOARD_USB
00149 GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, enable );
00150
00151 return BSP_STATUS_OK;
00152 #else
00153
00154 (void)enable;
00155 return BSP_STATUS_NOT_IMPLEMENTED;
00156 #endif
00157 }
00158