Files
EmbeddedESP/main/hw/mcp3550.h

36 lines
793 B
C

#ifndef MPC3550_COMPONENT
#define MPC3550_COMPONENT
#include "driver/spi_master.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "buscfg.h"
#define MCP3550_SPS 3.75f
#define MCP3550_CONVERSION_MS ((int)(1000.0f / MCP3550_SPS)) // ~267ms
extern spi_device_handle_t mcp3550_handle;
void mcp3550_spi_init();
int32_t mcp3550_read(uint8_t cs_pin);
float mcp3550_to_voltage(int32_t value, float vref);
typedef struct {
int32_t raw_nh3;
int32_t raw_co;
int32_t raw_no2;
int32_t raw_uvc;
float volts_nh3;
float volts_co;
float volts_no2;
float volts_uvc;
} mics_adc_data_t;
extern spi_device_handle_t mcp3550_handle;
void log_mics_adc_values(mics_adc_data_t *data);
mics_adc_data_t mcp3550_read_all(float vref);
#endif