b49c9ab0c6
完整实现了以下模块: - 系统数据总线(sys_data_bus)模块间通信 - UART/USART/LPUART驱动 + RS485半双工 - I2C驱动(AS5600角度传感器 + AT24C02 EEPROM) - Modbus RTU从站协议 - 步进电机微步进控制(正弦/余弦换相+S曲线加减速) - 到位开关驱动(DI_MIN/DI_MAX) - PGA+ADC电流检测 - 系统监控任务(内存/串口/传感器/任务状态) - LED/Key外设驱动 - 基于CMake + arm-none-eabi-gcc构建系统
34 lines
767 B
C
34 lines
767 B
C
#ifndef PGA_DRIVER_H__
|
|
#define PGA_DRIVER_H__
|
|
|
|
#include "common_types.h"
|
|
#include "sys_data_bus.h"
|
|
#include <stdint.h>
|
|
|
|
#define PGA_ADC_CH ADC_CH_0
|
|
|
|
#define PGA_GAIN_1 0x00
|
|
#define PGA_GAIN_2 0x01
|
|
#define PGA_GAIN_4 0x02
|
|
#define PGA_GAIN_8 0x03
|
|
#define PGA_GAIN_16 0x04
|
|
#define PGA_GAIN_32 0x05
|
|
#define PGA_GAIN_64 0x06
|
|
|
|
#define PGA_SHUNT_RESISTOR 0.001f
|
|
#define PGA_VREF 3.3f
|
|
#define PGA_ADC_RESOLUTION 4096.0f
|
|
|
|
typedef struct {
|
|
uint8_t gain;
|
|
float shunt_resistor;
|
|
float vref;
|
|
} pga_config_t;
|
|
|
|
ret_code_t pga_init(const pga_config_t *config);
|
|
ret_code_t pga_deinit(void);
|
|
float pga_read_current(void);
|
|
uint16_t pga_read_raw(void);
|
|
|
|
#endif
|