bsp_dk_mcuboard.c
Go to the documentation of this file.00001
00018 #include <stdbool.h>
00019 #include "bsp.h"
00020 #include "em_gpio.h"
00021 #include "em_cmu.h"
00022
00023
00028
00033
00037 int BSP_McuBoard_DeInit( void )
00038 {
00039 #ifdef BSP_MCUBOARD_USB
00040
00041 GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModeDisabled, 0 );
00042 GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeDisabled, 0 );
00043 GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModeDisabled, 0 );
00044 #endif
00045
00046 return BSP_STATUS_OK;
00047 }
00048
00049
00053 int BSP_McuBoard_Init( void )
00054 {
00055 #ifdef BSP_MCUBOARD_USB
00056
00057 CMU_ClockEnable( cmuClock_GPIO, true );
00058
00059
00060 GPIO_PinModeSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN, gpioModePushPull, 0 );
00061
00062
00063 GPIO_PinModeSet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN, gpioModeInput, 0 );
00064
00065
00066 GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, 0 );
00067 #endif
00068
00069 return BSP_STATUS_OK;
00070 }
00071
00072
00078 int BSP_McuBoard_UsbStatusLedEnable( bool enable )
00079 {
00080 #ifdef BSP_MCUBOARD_USB
00081 if ( enable )
00082 {
00083 GPIO_PinOutSet( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
00084 }
00085 else
00086 {
00087 GPIO_PinOutClear( BSP_USB_STATUSLED_PORT, BSP_USB_STATUSLED_PIN );
00088 }
00089
00090 return BSP_STATUS_OK;
00091 #else
00092
00093 (void)enable;
00094 return BSP_STATUS_NOT_IMPLEMENTED;
00095 #endif
00096 }
00097
00098
00102 bool BSP_McuBoard_UsbVbusOcFlagGet( void )
00103 {
00104 #ifdef BSP_MCUBOARD_USB
00105 bool flag;
00106
00107 if ( !GPIO_PinInGet( BSP_USB_OCFLAG_PORT, BSP_USB_OCFLAG_PIN ) )
00108 {
00109 flag = true;
00110 }
00111 else
00112 {
00113 flag = false;
00114 }
00115
00116 return flag;
00117 #else
00118
00119 return false;
00120 #endif
00121 }
00122
00123
00129 int BSP_McuBoard_UsbVbusPowerEnable( bool enable )
00130 {
00131 #ifdef BSP_MCUBOARD_USB
00132 GPIO_PinModeSet( BSP_USB_VBUSEN_PORT, BSP_USB_VBUSEN_PIN, gpioModePushPull, enable );
00133
00134 return BSP_STATUS_OK;
00135 #else
00136
00137 (void)enable;
00138 return BSP_STATUS_NOT_IMPLEMENTED;
00139 #endif
00140 }
00141