From aefd4b65965072ddd8d0cff3c9ef5d77db26c33e Mon Sep 17 00:00:00 2001 From: David Forrest Date: Mon, 1 Apr 2013 23:33:21 -0400 Subject: [PATCH] usb_serial.c: eliminate type punning compiler warnings --- usb_serial.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/usb_serial.c b/usb_serial.c index 9893a35..66f76c4 100644 --- a/usb_serial.c +++ b/usb_serial.c @@ -309,7 +309,9 @@ static uint8_t transmit_previous_timeout=0; // serial port settings (baud rate, control signals, etc) set // by the PC. These are ignored, but kept in RAM. -static uint8_t cdc_line_coding[7]={0x00, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x08}; +static union{ + uint8_t bytes[7]; + uint32_t baud; } cdc_line_coding={{0x00, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x08}}; static uint8_t cdc_line_rtsdtr=0; @@ -652,19 +654,19 @@ void usb_serial_flush_output(void) // communication uint32_t usb_serial_get_baud(void) { - return *(uint32_t *)cdc_line_coding; + return cdc_line_coding.baud; } uint8_t usb_serial_get_stopbits(void) { - return cdc_line_coding[4]; + return cdc_line_coding.bytes[4]; } uint8_t usb_serial_get_paritytype(void) { - return cdc_line_coding[5]; + return cdc_line_coding.bytes[5]; } uint8_t usb_serial_get_numbits(void) { - return cdc_line_coding[6]; + return cdc_line_coding.bytes[6]; } uint8_t usb_serial_get_control(void) { @@ -753,7 +755,7 @@ ISR(USB_GEN_vect) // Misc functions to wait for ready and send/receive packets -static inline void usb_wait_in_ready(void) +inline void usb_wait_in_ready(void) { while (!(UEINTX & (1<