00001
00018 #include <string.h>
00019 #include "em_device.h"
00020 #include "em_cmu.h"
00021 #include "em_gpio.h"
00022 #include "bsp.h"
00023 #if defined( BSP_STK_USE_EBI )
00024 #include "em_ebi.h"
00025 #endif
00026
00027 #if defined( BSP_STK )
00028
00029
00030
00035
00041
00047 int BSP_Disable(void)
00048 {
00049 BSP_BccDeInit();
00050 BSP_EbiDeInit();
00051
00052 return BSP_STATUS_OK;
00053 }
00056
00064 int BSP_EbiInit(void)
00065 {
00066 #if defined( BSP_STK_USE_EBI )
00067
00068
00069
00070
00071
00072 EBI_Init_TypeDef ebiConfig =
00073 { ebiModeD8A8,
00074 ebiActiveLow,
00075 ebiActiveLow,
00076 ebiActiveLow,
00077 ebiActiveLow,
00078 ebiActiveLow,
00079 ebiActiveLow,
00080 false,
00081 true,
00082 false,
00083 true,
00084 EBI_BANK0,
00085 0,
00086 0,
00087 0,
00088 false,
00089 0,
00090 2,
00091 1,
00092 false,
00093 false,
00094 false,
00095 0,
00096 2,
00097 1,
00098 false,
00099 false,
00100 ebiALowA24,
00101 ebiAHighA26,
00102 ebiLocation1,
00103 true,
00104 };
00105
00106
00107 CMU_ClockEnable(cmuClock_HFPER, true);
00108 CMU_ClockEnable(cmuClock_GPIO, true);
00109 CMU_ClockEnable(cmuClock_EBI, true);
00110
00111
00112
00113 GPIO_PinModeSet(gpioPortC, 1, gpioModePushPull, 0);
00114 GPIO_PinModeSet(gpioPortC, 2, gpioModePushPull, 0);
00115
00116
00117 GPIO_PinModeSet(gpioPortD, 13, gpioModePushPull, 0);
00118 GPIO_PinModeSet(gpioPortD, 14, gpioModePushPull, 1);
00119 GPIO_PinModeSet(gpioPortD, 15, gpioModeInput, 0);
00120
00121
00122 GPIO_PinModeSet(gpioPortE, 8, gpioModePushPull, 0);
00123 GPIO_PinModeSet(gpioPortE, 9, gpioModePushPull, 0);
00124 GPIO_PinModeSet(gpioPortE, 10, gpioModePushPull, 0);
00125 GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
00126 GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
00127 GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 0);
00128 GPIO_PinModeSet(gpioPortE, 14, gpioModePushPull, 0);
00129 GPIO_PinModeSet(gpioPortE, 15, gpioModePushPull, 0);
00130
00131
00132 GPIO_PinModeSet(gpioPortF, 8, gpioModePushPull, 1);
00133 GPIO_PinModeSet(gpioPortF, 9, gpioModePushPull, 1);
00134
00135
00136 GPIO_PinModeSet(gpioPortB, 15, gpioModePushPull, 1);
00137
00138 EBI_Init(&ebiConfig);
00139 EBI->NANDCTRL = (EBI_NANDCTRL_BANKSEL_BANK0 | EBI_NANDCTRL_EN);
00140
00141 return BSP_STATUS_OK;
00142 #else
00143 return BSP_STATUS_NOT_IMPLEMENTED;
00144 #endif
00145 }
00146
00147
00157 int BSP_EbiDeInit( void )
00158 {
00159 #if defined( BSP_STK_USE_EBI )
00160 return BSP_STATUS_OK;
00161 #else
00162 return BSP_STATUS_NOT_IMPLEMENTED;
00163 #endif
00164 }
00165
00167
00175 int BSP_Init( uint32_t flags )
00176 {
00177 if ( flags & BSP_INIT_BCC )
00178 {
00179 BSP_BccInit();
00180 }
00181
00182 return BSP_STATUS_OK;
00183 }
00186
00196 float BSP_CurrentGet( void )
00197 {
00198 BCP_Packet pkt;
00199 float *pcurrent;
00200
00201 pkt.type = BSP_BCP_CURRENT_REQ;
00202 pkt.payloadLength = 0;
00203
00204
00205 BSP_BccPacketSend( &pkt );
00206 BSP_BccPacketReceive( &pkt );
00207
00208
00209 pcurrent = (float *)pkt.data;
00210 if ( pkt.type != BSP_BCP_CURRENT_REPLY )
00211 {
00212 *pcurrent = 0.0f;
00213 }
00214
00215 return *pcurrent;
00216 }
00217
00218
00228 float BSP_VoltageGet( void )
00229 {
00230 BCP_Packet pkt;
00231 float *pvoltage;
00232
00233 pkt.type = BSP_BCP_VOLTAGE_REQ;
00234 pkt.payloadLength = 0;
00235
00236
00237 BSP_BccPacketSend( &pkt );
00238 BSP_BccPacketReceive( &pkt );
00239
00240
00241 pvoltage = (float *)pkt.data;
00242 if ( pkt.type != BSP_BCP_VOLTAGE_REPLY )
00243 {
00244 *pvoltage = 0.0f;
00245 }
00246
00247 return *pvoltage;
00248 }
00249
00253 #endif