blob: 46f2f3b7b608c15daa5172036d71f47e14353e7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <stdio.h>
#include <avr/io.h>
#include <util/twi.h>
#include <util/delay.h>
#include "i2c.h"
#include "ssd1306_display_driver.h"
#include "debug.h" //TODO move to timer
#include "br24t_eeprom_driver.h"
/**
* TODO
* make sure desired functions are static (it's just good practice)
* crashing, stack tracing, if that ever matters
* see if stdio is ever needed in non debug builds
* Battery factors to test:
* OLED clock (command 0xd5)
* OLED stay on/off
* organize i2c eeprom/timer code
*/
#if defined(DEBUG_BUILD) || defined(EEPROM_INSTALL)
#include "uart.h" //TODO remove if needed
#endif
int main() {
//initlizes i2c, right now only speed //TODO don't delegate a whole function if desired
i2c_init();
screen_init();
#if defined(DEBUG_BUILD) || defined(EEPROM_INSTALL)
//initlizes usart registers
uart_init();
FILE stdout_replacement = FDEV_SETUP_STREAM((void *)uart_sendbyte, NULL, _FDEV_SETUP_WRITE);
FILE stdin_replacement = FDEV_SETUP_STREAM(NULL, (void *)uart_recvbyte, _FDEV_SETUP_READ);
stdout = &stdout_replacement;
stdin = &stdin_replacement;
screen_testdraw();
#endif
//initilize timer
timer_init();
#ifdef EEPROM_INSTALL
flash_eeprom();
#endif
//initlizes screen registers with good values since we dont have control over reset functionallity
screen_init();
return 0;
}
|