diff --git a/fw/Core/Inc/config.h b/fw/Core/Inc/config.h new file mode 100644 index 0000000..e77cd41 --- /dev/null +++ b/fw/Core/Inc/config.h @@ -0,0 +1,43 @@ +/* + * config.h + * + * Created on: Sep 5, 2021 + * Author: dukenuc + */ + +#ifndef INC_CONFIG_H_ +#define INC_CONFIG_H_ + +/* TODO: add comments to everything */ + +#define VENDOR_NAME_LENGTH 64 +#define PRODUCT_CODE_LENGTH 64 +#define PRODUCT_NAME_LENGTH 64 +#define REVISION_LENGTH 16 +#define SERIAL_NUMBER_LENGTH 64 + +#define CONFIG_OK 0 +#define CONFIG_ERROR -1 + + +typedef struct +{ + /* DEVICE ID */ + uint8_t vendor_name[VENDOR_NAME_LENGTH]; + uint8_t product_code[PRODUCT_CODE_LENGTH]; + uint8_t product_name[PRODUCT_NAME_LENGTH]; + uint8_t revision[REVISION_LENGTH]; + uint8_t serial_number[SERIAL_NUMBER_LENGTH]; + + /* DEVICE SPECIFIC CONFIG */ + uint8_t led_on; + uint16_t led_co2_alert_limit1; + uint16_t led_co2_alert_limit2; +} config_t; + +int8_t read_config(config_t *config); + +int8_t write_config(config_t *config); + +#endif /* INC_CONFIG_H_ */ + diff --git a/fw/Core/Inc/scd4x.h b/fw/Core/Inc/scd4x.h index e76a6ca..921f9ee 100644 --- a/fw/Core/Inc/scd4x.h +++ b/fw/Core/Inc/scd4x.h @@ -52,6 +52,6 @@ int8_t scd4x_stop_periodic_measurement( void ); int8_t scd4x_perform_factory_reset( void ); -int8_t scd4x_read_measurement(int * co2, int *temperature, int *relative_humidity); +int8_t scd4x_read_measurement(uint16_t * co2, int16_t *temperature, uint16_t *relative_humidity); #endif /* INC_SCD4X_H_ */ diff --git a/fw/Core/Inc/sht4x.h b/fw/Core/Inc/sht4x.h index 8389107..36c4351 100644 --- a/fw/Core/Inc/sht4x.h +++ b/fw/Core/Inc/sht4x.h @@ -52,6 +52,6 @@ typedef enum { int8_t sht4x_send_cmd(sht4x_cmd_t cmd); int8_t sht4x_read_data(uint8_t *buffer, int len); -int8_t sht4x_measure(int *temperature, int *relative_humidity); +int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity); #endif /* INC_SHT4X_H_ */ diff --git a/fw/Core/Src/config.c b/fw/Core/Src/config.c new file mode 100644 index 0000000..f049680 --- /dev/null +++ b/fw/Core/Src/config.c @@ -0,0 +1,18 @@ +/* + * config.c + * + * Created on: Sep 5, 2021 + * Author: dukenuc + */ + + + +int8_t read_config(config_t *config) +{ + return CONFIG_OK; +} + +int8_t write_config(config_t *config) +{ + return CONFIG_OK; +} diff --git a/fw/Core/Src/main.c b/fw/Core/Src/main.c index 5cd0751..82e98f4 100644 --- a/fw/Core/Src/main.c +++ b/fw/Core/Src/main.c @@ -263,7 +263,9 @@ int main(void) /* Read SCD4x data (if connected) */ if (scd4x_is_connected == 1) { - scd4x_read_measurement(&CO2, &T_SCD4x, &RH_SCD4x); + scd4x_read_measurement(&CO2, + &T_SCD4x, + &RH_SCD4x); } /* Read SPS30 data (if connected) */ diff --git a/fw/Core/Src/scd4x.c b/fw/Core/Src/scd4x.c index 56f1d9a..450cea0 100644 --- a/fw/Core/Src/scd4x.c +++ b/fw/Core/Src/scd4x.c @@ -43,7 +43,7 @@ int8_t scd4x_perform_factory_reset( void ) return scd4x_send_cmd(SCD4X_PERFORM_FACTORY_RESET); } -int8_t scd4x_read_measurement(int * co2, int *temperature, int *relative_humidity) +int8_t scd4x_read_measurement(uint16_t * co2, int16_t *temperature, uint16_t *relative_humidity) { uint8_t buffer[32]; int result; diff --git a/fw/Core/Src/sht4x.c b/fw/Core/Src/sht4x.c index 63221fa..fd5bdd5 100644 --- a/fw/Core/Src/sht4x.c +++ b/fw/Core/Src/sht4x.c @@ -17,7 +17,7 @@ int8_t sht4x_read_data(uint8_t *buffer, int len) return SHT4X_OK; } -int8_t sht4x_measure(int *temperature, int *relative_humidity) +int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity) { uint8_t buffer[32]; int result;