diff --git a/projects/103/README.md b/projects/103/README.md new file mode 100644 index 00000000..acff15a9 --- /dev/null +++ b/projects/103/README.md @@ -0,0 +1,15 @@ + +# 103 \ No newline at end of file diff --git a/projects/103/config.json b/projects/103/config.json new file mode 100644 index 00000000..4019f474 --- /dev/null +++ b/projects/103/config.json @@ -0,0 +1,6 @@ +{ + "libs": [ + "FreeRTOS", + "ms-common" + ] +} \ No newline at end of file diff --git a/projects/103/src/main.c b/projects/103/src/main.c new file mode 100644 index 00000000..8e8a68c6 --- /dev/null +++ b/projects/103/src/main.c @@ -0,0 +1,28 @@ +#include + +#include "gpio.h" +#include "log.h" +#include "master_task.h" +#include "tasks.h" + +void pre_loop_init() {} + +void run_fast_cycle() {} + +void run_medium_cycle() {} + +void run_slow_cycle() {} + +int main() { + gpio_init(); + tasks_init(); + log_init(); + LOG_DEBUG("Welcome to TEST!"); + + init_master_task(); + + tasks_start(); + + LOG_DEBUG("exiting main?"); + return 0; +} diff --git a/projects/fw_103/inc/ads1115.h b/projects/fw_103/inc/ads1115.h index 2272266a..8a41be33 100644 --- a/projects/fw_103/inc/ads1115.h +++ b/projects/fw_103/inc/ads1115.h @@ -40,6 +40,6 @@ StatusCode ads1115_init(ADS1115_Config *config, ADS1115_Address i2c_addr, GpioAd StatusCode ads1115_select_channel(ADS1115_Config *config, ADS1115_Channel channel); -StatusCode ads1115_read_raw(ADS1115_Config *config, ADS1115_Channel channel, int16_t *reading); +StatusCode ads1115_read_raw(ADS1115_Config *config, ADS1115_Channel channel, uint16_t *reading); StatusCode ads1115_read_converted(ADS1115_Config *config, ADS1115_Channel channel, float *reading); diff --git a/projects/fw_103/src/ads1115.c b/projects/fw_103/src/ads1115.c index e4751d4d..49f96ae9 100644 --- a/projects/fw_103/src/ads1115.c +++ b/projects/fw_103/src/ads1115.c @@ -1,9 +1,8 @@ #include "ads1115.h" #include "gpio_it.h" -#include "log.h" - #include "i2c.h" +#include "log.h" #include "status.h" StatusCode ads1115_init(ADS1115_Config *config, ADS1115_Address i2c_addr, GpioAddress *ready_pin) { @@ -49,23 +48,19 @@ StatusCode ads1115_select_channel(ADS1115_Config *config, ADS1115_Channel channe return STATUS_CODE_OK; } -StatusCode ads1115_read_raw(ADS1115_Config *config, ADS1115_Channel channel, int16_t *reading) { +StatusCode ads1115_read_raw(ADS1115_Config *config, ADS1115_Channel channel, uint16_t *reading) { /* TODO: complete function */ - i2c_read_reg(config->i2c_port, config->i2c_addr, ADS1115_REG_CONVERSION, (uint8_t *) reading, 2); + i2c_read_reg(config->i2c_port, config->i2c_addr, ADS1115_REG_CONVERSION, (uint8_t *)reading, 2); return STATUS_CODE_OK; } StatusCode ads1115_read_converted(ADS1115_Config *config, ADS1115_Channel channel, float *reading) { /* TODO: complete function */ - uint16_t reader ; - - ads1115_read_raw(config, channel,(int16_t *) &reader); - - if (reader <= 32768) { - *reading = -1 * (reader/ 65535)*4.096; - } else { - *reading = (reader/ 65535)*4.096; - } + uint16_t reader; + + ads1115_read_raw(config, channel, &reader); + + *reading = ((float)reader / 65535.0f) * 8.192f - 4.096f; return STATUS_CODE_OK; -} +} \ No newline at end of file diff --git a/projects/fw_103/src/main.c b/projects/fw_103/src/main.c index 04a48b5c..f515ff05 100644 --- a/projects/fw_103/src/main.c +++ b/projects/fw_103/src/main.c @@ -11,20 +11,13 @@ #include +#include "ads1115.h" +#include "delay.h" +#include "gpio.h" #include "log.h" #include "tasks.h" -#include "gpio.h" -#include "delay.h" - -#include "ads1115.h" - -static GpioAddress led_addr = { - .port = GPIO_PORT_B, - .pin = 3 -}; - - +static GpioAddress led_addr = { .port = GPIO_PORT_B, .pin = 3 }; TASK(gpioTask, TASK_STACK_512) { GpioAddress ready_pin = { @@ -53,7 +46,7 @@ TASK(gpioTask, TASK_STACK_512) { LOG_DEBUG("reader value: %f\n", reader); - delay_s(1); + // delay_s(1); } }