Files

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_6
#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