This repository has been archived on 2025-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
controller-hd/User/system/bsp/adcs.h

63 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file adcs.h
* @author xxx
* @date 2023-09-04 15:59:16
* @brief LL库ADC驱动
* @copyright Copyright (c) 2023 by xxx, All Rights Reserved.
*/
#ifndef __ADCS_H__
#define __ADCS_H__
#include "lib.h"
#include "main.h"
typedef enum
{
// IN0,
// IN1,
// IN2,
// IN3,
// IN4,
IN5,
IN6,
IN7,
IN8,
IN9,
// IN10,
IN11,
IN12,
IN13,
IN14,
// IN15,
INVREF,
INTEMP,
INMAX,
} adc_num_t; // ADC通道号根据cubemax配置的通道数量而定
typedef struct
{
ADC_TypeDef *adc; // ADC外设
DMA_TypeDef *dma; // DMA外设
uint32_t dma_channel; // DMA通道
} adc_t;
extern volatile uint32_t adcs_ovr_count; // ADC溢出次数
extern void
adc_init(adc_t handle); // ADC初始化
extern void adc_start(adc_t handle); // 启动ADC转换
extern void adc_completed_state_change(BOOL state); // ADC转换完成状态改变
extern BOOL adc_completed(void); // ADC转换完成
extern uint16_t adc_get_result_median_average(uint8_t adc_num); // 中位值平均滤波,获取ADC转换结果
extern uint16_t adc_get_result_median(uint8_t adc_num); // 中位值滤波,获取ADC转换结果
extern uint16_t adc_get_result_average(uint8_t adc_num); // 平均值,获取ADC转换结果
extern uint16_t adc_get_n_result_average(uint8_t adc_num); // N次平均值,获取ADC转换结果
extern uint16_t adc_get_result0(uint8_t in_num); // 获取ADC转换结果
extern int32_t compute_temperature(uint16_t measure); // 计算内部温度
extern int32_t compute_value_local(uint16_t measure); // 计算内部电压
extern void adc_dma_callback(adc_t handle); // ADC转换完成回调函数
extern void adc_callback(adc_t handle); // ADC转换完成回调函数
#endif // __ADCS_H__