-
Notifications
You must be signed in to change notification settings - Fork 0
/
leds.c
80 lines (71 loc) · 2.85 KB
/
leds.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/***************************************************************************//**
* @file leds.c
* @brief Leds implementation file
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#include "hal-config.h"
#include "leds.h"
/***************************************************************************//**
* @addtogroup Leds
* @{
******************************************************************************/
/*******************************************************************************
* These defines are needed to support radio boards with active-low and
* active-high LED configuration
******************************************************************************/
#ifdef FEATURE_LED_BUTTON_ON_SAME_PIN
/* LED GPIO is active-low */
#define TURN_LED_OFF GPIO_PinOutSet
#define TURN_LED_ON GPIO_PinOutClear
#define LED_DEFAULT_STATE 1
#else
/* LED GPIO is active-high */
#define TURN_LED_OFF GPIO_PinOutClear
#define TURN_LED_ON GPIO_PinOutSet
#define LED_DEFAULT_STATE 0
#endif
/*******************************************************************************
* LED initialization. Configure LED pins as outputs.
******************************************************************************/
void led_init(void)
{
// configure LED0 and LED1 as outputs
GPIO_PinModeSet(BSP_LED0_PORT, BSP_LED0_PIN, gpioModePushPull, LED_DEFAULT_STATE);
GPIO_PinModeSet(BSP_LED1_PORT, BSP_LED1_PIN, gpioModePushPull, LED_DEFAULT_STATE);
}
/*******************************************************************************
* Update the state of LEDs.
*
* @param[in] state New state defined as LED_STATE_xxx.
******************************************************************************/
void led_set_state(uint8_t state)
{
switch (state) {
case LED_STATE_OFF:
TURN_LED_OFF(BSP_LED0_PORT, BSP_LED0_PIN);
TURN_LED_OFF(BSP_LED1_PORT, BSP_LED1_PIN);
break;
case LED_STATE_ON:
TURN_LED_ON(BSP_LED0_PORT, BSP_LED0_PIN);
TURN_LED_ON(BSP_LED1_PORT, BSP_LED1_PIN);
break;
case LED_STATE_PROV:
GPIO_PinOutToggle(BSP_LED0_PORT, BSP_LED0_PIN);
GPIO_PinOutToggle(BSP_LED1_PORT, BSP_LED1_PIN);
break;
default:
break;
}
}
/** @} (end addtogroup Leds) */