basic command implementation traditional way
[cortex-from-scratch] / main.c
diff --git a/main.c b/main.c
index 5b488cf..3c1035b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,60 +1,79 @@
+/* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
+ * 
+ * $LOG$
+ * 2019/7/20 - ROBIN KRENS     
+ * Initial version 
+ * 
+ * $DESCRIPTION$
+ * Main initialize basic components of the board
+ * and jumps to a terminal
+ *
+ * */
+
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <stm32.h> // <-- your own header file located located in ./include
-#include <mmap.h>
 
+#include <sys/robsys.h> 
+#include <sys/mmap.h>
 
-void *memcpy(void *dest, void *src, size_t count)
-{   
-    const char *sp = (const char *)src;
-    char *dp = (char *)dest;
-    for(; count != 0; count--) *dp++ = *sp++;
-    return dest;
-}
+#include <lib/regfunc.h>
+#include <lib/stdio.h>
+#include <lib/tinyprintf.h>
 
-/* fillout memory with 'val' (i.e. all zeroes)
- */
-void *memset(void *dest, unsigned char val, size_t count)
-{
-    char *temp = (char *)dest;
-    for( ; count != 0; count--) *temp++ = val;
-    return dest;
-}
+#include <drivers/uart.h>
+#include <drivers/led.h>
+#include <drivers/tm1637.h>
+//#include <drivers/at24c.h>
+#include <drivers/tsensor.h>
 
-/* same as above but shorter */
-unsigned short *memsetw(unsigned short *dest, unsigned short val, size_t count)
+void main()
 {
-    unsigned short *temp = (unsigned short *)dest;
-    for( ; count != 0; count--) *temp++ = val;
-    return dest;
-}
 
-int strlen(const char *str)
-{
-    int retval;
-    for(retval = 0; *str != '\0'; str++) retval++;
-    return retval;
-}
+       /* Initialize the clock system, */
+       clock_init();
 
+       /* Setup the interrupt vector table */
+       ivt_init();
 
+       /* Initialze basic input and output over serial */
+       uart_init();
 
+       /* Cortex M* integrated systick, can be replaced
+        * by the more accurate RTC.
+       systick_init();
+       */
 
-void main()
-{
+       /* Set up a very small libc library */
+       init_printf(NULL, putc);
 
-       ivt_init();
-//     clock_init();
-       uart_init();
-       systick_init();
-       uart_puts("LOADING SYSTEM 0.1 ...\n");
+       /* Display some basic info at startup */
        sysinfo();
-       addrtohex((volatile uint32_t) 0x12345678 );
-       addrtohex((volatile uint32_t) *SCB_VTOR );
 
-//     asm("cpsie i"); // enable irq , cpsied f (disable faukts(
+       /* On board LEDs*/
+       led_init();
+
+       /* Real time clock */
+       //rtc_init();
+
+       /* Eeprom Driver
+       eeprom_at24c_init();
+       eeprom_test();
+       */
+       
+       /* LED Segment Driver */
+       //tm1637_init();
+
+       //for (int i = 0; i < 1000; i++)
+       //      _block(10000);
+
+       /* TEMP SENSOR */
+       run();
+
+       /* Start up terminal */
+       terminal();
 
-       // loop
+       /* Should not be here, endless loop */
        for(;;) {
 
        }