From 877c758aaf5ccce15323c2bf3545edd0945a06f9 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 25 Feb 2018 20:46:02 +0000 Subject: [PATCH] Implement the new LED HAL (Launchpad CC26xx/CC13xx) --- .../srf06-cc26xx/launchpad/Makefile.launchpad | 2 +- .../srf06-cc26xx/launchpad/cc1310/board.h | 17 ++---- .../srf06-cc26xx/launchpad/cc1350/board.h | 17 ++---- .../srf06-cc26xx/launchpad/cc2650/board.h | 17 ++---- .../srf06-cc26xx/launchpad/leds-arch.c | 56 ++++--------------- 5 files changed, 23 insertions(+), 86 deletions(-) diff --git a/arch/platform/srf06-cc26xx/launchpad/Makefile.launchpad b/arch/platform/srf06-cc26xx/launchpad/Makefile.launchpad index 54bd81ced..8676c4171 100644 --- a/arch/platform/srf06-cc26xx/launchpad/Makefile.launchpad +++ b/arch/platform/srf06-cc26xx/launchpad/Makefile.launchpad @@ -2,7 +2,7 @@ CFLAGS += -DBOARD_LAUNCHPAD=1 CONTIKI_TARGET_DIRS += launchpad common -BOARD_SOURCEFILES += board.c launchpad-sensors.c leds-arch.c button-sensor.c +BOARD_SOURCEFILES += board.c launchpad-sensors.c button-sensor.c BOARD_SOURCEFILES += ext-flash.c board-spi.c ### Signal that we can be programmed with cc2538-bsl diff --git a/arch/platform/srf06-cc26xx/launchpad/cc1310/board.h b/arch/platform/srf06-cc26xx/launchpad/cc1310/board.h index 1d56d776a..d8a87e53a 100644 --- a/arch/platform/srf06-cc26xx/launchpad/cc1310/board.h +++ b/arch/platform/srf06-cc26xx/launchpad/cc1310/board.h @@ -55,20 +55,14 @@ #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 -#define LEDS_GREEN 2 -#define LEDS_YELLOW LEDS_GREEN -#define LEDS_ORANGE LEDS_RED - -#define LEDS_CONF_ALL 3 - -/* Notify various examples that we have LEDs */ -#define PLATFORM_HAS_LEDS 1 +#define LEDS_CONF_COUNT 2 +#define LEDS_CONF_RED 1 +#define LEDS_CONF_YELLOW 2 /** @} */ /*---------------------------------------------------------------------------*/ /** @@ -79,9 +73,6 @@ */ #define BOARD_IOID_LED_1 IOID_6 #define BOARD_IOID_LED_2 IOID_7 -#define BOARD_LED_1 (1 << BOARD_IOID_LED_1) -#define BOARD_LED_2 (1 << BOARD_IOID_LED_2) -#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2) /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/platform/srf06-cc26xx/launchpad/cc1350/board.h b/arch/platform/srf06-cc26xx/launchpad/cc1350/board.h index 9b5019179..c80fb1326 100644 --- a/arch/platform/srf06-cc26xx/launchpad/cc1350/board.h +++ b/arch/platform/srf06-cc26xx/launchpad/cc1350/board.h @@ -55,20 +55,14 @@ #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 -#define LEDS_GREEN 2 -#define LEDS_YELLOW LEDS_GREEN -#define LEDS_ORANGE LEDS_RED - -#define LEDS_CONF_ALL 3 - -/* Notify various examples that we have LEDs */ -#define PLATFORM_HAS_LEDS 1 +#define LEDS_CONF_COUNT 2 +#define LEDS_CONF_RED 1 +#define LEDS_CONF_YELLOW 2 /** @} */ /*---------------------------------------------------------------------------*/ /** @@ -79,9 +73,6 @@ */ #define BOARD_IOID_LED_1 IOID_6 #define BOARD_IOID_LED_2 IOID_7 -#define BOARD_LED_1 (1 << BOARD_IOID_LED_1) -#define BOARD_LED_2 (1 << BOARD_IOID_LED_2) -#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2) /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/platform/srf06-cc26xx/launchpad/cc2650/board.h b/arch/platform/srf06-cc26xx/launchpad/cc2650/board.h index 65a5bb766..1ea40957a 100644 --- a/arch/platform/srf06-cc26xx/launchpad/cc2650/board.h +++ b/arch/platform/srf06-cc26xx/launchpad/cc2650/board.h @@ -55,20 +55,14 @@ #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 -#define LEDS_GREEN 2 -#define LEDS_YELLOW LEDS_GREEN -#define LEDS_ORANGE LEDS_RED - -#define LEDS_CONF_ALL 3 - -/* Notify various examples that we have LEDs */ -#define PLATFORM_HAS_LEDS 1 +#define LEDS_CONF_COUNT 2 +#define LEDS_CONF_RED 1 +#define LEDS_CONF_YELLOW 2 /** @} */ /*---------------------------------------------------------------------------*/ /** @@ -79,9 +73,6 @@ */ #define BOARD_IOID_LED_1 IOID_6 #define BOARD_IOID_LED_2 IOID_7 -#define BOARD_LED_1 (1 << BOARD_IOID_LED_1) -#define BOARD_LED_2 (1 << BOARD_IOID_LED_2) -#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2) /** @} */ /*---------------------------------------------------------------------------*/ /** diff --git a/arch/platform/srf06-cc26xx/launchpad/leds-arch.c b/arch/platform/srf06-cc26xx/launchpad/leds-arch.c index 0d8385ad6..5d70dea40 100644 --- a/arch/platform/srf06-cc26xx/launchpad/leds-arch.c +++ b/arch/platform/srf06-cc26xx/launchpad/leds-arch.c @@ -1,10 +1,11 @@ /* - * Copyright (c) 2015, 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,54 +29,17 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ /*---------------------------------------------------------------------------*/ -/** - * \addtogroup launchpad-peripherals - * @{ - * - * \file - * Driver for LaunchPad LEDs - */ -/*---------------------------------------------------------------------------*/ #include "contiki.h" #include "dev/leds.h" - +#include "dev/gpio-hal.h" #include "ti-lib.h" -/*---------------------------------------------------------------------------*/ -static unsigned char c; -static int inited = 0; -/*---------------------------------------------------------------------------*/ -void -leds_arch_init(void) -{ - if(inited) { - return; - } - inited = 1; - ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1); - ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_2); +#include +/*---------------------------------------------------------------------------*/ +const leds_t leds_arch_leds[] = { + { .pin = BOARD_IOID_LED_1, .negative_logic = false }, + { .pin = BOARD_IOID_LED_2, .negative_logic = false }, +}; +/*---------------------------------------------------------------------------*/ - ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL); -} -/*---------------------------------------------------------------------------*/ -unsigned char -leds_arch_get(void) -{ - return c; -} -/*---------------------------------------------------------------------------*/ -void -leds_arch_set(unsigned char leds) -{ - c = leds; - 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); - } -} -/*---------------------------------------------------------------------------*/ -/** @} */