Read temperature over I2C works

Has not been tested with thermistor as I didn't have the hardware.
Testing with a hardcoded positive number works.
This commit is contained in:
Sebastian H. Gabrielli 2024-04-24 13:24:15 +02:00
parent d964ebea37
commit 1eaeeef9a0
4 changed files with 15 additions and 1 deletions

View File

@ -140,7 +140,16 @@ uint8_t route_command(int pos) {
case READ_VOLTAGE:
return READ_VOLTAGE;
case READ_TERMPERATURE:
return READ_TERMPERATURE;
{
uint16_t v_therm = thermistor_voltage_read();
union {
int16_t temp;
uint8_t bytes[2];
} temperature;
temperature.temp = (int16_t) ( calculate_thermistor_temp(v_therm) * 1000 );
return temperature.bytes[pos];
}
break;
case READ_FAN_SPEED:
if (context.fan == FAN1) {
return fan1_history[0];

View File

@ -16,6 +16,8 @@ extern "C" {
#include <avr/io.h>
#include <stdint.h>
#include <string.h>
#include "voltage.h"
#include "themistor-temp.h"
// Enum of all valid command types
typedef enum {

View File

@ -29,6 +29,8 @@ volatile uint16_t fan2_history[512] = {2, 3, 4, 5};
int main() {
init_uart((uint16_t)9600);
ADC0_init();
init_led();
init_i2c();
stdout = &USART_stream;

View File

@ -29,6 +29,7 @@
<itemPath>voltage.c</itemPath>
<itemPath>i2c.c</itemPath>
<itemPath>command-handler.c</itemPath>
<itemPath>thermistor-temp.c</itemPath>
</logicalFolder>
</logicalFolder>
<projectmakefile>Makefile</projectmakefile>