27 lines
661 B
C
27 lines
661 B
C
//
|
|
// Created by xemon on 29.08.22.
|
|
//
|
|
#include "Adcs.h"
|
|
#include "at32f435_437.h"
|
|
//#include "GpioPin.h"
|
|
|
|
tAdcs ADCS;
|
|
|
|
void Adcs_Init() {
|
|
tAdcs *env = &ADCS;
|
|
|
|
gpio_init_type gpio_initstructure;
|
|
crm_periph_clock_enable(CRM_GPIOF_PERIPH_CLOCK, TRUE);
|
|
crm_periph_clock_enable(CRM_ADC3_PERIPH_CLOCK, TRUE);
|
|
|
|
gpio_default_para_init(&gpio_initstructure);
|
|
|
|
/* config adc pin as analog input mode */
|
|
gpio_initstructure.gpio_mode = GPIO_MODE_ANALOG;
|
|
gpio_initstructure.gpio_pins = GPIO_PINS_8;
|
|
gpio_init(GPIOF, &gpio_initstructure);
|
|
|
|
env->vcc = ADC_Initial(ADC3, ADC_CHANNEL_6, 0, 1, 1);
|
|
env->vccIo = vAdcGetIo(&env->vcc);
|
|
|
|
} |