summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 96fb34e78bbfdebf67db80d9d49363a8cf67d2ac (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
58
59
60
61
62
63
64
65
66
67
68
69
#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"
#include "pcf_clock_driver.h"
#include "pins.h"
#include "uart.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
 */






#ifndef FLASH_EEPROM
int main() {
  LED_DEBUG_DDR |= _BV(LED_DEBUG); //TODO move to debug file or somethin
  LED_DEBUG_PORT &= ~(_BV(LED_DEBUG));
  //initlizes i2c, right now only speed //TODO don't delegate a whole function if desired
  i2c_init();
  screen_init();
#ifdef DEBUG_BUILD

  uart_debug_init();
  FILE stdout_replacement = FDEV_SETUP_STREAM((void *)uart_debug_sendbyte, NULL, _FDEV_SETUP_WRITE);
  FILE stdin_replacement = FDEV_SETUP_STREAM(NULL, (void *)uart_debug_recvbyte, _FDEV_SETUP_READ);
  stdout = &stdout_replacement;
  stdin = &stdin_replacement;

  printf("booted\n");

  screen_lowlvl_testdraw();

  eeprom_testbyte();
  //test_clock();
#endif
  
  
  //initilize timer
  timer_init();

#ifdef FLASH_EEPROM
  //uart_echo();
  flash_eeprom();
#endif


  //initlizes screen registers with good values since we dont have control over reset functionallity
  //screen_init();

  return 0;
}
#endif