00001
00035 #include <string.h>
00036 #include "em_device.h"
00037 #include "em_cmu.h"
00038 #include "em_gpio.h"
00039 #include "bsp.h"
00040 #if defined( BSP_STK_USE_EBI )
00041 #include "em_ebi.h"
00042 #endif
00043
00044 #if defined( BSP_STK )
00045
00046
00047
00052
00058
00064 int BSP_Disable(void)
00065 {
00066 BSP_BccDeInit();
00067 BSP_EbiDeInit();
00068
00069 return BSP_STATUS_OK;
00070 }
00073
00081 int BSP_EbiInit(void)
00082 {
00083 #if defined( BSP_STK_USE_EBI )
00084
00085
00086
00087
00088
00089 EBI_Init_TypeDef ebiConfig =
00090 { ebiModeD8A8,
00091 ebiActiveLow,
00092 ebiActiveLow,
00093 ebiActiveLow,
00094 ebiActiveLow,
00095 ebiActiveLow,
00096 ebiActiveLow,
00097 false,
00098 true,
00099 false,
00100 true,
00101 EBI_BANK0,
00102 0,
00103 0,
00104 0,
00105 false,
00106 0,
00107 2,
00108 1,
00109 false,
00110 false,
00111 false,
00112 0,
00113 2,
00114 1,
00115 false,
00116 false,
00117 ebiALowA24,
00118 ebiAHighA26,
00119 ebiLocation1,
00120 true,
00121 };
00122
00123
00124 CMU_ClockEnable(cmuClock_HFPER, true);
00125 CMU_ClockEnable(cmuClock_GPIO, true);
00126 CMU_ClockEnable(cmuClock_EBI, true);
00127
00128
00129
00130 GPIO_PinModeSet(gpioPortC, 1, gpioModePushPull, 0);
00131 GPIO_PinModeSet(gpioPortC, 2, gpioModePushPull, 0);
00132
00133
00134 GPIO_PinModeSet(gpioPortD, 13, gpioModePushPull, 0);
00135 GPIO_PinModeSet(gpioPortD, 14, gpioModePushPull, 1);
00136 GPIO_PinModeSet(gpioPortD, 15, gpioModeInput, 0);
00137
00138
00139 GPIO_PinModeSet(gpioPortE, 8, gpioModePushPull, 0);
00140 GPIO_PinModeSet(gpioPortE, 9, gpioModePushPull, 0);
00141 GPIO_PinModeSet(gpioPortE, 10, gpioModePushPull, 0);
00142 GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
00143 GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
00144 GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 0);
00145 GPIO_PinModeSet(gpioPortE, 14, gpioModePushPull, 0);
00146 GPIO_PinModeSet(gpioPortE, 15, gpioModePushPull, 0);
00147
00148
00149 GPIO_PinModeSet(gpioPortF, 8, gpioModePushPull, 1);
00150 GPIO_PinModeSet(gpioPortF, 9, gpioModePushPull, 1);
00151
00152
00153 GPIO_PinModeSet(gpioPortB, 15, gpioModePushPull, 1);
00154
00155 EBI_Init(&ebiConfig);
00156 EBI->NANDCTRL = (EBI_NANDCTRL_BANKSEL_BANK0 | EBI_NANDCTRL_EN);
00157
00158 return BSP_STATUS_OK;
00159 #else
00160 return BSP_STATUS_NOT_IMPLEMENTED;
00161 #endif
00162 }
00163
00164
00174 int BSP_EbiDeInit( void )
00175 {
00176 #if defined( BSP_STK_USE_EBI )
00177 return BSP_STATUS_OK;
00178 #else
00179 return BSP_STATUS_NOT_IMPLEMENTED;
00180 #endif
00181 }
00182
00184
00192 int BSP_Init( uint32_t flags )
00193 {
00194 if ( flags & BSP_INIT_BCC )
00195 {
00196 BSP_BccInit();
00197 }
00198
00199 return BSP_STATUS_OK;
00200 }
00203
00213 float BSP_CurrentGet( void )
00214 {
00215 BCP_Packet pkt;
00216 float *pcurrent;
00217
00218 pkt.type = BSP_BCP_CURRENT_REQ;
00219 pkt.payloadLength = 0;
00220
00221
00222 BSP_BccPacketSend( &pkt );
00223 BSP_BccPacketReceive( &pkt );
00224
00225
00226 pcurrent = (float *)pkt.data;
00227 if ( pkt.type != BSP_BCP_CURRENT_REPLY )
00228 {
00229 *pcurrent = 0.0f;
00230 }
00231
00232 return *pcurrent;
00233 }
00234
00235
00245 float BSP_VoltageGet( void )
00246 {
00247 BCP_Packet pkt;
00248 float *pvoltage;
00249
00250 pkt.type = BSP_BCP_VOLTAGE_REQ;
00251 pkt.payloadLength = 0;
00252
00253
00254 BSP_BccPacketSend( &pkt );
00255 BSP_BccPacketReceive( &pkt );
00256
00257
00258 pvoltage = (float *)pkt.data;
00259 if ( pkt.type != BSP_BCP_VOLTAGE_REPLY )
00260 {
00261 *pvoltage = 0.0f;
00262 }
00263
00264 return *pvoltage;
00265 }
00266
00270 #endif