summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32/stm32_serial.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-10-11 19:52:20 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-10-11 19:52:20 +0000
commit58278ea5cfe0d7bf7bdba285052d506c6cc677f3 (patch)
tree4455652298bcc4d204d17222dddd709481252b4c /nuttx/arch/arm/src/stm32/stm32_serial.c
parentdbda6f5f4a9f9175500e1db3641245be6f9fd3ac (diff)
downloadpx4-nuttx-58278ea5cfe0d7bf7bdba285052d506c6cc677f3.tar.gz
px4-nuttx-58278ea5cfe0d7bf7bdba285052d506c6cc677f3.tar.bz2
px4-nuttx-58278ea5cfe0d7bf7bdba285052d506c6cc677f3.zip
Basic USART setup works
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2126 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_serial.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_serial.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_serial.c b/nuttx/arch/arm/src/stm32/stm32_serial.c
index e56a8e7d0..c2518707e 100644
--- a/nuttx/arch/arm/src/stm32/stm32_serial.c
+++ b/nuttx/arch/arm/src/stm32/stm32_serial.c
@@ -325,30 +325,21 @@ static uart_dev_t g_usart3port =
* Name: up_serialin
****************************************************************************/
-static inline uint16 up_serialin(struct up_dev_s *priv, int offset)
+static inline uint32 up_serialin(struct up_dev_s *priv, int offset)
{
- return getreg16(priv->usartbase + offset);
+ return getreg32(priv->usartbase + offset);
}
/****************************************************************************
* Name: up_serialout
****************************************************************************/
-static inline void up_serialout(struct up_dev_s *priv, int offset, uint16 value)
+static inline void up_serialout(struct up_dev_s *priv, int offset, uint32 value)
{
putreg16(value, priv->usartbase + offset);
}
/****************************************************************************
- * Name: up_serialout32
- ****************************************************************************/
-
-static inline void up_serialout32(struct up_dev_s *priv, int offset, uint32 value)
-{
- putreg32(value, priv->usartbase + offset);
-}
-
-/****************************************************************************
* Name: up_disableusartint
****************************************************************************/
@@ -356,8 +347,8 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16 *ie)
{
if (ie)
{
- uint16 cr1;
- uint16 cr3;
+ uint32 cr1;
+ uint32 cr3;
/* USART interrupts:
*
@@ -399,7 +390,7 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16 *ie)
static inline void up_restoreusartint(struct up_dev_s *priv, uint16 ie)
{
- uint16 cr;
+ uint32 cr;
/* Save the interrupt mask */
@@ -435,7 +426,7 @@ static int up_setup(struct uart_dev_s *dev)
uint32 mantissa;
uint32 fraction;
uint32 brr;
- uint16 regval;
+ uint32 regval;
/* Note: The logic here depends on the fact that that the USART module
* was enabled and the pins were configured in stm32_lowsetup().
@@ -458,13 +449,13 @@ static int up_setup(struct uart_dev_s *dev)
/* Configure CR1 */
/* Clear M, PCE, PS, TE, REm and all interrupt enable bits */
-
+
regval = up_serialin(priv, STM32_USART_CR1_OFFSET);
regval &= ~(USART_CR1_M|USART_CR1_PCE|USART_CR1_PS|USART_CR1_TE|
USART_CR1_RE|USART_CR1_ALLINTS);
/* Configure word length and parity mode */
-
+
if (priv->bits == 9) /* Default: 1 start, 8 data, n stop */
{
regval |= USART_CR1_M; /* 1 start, 9 data, n stop */
@@ -481,7 +472,7 @@ static int up_setup(struct uart_dev_s *dev)
up_serialout(priv, STM32_USART_CR1_OFFSET, regval);
/* Configure CR3 */
- /* Clear CTSE, RTSE, and all interrupt enable bits */
+ /* Clear CTSE, RTSE, and all interrupt enable bits */
regval = up_serialin(priv, STM32_USART_CR3_OFFSET);
regval &= ~(USART_CR3_CTSIE|USART_CR3_CTSE|USART_CR3_RTSE|USART_CR3_EIE);
@@ -517,7 +508,7 @@ static int up_setup(struct uart_dev_s *dev)
fraction = (usartdiv32 - (mantissa << 5) + 1) >> 1;
brr |= fraction << USART_BRR_FRAC_SHIFT;
- up_serialout32(priv, STM32_USART1_BRR, brr);
+ up_serialout(priv, STM32_USART1_BRR, brr);
/* Enable Rx, Tx, and the USART */
@@ -544,7 +535,7 @@ static int up_setup(struct uart_dev_s *dev)
static void up_shutdown(struct uart_dev_s *dev)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
- uint16 regval;
+ uint32 regval;
/* Disable all interrupts */
@@ -786,7 +777,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
static int up_receive(struct uart_dev_s *dev, uint32 *status)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
- uint16 dr;
+ uint32 dr;
/* Get the Rx byte */
@@ -794,7 +785,7 @@ static int up_receive(struct uart_dev_s *dev, uint32 *status)
/* Get the Rx byte plux error information. Return those in status */
- *status = (uint32)priv->sr << 16 | dr;
+ *status = priv->sr << 16 | dr;
priv->sr = 0;
/* Then return the actual received byte */
@@ -880,7 +871,7 @@ static boolean up_rxavailable(struct uart_dev_s *dev)
static void up_send(struct uart_dev_s *dev, int ch)
{
struct up_dev_s *priv = (struct up_dev_s*)dev->priv;
- up_serialout(priv, STM32_USART_DR_OFFSET, (uint16)ch);
+ up_serialout(priv, STM32_USART_DR_OFFSET, (uint32)ch);
}
/****************************************************************************