Skip to content

Commit

Permalink
Fix 32 bit shifting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Nov 19, 2015
1 parent 37065bd commit 83d6b0b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion spi1_alt2/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion uart0_alt1/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion uart1_alt2/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion usb_ep0/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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( );
Expand Down

0 comments on commit 83d6b0b

Please sign in to comment.