+/* (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 <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/pool.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>
+//#include <drivers/mk450_joystick.h>
+#include <drivers/st7735s.h>
-/* same as above but shorter */
-unsigned short *memsetw(unsigned short *dest, unsigned short val, size_t count)
-{
- unsigned short *temp = (unsigned short *)dest;
- for( ; count != 0; count--) *temp++ = val;
- return dest;
-}
+mem_pool_t kheap_pool;
-int strlen(const char *str)
+void main()
{
- int retval;
- for(retval = 0; *str != '\0'; str++) retval++;
- return retval;
-}
-
+ /* Initialize the clock system, */
+ clock_init();
+ /* Setup the interrupt vector table */
+ ivt_init();
-void main()
-{
- //uart_init();
- //uart_puts("LOADING SYSTEM...\n");
+ /* Initialze basic input and output over serial */
+ uart_init();
- ivt_init();
+ /* TFT screen */
+ // tft_init();
+
+ /* Cortex M* integrated systick, can be replaced
+ * by the more accurate RTC.
systick_init();
-// asm("cpsie i"); // enable irq , cpsied f (disable faukts(
+ */
+
+ /* Set up a very small libc library */
+ init_printf(NULL, putc);
+
+ /* Display some basic info at startup */
+ sysinfo();
+
+ /* On board LEDs*/
+ led_init();
+
+ /* Real time clock */
+ rtc_init();
+
+ extern uint32_t * _beginofheap;
+ //printf("%p", &_beginofheap);
+ kpool_init(&kheap_pool, 512, 10, (uint32_t *) &_beginofheap);
+
+// printf("%p\n", &kheap_pool);
+
+ char * string = (char *) kalloc(&kheap_pool);
+ char * string2 = (char *) kalloc(&kheap_pool);
+ char * string3 = (char *) kalloc(&kheap_pool);
+
+
+ printf("%p\n", string);
+ printf("%p\n", string2);
+ printf("%p\n", string3);
+
+ kfree(&kheap_pool, string);
+
+ char * string6 = (char *) kalloc(&kheap_pool);
+ char * string7 = (char *) kalloc(&kheap_pool);
+ printf("%p\n", string6);
+ printf("%p\n", string7);
+
+ //free(string);
+
+ //char * string2 = (char *) alloc();
+
+ //string2 = "taalb";
+
+ /* Eeprom Driver
+ eeprom_at24c_init();
+ eeprom_test();
+ */
+
+ /* LED Segment Driver */
+ //tm1637_init();
+
+ /* ASM Blocking routine */
+ //for (int i = 0; i < 1000; i++)
+ // _block(10000);
+
+ /* TEMP SENSOR
+ tsensor_printid();
+ uint16_t temp = tsensor_get_temp();
+ printf("Current temperature: %d °C\n", temp); */
+
+ /* ADC Joystick module */
+ // mk450_init();
+
- // loop
+ /* Start up terminal */
+ terminal();
+
+ /* Should not be here, endless loop */
for(;;) {
}