BaseFlight ADC - FabLabSeoul/WingProject GitHub Wiki

์˜คํ”ˆ์†Œ์Šค Baseflight drv_adc.c,h ํŒŒ์ผ์„ ๋ถ„์„ํ•œ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•œ๋‹ค.

Baseflight์˜ drv_adc.c,h ํŒŒ์ผ์€ baseflight ์ „์šฉ adc ์ฝ”๋“œ๋‹ค. ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌํ™” ๋œ ์†Œ์Šค๊ฐ€ ์•„๋‹ˆ๋‹ค.

drv_adc ํ—ค๋” ํŒŒ์ผ์ด๋‹ค.

#pragma once

typedef enum {
    ADC_BATTERY = 0,
    ADC_EXTERNAL_PAD = 1,
    ADC_EXTERNAL_CURRENT = 2,
    ADC_RSSI = 3,
    ADC_CHANNEL_MAX = 4
} AdcChannel;

typedef struct drv_adc_config_t {
    uint8_t powerAdcChannel;     // which channel used for current monitor, allowed PA1, PB1 (ADC_Channel_1, ADC_Channel_9)
    uint8_t rssiAdcChannel;      // which channel used for analog-rssi (RC-filter), allowed PA1, PB1 (ADC_Channel_1, ADC_Channel_9)
} drv_adc_config_t;

void adcInit(drv_adc_config_t *init);
uint16_t adcGetChannel(uint8_t channel);

ํ—ค๋” ํŒŒ์ผ์—์„œ ๋ณด์ด๋“ฏ์ด, drv_adc๋Š” ๋ฐง๋ฐ๋ฆฌ์™€ ๋‹ค๋ฅธ ์ฃผ๋ณ€๊ธฐ๊ธฐ๋“ค์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ธฐ ์œ„ํ•ด ์“ฐ์ธ๋‹ค. A/D์ปจ๋ฒ„ํ„ฐ์— DMA๋ฅผ ์ด์šฉํ•ด์„œ ์—ฌ๋Ÿฌ ์ฑ„๋„๋กœ A/D๋ณ€ํ™˜์„ ํ•˜๊ณ  ์žˆ๋‹ค.

drv_adc_config_t ๊ตฌ์กฐ์ฒด์˜ powerAdcChannel, rssiAdcChannel ๋ณ€์ˆ˜๋Š” ๋ชจ๋‘ 0 ์œผ๋กœ ์ดˆ๊ธฐํ™” ๋œ ์ƒํƒœ๋ผ, ํ”„๋กœ๊ทธ๋žจ์—์„œ ์•„๋ฌด ์˜ํ–ฅ์„ ๋ฏธ์น˜์ง€ ๋ชปํ•œ๋‹ค.