From f932e51128c64863f6e07831082ae354e06cd333 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 25 Feb 2018 18:57:58 +0000 Subject: [PATCH] Implement the new LED HAL (SmartRF06 CC26xx/CC13xx) --- .../srf06-cc26xx/srf06/Makefile.srf06 | 2 +- .../srf06-cc26xx/srf06/cc13xx/board.h | 22 ++----- .../srf06-cc26xx/srf06/cc26xx/board.h | 22 ++----- arch/platform/srf06-cc26xx/srf06/leds-arch.c | 66 ++++--------------- 4 files changed, 24 insertions(+), 88 deletions(-) diff --git a/arch/platform/srf06-cc26xx/srf06/Makefile.srf06 b/arch/platform/srf06-cc26xx/srf06/Makefile.srf06 index 44d115ec8..bcfe21bca 100644 --- a/arch/platform/srf06-cc26xx/srf06/Makefile.srf06 +++ b/arch/platform/srf06-cc26xx/srf06/Makefile.srf06 @@ -2,7 +2,7 @@ CFLAGS += -DBOARD_SMARTRF06EB=1 CONTIKI_TARGET_DIRS += srf06 -BOARD_SOURCEFILES += leds-arch.c srf06-sensors.c button-sensor.c board.c +BOARD_SOURCEFILES += srf06-sensors.c button-sensor.c board.c BOARD_SOURCEFILES += als-sensor.c ### Signal that we can be programmed with cc2538-bsl diff --git a/arch/platform/srf06-cc26xx/srf06/cc13xx/board.h b/arch/platform/srf06-cc26xx/srf06/cc13xx/board.h index e210d82d8..bf12b2b09 100644 --- a/arch/platform/srf06-cc26xx/srf06/cc13xx/board.h +++ b/arch/platform/srf06-cc26xx/srf06/cc13xx/board.h @@ -58,20 +58,16 @@ #include "ioc.h" /*---------------------------------------------------------------------------*/ /** - * \name LED configurations + * \name LED HAL configuration * * Those values are not meant to be modified by the user * @{ */ -#define LEDS_RED 1 /**< LED1 (Red) */ -#define LEDS_YELLOW 2 /**< LED2 (Yellow) */ -#define LEDS_GREEN 4 /**< LED3 (Green) */ -#define LEDS_ORANGE 8 /**< LED4 (Orange) */ - -#define LEDS_CONF_ALL 15 - -/* Notify various examples that we have LEDs */ -#define PLATFORM_HAS_LEDS 1 +#define LEDS_CONF_COUNT 4 +#define LEDS_CONF_RED 1 +#define LEDS_CONF_YELLOW 2 +#define LEDS_CONF_GREEN 4 +#define LEDS_CONF_ORANGE 8 /** @} */ /*---------------------------------------------------------------------------*/ /** @@ -84,12 +80,6 @@ #define BOARD_IOID_LED_2 IOID_27 #define BOARD_IOID_LED_3 IOID_7 #define BOARD_IOID_LED_4 IOID_6 -#define BOARD_LED_1 (1 << BOARD_IOID_LED_1) -#define BOARD_LED_2 (1 << BOARD_IOID_LED_2) -#define BOARD_LED_3 (1 << BOARD_IOID_LED_3) -#define BOARD_LED_4 (1 << BOARD_IOID_LED_4) -#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2 | BOARD_LED_3 | \ - BOARD_LED_4) /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/platform/srf06-cc26xx/srf06/cc26xx/board.h b/arch/platform/srf06-cc26xx/srf06/cc26xx/board.h index 99f97fbf2..44080f474 100644 --- a/arch/platform/srf06-cc26xx/srf06/cc26xx/board.h +++ b/arch/platform/srf06-cc26xx/srf06/cc26xx/board.h @@ -58,20 +58,16 @@ #include "ioc.h" /*---------------------------------------------------------------------------*/ /** - * \name LED configurations + * \name LED HAL configuration * * Those values are not meant to be modified by the user * @{ */ -#define LEDS_RED 1 /**< LED1 (Red) */ -#define LEDS_YELLOW 2 /**< LED2 (Yellow) */ -#define LEDS_GREEN 4 /**< LED3 (Green) */ -#define LEDS_ORANGE 8 /**< LED4 (Orange) */ - -#define LEDS_CONF_ALL 15 - -/* Notify various examples that we have LEDs */ -#define PLATFORM_HAS_LEDS 1 +#define LEDS_CONF_COUNT 4 +#define LEDS_CONF_RED 1 +#define LEDS_CONF_YELLOW 2 +#define LEDS_CONF_GREEN 4 +#define LEDS_CONF_ORANGE 8 /** @} */ /*---------------------------------------------------------------------------*/ /** @@ -84,12 +80,6 @@ #define BOARD_IOID_LED_2 IOID_27 #define BOARD_IOID_LED_3 IOID_7 #define BOARD_IOID_LED_4 IOID_6 -#define BOARD_LED_1 (1 << BOARD_IOID_LED_1) -#define BOARD_LED_2 (1 << BOARD_IOID_LED_2) -#define BOARD_LED_3 (1 << BOARD_IOID_LED_3) -#define BOARD_LED_4 (1 << BOARD_IOID_LED_4) -#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2 | BOARD_LED_3 | \ - BOARD_LED_4) /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/platform/srf06-cc26xx/srf06/leds-arch.c b/arch/platform/srf06-cc26xx/srf06/leds-arch.c index 2a1627005..9de716b97 100644 --- a/arch/platform/srf06-cc26xx/srf06/leds-arch.c +++ b/arch/platform/srf06-cc26xx/srf06/leds-arch.c @@ -1,10 +1,11 @@ /* - * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2018, George Oikonomou - http://www.spd.gr * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -28,63 +29,18 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -/** - * \addtogroup srf06-common-peripherals - * @{ - * - * \file - * Driver for the SmartRF06EB LEDs when a CC13xx/CC26xx EM is mounted on it - */ -/*---------------------------------------------------------------------------*/ #include "contiki.h" -#include "dev/leds.h" -#include "ti-lib.h" -/*---------------------------------------------------------------------------*/ -static unsigned char c; -static int inited = 0; -/*---------------------------------------------------------------------------*/ -void -leds_arch_init(void) -{ - if(inited) { - return; - } - inited = 1; +#include "dev/led.h" +#include "dev/gpio-hal.h" - ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_1); - ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_2); - ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_3); - ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_4); - - ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL); -} +#include /*---------------------------------------------------------------------------*/ -unsigned char -leds_arch_get(void) -{ - return c; -} +const led_t led_arch_leds[] = { + { .pin = BOARD_IOID_LED_1, .negative_logic = false }, + { .pin = BOARD_IOID_LED_2, .negative_logic = false }, + { .pin = BOARD_IOID_LED_3, .negative_logic = false }, + { .pin = BOARD_IOID_LED_4, .negative_logic = false }, +}; /*---------------------------------------------------------------------------*/ -void -leds_arch_set(unsigned char leds) -{ - c = leds; - /* Clear everything */ - ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL); - if((leds & LEDS_RED) == LEDS_RED) { - ti_lib_gpio_set_dio(BOARD_IOID_LED_1); - } - if((leds & LEDS_YELLOW) == LEDS_YELLOW) { - ti_lib_gpio_set_dio(BOARD_IOID_LED_2); - } - if((leds & LEDS_GREEN) == LEDS_GREEN) { - ti_lib_gpio_set_dio(BOARD_IOID_LED_3); - } - if((leds & LEDS_ORANGE) == LEDS_ORANGE) { - ti_lib_gpio_set_dio(BOARD_IOID_LED_4); - } -} -/*---------------------------------------------------------------------------*/ -/** @} */