converted files to cpp
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
#include <fsfw_hal/stm32h7/dmaInterrupts.h>
|
||||
#include "mspInit.h"
|
||||
#include "spiConf.h"
|
||||
#include "spiCore.h"
|
||||
#include "spiInterrupts.h"
|
||||
#include "../dma_interrupts.h"
|
||||
|
||||
#include "stm32h743xx.h"
|
||||
#include "stm32h7xx_hal_spi.h"
|
||||
#include "stm32h7xx_hal_dma.h"
|
||||
@ -21,7 +20,7 @@
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void hal_spi_msp_init_dma(void *spi_handle) {
|
||||
void spi::halMspInitDma(void *spi_handle) {
|
||||
SPI_HandleTypeDef* hspi = (SPI_HandleTypeDef*) spi_handle;
|
||||
if(hspi == NULL) {
|
||||
return;
|
||||
@ -30,17 +29,17 @@ void hal_spi_msp_init_dma(void *spi_handle) {
|
||||
printf("HAL_SPI_MspInit: Invalid SPI handle!\n");
|
||||
return;
|
||||
}
|
||||
assign_spi_handle(hspi);
|
||||
setSpiHandle(hspi);
|
||||
|
||||
DMA_HandleTypeDef* hdma_tx = NULL;
|
||||
DMA_HandleTypeDef* hdma_rx = NULL;
|
||||
get_dma_handles(&hdma_tx, &hdma_rx);
|
||||
spi::getDmaHandles(&hdma_tx, &hdma_rx);
|
||||
if(hdma_tx == NULL || hdma_rx == NULL) {
|
||||
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
hal_spi_msp_init_polling(spi_handle);
|
||||
spi::halMspInitPolling(spi_handle);
|
||||
if (hspi->Instance == SPI1) {
|
||||
// DMA setup
|
||||
DMAx_CLK_ENABLE();
|
||||
@ -90,20 +89,22 @@ void hal_spi_msp_init_dma(void *spi_handle) {
|
||||
/*##-4- Configure the NVIC for DMA #########################################*/
|
||||
/* NVIC configuration for DMA transfer complete interrupt (SPI1_RX) */
|
||||
// Assign the interrupt handler
|
||||
assign_dma_user_handler(DMA_2, DMAStreams::STREAM_2, &dma_rx_irq_handler, hdma_rx);
|
||||
dma::assignDmaUserHandler(dma::DMAIndexes::DMA_2, dma::DMAStreams::STREAM_2,
|
||||
&spi::dmaRxIrqHandler, hdma_rx);
|
||||
HAL_NVIC_SetPriority(SPIx_DMA_RX_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(SPIx_DMA_RX_IRQn);
|
||||
|
||||
/* NVIC configuration for DMA transfer complete interrupt (SPI1_TX) */
|
||||
// Assign the interrupt handler
|
||||
assign_dma_user_handler(DMA_2, DMAStreams::STREAM_3, &dma_tx_irq_handler, hdma_tx);
|
||||
dma::assignDmaUserHandler(dma::DMAIndexes::DMA_2, dma::DMAStreams::STREAM_3,
|
||||
&spi::dmaTxIrqHandler, hdma_tx);
|
||||
HAL_NVIC_SetPriority(SPIx_DMA_TX_IRQn, 1, 1);
|
||||
HAL_NVIC_EnableIRQ(SPIx_DMA_TX_IRQn);
|
||||
|
||||
/*##-5- Configure the NVIC for SPI #########################################*/
|
||||
/* NVIC configuration for SPI transfer complete interrupt (SPI1) */
|
||||
// Assign the interrupt handler
|
||||
assign_spi_user_handler(spi::SPI_1, &spi1_irq_handler, hspi);
|
||||
spi::assignSpiUserHandler(spi::SPI_1, &spi::spi1IrqHandler, hspi);
|
||||
HAL_NVIC_SetPriority(SPIx_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(SPIx_IRQn);
|
||||
}
|
||||
@ -117,17 +118,17 @@ void hal_spi_msp_init_dma(void *spi_handle) {
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void hal_spi_msp_deinit_dma(void *spi_handle)
|
||||
void spi::halMspDeinitDma(void *spi_handle)
|
||||
{
|
||||
SPI_HandleTypeDef* hspi = (SPI_HandleTypeDef*) spi_handle;
|
||||
if(hspi == NULL) {
|
||||
return;
|
||||
}
|
||||
hal_spi_msp_deinit_polling(spi_handle);
|
||||
spi::halMspDeinitPolling(spi_handle);
|
||||
if(hspi->Instance == SPIx) {
|
||||
DMA_HandleTypeDef* hdma_tx = NULL;
|
||||
DMA_HandleTypeDef* hdma_rx = NULL;
|
||||
get_dma_handles(&hdma_tx, &hdma_rx);
|
||||
spi::getDmaHandles(&hdma_tx, &hdma_rx);
|
||||
if(hdma_tx == NULL || hdma_rx == NULL) {
|
||||
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
||||
}
|
||||
@ -148,7 +149,7 @@ void hal_spi_msp_deinit_dma(void *spi_handle)
|
||||
}
|
||||
}
|
||||
|
||||
void hal_spi_msp_init_polling(void *hspi) {
|
||||
void spi::halMspInitPolling(void *hspi) {
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {};
|
||||
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
||||
/* Enable GPIO TX/RX clock */
|
||||
@ -178,7 +179,7 @@ void hal_spi_msp_init_polling(void *hspi) {
|
||||
HAL_GPIO_Init(SPIx_MOSI_GPIO_PORT, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
void hal_spi_msp_deinit_polling(void *hspi) {
|
||||
void spi::halMspDeinitPolling(void *hspi) {
|
||||
/*##-1- Reset peripherals ##################################################*/
|
||||
SPIx_FORCE_RESET();
|
||||
SPIx_RELEASE_RESET();
|
||||
@ -192,16 +193,16 @@ void hal_spi_msp_deinit_polling(void *hspi) {
|
||||
HAL_GPIO_DeInit(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_PIN);
|
||||
}
|
||||
|
||||
void hal_spi_msp_init_interrupt(void *hspi) {
|
||||
hal_spi_msp_init_polling(hspi);
|
||||
void spi::halMspInitInterrupt(void *hspi) {
|
||||
spi::halMspInitPolling(hspi);
|
||||
// Configure the NVIC for SPI
|
||||
assign_spi_user_handler(spi::SPI_1, &spi1_irq_handler, hspi);
|
||||
spi::assignSpiUserHandler(spi::SPI_1, &spi::spi1IrqHandler, hspi);
|
||||
HAL_NVIC_SetPriority(SPIx_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(SPIx_IRQn);
|
||||
}
|
||||
|
||||
void hal_spi_msp_deinit_interrupt(void *hspi) {
|
||||
hal_spi_msp_deinit_polling(hspi);
|
||||
void spi::halMspDeinitInterrupt(void *hspi) {
|
||||
spi::halMspDeinitPolling(hspi);
|
||||
// Disable the NVIC for SPI
|
||||
HAL_NVIC_DisableIRQ(SPIx_IRQn);
|
||||
}
|
||||
|
Reference in New Issue
Block a user