Files
@ c5bc128e44a6
Branch filter:
Location: FeatherHAB/wsprhab/src/adc.c - annotation
c5bc128e44a6
1.2 KiB
text/plain
WSPR and gps now coexist, don't call jtencode_init because it inits the reed-solomon encoder that wspr doesn't even use
4202475a7575 0d9900312165 0d9900312165 0d9900312165 0d9900312165 0d9900312165 4202475a7575 4202475a7575 0d9900312165 4202475a7575 0d9900312165 4202475a7575 0d9900312165 0d9900312165 0d9900312165 0d9900312165 0d9900312165 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 0d9900312165 4202475a7575 4202475a7575 4202475a7575 4202475a7575 4202475a7575 0d9900312165 0d9900312165 | #include "stm32f0xx_hal.h"
#include "adc.h"
#include "gpio.h"
ADC_HandleTypeDef hadc;
// Initialize ADC
void adc_init(void)
{
__ADC1_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = VBATT_SENSE_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(VBATT_SENSE_GPIO_Port, &GPIO_InitStruct);
ADC_ChannelConfTypeDef sConfig;
hadc.Instance = ADC1;
hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC;
hadc.Init.Resolution = ADC_RESOLUTION12b;
hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
hadc.Init.EOCSelection = EOC_SINGLE_CONV;
hadc.Init.LowPowerAutoWait = DISABLE;
hadc.Init.LowPowerAutoPowerOff = DISABLE;
hadc.Init.ContinuousConvMode = DISABLE;
hadc.Init.DiscontinuousConvMode = DISABLE;
hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc.Init.DMAContinuousRequests = DISABLE;
hadc.Init.Overrun = OVR_DATA_PRESERVED;
HAL_ADC_Init(&hadc);
sConfig.Channel = ADC_CHANNEL_6;
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
HAL_ADC_ConfigChannel(&hadc, &sConfig);
}
|