Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit 690ef85

Browse files
committed
blackpill-f4: Extract macros for VTRef pin and channel
1 parent 279949c commit 690ef85

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/platforms/common/blackpill-f4/blackpill-f4.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,16 @@ bool platform_nrst_get_val(void)
162162
static void adc_init(void)
163163
{
164164
rcc_periph_clock_enable(RCC_ADC1);
165-
gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0);
165+
gpio_mode_setup(VTREF_PORT, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, VTREF_PIN);
166166
adc_power_off(ADC1);
167167
adc_disable_scan_mode(ADC1);
168-
adc_set_sample_time(ADC1, ADC_CHANNEL0, ADC_SMPR_SMP_480CYC);
168+
adc_set_sample_time(ADC1, VTREF_CHANNEL, ADC_SMPR_SMP_480CYC);
169169
adc_power_on(ADC1);
170170
}
171171

172172
static uint16_t platform_adc_read(void)
173173
{
174-
const uint8_t channel = ADC_CHANNEL0;
174+
const uint8_t channel = VTREF_CHANNEL;
175175
adc_set_regular_sequence(ADC1, 1, &channel);
176176
adc_start_conversion_regular(ADC1);
177177
while (!adc_eoc(ADC1))

src/platforms/common/blackpill-f4/blackpill-f4.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ extern bool debug_bmp;
196196
#define OB_SPI_CS_PORT GPIOA
197197
#define OB_SPI_CS GPIO4
198198

199+
#define VTREF_PORT GPIOB
200+
#define VTREF_PIN GPIO0
201+
#define VTREF_CHANNEL ADC_CHANNEL8
202+
199203
/* USART2 with PA2 and PA3 is selected as USBUSART. Alternatively USART1 with PB6 and PB7 can be used. */
200204
#define USBUSART USBUSART2
201205
#define USBUSART_CR1 USBUSART2_CR1

0 commit comments

Comments
 (0)