Compare commits
No commits in common. "d215e204d4563b37ba33ceb437505751708119cc" and "b858d29ce8e0b90edc451d5d22c81feadc055c1f" have entirely different histories.
d215e204d4
...
b858d29ce8
@ -1,5 +1,5 @@
|
||||
#include "command-handler.h"
|
||||
#include "fan-speed.h"
|
||||
#include "fan_speeeed.h"
|
||||
|
||||
// Initialize empty, global command context
|
||||
volatile command_context_t context = {UNKNOWN_COMMAND, SRC_NONE, FAN_NONE,
|
||||
@ -169,10 +169,6 @@ uint8_t route_command(int pos) {
|
||||
|
||||
// Set the flag to store it in the EEPROM
|
||||
store_config = true;
|
||||
return 0;
|
||||
break;
|
||||
case CNF_NONE:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -277,7 +273,6 @@ uint8_t route_command(int pos) {
|
||||
} else if (context.fan == FAN2) {
|
||||
memset(fan2_history, 0, sizeof(fan2_history));
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
case UNKNOWN_COMMAND:
|
||||
default:
|
||||
|
||||
@ -67,8 +67,8 @@ typedef struct {
|
||||
extern volatile uint16_t fan1_history[512];
|
||||
extern volatile uint16_t fan2_history[512];
|
||||
// Fan history index variable
|
||||
extern volatile uint16_t fan1_history_index;
|
||||
extern volatile uint16_t fan2_history_index;
|
||||
volatile uint16_t fan1_history_index = 0;
|
||||
volatile uint16_t fan2_history_index = 0;
|
||||
|
||||
// Config
|
||||
extern volatile config_t config;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "fan-speed.h"
|
||||
#include "fan_speeeed.h"
|
||||
#include "uart.h"
|
||||
|
||||
uint16_t timer_period_ms = 1;
|
||||
@ -33,8 +33,8 @@ extern "C" {
|
||||
extern volatile uint16_t fan1_history[512];
|
||||
extern volatile uint16_t fan2_history[512];
|
||||
// Fan history index variable
|
||||
extern volatile uint16_t fan1_history_index;
|
||||
extern volatile uint16_t fan2_history_index;
|
||||
volatile uint16_t fan1_history_index = 0;
|
||||
volatile uint16_t fan2_history_index = 0;
|
||||
|
||||
// INITALICE TIMER COUNTER
|
||||
void init_TCA0();
|
||||
@ -14,6 +14,7 @@ extern "C" {
|
||||
|
||||
// Include the IO for I2C
|
||||
#include "command-handler.h"
|
||||
#include "uart.h"
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -4,39 +4,28 @@
|
||||
*
|
||||
* Created on March 6, 2024, 12:34 PM
|
||||
*/
|
||||
#define F_CPU 4E6
|
||||
|
||||
// Include AVR specific libs
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
// Include standard C libraries
|
||||
#include "uart.h"
|
||||
#include "voltage.h"
|
||||
#include <stdbool.h>
|
||||
#define RTC_PERIOD (511)
|
||||
#define DELAY_TIME 1000
|
||||
#include "eeprom.h"
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Include custom source files
|
||||
#include "eeprom.h"
|
||||
#include "voltage.h"
|
||||
#define F_CPU 4E6
|
||||
#include "command-handler.h"
|
||||
#include "i2c.h"
|
||||
#include "themistor-temp.h"
|
||||
#include "fan-speed.h"
|
||||
|
||||
// Only enable UART when required for debugging
|
||||
#ifdef ENABLE_UART
|
||||
#include "uart.h"
|
||||
#endif
|
||||
#include <avr/io.h>
|
||||
#include <stdint.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
// Fan history variables
|
||||
volatile uint16_t fan1_history[512] = {0};
|
||||
volatile uint16_t fan2_history[512] = {0};
|
||||
// Fan history index variable
|
||||
volatile uint16_t fan1_history_index = 0;
|
||||
volatile uint16_t fan2_history_index = 0;
|
||||
|
||||
// Default config is 500ms sample rate
|
||||
volatile config_t config = {500};
|
||||
@ -44,25 +33,17 @@ volatile bool store_config = false;
|
||||
|
||||
int main() {
|
||||
// Initialize functionality
|
||||
ADC0_init();
|
||||
init_alarm_gpio();
|
||||
init_i2c();
|
||||
|
||||
// Fanspeed
|
||||
init_AC0();
|
||||
init_AC1();
|
||||
init_TCA0();
|
||||
|
||||
// Only enable UART when required for debugging
|
||||
#ifdef ENABLE_UART
|
||||
init_uart((uint16_t)9600);
|
||||
ADC0_init();
|
||||
init_led();
|
||||
init_i2c();
|
||||
stdout = &USART_stream;
|
||||
#endif
|
||||
|
||||
// Read the stored config struct
|
||||
config = read_struct_from_EEPROM();
|
||||
|
||||
// Enable interrupts
|
||||
PORTB.DIRSET = PIN3_bm;
|
||||
|
||||
sei();
|
||||
|
||||
while (1) {
|
||||
|
||||
@ -6,11 +6,11 @@
|
||||
projectFiles="true">
|
||||
<itemPath>uart.h</itemPath>
|
||||
<itemPath>voltage.h</itemPath>
|
||||
<itemPath>fan_speeeed.h</itemPath>
|
||||
<itemPath>themistor-temp.h</itemPath>
|
||||
<itemPath>command-handler.h</itemPath>
|
||||
<itemPath>eeprom.h</itemPath>
|
||||
<itemPath>i2c.h</itemPath>
|
||||
<itemPath>fan-speed.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
displayName="Important Files"
|
||||
@ -28,11 +28,11 @@
|
||||
<itemPath>main.c</itemPath>
|
||||
<itemPath>uart.c</itemPath>
|
||||
<itemPath>voltage.c</itemPath>
|
||||
<itemPath>fan_speeeed.c</itemPath>
|
||||
<itemPath>thermistor-temp.c</itemPath>
|
||||
<itemPath>command-handler.c</itemPath>
|
||||
<itemPath>i2c.c</itemPath>
|
||||
<itemPath>eeprom.c</itemPath>
|
||||
<itemPath>fan-speed.c</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
|
||||
@ -23,8 +23,7 @@ extern "C" {
|
||||
#define T_0 298.15
|
||||
#define B 3950
|
||||
#define R_1 1000
|
||||
|
||||
#define ALERT_PIN PIN3_bm
|
||||
#define ledpin PIN3_bm
|
||||
|
||||
// Takes inn messured value
|
||||
// Calculates the temperature in celcius
|
||||
@ -37,8 +36,8 @@ bool voltage_threshold_bool(float thermistor_temp, uint8_t max_temp);
|
||||
|
||||
void alert_voltage_threshold_exceeded(bool voltage_threshold_bool);
|
||||
|
||||
// Initialise alarm GPIO
|
||||
void init_alarm_gpio();
|
||||
// Initialise led
|
||||
void init_led();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#include "themistor-temp.h"
|
||||
|
||||
|
||||
void init_alarm_gpio(){
|
||||
PORTB.DIRSET = ALERT_PIN;
|
||||
void init_led(){
|
||||
PORTB.DIRSET = ledpin;
|
||||
}
|
||||
|
||||
float calculate_thermistor_temp(float thermistor_voltage){
|
||||
@ -42,8 +42,8 @@ bool voltage_threshold_bool(float thermistor_temp, uint8_t max_temp){
|
||||
void alert_voltage_threshold_exceeded(bool voltage_threshold_bool){
|
||||
if (voltage_threshold_bool){
|
||||
printf("Error: maximum temperature exceeded");
|
||||
PORTB.OUTSET = ALERT_PIN;
|
||||
PORTB.OUTSET = ledpin;
|
||||
} else{
|
||||
PORTB.OUTCLR = ALERT_PIN;
|
||||
PORTB.OUTCLR = ledpin;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user