21 #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS 26 #if HAL_USE_ICU == TRUE 30 if (chan > ICU_CHANNEL_2) {
39 dma = STM32_DMA_STREAM(dma_stream);
41 bool dma_allocated = dmaStreamAllocate(
dma,
45 osalDbgAssert(!dma_allocated,
"stream already allocated");
48 dmaStreamSetPeripheral(
dma, &icu_drv->tim->DMAR);
50 uint32_t dmamode = STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE;
51 dmamode |= STM32_DMA_CR_CHSEL(dma_channel);
52 dmamode |= STM32_DMA_CR_PL(0);
54 dmaStreamSetTransactionSize(
dma, _bounce_buf_size);
55 dmaStreamSetMode(
dma, dmamode | STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_PSIZE_WORD |
56 STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE);
64 if (chan == ICU_CHANNEL_1) {
65 icucfg.dier = STM32_TIM_DIER_CC1DE;
66 icucfg.mode = ICU_INPUT_ACTIVE_HIGH;
69 icucfg.mode = ICU_INPUT_ACTIVE_LOW;
70 icucfg.dier = STM32_TIM_DIER_CC2DE;
72 #ifdef HAL_RCIN_IS_INVERTED 73 icucfg.mode = (
icucfg.mode==ICU_INPUT_ACTIVE_LOW)?ICU_INPUT_ACTIVE_HIGH:ICU_INPUT_ACTIVE_LOW;
78 _icu_drv->tim->DCR = STM32_TIM_DCR_DBA(0x0D) | STM32_TIM_DCR_DBL(1);
95 dmaStreamSetMemory0(sig_reader->
dma, sig_reader->
signal);
97 dmaStreamEnable(sig_reader->
dma);
109 uint32_t tmp = widths1;
138 #endif // HAL_USE_ICU 140 #endif //CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
void stm32_timer_set_input_filter(stm32_tim_t *tim, uint8_t channel, uint8_t filter_mode)
bool attach_capture_timer(ICUDriver *icu_drv, icuchannel_t chan, uint8_t dma_stream, uint32_t dma_channel)
ObjectBuffer< uint32_t > sigbuf
virtual void free_type(void *ptr, size_t size, Memory_Type mem_type)
bool read(uint32_t &widths0, uint32_t &widths1)
enum Dma_stream dma_stream
virtual void * malloc_type(size_t size, Memory_Type mem_type)
bool push(const T &object)
AP_HAL::AnalogSource * chan
uint16_t _bounce_buf_size
#define INPUT_CAPTURE_FREQUENCY
static void _irq_handler(void *self, uint32_t flags)
bool set_bounce_buf_size(uint16_t buf_size)
const stm32_dma_stream_t * dma