dvk.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /**************************************************************************//**
  2. * @file
  3. * @brief EFM32GG_DK3750 board support package API
  4. * @author Energy Micro AS
  5. * @version 2.0.1
  6. ******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2012 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * Permission is granted to anyone to use this software for any purpose,
  12. * including commercial applications, and to alter it and redistribute it
  13. * freely, subject to the following restrictions:
  14. *
  15. * 1. The origin of this software must not be misrepresented; you must not
  16. * claim that you wrote the original software.
  17. * 2. Altered source versions must be plainly marked as such, and must not be
  18. * misrepresented as being the original software.
  19. * 3. This notice may not be removed or altered from any source distribution.
  20. * 4. The source and compiled code may only be used on Energy Micro "EFM32"
  21. * microcontrollers and "EFR4" radios.
  22. *
  23. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  24. * obligation to support this Software. Energy Micro AS is providing the
  25. * Software "AS IS", with no express or implied warranties of any kind,
  26. * including, but not limited to, any implied warranties of merchantability
  27. * or fitness for any particular purpose or warranties against infringement
  28. * of any proprietary rights of a third party.
  29. *
  30. * Energy Micro AS will not be liable for any consequential, incidental, or
  31. * special damages, or any other relief, or for any claim by any third party,
  32. * arising from your use of this Software.
  33. *
  34. *****************************************************************************/
  35. #ifndef __DVK_H
  36. #define __DVK_H
  37. /***************************************************************************//**
  38. * @addtogroup BSP
  39. * @{
  40. ******************************************************************************/
  41. #include <stdbool.h>
  42. #include <stdint.h>
  43. #include "efm32.h"
  44. #include "dvk_bcregisters.h"
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. /** DVK board control access method */
  49. typedef enum
  50. {
  51. DVK_Init_EBI, /**< Use EBI to interface board control functionality */
  52. DVK_Init_SPI, /**< Use SPI to interface board control functionality */
  53. DVK_Init_DIRECT, /**< No board control, only GPIO */
  54. DVK_Init_OFF, /**< Disabled */
  55. } DVK_Init_TypeDef;
  56. extern DVK_Init_TypeDef dvkOperationMode;
  57. /** Bus control access */
  58. typedef enum
  59. {
  60. DVK_BusControl_OFF, /**< Board control disable */
  61. DVK_BusControl_DIRECT, /**< GPIO direct drive (n/a) */
  62. DVK_BusControl_SPI, /**< Configure Board controller for SPI mode */
  63. DVK_BusControl_EBI, /**< Configure Board controller for EBI mode */
  64. } DVK_BusControl_TypeDef;
  65. /** Display Control */
  66. typedef enum
  67. {
  68. DVK_Display_EBI, /**< SSD2119 TFT controller driven by EFM32GG EBI interface */
  69. DVK_Display_SPI, /**< SSD2119 TFT controller driven by EFM32GG SPI interface */
  70. DVK_Display_BC, /**< SSD2119 TFT controller driven by board controller (AEM) */
  71. DVK_Display_PowerEnable, /**< SSD2119 Enable power */
  72. DVK_Display_PowerDisable, /**< SSD2119 Disable power */
  73. DVK_Display_ResetAssert, /**< Hold SSD2119 in reset */
  74. DVK_Display_ResetRelease, /**< Release SSD2119 in reset */
  75. DVK_Display_Mode8080, /**< Configure SSD2119 for 8080 mode of operation */
  76. DVK_Display_ModeGeneric, /**< Configure SSD2119 for Generic+SPI mode of operation */
  77. } DVK_Display_TypeDef;
  78. /** SPI control */
  79. typedef enum
  80. {
  81. DVK_SPI_Audio, /**< Configure switchable SPI interface to Audio I2S */
  82. DVK_SPI_Ethernet, /**< Configure switchable SPI interface to Ethernet */
  83. DVK_SPI_Display, /**< Configure switchable SPI interface to SSD2119 */
  84. DVK_SPI_OFF, /**< Disable SPI interface */
  85. } DVK_SpiControl_TypeDef;
  86. /** Peripherals control structure */
  87. typedef enum
  88. {
  89. DVK_RS232_SHUTDOWN, /**< Disable RS232 */
  90. DVK_RS232_UART, /**< UART control of RS232 */
  91. DVK_RS232_LEUART, /**< LEUART control of RS232 */
  92. DVK_I2C, /**< I2C */
  93. DVK_ETH, /**< Ethernet */
  94. DVK_I2S, /**< Audio I2S */
  95. DVK_TRACE, /**< ETM Trace */
  96. DVK_TOUCH, /**< Display touch interface */
  97. DVK_AUDIO_IN, /**< Audio In */
  98. DVK_AUDIO_OUT, /**< Audio Out */
  99. DVK_ANALOG_DIFF, /**< Analog DIFF */
  100. DVK_ANALOG_SE, /**< Analog SE */
  101. DVK_MICROSD, /**< MicroSD SPI interace */
  102. DVK_TFT, /**< SSD2119 TFT controller */
  103. } DVK_Peripheral_TypeDef;
  104. /* Initalize DVK board for access to external PSRAM, Flash and BC registers */
  105. void DVK_init(DVK_Init_TypeDef mode);
  106. void DVK_disable(void);
  107. /* Board controller control API */
  108. void DVK_busControlMode(DVK_BusControl_TypeDef mode);
  109. void DVK_peripheralAccess(DVK_Peripheral_TypeDef perf, bool enable);
  110. void DVK_spiControl(DVK_SpiControl_TypeDef device);
  111. /* Board controller access function */
  112. uint16_t DVK_getPushButtons(void);
  113. uint16_t DVK_getJoystick(void);
  114. uint16_t DVK_getDipSwitch(void);
  115. void DVK_setLEDs(uint16_t leds);
  116. uint16_t DVK_getLEDs(void);
  117. /* Miscellaneous */
  118. void DVK_setEnergyMode(uint16_t energyMode);
  119. void DVK_displayControl(DVK_Display_TypeDef option);
  120. /* Board controller interrupt support */
  121. void DVK_enableInterrupt(uint16_t flags);
  122. void DVK_disableInterrupt(uint16_t flags);
  123. uint16_t DVK_getInterruptFlags(void);
  124. void DVK_clearInterruptFlags(uint16_t flags);
  125. /* EBI access */
  126. bool DVK_EBI_init(void);
  127. void DVK_EBI_disable(void);
  128. void DVK_EBI_extendedAddressRange(bool enable);
  129. __STATIC_INLINE void DVK_EBI_writeRegister(volatile uint16_t *addr, uint16_t data);
  130. __STATIC_INLINE uint16_t DVK_EBI_readRegister(volatile uint16_t *addr);
  131. /* SPI access */
  132. bool DVK_SPI_init(void);
  133. void DVK_SPI_disable(void);
  134. uint16_t DVK_SPI_readRegister(volatile uint16_t *addr);
  135. void DVK_SPI_writeRegister(volatile uint16_t *addr, uint16_t data);
  136. /* MCU-plug-in-board (BRD3600) API */
  137. void DVK_BRD3600A_init(void);
  138. void DVK_BRD3600A_deInit(void);
  139. void DVK_BRD3600A_usbStatusLEDEnable(int enable);
  140. void DVK_BRD3600A_usbVBUSSwitchEnable(int enable);
  141. int DVK_BRD3600A_usbVBUSGetOCFlagState(void);
  142. /* For "backward compatibility" with DVK */
  143. /** DVK_enablePeripheral() backward compatibility */
  144. #define DVK_enablePeripheral(X) DVK_peripheralAccess(X, true)
  145. /** DVK_disablePeripheral() backward compatibility */
  146. #define DVK_disablePeripheral(X) DVK_peripheralAccess(X, false)
  147. /**************************************************************************//**
  148. * @brief Write data into 16-bit board control register using mem.mapped EBI
  149. * @param addr Address of board controller register
  150. * @param data Data to write into register
  151. *****************************************************************************/
  152. __STATIC_INLINE void DVK_EBI_writeRegister(volatile uint16_t *addr, uint16_t data)
  153. {
  154. *addr = data;
  155. }
  156. /**************************************************************************//**
  157. * @brief Read data from 16-bit board control register using memory mapped EBI
  158. * @param addr Register to read from
  159. * @return Value of board controller register
  160. *****************************************************************************/
  161. __STATIC_INLINE uint16_t DVK_EBI_readRegister(volatile uint16_t *addr)
  162. {
  163. return *addr;
  164. }
  165. /**************************************************************************//**
  166. * @brief Read data from 16-bit board control register
  167. * @param addr Register to read
  168. * @return Value of board controller register
  169. *****************************************************************************/
  170. __STATIC_INLINE uint16_t DVK_readRegister(volatile uint16_t *addr)
  171. {
  172. if (dvkOperationMode == DVK_Init_EBI)
  173. {
  174. return DVK_EBI_readRegister(addr);
  175. }
  176. else
  177. {
  178. return DVK_SPI_readRegister(addr);
  179. }
  180. }
  181. /**************************************************************************//**
  182. * @brief Write data into 16-bit board control register
  183. * @param addr Address to board control register
  184. * @param data Data to write into register
  185. *****************************************************************************/
  186. __STATIC_INLINE void DVK_writeRegister(volatile uint16_t *addr, uint16_t data)
  187. {
  188. if (dvkOperationMode == DVK_Init_EBI)
  189. {
  190. DVK_EBI_writeRegister(addr, data);
  191. }
  192. else
  193. {
  194. DVK_SPI_writeRegister(addr, data);
  195. }
  196. }
  197. #ifdef __cplusplus
  198. }
  199. #endif
  200. /** @} (end group BSP) */
  201. #endif