From 83d6b0b6c54695656d468579cdb932b159e5a4a6 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 19 Nov 2015 00:39:30 -0600 Subject: [PATCH] Fix 32 bit shifting issue --- spi1_alt2/serial.c | 2 +- uart0_alt1/serial.c | 3 ++- uart1_alt2/serial.c | 3 ++- usb_ep0/serial.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spi1_alt2/serial.c b/spi1_alt2/serial.c index d332917..eaebb8e 100644 --- a/spi1_alt2/serial.c +++ b/spi1_alt2/serial.c @@ -180,7 +180,7 @@ uint16_t serial_rx_word() { } uint32_t serial_rx_long() { - return serial_rx_word() << 16 + serial_rx_word(); + return ((uint32_t)serial_rx_word() << 16) + serial_rx_word(); } void serial_tx_byte(uint8_t tx_byte) { diff --git a/uart0_alt1/serial.c b/uart0_alt1/serial.c index 05a3cd5..77b2dca 100644 --- a/uart0_alt1/serial.c +++ b/uart0_alt1/serial.c @@ -44,9 +44,10 @@ uint16_t serial_rx_word() { } uint32_t serial_rx_long() { - return serial_rx_word() << 16 + serial_rx_word(); + return ((uint32_t)serial_rx_word() << 16) + serial_rx_word(); } + void serial_tx_byte(uint8_t tx_byte) { UTX0IF = 0; U0DBUF = tx_byte; diff --git a/uart1_alt2/serial.c b/uart1_alt2/serial.c index fa6ed37..0d1185c 100644 --- a/uart1_alt2/serial.c +++ b/uart1_alt2/serial.c @@ -44,9 +44,10 @@ uint16_t serial_rx_word() { } uint32_t serial_rx_long() { - return serial_rx_word() << 16 + serial_rx_word(); + return ((uint32_t)serial_rx_word() << 16) + serial_rx_word(); } + void serial_tx_byte(uint8_t tx_byte) { UTX1IF = 0; U1DBUF = tx_byte; diff --git a/usb_ep0/serial.c b/usb_ep0/serial.c index 62bc8a1..b566847 100644 --- a/usb_ep0/serial.c +++ b/usb_ep0/serial.c @@ -46,9 +46,10 @@ uint16_t serial_rx_word() { } uint32_t serial_rx_long() { - return serial_rx_word() << 16 + serial_rx_word(); + return ((uint32_t)serial_rx_word() << 16) + serial_rx_word(); } + void flush_serial( ) { GREEN_LED ^= 1; usb_flush( );