its working
This commit is contained in:
@ -36,7 +36,7 @@ void spi::halMspInitDma(SPI_HandleTypeDef* hspi, MspCfgBase* cfgBase) {
|
||||
DMA_HandleTypeDef* hdma_tx = nullptr;
|
||||
DMA_HandleTypeDef* hdma_rx = nullptr;
|
||||
spi::getDmaHandles(&hdma_tx, &hdma_rx);
|
||||
if(hdma_tx == NULL || hdma_rx == NULL) {
|
||||
if(hdma_tx == nullptr or hdma_rx == nullptr) {
|
||||
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
||||
return;
|
||||
}
|
||||
@ -55,46 +55,12 @@ void spi::halMspInitDma(SPI_HandleTypeDef* hspi, MspCfgBase* cfgBase) {
|
||||
// Assume it was not configured properly
|
||||
mspErrorHandler("spi::halMspInitDma", "DMA TX handle invalid");
|
||||
}
|
||||
hdma_tx->Instance = SPIx_TX_DMA_STREAM;
|
||||
|
||||
hdma_tx->Init.Request = SPIx_TX_DMA_REQUEST;
|
||||
|
||||
// offer function to configure this..
|
||||
hdma_tx->Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
hdma_tx->Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||
hdma_tx->Init.MemBurst = DMA_MBURST_INC4;
|
||||
hdma_tx->Init.PeriphBurst = DMA_PBURST_INC4;
|
||||
hdma_tx->Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
hdma_tx->Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_tx->Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_tx->Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_tx->Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_tx->Init.Mode = DMA_NORMAL;
|
||||
hdma_tx->Init.Priority = DMA_PRIORITY_LOW;
|
||||
|
||||
HAL_DMA_Init(hdma_tx);
|
||||
|
||||
/* Associate the initialized DMA handle to the the SPI handle */
|
||||
__HAL_LINKDMA(hspi, hdmatx, *hdma_tx);
|
||||
|
||||
/* Configure the DMA handler for Transmission process */
|
||||
hdma_rx->Instance = SPIx_RX_DMA_STREAM;
|
||||
|
||||
hdma_rx->Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
hdma_rx->Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||
hdma_rx->Init.MemBurst = DMA_MBURST_INC4;
|
||||
hdma_rx->Init.PeriphBurst = DMA_PBURST_INC4;
|
||||
hdma_rx->Init.Request = SPIx_RX_DMA_REQUEST;
|
||||
hdma_rx->Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_rx->Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_rx->Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_rx->Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_rx->Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_rx->Init.Mode = DMA_NORMAL;
|
||||
hdma_rx->Init.Priority = DMA_PRIORITY_HIGH;
|
||||
|
||||
HAL_DMA_Init(hdma_rx);
|
||||
|
||||
/* Associate the initialized DMA handle to the the SPI handle */
|
||||
__HAL_LINKDMA(hspi, hdmarx, *hdma_rx);
|
||||
|
||||
@ -111,14 +77,6 @@ void spi::halMspInitDma(SPI_HandleTypeDef* hspi, MspCfgBase* cfgBase) {
|
||||
&spi::dmaTxIrqHandler, hdma_tx);
|
||||
HAL_NVIC_SetPriority(cfg->txDmaIrqNumber, cfg->txPreEmptPriority, cfg->txSubpriority);
|
||||
HAL_NVIC_EnableIRQ(cfg->txDmaIrqNumber);
|
||||
|
||||
/*##-5- Configure the NVIC for SPI #########################################*/
|
||||
/* NVIC configuration for SPI transfer complete interrupt (SPI1) */
|
||||
// Assign the interrupt handler
|
||||
spi::assignSpiUserHandler(spi::SPI_1, &spi::spiIrqHandler, hspi);
|
||||
HAL_NVIC_SetPriority(SPIx_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(SPIx_IRQn);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user