diff --git a/arch/cpu/cc13xx-cc26xx/Makefile.cc13xx-cc26xx b/arch/cpu/cc13xx-cc26xx/Makefile.cc13xx-cc26xx index 9dcc5d91c..a9b36ab17 100644 --- a/arch/cpu/cc13xx-cc26xx/Makefile.cc13xx-cc26xx +++ b/arch/cpu/cc13xx-cc26xx/Makefile.cc13xx-cc26xx @@ -47,7 +47,7 @@ endif # root path. Note that the returned path is encased in angular brackets, <...>, # and is therefore extracted with sed. SDK_DEVICE_DIR := $(shell echo "DeviceFamily_constructPath(dummy)" \ - | arm-none-eabi-gcc -x c -E -DDeviceFamily_$(DEVICE_FAMILY) -include $(DEVICE_FAMILY_H) - \ + | arm-none-eabi-cpp -x c -E -DDeviceFamily_$(DEVICE_FAMILY) -include $(DEVICE_FAMILY_H) - \ | tail -1 \ | sed -E 's:<(.+)/dummy>:\1:') diff --git a/arch/platform/simplelink/cc13xx-cc26xx/common/button-sensor.h b/arch/platform/simplelink/cc13xx-cc26xx/common/button-sensor.h index 8756d9b6c..a27a97cf6 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/common/button-sensor.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/common/button-sensor.h @@ -45,18 +45,22 @@ #define BUTTON_SENSOR_H_ /*---------------------------------------------------------------------------*/ /* Contiki API */ -#include +#include "lib/sensors.h" /*---------------------------------------------------------------------------*/ /* Board specific button sensors */ #include "button-sensor-arch.h" /*---------------------------------------------------------------------------*/ #define BUTTON_SENSOR "Button" /*---------------------------------------------------------------------------*/ -#define BUTTON_SENSOR_VALUE_STATE 0 -#define BUTTON_SENSOR_VALUE_DURATION 1 +typedef enum { + BUTTON_SENSOR_TYPE_STATE, + BUTTON_SENSOR_TYPE_DURATION +} button_sensor_type_t; -#define BUTTON_SENSOR_VALUE_RELEASED 0 -#define BUTTON_SENSOR_VALUE_PRESSED 1 +typedef enum { + BUTTON_SENSOR_VALUE_RELEASED, + BUTTON_SENSOR_VALUE_PRESSED +} button_sensor_value_t; /*---------------------------------------------------------------------------*/ #endif /* BUTTON_SENSOR_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/contiki-conf.h b/arch/platform/simplelink/cc13xx-cc26xx/contiki-conf.h index bd5cbb195..99a424dbd 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/contiki-conf.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/contiki-conf.h @@ -59,14 +59,10 @@ * Override button symbols from dev/button-sensor.h, for the examples that * include it */ -#define button_left_sensor btn1_sensor -#define button_right_sensor btn2_sensor +#define button_sensor button_left_sensor +#define button_sensor2 button_right_sensor /** @} */ /*---------------------------------------------------------------------------*/ -/* Platform-specific define to signify sensor reading failure */ -/* TODO: remove */ -#define CC26XX_SENSOR_READING_ERROR 0x80000000 -/*---------------------------------------------------------------------------*/ /* Include CPU-related configuration */ #include "cc13xx-cc26xx-conf.h" /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.c index 6950b16f1..f9c3300bf 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.c @@ -48,7 +48,6 @@ #include /*---------------------------------------------------------------------------*/ #include "button-sensor.h" -#include "button-sensor-arch.h" /*---------------------------------------------------------------------------*/ /* LaunchPad has 2 buttons: BTN1 and BTN2 */ /* Map the GPIO defines from the Board file */ @@ -96,9 +95,9 @@ button_press_cb(PIN_Handle handle, PIN_Id pin_id) switch (pin_id) { case BTN1_PIN: btn_timer = &btn1_timer; - btn_sensor = &btn1_sensor; break; + btn_sensor = &button_left_sensor; break; case BTN2_PIN: btn_timer = &btn2_timer; - btn_sensor = &btn2_sensor; break; + btn_sensor = &button_right_sensor; break; default: return; /* No matching PIN */ } @@ -121,14 +120,18 @@ button_press_cb(PIN_Handle handle, PIN_Id pin_id) static int button_value(int type, uint8_t pin, BtnTimer *btn_timer) { - if (type == BUTTON_SENSOR_VALUE_STATE) { + switch (type) { + case BUTTON_SENSOR_TYPE_STATE: return (PIN_getInputValue(pin) == 0) ? BUTTON_SENSOR_VALUE_PRESSED : BUTTON_SENSOR_VALUE_RELEASED; - } else if (type == BUTTON_SENSOR_VALUE_DURATION) { + + case BUTTON_SENSOR_TYPE_DURATION: return (int)btn_timer->duration; + + default: + return 0; } - return 0; } /*---------------------------------------------------------------------------*/ static int @@ -212,7 +215,7 @@ btn2_status(int type) return button_status(type, BTN2_PIN); } /*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(btn1_sensor, BUTTON_SENSOR, btn1_value, btn1_config, btn1_status); -SENSORS_SENSOR(btn2_sensor, BUTTON_SENSOR, btn2_value, btn2_config, btn2_status); +SENSORS_SENSOR(button_left_sensor, BUTTON_SENSOR, btn1_value, btn1_config, btn1_status); +SENSORS_SENSOR(button_right_sensor, BUTTON_SENSOR, btn2_value, btn2_config, btn2_status); /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.h b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.h index ecd04e8b6..9fca110ae 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.h +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/button-sensor-arch.h @@ -45,10 +45,10 @@ #define BUTTON_SENSOR_ARCH_H_ /*---------------------------------------------------------------------------*/ /* Contiki API */ -#include +#include "lib/sensors.h" /*---------------------------------------------------------------------------*/ -extern const struct sensors_sensor btn1_sensor; -extern const struct sensors_sensor btn2_sensor; +extern const struct sensors_sensor button_left_sensor; +extern const struct sensors_sensor button_right_sensor; /*---------------------------------------------------------------------------*/ #endif /* BUTTON_SENSOR_ARCH_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/launchpad-sensors.c b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/launchpad-sensors.c index f2a669037..af783f88a 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/launchpad/launchpad-sensors.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/launchpad/launchpad-sensors.c @@ -43,8 +43,8 @@ /*---------------------------------------------------------------------------*/ /* Exports a global symbol to be used by the sensor API */ SENSORS( - &btn1_sensor, - &btn2_sensor, + &button_left_sensor, + &button_right_sensor, NULL ); /*---------------------------------------------------------------------------*/ diff --git a/arch/platform/simplelink/cc13xx-cc26xx/platform.c b/arch/platform/simplelink/cc13xx-cc26xx/platform.c index 0ced25f26..a7c2e326e 100644 --- a/arch/platform/simplelink/cc13xx-cc26xx/platform.c +++ b/arch/platform/simplelink/cc13xx-cc26xx/platform.c @@ -79,7 +79,6 @@ /* Arch driver implementations */ #include "uart0-arch.h" /*---------------------------------------------------------------------------*/ -//#include "gpio-interrupt.h" #include "ieee-addr.h" #include "dev/rf-common.h" #include "lib/random.h" @@ -94,8 +93,11 @@ /*---------------------------------------------------------------------------*/ unsigned short g_nodeId = 0; /*---------------------------------------------------------------------------*/ -/** \brief Board specific initialization */ -void board_init(void); +/* + * Board-specific initialization function. + * This function is defined in the file _fxns.c + */ +extern void Board_initHook(void); /*---------------------------------------------------------------------------*/ static void fade(unsigned char l) @@ -138,17 +140,20 @@ platform_init_stage_one(void) { DRIVERLIB_ASSERT_CURR_RELEASE(); - // TODO: TEMPORARY WHILE DEVELOP. REMOVE - HWREG(CPU_SCS_BASE + CPU_SCS_O_ACTLR) = CPU_SCS_ACTLR_DISDEFWBUF; - // Enable flash cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); // Configure round robin arbitration and prefetching VIMSConfigure(VIMS_BASE, true, true); - // Board_initGeneral() will call Power_init() - // Board_initGeneral() will call PIN_init(BoardGpioInitTable) - Board_initGeneral(); + Power_init(); + + if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) { + /* Error with PIN_init */ + while (1); + } + + /* Perform board-specific initialization */ + Board_initHook(); // Contiki drivers init leds_init();