2020-02-12 21:06:52 +01:00
|
|
|
#include <stm-periph/uart.h>
|
2020-02-15 01:04:40 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2020-01-26 15:27:06 +01:00
|
|
|
|
2020-02-12 21:15:25 +01:00
|
|
|
char* _sbrk(int incr)
|
|
|
|
{
|
|
|
|
extern char heap_low; // Defined by the linker
|
|
|
|
extern char heap_top;
|
|
|
|
static char *heap_end;
|
|
|
|
char *prev_heap_end;
|
|
|
|
|
|
|
|
if (heap_end == 0) {
|
|
|
|
heap_end = &heap_low;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_heap_end = heap_end;
|
2020-02-15 01:04:40 +01:00
|
|
|
|
|
|
|
|
2020-02-12 21:15:25 +01:00
|
|
|
if (heap_end + incr > &heap_top) {
|
2020-02-15 01:04:40 +01:00
|
|
|
errno = ENOMEM;
|
|
|
|
return (char *)-1;
|
2020-02-12 21:15:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
heap_end += incr;
|
2020-02-15 01:04:40 +01:00
|
|
|
|
|
|
|
return (char *) prev_heap_end;
|
2020-02-12 21:15:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int _isatty(int fd)
|
|
|
|
{
|
|
|
|
(void)fd;
|
|
|
|
|
2020-01-26 15:27:06 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2020-02-12 21:15:25 +01:00
|
|
|
|
|
|
|
int _close(int fd)
|
|
|
|
{
|
|
|
|
(void)fd;
|
|
|
|
|
2020-01-26 15:27:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2020-02-12 21:15:25 +01:00
|
|
|
|
|
|
|
int _open(int fd)
|
|
|
|
{
|
|
|
|
(void)fd;
|
|
|
|
|
2020-01-26 15:27:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2020-02-12 21:15:25 +01:00
|
|
|
|
|
|
|
int _fstat(void)
|
|
|
|
{
|
2020-01-26 15:27:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2020-02-12 21:15:25 +01:00
|
|
|
|
|
|
|
int _lseek(void)
|
|
|
|
{
|
2020-01-26 15:27:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2020-02-12 21:15:25 +01:00
|
|
|
|
|
|
|
int _read(void)
|
|
|
|
{
|
2020-01-26 15:27:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2020-02-12 21:15:25 +01:00
|
|
|
|
|
|
|
int _write(int fd, const void *buf, int count)
|
|
|
|
{
|
|
|
|
if (fd == 1)
|
2020-02-15 17:53:15 +01:00
|
|
|
uart_send_array_with_dma((char*)buf, count);
|
2020-01-26 15:27:06 +01:00
|
|
|
return count;
|
|
|
|
}
|