changeset 2984:cd4e37e75648

* src/stm32_serial.c, src/stm32_serial.h: Set the M bit when configuring for 8 data bits + parity bit. [ Bugzilla 1001068 ]
author jld
date Fri, 31 Dec 2010 09:37:26 +0000
parents 790fa8c690f4
children 7650f522d135
files packages/devs/serial/cortexm/stm32/current/ChangeLog packages/devs/serial/cortexm/stm32/current/src/stm32_serial.c packages/devs/serial/cortexm/stm32/current/src/stm32_serial.h
diffstat 3 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/serial/cortexm/stm32/current/ChangeLog
+++ b/packages/devs/serial/cortexm/stm32/current/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-31  John Dallaway  <john@dallaway.org.uk>
+
+	* src/stm32_serial.c, src/stm32_serial.h: Set the M bit when
+	configuring for 8 data bits + parity bit. [ Bugzilla 1001068 ]
+
 2008-10-07  Nick Garnett  <nickg@ecoscentric.com>
 
 	* cdl/ser_cortexm_stm32.cdl: 
@@ -10,7 +15,7 @@ 2008-10-07  Nick Garnett  <nickg@ecoscen
 // ####GPLCOPYRIGHTBEGIN####                                                
 // -------------------------------------------                              
 // This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 2008 Free Software Foundation, Inc.                        
+// Copyright (C) 2008, 2010 Free Software Foundation, Inc.                        
 //
 // This program is free software; you can redistribute it and/or modify     
 // it under the terms of the GNU General Public License as published by     
--- a/packages/devs/serial/cortexm/stm32/current/src/stm32_serial.c
+++ b/packages/devs/serial/cortexm/stm32/current/src/stm32_serial.c
@@ -8,7 +8,7 @@
 // ####ECOSGPLCOPYRIGHTBEGIN####                                            
 // -------------------------------------------                              
 // This file is part of eCos, the Embedded Configurable Operating System.   
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2008, 2010 Free Software Foundation, Inc.
 //
 // eCos is free software; you can redistribute it and/or modify it under    
 // the terms of the GNU General Public License as published by the Free     
@@ -415,7 +415,9 @@ stm32_serial_config_port(serial_channel 
     stm32_serial_info * const stm32_chan = (stm32_serial_info *)chan->dev_priv;
     const CYG_ADDRWORD base = stm32_chan->base;
     cyg_uint32 parity = select_parity[new_config->parity];
-    cyg_uint32 word_length = select_word_length[new_config->word_length-CYGNUM_SERIAL_WORD_LENGTH_5];
+    cyg_uint32 word_length = ((new_config->word_length == CYGNUM_SERIAL_WORD_LENGTH_8) &&
+        (new_config->parity != CYGNUM_SERIAL_PARITY_NONE)) ?
+        CYGHWR_HAL_STM32_UART_CR1_M_9 : CYGHWR_HAL_STM32_UART_CR1_M_8;
     cyg_uint32 stop_bits = select_stop_bits[new_config->stop];
     cyg_uint32 cr1 = 0;
     cyg_uint32 cr2 = 0;
--- a/packages/devs/serial/cortexm/stm32/current/src/stm32_serial.h
+++ b/packages/devs/serial/cortexm/stm32/current/src/stm32_serial.h
@@ -54,16 +54,6 @@
 #include <cyg/hal/hal_io.h>  // Register definitions
 
 // ====================================================================
-// Translate system word length selector into local values.
-
-static cyg_uint32 select_word_length[] = {
-    0,
-    0,
-    0,
-    CYGHWR_HAL_STM32_UART_CR1_M_8
-};
-
-// ====================================================================
 // Translate system stop bit selector into control register bits.
 
 static cyg_uint32 select_stop_bits[] = {