Transmit DMX data with DMA

I’m trying to port a DMX library made for the STM32F4Discovery board to the Photon. However probably something goes wrong in the DMA/Interrupt configuration.

I’ve tried to modify the code based on different w2812 dma, one wire and the Spark Interval Timer library

I had the idea I might the right selection of DMA Channels, Timers etc. (also based on the STM manual). However after uploading I can’t use the Serial ports anymore. I’m a bit clueless how to debug further.

This is a pretty new topic for me, so I’m not 100% sure if my conclusions are good.

I use now Timer4, which is only used for i2c as far as I’m aware. What I understood as well is that for DMA I need to use timer 2-4, because higher timers (6 and 7 seem free) can’t be used.

I use DMA1, stream5 (which I think is mapped to timer4).

I’ve noticed that I get an error on 'RCC_APB2Periph_GPIOB' was not declared in this scope RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); However all the other low-level GPIO commands seem to be supported.

I tried to work around this with:

GPIO_TypeDef *gpio_port = PIN_MAP[dmxPin].gpio_peripheral;

HAL_Pin_Mode(dmxPin, OUTPUT);

if (gpio_port == GPIOA ) {
    dmxOutputPort = (uint32_t)&GPIOA->ODR;
}
else if (gpio_port == GPIOB ) {
    dmxOutputPort = (uint32_t)&GPIOB->ODR;
}

I hope someone that understands the low-level stuff has time to chime in. @bko @peekay123 @BDub

Maybe I overlook something essential.

The whole code on Gist:

My next try would be SPI.transfer. However that limits the DMX output to A5 or D2 (SPI MOSI).