63 lines
1.1 KiB
C
63 lines
1.1 KiB
C
|
|
#ifndef __DRV_POWER_H__
|
||
|
|
#define __DRV_POWER_H__
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#include "global.h"
|
||
|
|
#include "math.h"
|
||
|
|
|
||
|
|
#define FILTER_BUFF_DEEP 8
|
||
|
|
|
||
|
|
#define ADC_PWR_VOLTAGE ADC_CHANNEL_1
|
||
|
|
#define ADC_BIN_VOLTAGE ADC_CHANNEL_2
|
||
|
|
#define ADC_BOU_VOLTAGE ADC_CHANNEL_3
|
||
|
|
#define ADC_BAT_VOLTAGE ADC_CHANNEL_4
|
||
|
|
#define ADC_BAT_CURRENT ADC_CHANNEL_6
|
||
|
|
#define ADC_TEMPERATURE ADC_CHANNEL_9
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
uint32_t channel;
|
||
|
|
|
||
|
|
double *filter_buff;
|
||
|
|
uint32_t filter_deep;
|
||
|
|
|
||
|
|
double (*scale)(double);
|
||
|
|
|
||
|
|
}adcInfo_t;
|
||
|
|
|
||
|
|
|
||
|
|
extern adcInfo_t power_voltage;
|
||
|
|
extern adcInfo_t buck_in_voltage;
|
||
|
|
extern adcInfo_t buck_out_voltage;
|
||
|
|
extern adcInfo_t bat_voltage;
|
||
|
|
extern adcInfo_t bat_current;
|
||
|
|
extern adcInfo_t bat_temper;
|
||
|
|
|
||
|
|
void adc_init(void);
|
||
|
|
|
||
|
|
double get_voltage(adcInfo_t *ptr);
|
||
|
|
|
||
|
|
|
||
|
|
double scale_bat(double value);
|
||
|
|
double scale_pwr(double value);
|
||
|
|
double scale_buck_in(double value);
|
||
|
|
double scale_buck_out(double value);
|
||
|
|
double scale_current(double value);
|
||
|
|
double scale_temp(double Vx);
|
||
|
|
|
||
|
|
void power_init(void);
|
||
|
|
|
||
|
|
void power_set(uint32_t pwm);
|
||
|
|
|
||
|
|
uint16_t power_state(void);
|
||
|
|
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif
|
||
|
|
|