* Initial version
*
* $DESCRIPTION$
- * Main intialize basic components of the boards
+ * Main initialize basic components of the board
* and jumps to a terminal
*
* */
#include <sys/mmap.h>
#include <lib/regfunc.h>
+#include <lib/pool.h>
#include <lib/stdio.h>
#include <lib/tinyprintf.h>
#include <drivers/uart.h>
#include <drivers/led.h>
-#include <drivers/tm1637.h>
-#include <drivers/tsensor.h>
+//#include <drivers/tm1637.h>
+//#include <drivers/at24c.h>
+//#include <drivers/tsensor.h>
+//#include <drivers/mk450_joystick.h>
+#include <drivers/st7735s.h>
-//void sleep() {
-//
-// __asm__ __volatile__("wfe");
-//
-//}
+mem_pool_t kheap_pool;
void main()
{
+
+ /* Initialize the clock system, */
clock_init();
+
+ /* Setup the interrupt vector table */
ivt_init();
+
+ /* Initialze basic input and output over serial */
uart_init();
-// cputs("ROBSYS LOADING...\n");
- systick_init();
-// tsensor_output(0xFFFF, 0x7FFF);
- init_printf(NULL, putc);
- // SPEED_TEST
-/* cputs("START TEST (8MHz) \n");
- int a;
- for (int i = 0; i < 20000000; i++) {
- a + 2;
- }
- a = 0;
- cputs("END TEST\n");
+ /* TFT screen */
+ // tft_init();
- //!
- clock_init();
+ /* Cortex M* integrated systick, can be replaced
+ * by the more accurate RTC.
+ systick_init();
+ */
+
+ /* Set up a very small libc library */
+ init_printf(NULL, putc);
- cputs("START TEST (??MHz) \n");
- for (int i = 0; i < 20000000; i++) {
- a + 2;
- }
- cputs("END TEST\n"); */
+ /* Display some basic info at startup */
sysinfo();
-
- tsensor_input(5000);
-
+ /* On board LEDs*/
led_init();
+
+ /* Real time clock */
rtc_init();
-// tm1637_init();
-// tm1637_start();
-
- //uint32_t test = hextoreg("12345678");
-
-// cputs(regtohex(test));
-
- //extern void stub();
- //stub();
- //__asm__ __volatile__ ("ldc p1, cr1, r0");
-
-/* while(1) {
- int r;
- for (int i = 0; i < 50000; i++) {
- r = 0;
- }
- led_on();
- for (int i = 0; i < 50000; i++) {
- r = 0;
- }
- led_off();
- } */
- terminal();
+ 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();
+
+
+ /* Start up terminal */
+ terminal();
+
+ /* Should not be here, endless loop */
for(;;) {
}