Skip to content

Commit

Permalink
Merge pull request #7327 from smlng/cpu/cc2538/periph_adc
Browse files Browse the repository at this point in the history
cpu, cc2538: add low-level adc periph driver
  • Loading branch information
smlng committed Jul 27, 2017
2 parents 3f00ab1 + 2806484 commit 027d65d
Show file tree
Hide file tree
Showing 18 changed files with 447 additions and 10 deletions.
1 change: 1 addition & 0 deletions boards/cc2538dk/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_adc

# Various other features (if any)
FEATURES_PROVIDED += cpp
Expand Down
13 changes: 13 additions & 0 deletions boards/cc2538dk/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ static const spi_conf_t spi_config[] = {
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
/** @} */

/**
* @name ADC configuration
* @{
*/
#define SOC_ADC_ADCCON_REF SOC_ADC_ADCCON_REF_AVDD5

static const adc_conf_t adc_config[] = {
GPIO_PIN(0, 6), /**< GPIO_PA6 = ADC_ALS_PIN */
};

#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/** @} */

/**
* @name Radio peripheral configuration
* @{
Expand Down
1 change: 1 addition & 0 deletions boards/openmote-cc2538/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_adc

# Various other features (if any)
FEATURES_PROVIDED += cpp
Expand Down
18 changes: 18 additions & 0 deletions boards/openmote-cc2538/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @brief Peripheral MCU configuration for the OpenMote-cc2538 board
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/

#ifndef PERIPH_CONF_H
Expand Down Expand Up @@ -64,6 +65,23 @@ static const timer_conf_t timer_config[] = {
#define TIMER_IRQ_PRIO 1
/** @} */

/**
* @name ADC configuration
* @{
*/
#define SOC_ADC_ADCCON_REF SOC_ADC_ADCCON_REF_AVDD5

static const adc_conf_t adc_config[] = {
GPIO_PIN(0, 2), /**< GPIO_PA2 = AD4_PIN */
GPIO_PIN(0, 3), /**< GPIO_PA3 = CTS_DI07_PIN */
GPIO_PIN(0, 4), /**< GPIO_PA4 = AD5_PIN */
GPIO_PIN(0, 5), /**< GPIO_PA5 = AD6_PIN */
GPIO_PIN(0, 6), /**< GPIO_PA6 = ON_SLEEP_PIN */
};

#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/** @} */

/**
* @name UART configuration
* @{
Expand Down
2 changes: 2 additions & 0 deletions boards/remote-common/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
USEMODULE += gnrc_netdev
USEMODULE += netdev_ieee802154
endif

ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
USEMODULE += saul_adc
endif
1 change: 1 addition & 0 deletions boards/remote-pa/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_adc

# Various other features (if any)
FEATURES_PROVIDED += cpp
Expand Down
53 changes: 53 additions & 0 deletions boards/remote-pa/include/adc_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2016 Eistec AB
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_remote
* @{
*
* @file
* @brief Board specific configuration of direct mapped ADC
*
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
* @author Antonio Lignan <alinan@zolertia.com>
*/

#ifndef ADC_PARAMS_H
#define ADC_PARAMS_H

#include "board.h"
#include "saul/periph.h"
#include "periph/adc.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief ADC configuration
*/
static const saul_adc_params_t saul_adc_params[] =
{
{
.name = "ADC2",
.line = ADC_LINE(0),
.res = ADC_RES_12BIT,
},
{
.name = "ADC3",
.line = ADC_LINE(1),
.res = ADC_RES_12BIT,
}
};

#ifdef __cplusplus
}
#endif

#endif /* ADC_PARAMS_H */
/** @} */
15 changes: 15 additions & 0 deletions boards/remote-pa/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Antonio Lignan <alinan@zolertia.com>
* @author Sebastian Meiling <s@mlng.net>
*/

#ifndef PERIPH_CONF_H
Expand Down Expand Up @@ -106,6 +107,20 @@ static const spi_conf_t spi_config[] = {
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
/** @} */

/**
* @name ADC configuration
* @{
*/
#define SOC_ADC_ADCCON_REF SOC_ADC_ADCCON_REF_AVDD5

static const adc_conf_t adc_config[] = {
GPIO_PIN(0, 6), /**< GPIO_PA6 = ADC2_PIN */
GPIO_PIN(0, 7), /**< GPIO_PA7 = ADC3_PIN */
};

#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/** @} */

#ifdef __cplusplus
} /* end extern "C" */
#endif
Expand Down
1 change: 1 addition & 0 deletions boards/remote-reva/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_adc

# Various other features (if any)
FEATURES_PROVIDED += cpp
Expand Down
2 changes: 1 addition & 1 deletion boards/remote-reva/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ In terms of hardware support, the following drivers have been implemented:
* I2C/SPI library
* LEDs
* Buttons
* ADC
* RF switch to programatically drive either 2.4GHz or sub-1GHz to a single RP-SMA
* RF 2.4GHz built-in in CC2538

Expand All @@ -35,7 +36,6 @@ And under work or pending at cc2538 base cpu:
* Built-in core temperature and battery sensor.
* CC1200 sub-1GHz radio interface.
* Micro-SD external storage.
* ADC
* USB (in CDC-ACM).
* uDMA Controller.

Expand Down
58 changes: 58 additions & 0 deletions boards/remote-reva/include/adc_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2016 Eistec AB
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_remote
* @{
*
* @file
* @brief Board specific configuration of direct mapped ADC
*
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
* @author Antonio Lignan <alinan@zolertia.com>
*/

#ifndef ADC_PARAMS_H
#define ADC_PARAMS_H

#include "board.h"
#include "saul/periph.h"
#include "periph/adc.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief ADC configuration
*/
static const saul_adc_params_t saul_adc_params[] =
{
{
.name = "ADC1",
.line = ADC_LINE(0),
.res = ADC_RES_12BIT,
},
{
.name = "ADC2",
.line = ADC_LINE(1),
.res = ADC_RES_12BIT,
},
{
.name = "ADC3",
.line = ADC_LINE(2),
.res = ADC_RES_12BIT,
}
};

#ifdef __cplusplus
}
#endif

#endif /* ADC_PARAMS_H */
/** @} */
19 changes: 19 additions & 0 deletions boards/remote-reva/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Antonio Lignan <alinan@zolertia.com>
* @author Sebastian Meiling <s@mlng.net>
*/

#ifndef PERIPH_CONF_H
Expand Down Expand Up @@ -107,6 +108,24 @@ static const spi_conf_t spi_config[] = {
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
/** @} */

/**
* @name ADC configuration
* @{
*/
#define SOC_ADC_ADCCON_REF SOC_ADC_ADCCON_REF_AVDD5

static const adc_conf_t adc_config[] = {
GPIO_PIN(0, 5), /**< GPIO_PA5 = ADC1_PIN */
GPIO_PIN(0, 4), /**< GPIO_PA4 = ADC2_PIN */
/* voltage divider with 5/3 relationship to allow 5V sensors */
GPIO_PIN(0, 2), /**< GPIO_PA2 = ADC3_PIN */
};

#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/** @} */



#ifdef __cplusplus
} /* end extern "C" */
#endif
Expand Down
1 change: 1 addition & 0 deletions boards/remote-revb/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_adc

# Various other features (if any)
FEATURES_PROVIDED += cpp
Expand Down
58 changes: 58 additions & 0 deletions boards/remote-revb/include/adc_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2016 Eistec AB
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_remote
* @{
*
* @file
* @brief Board specific configuration of direct mapped ADC in Revision B
*
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
* @author Antonio Lignan <alinan@zolertia.com>
*/

#ifndef ADC_PARAMS_H
#define ADC_PARAMS_H

#include "board.h"
#include "saul/periph.h"
#include "periph/adc.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief ADC configuration
*/
static const saul_adc_params_t saul_adc_params[] =
{
{
.name = "ADC1",
.line = ADC_LINE(0),
.res = ADC_RES_12BIT,
},
{
.name = "ADC2",
.line = ADC_LINE(1),
.res = ADC_RES_12BIT,
},
{
.name = "ADC3",
.line = ADC_LINE(2),
.res = ADC_RES_12BIT,
}
};

#ifdef __cplusplus
}
#endif

#endif /* ADC_PARAMS_H */
/** @} */
21 changes: 19 additions & 2 deletions boards/remote-revb/include/periph_conf.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
* Copyright (C) 2015 Zolertia SL
* 2017 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
Expand All @@ -15,7 +16,8 @@
* @brief Peripheral MCU configuration for the RE-Mote board revision B
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* Antonio Lignan <alinan@zolertia.com>
* @author Antonio Lignan <alinan@zolertia.com>
* @author Sebastian Meiling <s@mlng.net>
*/

#ifndef PERIPH_CONF_H
Expand Down Expand Up @@ -105,10 +107,25 @@ static const spi_conf_t spi_config[] = {
.cs_pin = GPIO_PA7
}
};

#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
/** @} */

/**
* @name ADC configuration
* @{
*/
#define SOC_ADC_ADCCON_REF SOC_ADC_ADCCON_REF_AVDD5

static const adc_conf_t adc_config[] = {
GPIO_PIN(0, 5), /**< GPIO_PA5 = ADC1_PIN */
GPIO_PIN(0, 4), /**< GPIO_PA4 = ADC2_PIN */
/* voltage divider with 5/3 relationship to allow 5V sensors */
GPIO_PIN(0, 2), /**< GPIO_PA2 = ADC3_PIN */
};

#define ADC_NUMOF (sizeof(adc_config) / sizeof(adc_config[0]))
/** @} */

#ifdef __cplusplus
} /* end extern "C" */
#endif
Expand Down
Loading

0 comments on commit 027d65d

Please sign in to comment.