#include #include #include "FreeRTOS.h" #include "task.h" #include "MK60D10.h" int _gettimeofday(struct timeval *restrict tp, void *restrict tzp) { tp->tv_sec = RTC->TSR; tp->tv_usec = 0U; return 0; } caddr_t _sbrk(int incr) { extern char end __asm("end"); extern char heap_limit __asm("__HeapLimit"); static char *heap_end; char *prev_heap_end; taskENTER_CRITICAL(); if (heap_end == NULL) heap_end = &end; prev_heap_end = heap_end; if (heap_end + incr > &heap_limit) { errno = ENOMEM; taskEXIT_CRITICAL(); return (caddr_t)-1; } heap_end += incr; taskEXIT_CRITICAL(); return (caddr_t)prev_heap_end; }