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