aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/px4io/px4io_serial.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/px4io/px4io_serial.cpp')
-rw-r--r--src/drivers/px4io/px4io_serial.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/drivers/px4io/px4io_serial.cpp b/src/drivers/px4io/px4io_serial.cpp
index d227e15d5..1a848cbc0 100644
--- a/src/drivers/px4io/px4io_serial.cpp
+++ b/src/drivers/px4io/px4io_serial.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
*
- * Copyright (c) 2013 PX4 Development Team. All rights reserved.
+ * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -217,6 +217,9 @@ PX4IO_serial::~PX4IO_serial()
stm32_unconfiggpio(PX4IO_SERIAL_TX_GPIO);
stm32_unconfiggpio(PX4IO_SERIAL_RX_GPIO);
+ /* Disable APB clock for the USART peripheral */
+ modifyreg32(STM32_RCC_APB2ENR, RCC_APB2ENR_USART6EN, 0);
+
/* and kill our semaphores */
sem_destroy(&_completion_semaphore);
sem_destroy(&_bus_semaphore);
@@ -239,12 +242,17 @@ PX4IO_serial::~PX4IO_serial()
int
PX4IO_serial::init()
{
+
/* allocate DMA */
_tx_dma = stm32_dmachannel(PX4IO_SERIAL_TX_DMAMAP);
_rx_dma = stm32_dmachannel(PX4IO_SERIAL_RX_DMAMAP);
if ((_tx_dma == nullptr) || (_rx_dma == nullptr))
return -1;
+
+ /* Enable the APB clock for the USART peripheral */
+ modifyreg32(STM32_RCC_APB2ENR, 0, RCC_APB2ENR_USART6EN);
+
/* configure pins for serial use */
stm32_configgpio(PX4IO_SERIAL_TX_GPIO);
stm32_configgpio(PX4IO_SERIAL_RX_GPIO);
@@ -258,6 +266,7 @@ PX4IO_serial::init()
(void)rSR;
(void)rDR;
+
/* configure line speed */
uint32_t usartdiv32 = PX4IO_SERIAL_CLOCK / (PX4IO_SERIAL_BITRATE / 2);
uint32_t mantissa = usartdiv32 >> 5;