diff options
-rw-r--r-- | firmware/drivers/rtc/rtc_rx5x348ab.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/spi-dm320.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/uart-dm320.c | 55 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/uart-target.h | 11 |
5 files changed, 37 insertions, 35 deletions
diff --git a/firmware/drivers/rtc/rtc_rx5x348ab.c b/firmware/drivers/rtc/rtc_rx5x348ab.c index 3db30d2a38..4899d99567 100644 --- a/firmware/drivers/rtc/rtc_rx5x348ab.c +++ b/firmware/drivers/rtc/rtc_rx5x348ab.c @@ -32,4 +32,4 @@ int rtc_read_datetime(unsigned char* buf) spi_block_transfer(SPI_target_RX5X348AB, &command, 1, buf, 7); return 1; -}
\ No newline at end of file +} diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index b57680afb4..b157ae2d12 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c @@ -84,7 +84,7 @@ int button_read_device(void) btn |= BUTTON_POWER; uart1_heartbeat(); - while (uartAvailable()) + while (uart1_available()) { if (uart1_getch(&c)) { diff --git a/firmware/target/arm/tms320dm320/spi-dm320.c b/firmware/target/arm/tms320dm320/spi-dm320.c index 31fe63d9dd..b36456b520 100644 --- a/firmware/target/arm/tms320dm320/spi-dm320.c +++ b/firmware/target/arm/tms320dm320/spi-dm320.c @@ -38,7 +38,7 @@ struct SPI_info { volatile unsigned short *clrreg; int bit; }; -#define reg(a) (PHY_IO_BASE+a) +#define reg(a) ((volatile unsigned short *)(PHY_IO_BASE+a)) struct SPI_info spi_targets[] = { [SPI_target_TSC2100] = { reg(0x0594), reg(0x058E), GIO_TS_ENABLE }, diff --git a/firmware/target/arm/tms320dm320/uart-dm320.c b/firmware/target/arm/tms320dm320/uart-dm320.c index 66e59eaaac..f50add4363 100644 --- a/firmware/target/arm/tms320dm320/uart-dm320.c +++ b/firmware/target/arm/tms320dm320/uart-dm320.c @@ -28,7 +28,8 @@ static unsigned char uart1buffer[MAX_UART_BUFFER]; int uart1read = 0, uart1write = 0, uart1count = 0; -void do_checksums(char *data, int len, char *xor, char *add) +/* +static void do_checksums(char *data, int len, char *xor, char *add) { int i; *xor = data[0]; @@ -39,6 +40,7 @@ void do_checksums(char *data, int len, char *xor, char *add) *add += data[i]; } } +*/ void uart_init(void) { @@ -60,46 +62,50 @@ void uart_init(void) IO_INTC_EINT0 |= (1<<IRQ_UART1); } -void uartPutc(char ch) { - // Wait for room in FIFO +void uart1_putc(char ch) +{ + /* Wait for room in FIFO */ while ((IO_UART1_TFCR & 0x3f) >= 0x20); - // Write character + /* Write character */ IO_UART1_DTRR=ch; } -// Unsigned integer to ASCII hexadecimal conversion -void uartPutHex(unsigned int n) { +/* Unsigned integer to ASCII hexadecimal conversion */ +void uart1_putHex(unsigned int n) +{ unsigned int i; for (i = 8; i != 0; i--) { unsigned int digit = n >> 28; - uartPutc(digit >= 10 ? digit - 10 + 'A' : digit + '0'); + uart1_putc(digit >= 10 ? digit - 10 + 'A' : digit + '0'); n <<= 4; } } -void uartPuts(const char *str) { +void uart1_puts(const char *str) +{ char ch; while ((ch = *str++) != '\0') { - uartPutc(ch); + uart1_putc(ch); } } -void uartGets(char *str, unsigned int size) { +void uart1_gets(char *str, unsigned int size) +{ for (;;) { char ch; - // Wait for FIFO to contain something + /* Wait for FIFO to contain something */ while ((IO_UART1_RFCR & 0x3f) == 0); - // Read character + /* Read character */ ch = (char)IO_UART1_DTRR; - // Echo character back + /* Echo character back */ IO_UART1_DTRR=ch; - // If CR, also echo LF, null-terminate, and return + /* If CR, also echo LF, null-terminate, and return */ if (ch == '\r') { IO_UART1_DTRR='\n'; if (size) { @@ -108,7 +114,7 @@ void uartGets(char *str, unsigned int size) { return; } - // Append to buffer + /* Append to buffer */ if (size) { *str++ = ch; --size; @@ -116,17 +122,17 @@ void uartGets(char *str, unsigned int size) { } } -int uartPollch(unsigned int ticks) { +int uart1_pollch(unsigned int ticks) +{ while (ticks--) { if (IO_UART1_RFCR & 0x3f) { return IO_UART1_DTRR & 0xff; } } - return -1; } -bool uartAvailable(void) +bool uart1_available(void) { return uart1count > 0; } @@ -134,14 +140,7 @@ bool uartAvailable(void) void uart1_heartbeat(void) { char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; - uartPuts(data); -} - -void uartSendData(char* data, int len) -{ - int i; - for(i=0;i<len;i++) - uartPutc(data[i]); + uart1_puts(data); } bool uart1_getch(char *c) @@ -161,12 +160,14 @@ void UART1(void) { if (IO_UART1_RFCR & 0x3f) { +/* if (uart1count >= MAX_UART_BUFFER) panicf("UART1 buffer overflow"); +*/ uart1buffer[uart1write] = IO_UART1_DTRR & 0xff; uart1write = (uart1write+1) % MAX_UART_BUFFER; uart1count++; } - + IO_INTC_IRQ0 = (1<<IRQ_UART1); } diff --git a/firmware/target/arm/tms320dm320/uart-target.h b/firmware/target/arm/tms320dm320/uart-target.h index f077dc1025..70210c9f52 100644 --- a/firmware/target/arm/tms320dm320/uart-target.h +++ b/firmware/target/arm/tms320dm320/uart-target.h @@ -23,11 +23,12 @@ void uart_init(void);
bool uart1_getch(char *c);
void uart1_heartbeat(void);
+bool uart1_available(void);
-void uartPuts(const char *str);
-void uartGets(char *str, unsigned int size);
-int uartPollch(unsigned int ticks);
-void uartPutc(char ch);
-void uartPutHex(unsigned int n);
+void uart1_puts(const char *str);
+void uart1_gets(char *str, unsigned int size);
+int uart1_pollch(unsigned int ticks);
+void uart1_putc(char ch);
+void uart1_putHex(unsigned int n);
#endif
|