[Pito – Mon Oct 09, 2017 3:15 pm] –
Comment out all delays if you need more speed (bitBangedSPI.cpp):
First try to use this code, when you gather more experience with stm32 you may replace the digitalWrite()..
I just tried it , i do see some speed but , this isnt the issue though.
i suspect that i am making something wrong , and i guess its the intrerupt that i am not taking care of , so i will post my code in order to get things straigh,
So my normal code before the bit bang is
........
dma_init(SPIDMA_1);
dma_attach_interrupt(SPIDMA_1, DMA_CH3, &DMA1_CH3_handler);
spi_tx_dma_enable(SPI_Class->dev());
.......
// Interrupt handler for DMA (clear data output)
void DMA1_CH3_handler()
{
while(SPI_Class->dev()->regs->SR & SPI_SR_BSY);
SPI_Class->dev()->regs->DR = 0;
}
///SEND DATA
void SPI_dmaSend(uint8_t *transmitBuffer, uint16_t length) {
//DATA SEND INTO PA7 MOSI1
dma_setup_transfer(
SPIDMA_1, DMA_CH3, // DMA channel specification for SPI 1
&SPI_Class->dev()->regs->DR, // destination address: specify the SPI data register
DMA_SIZE_8BITS, // Destination data size: 1 byte
transmitBuffer, // source address: SRAM address
DMA_SIZE_8BITS, // Destination data size: 1 byte
DMA_MINC_MODE| // flag: cyclic
DMA_FROM_MEM | // Peripheral from memory, transfer complete interrupted
DMA_TRNS_CMPLT // Transfer complete Interrupted calling * /
);
dma_set_num_transfers(SPIDMA_1, DMA_CH3, length);
dma_enable(SPIDMA_1, DMA_CH3);
}