dvk.h 8.0 KB

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