summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorBrett Weiland <brett_weiland@bpcspace.com>2022-09-09 18:33:15 -0500
committerBrett Weiland <brett_weiland@bpcspace.com>2022-09-09 18:33:15 -0500
commit7b006d6f2032ac46074d693ae59a971bee327ace (patch)
tree60963598d99001e0850e34d6271db8bd65e04fa4 /src/main.c
init
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..46f2f3b
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,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;
+}
+
+