From bff735a698a81067ad6a69ae520f3c93a5cec770 Mon Sep 17 00:00:00 2001 From: vetch Date: Tue, 12 Nov 2019 17:45:03 +0100 Subject: finalize Makefile for writing to rpi --- interrupts.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 interrupts.c (limited to 'interrupts.c') diff --git a/interrupts.c b/interrupts.c new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From d302f79c13df6ecaa63c477c6a811fa94996b7cb Mon Sep 17 00:00:00 2001 From: vetch Date: Tue, 12 Nov 2019 17:45:36 +0100 Subject: add interrupts; add some more content in pipe (commented out for now) --- interrupts.c | 15 +++++++++++++++ pipe_image.c | 21 ++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) (limited to 'interrupts.c') diff --git a/interrupts.c b/interrupts.c index e69de29..3dc3d6f 100644 --- a/interrupts.c +++ b/interrupts.c @@ -0,0 +1,15 @@ +#include "uart.h" +/** + @brief The undefined instruction interrupt handler + + If an undefined instruction is encountered, the CPU will start + executing this function. Just trap here as a debug solution. +*/ +void __attribute__((interrupt("UNDEF"))) undefined_instruction_vector(void) +{ + uart_puts("Undefined instruction occured"); + while( 1 ) + { + /* Do Nothing! */ + } +} \ No newline at end of file diff --git a/pipe_image.c b/pipe_image.c index 03d2c8f..1266e90 100644 --- a/pipe_image.c +++ b/pipe_image.c @@ -50,7 +50,7 @@ int main(int argc, const char **argv) { const int comport=16; if (!stdout_instead_of_uart) - if (RS232_OpenComport(comport, 115200, "8N1", 0) == 1) + if (RS232_OpenComport(comport, 115200, "8N1", 1) == 1) err(-1, "Error opening comport"); uint32_t image_size_le = htole32(image_size); @@ -63,7 +63,7 @@ int main(int argc, const char **argv) { else { if (RS232_SendBuf(comport, (unsigned char*) &image_size_le, 4) - == 1) + == -1) err(-1, "error writing number to serial"); } @@ -84,12 +84,27 @@ int main(int argc, const char **argv) { } else { - if (RS232_SendBuf(comport, buf, bytes_read) == 1) + if (RS232_SendBuf(comport, buf, bytes_read) == -1) err(-1, "error writing to serial"); } bytes_left -= bytes_read; } +/* + while(1){ + int bytes_read=read(0,buf,sizeof(buf)); + if (stdout_instead_of_uart) + { + if (fwrite((unsigned char*) buf, bytes_read, 1, stdout) != 1) + err(-1, "error writing to stdout"); + } + else + { + if (RS232_SendBuf(comport, buf, bytes_read) == 1) + err(-1, "error writing to serial"); + } + } + */ if (!stdout_instead_of_uart) RS232_CloseComport(comport); -- cgit v1.2.3