1 /***************************************************************************//**
\r
3 * @brief Board support package API for GPIO leds on 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
18 #include "em_device.h"
\r
20 #include "em_gpio.h"
\r
23 #if defined( BSP_GPIO_LEDS )
\r
24 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
\r
28 GPIO_Port_TypeDef port;
\r
32 static const tLedArray ledArray[ BSP_NO_OF_LEDS ] = BSP_GPIO_LEDARRAY_INIT;
\r
34 int BSP_LedsInit(void)
\r
38 CMU_ClockEnable(cmuClock_HFPER, true);
\r
39 CMU_ClockEnable(cmuClock_GPIO, true);
\r
40 for ( i=0; i<BSP_NO_OF_LEDS; i++ )
\r
42 GPIO_PinModeSet(ledArray[i].port, ledArray[i].pin, gpioModePushPull, 0);
\r
44 return BSP_STATUS_OK;
\r
47 uint32_t BSP_LedsGet(void)
\r
50 uint32_t retVal, mask;
\r
52 for ( i=0, retVal=0, mask=0x1; i<BSP_NO_OF_LEDS; i++, mask <<= 1 )
\r
54 if (GPIO_PinOutGet(ledArray[i].port, ledArray[i].pin))
\r
60 int BSP_LedsSet(uint32_t leds)
\r
65 for ( i=0, mask=0x1; i<BSP_NO_OF_LEDS; i++, mask <<= 1 )
\r
68 GPIO_PinOutSet(ledArray[i].port, ledArray[i].pin);
\r
70 GPIO_PinOutClear(ledArray[i].port, ledArray[i].pin);
\r
72 return BSP_STATUS_OK;
\r
75 int BSP_LedClear(int ledNo)
\r
77 if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
\r
79 GPIO_PinOutClear(ledArray[ledNo].port, ledArray[ledNo].pin);
\r
80 return BSP_STATUS_OK;
\r
82 return BSP_STATUS_ILLEGAL_PARAM;
\r
85 int BSP_LedGet(int ledNo)
\r
87 int retVal = BSP_STATUS_ILLEGAL_PARAM;
\r
89 if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
\r
91 retVal = (int)GPIO_PinOutGet(ledArray[ledNo].port, ledArray[ledNo].pin);
\r
96 int BSP_LedSet(int ledNo)
\r
98 if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
\r
100 GPIO_PinOutSet(ledArray[ledNo].port, ledArray[ledNo].pin);
\r
101 return BSP_STATUS_OK;
\r
103 return BSP_STATUS_ILLEGAL_PARAM;
\r
106 int BSP_LedToggle(int ledNo)
\r
108 if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS))
\r
110 GPIO_PinOutToggle(ledArray[ledNo].port, ledArray[ledNo].pin);
\r
111 return BSP_STATUS_OK;
\r
113 return BSP_STATUS_ILLEGAL_PARAM;
\r
117 #endif /* BSP_GPIO_LEDS */
\r