Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Bug fix:The CRC detection on px4io was failing with -1 result, do the…
Browse files Browse the repository at this point in the history
… the fact that the PX4IO_Uploader had closed the port and Nuttx (now) disabled the clock and PX4IO_serial did not managed the clock
  • Loading branch information
David Sidrane committed Jan 26, 2015
1 parent 72f4229 commit 9dcd7ef
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/drivers/px4io/px4io_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 9dcd7ef

Please sign in to comment.