75 lines
1.7 KiB
C
75 lines
1.7 KiB
C
//
|
|
// Created by CFIF on 14.12.23.
|
|
//
|
|
#include <stdbool.h>
|
|
#include "fc7xxx_driver_port.h"
|
|
#include "Adcs.h"
|
|
|
|
|
|
tAdcs ADCS;
|
|
|
|
void Bsp_ADC0_HandleResult(const uint32_t *const pBuffer) {
|
|
Get_ADC_Result(ADCS.vccIo.env);
|
|
}
|
|
|
|
#define ADC0_CHN_NUM_EN 2
|
|
|
|
static uint32_t s_aAdc0ResultBuf[ADC0_CHN_NUM_EN] = {0U};
|
|
|
|
static const ADC_ChannelCfgType s_aChannels[ADC0_CHN_NUM_EN] =
|
|
{
|
|
{
|
|
.eChannel = ADC_CHANNEL_10,
|
|
.eSampleTimeOption = ADC_SAMPLE_TIME_OPTION_1
|
|
},
|
|
{
|
|
.eChannel = ADC_CHANNEL_11,
|
|
.eSampleTimeOption = ADC_SAMPLE_TIME_OPTION_1
|
|
}
|
|
};
|
|
|
|
|
|
void Adcs_Init() {
|
|
tAdcs *env = &ADCS;
|
|
|
|
PORT_InitType tInitStruct = {0};
|
|
|
|
/* PTD16: ADC0_SE10 */
|
|
tInitStruct.u32PortPins = PORT_PIN_16;
|
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTD_16_ADC0_SE10_CMP0_IN0;
|
|
tInitStruct.bPullEn = false;
|
|
tInitStruct.ePullSel = PORT_PULL_UP;
|
|
PORT_InitPins(PORT_D, &tInitStruct);
|
|
|
|
/* PTD15: ADC0_SE11 */
|
|
tInitStruct.u32PortPins = PORT_PIN_15;
|
|
tInitStruct.uPortPinMux.u32PortPinMode = PORTD_15_ADC0_SE11_CMP0_IN1;
|
|
tInitStruct.bPullEn = false;
|
|
tInitStruct.ePullSel = PORT_PULL_UP;
|
|
PORT_InitPins(PORT_D, &tInitStruct);
|
|
|
|
ADC_Initial(
|
|
&env->vcc,
|
|
ADC_INSTANCE_0, // ADC_INSTANCE_0, ADC_INSTANCE_1
|
|
|
|
DMA_CHANNEL_3, // DMA_CHANNEL_0 .. DMA_CHANNEL_15
|
|
|
|
DMA2_IRQn,
|
|
0x55,
|
|
2,
|
|
|
|
s_aAdc0ResultBuf,
|
|
|
|
ADC0_CHN_NUM_EN,
|
|
(ADC_ChannelCfgType *) s_aChannels,
|
|
|
|
0,
|
|
0,
|
|
0,
|
|
|
|
Bsp_ADC0_HandleResult
|
|
);
|
|
|
|
env->vccIo = vAdcGetIo(&env->vcc);
|
|
}
|