Skip to content

Commit c049ff1

Browse files
authored
Merge pull request #21546 from krzysztof-cabaj/nucleo-l432-ADC
boards/nucleo-l432: enable ADC
2 parents 168799c + ac4b20b commit c049ff1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

boards/nucleo-l432kc/Makefile.features

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CPU = stm32
22
CPU_MODEL = stm32l432kc
33

44
# Put defined MCU peripherals here (in alphabetical order)
5+
FEATURES_PROVIDED += periph_adc
56
FEATURES_PROVIDED += periph_can
67
FEATURES_PROVIDED += periph_i2c
78
FEATURES_PROVIDED += periph_pwm

boards/nucleo-l432kc/include/periph_conf.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,44 @@ static const spi_conf_t spi_config[] = {
115115
#define SPI_NUMOF ARRAY_SIZE(spi_config)
116116
/** @} */
117117

118+
/**
119+
* @brief ADC configuration
120+
*
121+
* Note that we do not configure all ADC channels,
122+
* and not in the STM32L432KC order. Instead, we
123+
* just define 5 ADC channels, for the Nucleo
124+
* Arduino Nano header pins A0-A3 and A6 - all which are
125+
* enabled by default and without collision with other
126+
* features, for example, I2C or VCP_TX.
127+
*
128+
* To find appropriate device and channel find in the
129+
* board manual, table showing pin assignments and
130+
* information about ADC - a text similar to ADC[X]_IN[Y],
131+
* where:
132+
* [X] - describes used device - indexed from 0,
133+
* for example ADC1_IN10 is device 0,
134+
* [Y] - describes used channel - indexed from 1,
135+
* for example ADC1_IN10 is channel 10
136+
*
137+
* For Nucleo-L432KC this information is in board manual,
138+
* Table 16 or STM32L432KC MCU datasheet - Table 14.
139+
* @{
140+
*/
141+
static const adc_conf_t adc_config[] = {
142+
{GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 5}, /* ADC12_IN5 */
143+
{GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 6}, /* ADC12_IN6 */
144+
{GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 8}, /* ADC12_IN8 */
145+
{GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 9}, /* ADC12_IN9 */
146+
{GPIO_PIN(PORT_A, 7), .dev = 0, .chan = 12}, /* ADC12_IN12 */
147+
};
148+
149+
/**
150+
* @brief Number of ADC devices
151+
*/
152+
#define ADC_NUMOF ARRAY_SIZE(adc_config)
153+
154+
/** @} */
155+
118156
#ifdef __cplusplus
119157
}
120158
#endif

0 commit comments

Comments
 (0)