41 lines
790 B
C++
41 lines
790 B
C++
#ifndef _ADC_H
|
|||
|
|
#define _ADC_H
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#include "stdint.h"
|
||
|
|
constexpr u8 FILTER_SIZE = 6;
|
||
|
|
constexpr u8 BLOCK_SIZE = FILTER_SIZE * sizeof(float);
|
||
|
|
class sampler {
|
||
|
|
private:
|
||
|
|
float vbus_samples[FILTER_SIZE + 1];
|
||
|
|
float currU_samples[FILTER_SIZE + 1];
|
||
|
|
float currV_samples[FILTER_SIZE + 1];
|
||
|
|
float currW_samples[FILTER_SIZE + 1];
|
||
|
|
float mcu_temp_samples[FILTER_SIZE + 1];
|
||
|
|
float drv_temp_samples[FILTER_SIZE + 1];
|
||
|
|
u8 current_sample_index;
|
||
|
|
|
||
|
|
float tempora_sample;
|
||
|
|
|
||
|
|
public:
|
||
|
|
u8 init(void);
|
||
|
|
void update_mcu_temp(void);
|
||
|
|
void update_drv_temp(void);
|
||
|
|
void update_vbus_voltage(void);
|
||
|
|
void update_current(void);
|
||
|
|
|
||
|
|
float get_mcu_temp(void);
|
||
|
|
float get_drv_temp(void);
|
||
|
|
float get_vbus_voltage(void);
|
||
|
|
float get_current(char);
|
||
|
|
};
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif
|