samples: board: 96b_argonkey: Add testing of 12 on-board leds
Enable the TI LP3943 led controller and test the 12 on-board leds. Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
parent
ef33b79d58
commit
2ad2d07ce8
|
@ -7,3 +7,4 @@ CONFIG_HTS221=y
|
|||
CONFIG_LPS22HB=y
|
||||
CONFIG_VL53L0X=y
|
||||
CONFIG_LSM6DSL=y
|
||||
CONFIG_LP3943=y
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <board.h>
|
||||
#include <gpio.h>
|
||||
#include <led.h>
|
||||
#include <i2c.h>
|
||||
#include <spi.h>
|
||||
#include <sensor.h>
|
||||
|
@ -98,6 +99,9 @@ static void lsm6dsl_trigger_handler(struct device *dev,
|
|||
}
|
||||
#endif
|
||||
|
||||
#define NUM_LEDS 12
|
||||
#define DELAY_TIME K_MSEC(50)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int cnt = 0;
|
||||
|
@ -105,6 +109,42 @@ void main(void)
|
|||
static struct device *led0, *led1;
|
||||
int i, on = 1;
|
||||
|
||||
#ifdef CONFIG_LP3943
|
||||
static struct device *ledc;
|
||||
|
||||
ledc = device_get_binding(CONFIG_LP3943_DEV_NAME);
|
||||
if (!ledc) {
|
||||
printk("Could not get pointer to %s sensor\n",
|
||||
CONFIG_LP3943_DEV_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
/* turn all leds on */
|
||||
for (i = 0; i < NUM_LEDS; i++) {
|
||||
led_on(ledc, i);
|
||||
k_sleep(DELAY_TIME);
|
||||
}
|
||||
|
||||
/* turn all leds off */
|
||||
for (i = 0; i < NUM_LEDS; i++) {
|
||||
led_off(ledc, i);
|
||||
k_sleep(DELAY_TIME);
|
||||
}
|
||||
|
||||
/* blink all leds */
|
||||
for (i = 0; i < NUM_LEDS; i++) {
|
||||
led_blink(ledc, i, 200, 50);
|
||||
}
|
||||
|
||||
k_sleep(1000);
|
||||
|
||||
/* turn all leds off */
|
||||
for (i = 0; i < NUM_LEDS; i++) {
|
||||
led_off(ledc, i);
|
||||
k_sleep(5);
|
||||
}
|
||||
#endif
|
||||
|
||||
led0 = device_get_binding(LED0_GPIO_CONTROLLER);
|
||||
gpio_pin_configure(led0, LED0_GPIO_PIN, GPIO_DIR_OUT);
|
||||
gpio_pin_write(led0, LED0_GPIO_PIN, 1);
|
||||
|
|
Loading…
Reference in a new issue