Skip to content

Commit

Permalink
Merge pull request #9951 from leandrolanzieri/pr/sensebox_adc
Browse files Browse the repository at this point in the history
boards/sensebox_samd21: Add ADC configuration
  • Loading branch information
PeterKietzmann committed Sep 20, 2018
2 parents 1f83769 + a5cc36e commit b0ff74b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions boards/sensebox_samd21/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_rtc
Expand Down
32 changes: 32 additions & 0 deletions boards/sensebox_samd21/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,38 @@ static const i2c_conf_t i2c_config[] = {

/** @} */

/**
* @name ADC configuration
* @{
*/
#define ADC_0_EN 1
/* ADC 0 device configuration */
#define ADC_0_DEV ADC
#define ADC_0_IRQ ADC_IRQn

/* ADC 0 Default values */
#define ADC_0_CLK_SOURCE 0 /* GCLK_GENERATOR_0 */
#define ADC_0_PRESCALER ADC_CTRLB_PRESCALER_DIV512

#define ADC_0_NEG_INPUT ADC_INPUTCTRL_MUXNEG_GND
#define ADC_0_GAIN_FACTOR_DEFAULT ADC_INPUTCTRL_GAIN_1X
#define ADC_0_REF_DEFAULT ADC_REFCTRL_REFSEL_INT1V

/* Digital pins (1 to 6) on the board can be configured as analog inputs */
static const adc_conf_chan_t adc_channels[] = {
/* port, pin, muxpos */
{ GPIO_PIN(PA, 4), ADC_INPUTCTRL_MUXPOS_PIN4 }, /* Digital 1 */
{ GPIO_PIN(PA, 5), ADC_INPUTCTRL_MUXPOS_PIN5 }, /* Digital 2 */
{ GPIO_PIN(PA, 6), ADC_INPUTCTRL_MUXPOS_PIN6 }, /* Digital 3 */
{ GPIO_PIN(PA, 7), ADC_INPUTCTRL_MUXPOS_PIN7 }, /* Digital 4 */
{ GPIO_PIN(PA, 3), ADC_INPUTCTRL_MUXPOS_PIN1 }, /* Digital 5 */
{ GPIO_PIN(PA, 2), ADC_INPUTCTRL_MUXPOS_PIN0 }, /* Digital 6 */
};

#define ADC_0_CHANNELS (6U)
#define ADC_NUMOF ADC_0_CHANNELS
/** @} */

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit b0ff74b

Please sign in to comment.