Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bafran committed Sep 23, 2024
1 parent cc4ba84 commit 9daae47
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 27 deletions.
15 changes: 15 additions & 0 deletions projects/103/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
General guidelines
These are just guidelines, not strict rules - document however seems best.
A README for a firmware-only project (e.g. Babydriver, MPXE, bootloader, CAN explorer) should answer the following questions:
- What is it?
- What problem does it solve?
- How do I use it? (with usage examples / example commands, etc)
- How does it work? (architectural overview)
A README for a board project (powering a hardware board, e.g. power distribution, centre console, charger, BMS carrier) should answer the following questions:
- What is the purpose of the board?
- What are all the things that the firmware needs to do?
- How does it fit into the overall system?
- How does it work? (architectural overview, e.g. what each module's purpose is or how data flows through the firmware)
-->
# 103
6 changes: 6 additions & 0 deletions projects/103/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"libs": [
"FreeRTOS",
"ms-common"
]
}
28 changes: 28 additions & 0 deletions projects/103/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>

#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;
}
2 changes: 1 addition & 1 deletion projects/fw_103/inc/ads1115.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
23 changes: 9 additions & 14 deletions projects/fw_103/src/ads1115.c
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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;
}
}
17 changes: 5 additions & 12 deletions projects/fw_103/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@

#include <stdio.h>

#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 = {
Expand Down Expand Up @@ -53,7 +46,7 @@ TASK(gpioTask, TASK_STACK_512) {

LOG_DEBUG("reader value: %f\n", reader);

delay_s(1);
// delay_s(1);
}
}

Expand Down

0 comments on commit 9daae47

Please sign in to comment.