mikrokontrollersystemer-pro.../prosjekt.X/main.c
2024-04-30 10:59:47 +02:00

57 lines
1.1 KiB
C

/*
* File: main.c
* Author: Sebastian H. Gabrielli, Helle Augland Grasmo, Ina Min Rørnes
*
* Created on March 6, 2024, 12:34 PM
*/
#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>
#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] = {0};
volatile uint16_t fan2_history[512] = {0};
// 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;
}
}
}