reflow-oven-control-sw/stm-firmware/syscalls.c

120 lines
1.9 KiB
C
Raw Permalink Normal View History

2020-02-15 22:09:55 +01:00
/* Reflow Oven Controller
*
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of the Reflow Oven Controller Project.
*
* The reflow oven controller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
2020-02-15 22:09:55 +01:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the reflow oven controller project.
* If not, see <http://www.gnu.org/licenses/>.
*/
2020-02-12 21:06:52 +01:00
#include <stm-periph/uart.h>
#include <sys/types.h>
#include <errno.h>
#include <stddef.h>
2020-02-24 18:50:09 +01:00
extern struct stm_uart shell_uart;
2020-01-26 15:27:06 +01:00
char* _sbrk(int incr)
{
extern char __ld_sheap; // Defined by the linker
extern char __ld_eheap;
static char *heap_end;
char *prev_heap_end;
if (heap_end == 0) {
heap_end = &__ld_sheap;
}
prev_heap_end = heap_end;
if (heap_end + incr > &__ld_eheap) {
errno = ENOMEM;
return (char *)-1;
}
heap_end += incr;
return (char *) prev_heap_end;
}
int _isatty(int fd)
{
(void)fd;
2020-01-26 15:27:06 +01:00
return 1;
}
int _close(int fd)
{
(void)fd;
2020-01-26 15:27:06 +01:00
return 0;
}
int _open(int fd)
{
(void)fd;
2020-01-26 15:27:06 +01:00
return 0;
}
int _fstat(void)
{
2020-01-26 15:27:06 +01:00
return 0;
}
int _lseek(void)
{
2020-01-26 15:27:06 +01:00
return 0;
}
int _read(void)
{
2020-01-26 15:27:06 +01:00
return 0;
}
int _write(int fd, const void *buf, int count)
{
if (fd == 1)
2020-02-24 18:50:09 +01:00
uart_send_array_with_dma(&shell_uart, (char *)buf, count);
else if (fd == 2) {
uart_send_string_with_dma(&shell_uart, "\e[31m");
uart_send_array_with_dma(&shell_uart, (char *)buf, count);
uart_send_string_with_dma(&shell_uart, "\e[m");
}
2020-01-26 15:27:06 +01:00
return count;
}
int _getpid()
{
return 0;
}
int _kill(int pid)
{
(void)pid;
return -1;
}
void _exit(int pid)
{
(void)pid;
while(1);
}