dvk_brd3600.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**************************************************************************//**
  2. * @file
  3. * @brief EFM32GG_DK3750 board support package BRD3600A API implementation
  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. /***************************************************************************//**
  36. * @addtogroup BSP
  37. * @{
  38. ******************************************************************************/
  39. #include "efm32.h"
  40. #include "em_gpio.h"
  41. #include "em_ebi.h"
  42. #include "em_cmu.h"
  43. #include "dvk.h"
  44. #include "dvk_bcregisters.h"
  45. /**************************************************************************//**
  46. * @brief Configure BRD3600A on-board peripherals.
  47. *****************************************************************************/
  48. void DVK_BRD3600A_init(void)
  49. {
  50. /* Enable CMU GPIO clocks */
  51. CMU_ClockEnable(cmuClock_GPIO, true);
  52. /* USB status LED - configure PE1 as push pull */
  53. GPIO_PinModeSet(gpioPortE, 1, gpioModePushPull, 0);
  54. /* USB overcurrent status - configure PE2 as push pull */
  55. GPIO_PinModeSet(gpioPortE, 2, gpioModeInput, 0);
  56. /* USB VBUS switch - configure PF5 as push pull - Default OFF */
  57. GPIO_PinModeSet(gpioPortF, 5, gpioModePushPull, 0);
  58. return;
  59. }
  60. /**************************************************************************//**
  61. * @brief Disable EFM32GG_DK3750 EBI board support package functionality
  62. *****************************************************************************/
  63. void DVK_BRD3600A_deInit(void)
  64. {
  65. /* Disable PE1 */
  66. GPIO_PinModeSet(gpioPortE, 1, gpioModePushPull, 0);
  67. /* Disable CMU GPIO clocks */
  68. CMU_ClockEnable(cmuClock_GPIO, false);
  69. return;
  70. }
  71. /**************************************************************************//**
  72. * @brief Set state of USB status LED
  73. * @param[in] enable Set to true to light LED, false to dim it
  74. *****************************************************************************/
  75. void DVK_BRD3600A_usbStatusLEDEnable(int enable)
  76. {
  77. GPIO_PinModeSet(gpioPortE, 1, gpioModePushPull, enable);
  78. return;
  79. }
  80. /**************************************************************************//**
  81. * @brief Enable VBUS switch
  82. * @param[in] enable Set to true to enable switch
  83. *****************************************************************************/
  84. void DVK_BRD3600A_usbVBUSSwitchEnable(int enable)
  85. {
  86. GPIO_PinModeSet(gpioPortF, 5, gpioModePushPull, enable);
  87. return;
  88. }
  89. /**************************************************************************//**
  90. * @brief Get state of VBUS switch overcurrent flag
  91. *****************************************************************************/
  92. int DVK_BRD3600A_usbVBUSGetOCFlagState(void)
  93. {
  94. return ~GPIO_PinInGet(gpioPortE, 2);
  95. }
  96. /** @} (end group BSP) */