From 5eb0470ad403cd398de0d4e2f8e25e0b0e1f6277 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 24 Jan 2016 16:52:56 +0000 Subject: [PATCH] Move the SPI and Ext Flash Driver to a common directory This commit creates a `common` directory, aimed to host drivers supported by multiple boards of the CC13xx/CC26xx family. We move the Sensortag SPI and External Flash drivers to this location and we change the Sensortag build system to pull the respective files from therein. --- .../{sensortag => common}/board-spi.c | 4 ++-- .../{sensortag => common}/board-spi.h | 15 ++++++++++++--- .../{sensortag => common}/ext-flash.c | 4 ++-- .../{sensortag => common}/ext-flash.h | 6 +++--- .../srf06-cc26xx/sensortag/Makefile.sensortag | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) rename platform/srf06-cc26xx/{sensortag => common}/board-spi.c (98%) rename platform/srf06-cc26xx/{sensortag => common}/board-spi.h (89%) rename platform/srf06-cc26xx/{sensortag => common}/ext-flash.c (99%) rename platform/srf06-cc26xx/{sensortag => common}/ext-flash.h (95%) diff --git a/platform/srf06-cc26xx/sensortag/board-spi.c b/platform/srf06-cc26xx/common/board-spi.c similarity index 98% rename from platform/srf06-cc26xx/sensortag/board-spi.c rename to platform/srf06-cc26xx/common/board-spi.c index 960db75c8..fb9fecd63 100644 --- a/platform/srf06-cc26xx/sensortag/board-spi.c +++ b/platform/srf06-cc26xx/common/board-spi.c @@ -33,7 +33,7 @@ * @{ * * \file - * Board-specific SPI driver for the Sensortag-CC26xx + * Board-specific SPI driver common to the Sensortag and LaunchPad */ /*---------------------------------------------------------------------------*/ #include "contiki.h" @@ -120,7 +120,7 @@ board_spi_open(uint32_t bit_rate, uint32_t clk_pin) /* First, make sure the SERIAL PD is on */ ti_lib_prcm_power_domain_on(PRCM_DOMAIN_SERIAL); while((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_SERIAL) - != PRCM_DOMAIN_POWER_ON)); + != PRCM_DOMAIN_POWER_ON)); /* Enable clock in active mode */ ti_lib_rom_prcm_peripheral_run_enable(PRCM_PERIPH_SSI0); diff --git a/platform/srf06-cc26xx/sensortag/board-spi.h b/platform/srf06-cc26xx/common/board-spi.h similarity index 89% rename from platform/srf06-cc26xx/sensortag/board-spi.h rename to platform/srf06-cc26xx/common/board-spi.h index 26bdff162..3699db120 100644 --- a/platform/srf06-cc26xx/sensortag/board-spi.h +++ b/platform/srf06-cc26xx/common/board-spi.h @@ -29,14 +29,22 @@ */ /*---------------------------------------------------------------------------*/ /** - * \addtogroup sensortag-cc26xx-peripherals + * \addtogroup cc26xx-srf-tag * @{ * - * \defgroup sensortag-cc26xx-spi SensorTag 2.0 SPI functions + * \defgroup common-cc26xx-peripherals CC13xx/CC26xx peripheral driver pool + * + * Drivers for peripherals present on more than one CC13xx/CC26xx board. For + * example, the same external flash driver is used for both the part found on + * the Sensortag as well as the part on the LaunchPad. + * + * @{ + * + * \defgroup sensortag-cc26xx-spi SensorTag/LaunchPad SPI functions * @{ * * \file - * Header file for the Sensortag-CC26xx SPI Driver + * Header file for the Sensortag/LaunchPad SPI Driver */ /*---------------------------------------------------------------------------*/ #ifndef BOARD_SPI_H_ @@ -100,6 +108,7 @@ bool board_spi_write(const uint8_t *buf, size_t length); #endif /* BOARD_SPI_H_ */ /*---------------------------------------------------------------------------*/ /** + * @} * @} * @} */ diff --git a/platform/srf06-cc26xx/sensortag/ext-flash.c b/platform/srf06-cc26xx/common/ext-flash.c similarity index 99% rename from platform/srf06-cc26xx/sensortag/ext-flash.c rename to platform/srf06-cc26xx/common/ext-flash.c index d469c1d56..721a36424 100644 --- a/platform/srf06-cc26xx/sensortag/ext-flash.c +++ b/platform/srf06-cc26xx/common/ext-flash.c @@ -33,7 +33,7 @@ * @{ * * \file - * Driver for the Sensortag-CC26xx WinBond W25X20CL Flash + * Driver for the LaunchPad Flash and the Sensortag WinBond W25X20CL/W25X40CL */ /*---------------------------------------------------------------------------*/ #include "contiki.h" @@ -158,7 +158,7 @@ static uint8_t verify_part(void) { const uint8_t wbuf[] = { BLS_CODE_MDID, 0xFF, 0xFF, 0x00 }; - uint8_t rbuf[2] = {0, 0}; + uint8_t rbuf[2] = { 0, 0 }; bool ret; select_on_bus(); diff --git a/platform/srf06-cc26xx/sensortag/ext-flash.h b/platform/srf06-cc26xx/common/ext-flash.h similarity index 95% rename from platform/srf06-cc26xx/sensortag/ext-flash.h rename to platform/srf06-cc26xx/common/ext-flash.h index 3038872cd..5f2717edb 100644 --- a/platform/srf06-cc26xx/sensortag/ext-flash.h +++ b/platform/srf06-cc26xx/common/ext-flash.h @@ -29,14 +29,14 @@ */ /*---------------------------------------------------------------------------*/ /** - * \addtogroup sensortag-cc26xx-peripherals + * \addtogroup common-cc26xx-peripherals * @{ * - * \defgroup sensortag-cc26xx-ext-flash SensorTag 2.0 External Flash + * \defgroup sensortag-cc26xx-ext-flash SensorTag/LaunchPad External Flash * @{ * * \file - * Header file for the Sensortag-CC26xx External Flash Driver + * Header file for the Sensortag/LaunchPad External Flash Driver */ /*---------------------------------------------------------------------------*/ #ifndef EXT_FLASH_H_ diff --git a/platform/srf06-cc26xx/sensortag/Makefile.sensortag b/platform/srf06-cc26xx/sensortag/Makefile.sensortag index a37f8dd05..68e4b007f 100644 --- a/platform/srf06-cc26xx/sensortag/Makefile.sensortag +++ b/platform/srf06-cc26xx/sensortag/Makefile.sensortag @@ -1,7 +1,7 @@ CFLAGS += -DBOARD_SENSORTAG=1 CFLAGS += -DBACKDOOR_IOID=0x00000000 -CONTIKI_TARGET_DIRS += sensortag +CONTIKI_TARGET_DIRS += sensortag common BOARD_SOURCEFILES += sensortag-sensors.c sensor-common.c BOARD_SOURCEFILES += bmp-280-sensor.c tmp-007-sensor.c opt-3001-sensor.c