1 /***************************************************************************//**
\r
3 * @brief Board support package API implementation STK's.
\r
5 *******************************************************************************
\r
7 * <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
\r
8 *******************************************************************************
\r
10 * This file is licensed under the Silabs License Agreement. See the file
\r
11 * "Silabs_License_Agreement.txt" for details. Before using this software for
\r
12 * any purpose, you must agree to the terms of that agreement.
\r
14 ******************************************************************************/
\r
19 #include "em_device.h"
\r
21 #include "em_gpio.h"
\r
23 #if defined( BSP_STK_USE_EBI )
\r
27 #if defined( BSP_STK )
\r
30 /***************************************************************************//**
\r
33 ******************************************************************************/
\r
35 /***************************************************************************//**
\r
36 * @addtogroup BSP_STK API for STK's
\r
38 ******************************************************************************/
\r
40 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
\r
41 /**************************************************************************//**
\r
42 * @brief Deinitialize board support package functionality.
\r
43 * Reverse actions performed by @ref BSP_Init().
\r
45 * @return @ref BSP_STATUS_OK.
\r
46 *****************************************************************************/
\r
47 int BSP_Disable(void)
\r
52 return BSP_STATUS_OK;
\r
56 /**************************************************************************//**
\r
57 * @brief Initialize the EBI interface for accessing the onboard nandflash.
\r
59 * @note This function is not relevant for Gxxx_STK's.
\r
62 * @ref BSP_STATUS_OK or @ref BSP_STATUS_NOT_IMPLEMENTED
\r
63 *****************************************************************************/
\r
64 int BSP_EbiInit(void)
\r
66 #if defined( BSP_STK_USE_EBI )
\r
67 /* ------------------------------------------ */
\r
68 /* NAND Flash, Bank0, Base Address 0x80000000 */
\r
69 /* Micron flash NAND256W3A */
\r
70 /* ------------------------------------------ */
\r
72 EBI_Init_TypeDef ebiConfig =
\r
73 { ebiModeD8A8, /* 8 bit address, 8 bit data */
\r
74 ebiActiveLow, /* ARDY polarity */
\r
75 ebiActiveLow, /* ALE polarity */
\r
76 ebiActiveLow, /* WE polarity */
\r
77 ebiActiveLow, /* RE polarity */
\r
78 ebiActiveLow, /* CS polarity */
\r
79 ebiActiveLow, /* BL polarity */
\r
80 false, /* disble BL */
\r
81 true, /* enable NOIDLE */
\r
82 false, /* disable ARDY */
\r
83 true, /* disable ARDY timeout */
\r
84 EBI_BANK0, /* enable bank 0 */
\r
85 0, /* no chip select */
\r
86 0, /* addr setup cycles */
\r
87 0, /* addr hold cycles */
\r
88 false, /* disable half cycle ALE strobe */
\r
89 0, /* read setup cycles */
\r
90 2, /* read strobe cycles */
\r
91 1, /* read hold cycles */
\r
92 false, /* disable page mode */
\r
93 false, /* disable prefetch */
\r
94 false, /* disable half cycle REn strobe */
\r
95 0, /* write setup cycles */
\r
96 2, /* write strobe cycles */
\r
97 1, /* write hold cycles */
\r
98 false, /* enable the write buffer */
\r
99 false, /* disable half cycle WEn strobe */
\r
100 ebiALowA24, /* ALB - Low bound, address lines */
\r
101 ebiAHighA26, /* APEN - High bound, address lines */
\r
102 ebiLocation1, /* Use Location 1 */
\r
103 true, /* enable EBI */
\r
106 /* Enable clocks */
\r
107 CMU_ClockEnable(cmuClock_HFPER, true);
\r
108 CMU_ClockEnable(cmuClock_GPIO, true);
\r
109 CMU_ClockEnable(cmuClock_EBI, true);
\r
111 /* Enable GPIO's */
\r
113 GPIO_PinModeSet(gpioPortC, 1, gpioModePushPull, 0);
\r
114 GPIO_PinModeSet(gpioPortC, 2, gpioModePushPull, 0);
\r
116 /* WP, CE and R/B */
\r
117 GPIO_PinModeSet(gpioPortD, 13, gpioModePushPull, 0); /* active low write-protect */
\r
118 GPIO_PinModeSet(gpioPortD, 14, gpioModePushPull, 1); /* active low chip-enable */
\r
119 GPIO_PinModeSet(gpioPortD, 15, gpioModeInput, 0); /* ready/busy */
\r
122 GPIO_PinModeSet(gpioPortE, 8, gpioModePushPull, 0);
\r
123 GPIO_PinModeSet(gpioPortE, 9, gpioModePushPull, 0);
\r
124 GPIO_PinModeSet(gpioPortE, 10, gpioModePushPull, 0);
\r
125 GPIO_PinModeSet(gpioPortE, 11, gpioModePushPull, 0);
\r
126 GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
\r
127 GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 0);
\r
128 GPIO_PinModeSet(gpioPortE, 14, gpioModePushPull, 0);
\r
129 GPIO_PinModeSet(gpioPortE, 15, gpioModePushPull, 0);
\r
132 GPIO_PinModeSet(gpioPortF, 8, gpioModePushPull, 1);
\r
133 GPIO_PinModeSet(gpioPortF, 9, gpioModePushPull, 1);
\r
135 /* NAND Power Enable */
\r
136 GPIO_PinModeSet(gpioPortB, 15, gpioModePushPull, 1);
\r
138 EBI_Init(&ebiConfig);
\r
139 EBI->NANDCTRL = (EBI_NANDCTRL_BANKSEL_BANK0 | EBI_NANDCTRL_EN);
\r
141 return BSP_STATUS_OK;
\r
143 return BSP_STATUS_NOT_IMPLEMENTED;
\r
147 /**************************************************************************//**
\r
148 * @brief Deinitialize the EBI interface for accessing the onboard nandflash.
\r
150 * @note This function is not relevant for Gxxx_STK's.
\r
151 * This function is provided for API completeness, it does not perform
\r
152 * an actual EBI deinitialization.
\r
155 * @ref BSP_STATUS_OK or @ref BSP_STATUS_NOT_IMPLEMENTED
\r
156 *****************************************************************************/
\r
157 int BSP_EbiDeInit( void )
\r
159 #if defined( BSP_STK_USE_EBI )
\r
160 return BSP_STATUS_OK;
\r
162 return BSP_STATUS_NOT_IMPLEMENTED;
\r
166 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
\r
167 /**************************************************************************//**
\r
168 * @brief Initialize board support package functionality.
\r
170 * @param[in] flags Initialization mask, use 0 or @ref BSP_INIT_BCC.
\r
173 * @ref BSP_STATUS_OK
\r
174 *****************************************************************************/
\r
175 int BSP_Init( uint32_t flags )
\r
177 if ( flags & BSP_INIT_BCC )
\r
182 return BSP_STATUS_OK;
\r
186 /**************************************************************************//**
\r
187 * @brief Request AEM (Advanced Energy Monitoring) current from board controller.
\r
189 * @note Assumes that BSP_Init() has been called with @ref BSP_INIT_BCC
\r
193 * The current expressed in milliamperes. Returns 0.0 on board controller
\r
194 * communication error.
\r
195 *****************************************************************************/
\r
196 float BSP_CurrentGet( void )
\r
201 pkt.type = BSP_BCP_CURRENT_REQ;
\r
202 pkt.payloadLength = 0;
\r
204 /* Send Request/Get reply */
\r
205 BSP_BccPacketSend( &pkt );
\r
206 BSP_BccPacketReceive( &pkt );
\r
208 /* Process reply */
\r
209 pcurrent = (float *)pkt.data;
\r
210 if ( pkt.type != BSP_BCP_CURRENT_REPLY )
\r
218 /**************************************************************************//**
\r
219 * @brief Request AEM (Advanced Energy Monitoring) voltage from board controller.
\r
221 * @note Assumes that BSP_Init() has been called with @ref BSP_INIT_BCC
\r
225 * The voltage. Returns 0.0 on board controller communication
\r
227 *****************************************************************************/
\r
228 float BSP_VoltageGet( void )
\r
233 pkt.type = BSP_BCP_VOLTAGE_REQ;
\r
234 pkt.payloadLength = 0;
\r
236 /* Send Request/Get reply */
\r
237 BSP_BccPacketSend( &pkt );
\r
238 BSP_BccPacketReceive( &pkt );
\r
240 /* Process reply */
\r
241 pvoltage = (float *)pkt.data;
\r
242 if ( pkt.type != BSP_BCP_VOLTAGE_REPLY )
\r
250 /** @} (end group BSP_STK) */
\r
251 /** @} (end group BSP) */
\r
253 #endif /* BSP_STK */
\r