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

DMA based bitbanging level interface #79

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bugobliterator
Copy link
Member

This commit adds setup and interface to dma to enable bitbanging on GPIO pins. This work is to be utilized to support ProfiLEDs by @proficnc and could easily be extended to create software based bitbanging o/p only interface like UART, I2C etc.

Also adds support for adding ledbin (generated led pattern files) to the ROMFS.

@tridge @lucasdemarchi @davidbuzz for review.

@bugobliterator bugobliterator changed the title DMA based bitbanging hardware level interface DMA based bitbanging level interface Aug 17, 2017
Copy link

@lucasdemarchi lucasdemarchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some trivial comments below. It looks good to me, and from a quick look it seems it will work, but I'm trusting on your tests since I don't have the HW.

@@ -0,0 +1,224 @@
/****************************************************************************
*
* Copyright (C) 2012 PX4 Development Team. All rights reserved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this driver in PX4. You may want to adjust the copyright. Last time @tridge asked me to adjust the license as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reference I can follow?

# define DMA_TIMER_POWER_REG STM32_RCC_APB2ENR
# define DMA_TIMER_POWER_BIT RCC_APB2ENR_TIM8EN
# define DMA_TIMER_VECTOR STM32_IRQ_TIM8CC
# define DMA_TIMER_CLOCK STM32_APB2_TIM8_CLKIN

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't all these defines be in board_config.h and then here you just error out if there's no define for BITBANG_DMA_TIMER_BASE?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am following the routine of other drivers under this category. If you look at driver for hrt and pwmin. they have same methodology for setting timer.

*/
void dma_bb_send_buff(uint32_t* dat, uint32_t len, dma_callback_t callback, void* arg)
{
if(!init) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick on coding style... needs a space after if

modifyreg32(DMA_TIMER_POWER_REG, 0, DMA_TIMER_POWER_BIT);

tx_dma = stm32_dmachannel(DMAMAP_BITBANG);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need a call to configgpio to make sure the pin is configured to gpio.

Copy link
Member Author

@bugobliterator bugobliterator Aug 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am leaving off the load to declare the direction settings to HAL in APM via relevant functions. In APM this is going to be interfaced via GPIO methods.

static DMA_HANDLE tx_dma;

static void dma_reset(void);
static bool init = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: dma_bitbang_initialized = false.

If dma_bb_send_buff is going to be called by a different thread than init(), then this also needs to be volatile.

@bugobliterator
Copy link
Member Author

@lucasdemarchi @tridge I have the requested changes, please do the needful.

@bugobliterator
Copy link
Member Author

@tridge I had to move HRT Timer to TIM5 from TIM8 and change USART6 DMA channel so that I can move the dycoled pins to 5th and 6th AUX pin on Pixhawk boards and spare rest of AUX channels for other usage. Do you think that's acceptable?

@tridge tridge self-assigned this Sep 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants