generated from Embedded_Projects/Landzo_K60Z_LwIP
42 lines
735 B
C
42 lines
735 B
C
|
#include <sys/time.h>
|
||
|
#include <sys/errno.h>
|
||
|
|
||
|
#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;
|
||
|
}
|