Skip to content

Commit

Permalink
boards/p-nucleo-wb55: enable ADC support
Browse files Browse the repository at this point in the history
  • Loading branch information
crasbe committed Jul 5, 2024
1 parent 5b985c4 commit da5f431
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions boards/p-nucleo-wb55/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CPU = stm32
CPU_MODEL = stm32wb55rg

# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_lpuart
FEATURES_PROVIDED += periph_pwm
Expand Down
42 changes: 42 additions & 0 deletions boards/p-nucleo-wb55/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,48 @@ static const stm32_usbdev_fs_config_t stm32_usbdev_fs_config[] = {
*/
#define USBDEV_NUMOF ARRAY_SIZE(stm32_usbdev_fs_config)

/**
* @brief ADC configuration
*
* Note that we do not configure all ADC channels,
* and not in the STM32WB55RG order. Instead, we
* just define 6 ADC channels, for the Nucleo
* Arduino header pins A0-A5 and the internal VBAT channel.
*
* To find appropriate device and channel find in the
* board manual, table showing pin assignments and
* information about ADC - a text similar to ADC[X]_IN[Y],
* where:
* [X] - describes used device - indexed from 0,
* for example ADC1_IN10 is device 0,
* [Y] - describes used channel - indexed from 1,
* for example ADC1_IN10 is channel 10
*
* For P-NUCLEO-WB55 this information is in board manual,
* Table 10, page 39.
*
* VBAT is connected ADC1_IN18 or ADC3_IN18 and a voltage divider
* is used, so that only 1/3 of the actual VBAT is measured. This
* allows for a supply voltage higher than the reference voltage.
*
* For P-NUCLEO-WB55 more information is provided in the Reference Manual,
* in section 16.4.31 - Vbat supply monitoring, page 475.
* @{
*/
static const adc_conf_t adc_config[] = {
{GPIO_PIN(PORT_C, 0), 0, 1}, /*< ADC1_IN1 */
{GPIO_PIN(PORT_C, 1), 0, 2}, /*< ADC1_IN2 */
{GPIO_PIN(PORT_A, 1), 0, 6}, /*< ADC1_IN6 */
{GPIO_PIN(PORT_A, 0), 0, 5}, /*< ADC1_IN5 */
{GPIO_PIN(PORT_C, 3), 0, 4}, /*< ADC1_IN4 */
{GPIO_PIN(PORT_C, 2), 0, 3}, /*< ADC1_IN3 */
{GPIO_UNDEF, 0, 18}, /* VBAT */
};

#define VBAT_ADC ADC_LINE(6) /**< VBAT ADC line */
#define ADC_NUMOF ARRAY_SIZE(adc_config)
/** @} */

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit da5f431

Please sign in to comment.