#ifndef __CONCENTRATION_H__
#define __CONCENTRATION_H__

#ifdef __cplusplus
 extern "C" {
#endif

#include "stm32f4xx.h"
#include "device.h"

struct data_lookup_table_s {
    uint8_t concentration_points;
    uint8_t temperature_points;
    uint8_t resv0;
    uint8_t resv1;
    float temperature[LOOKUP_TABLE_TEMPERATURE_POINTS_MAX];
    float concentration[LOOKUP_TABLE_CONCENTRATION_POINTS_MAX];
    float b0[LOOKUP_TABLE_TEMPERATURE_POINTS_MAX];
    float delta_b[LOOKUP_TABLE_CONCENTRATION_POINTS_MAX][LOOKUP_TABLE_TEMPERATURE_POINTS_MAX];
    float calc_b0;
    float calc_b[LOOKUP_TABLE_CONCENTRATION_POINTS_MAX];
};

extern struct data_lookup_table_s data_lookup_table[4];

void concentration_lookup_table_copy(uint8_t ch);
void concentration_init(void);
int32_t concentration_neg_drift_compensation(uint8_t ch, int32_t reading);
int32_t concentration_calc(uint8_t ch);
void concentration_loop(void);

#ifdef __cplusplus
}
#endif

#endif /* __CONCENTRATION_H__ */
