57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
/*
|
|
* File: main.c
|
|
* Author: Sebastian H. Gabrielli, Helle Augland Grasmo
|
|
*
|
|
* Created on March 6, 2024, 12:34 PM
|
|
*/
|
|
#include <stdbool.h>
|
|
#include "uart.h"
|
|
#include "voltage.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>
|
|
#define F_CPU 4E6
|
|
#include "command-handler.h"
|
|
#include "i2c.h"
|
|
#include "themistor-temp.h"
|
|
#include "uart.h"
|
|
#include <avr/io.h>
|
|
#include <stdint.h>
|
|
#include <util/delay.h>
|
|
|
|
// Fan history variables
|
|
volatile uint16_t fan1_history[512] = {1, 2, 3, 4};
|
|
volatile uint16_t fan2_history[512] = {2, 3, 4, 5};
|
|
|
|
// Default config is 500ms sample rate
|
|
volatile config_t config = { 500 };
|
|
volatile bool store_config = false;
|
|
|
|
int main() {
|
|
// Initialize functionality
|
|
init_uart((uint16_t)9600);
|
|
ADC0_init();
|
|
init_led();
|
|
init_i2c();
|
|
stdout = &USART_stream;
|
|
|
|
// Read the stored config struct
|
|
config = read_struct_from_EEPROM();
|
|
|
|
PORTB.DIRSET = PIN3_bm;
|
|
|
|
sei();
|
|
|
|
while (1) {
|
|
// If we have made a config change, store it.
|
|
if (store_config) {
|
|
write_struct_from_EEPROM(config);
|
|
store_config = false;
|
|
}
|
|
}
|
|
}
|