-
Notifications
You must be signed in to change notification settings - Fork 441
DMA based bitbanging level interface #79
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
src/drivers/stm32/drv_dma_bitbang.c
Outdated
@@ -0,0 +1,224 @@ | |||
/**************************************************************************** | |||
* | |||
* Copyright (C) 2012 PX4 Development Team. All rights reserved. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/drivers/stm32/drv_dma_bitbang.c
Outdated
*/ | ||
void dma_bb_send_buff(uint32_t* dat, uint32_t len, dma_callback_t callback, void* arg) | ||
{ | ||
if(!init) { |
There was a problem hiding this comment.
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); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/drivers/stm32/drv_dma_bitbang.c
Outdated
static DMA_HANDLE tx_dma; | ||
|
||
static void dma_reset(void); | ||
static bool init = false; |
There was a problem hiding this comment.
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.
4245345
to
fc09be8
Compare
@lucasdemarchi @tridge I have the requested changes, please do the needful. |
@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? |
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.