73 lines
		
	
	
		
			817 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			817 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <stm-periph/uart.h>
 | |
| #include <sys/types.h>
 | |
| #include <errno.h>
 | |
| #include <stddef.h>
 | |
| 
 | |
| 
 | |
| 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;
 | |
| 
 | |
| 
 | |
| 	if (heap_end + incr > &heap_top) {
 | |
| 		errno = ENOMEM;
 | |
| 		return (char *)-1;
 | |
| 	}
 | |
| 
 | |
| 	heap_end += incr;
 | |
| 
 | |
| 	return (char *) prev_heap_end;
 | |
| }
 | |
| 
 | |
| int _isatty(int fd)
 | |
| {
 | |
| 	(void)fd;
 | |
| 
 | |
| 	return 1;
 | |
| }
 | |
| 
 | |
| int _close(int fd)
 | |
| {
 | |
| 	(void)fd;
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| int _open(int fd)
 | |
| {
 | |
| 	(void)fd;
 | |
| 
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| int _fstat(void)
 | |
| {
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| int _lseek(void)
 | |
| {
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| int _read(void)
 | |
| {
 | |
| 	return 0;
 | |
| }
 | |
| 
 | |
| int _write(int fd, const void *buf, int count)
 | |
| {
 | |
| 	if (fd == 1)
 | |
| 		uart_send_array_with_dma((char*)buf, count);
 | |
| 	return count;
 | |
| }
 |