converted files to cpp
This commit is contained in:
parent
be88bf1d50
commit
01d3bc2568
@ -2,5 +2,5 @@ add_subdirectory(spi)
|
|||||||
add_subdirectory(devicetest)
|
add_subdirectory(devicetest)
|
||||||
|
|
||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
dma_interrupts.c
|
dmaInterrupts.cpp
|
||||||
)
|
)
|
||||||
|
@ -27,18 +27,22 @@ GyroL3GD20H::GyroL3GD20H(SPI_HandleTypeDef *spiHandle, spi::TransferModes transf
|
|||||||
spiHandle(spiHandle) {
|
spiHandle(spiHandle) {
|
||||||
transferMode = transferMode_;
|
transferMode = transferMode_;
|
||||||
if(transferMode == spi::TransferModes::DMA) {
|
if(transferMode == spi::TransferModes::DMA) {
|
||||||
set_dma_handles(&txDmaHandle, &rxDmaHandle);
|
spi::setDmaHandles(&txDmaHandle, &rxDmaHandle);
|
||||||
set_spi_msp_functions(&hal_spi_msp_init_dma, spiHandle, &hal_spi_msp_deinit_dma, spiHandle);
|
spi::setSpiMspFunctions(&spi::halMspInitDma, spiHandle,
|
||||||
|
&spi::halMspDeinitDma, spiHandle);
|
||||||
}
|
}
|
||||||
else if(transferMode == spi::TransferModes::INTERRUPT) {
|
else if(transferMode == spi::TransferModes::INTERRUPT) {
|
||||||
set_spi_msp_functions(&hal_spi_msp_init_interrupt, spiHandle,
|
spi::setSpiMspFunctions(&spi::halMspInitInterrupt, spiHandle,
|
||||||
&hal_spi_msp_deinit_interrupt, spiHandle);
|
&spi::halMspDeinitInterrupt, spiHandle);
|
||||||
}
|
}
|
||||||
else if(transferMode == spi::TransferModes::POLLING) {
|
else if(transferMode == spi::TransferModes::POLLING) {
|
||||||
set_spi_msp_functions(&hal_spi_msp_init_polling, spiHandle,
|
spi::setSpiMspFunctions(&spi::halMspInitPolling, spiHandle,
|
||||||
&hal_spi_msp_deinit_polling, spiHandle);
|
&spi::halMspDeinitPolling, spiHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spi::assignTransferRxTxCompleteCallback(&spiTransferCompleteCallback, nullptr);
|
||||||
|
spi::assignTransferErrorCallback(&spiTransferErrorCallback, nullptr);
|
||||||
|
|
||||||
GPIO_InitTypeDef chipSelect = {};
|
GPIO_InitTypeDef chipSelect = {};
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
chipSelect.Pin = GPIO_PIN_14;
|
chipSelect.Pin = GPIO_PIN_14;
|
||||||
@ -502,14 +506,8 @@ void GyroL3GD20H::handleSensorReadout() {
|
|||||||
sif::printInfo("Gyro Z: %f\n", gyroZ);
|
sif::printInfo("Gyro Z: %f\n", gyroZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief TxRx Transfer completed callback.
|
void GyroL3GD20H::spiTransferCompleteCallback(SPI_HandleTypeDef *hspi, void* args) {
|
||||||
* @param hspi: SPI handle
|
|
||||||
* @note This example shows a simple way to report end of DMA TxRx transfer, and
|
|
||||||
* you can add your own implementation.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) {
|
|
||||||
transferState = TransferStates::SUCCESS;
|
transferState = TransferStates::SUCCESS;
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
if(GyroL3GD20H::transferMode == spi::TransferModes::DMA) {
|
if(GyroL3GD20H::transferMode == spi::TransferModes::DMA) {
|
||||||
@ -526,6 +524,6 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) {
|
|||||||
* add your own implementation.
|
* add your own implementation.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi) {
|
void GyroL3GD20H::spiTransferErrorCallback(SPI_HandleTypeDef *hspi, void* args) {
|
||||||
transferState = TransferStates::FAILURE;
|
transferState = TransferStates::FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ enum class TransferStates {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class GyroL3GD20H {
|
class GyroL3GD20H {
|
||||||
friend void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
|
|
||||||
public:
|
public:
|
||||||
GyroL3GD20H(SPI_HandleTypeDef* spiHandle, spi::TransferModes transferMode);
|
GyroL3GD20H(SPI_HandleTypeDef* spiHandle, spi::TransferModes transferMode);
|
||||||
|
|
||||||
@ -51,6 +50,10 @@ private:
|
|||||||
ReturnValue_t handlePollingSensorRead();
|
ReturnValue_t handlePollingSensorRead();
|
||||||
ReturnValue_t handleInterruptSensorRead();
|
ReturnValue_t handleInterruptSensorRead();
|
||||||
|
|
||||||
|
friend void spiTransferCompleteCallback(SPI_HandleTypeDef *hspi, void* args);
|
||||||
|
static void spiTransferCompleteCallback(SPI_HandleTypeDef *hspi, void* args);
|
||||||
|
static void spiTransferErrorCallback(SPI_HandleTypeDef *hspi, void* args);
|
||||||
|
|
||||||
void prepareConfigRegs(uint8_t* configRegs);
|
void prepareConfigRegs(uint8_t* configRegs);
|
||||||
void handleSensorReadout();
|
void handleSensorReadout();
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "dma_interrupts.h"
|
#include "dmaInterrupts.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -9,7 +9,7 @@ user_args_t DMA_1_USER_ARGS[8];
|
|||||||
user_handler_t DMA_2_USER_HANDLERS[8];
|
user_handler_t DMA_2_USER_HANDLERS[8];
|
||||||
user_args_t DMA_2_USER_ARGS[8];
|
user_args_t DMA_2_USER_ARGS[8];
|
||||||
|
|
||||||
void assign_dma_user_handler(DMAIndexes dma_idx, DMAStreams stream_idx,
|
void dma::assignDmaUserHandler(DMAIndexes dma_idx, DMAStreams stream_idx,
|
||||||
user_handler_t user_handler, user_args_t user_args) {
|
user_handler_t user_handler, user_args_t user_args) {
|
||||||
if(dma_idx == DMA_1) {
|
if(dma_idx == DMA_1) {
|
||||||
DMA_1_USER_HANDLERS[stream_idx] = user_handler;
|
DMA_1_USER_HANDLERS[stream_idx] = user_handler;
|
||||||
@ -33,52 +33,52 @@ defined in the startup_stm32h743xx.s files! */
|
|||||||
} \
|
} \
|
||||||
Default_Handler() \
|
Default_Handler() \
|
||||||
|
|
||||||
void DMA1_Stream0_IRQHandler() {
|
extern"C" void DMA1_Stream0_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 0);
|
GENERIC_DMA_IRQ_HANDLER(1, 0);
|
||||||
}
|
}
|
||||||
void DMA1_Stream1_IRQHandler() {
|
extern"C" void DMA1_Stream1_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 1);
|
GENERIC_DMA_IRQ_HANDLER(1, 1);
|
||||||
}
|
}
|
||||||
void DMA1_Stream2_IRQHandler() {
|
extern"C" void DMA1_Stream2_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 2);
|
GENERIC_DMA_IRQ_HANDLER(1, 2);
|
||||||
}
|
}
|
||||||
void DMA1_Stream3_IRQHandler() {
|
extern"C" void DMA1_Stream3_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 3);
|
GENERIC_DMA_IRQ_HANDLER(1, 3);
|
||||||
}
|
}
|
||||||
void DMA1_Stream4_IRQHandler() {
|
extern"C" void DMA1_Stream4_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 4);
|
GENERIC_DMA_IRQ_HANDLER(1, 4);
|
||||||
}
|
}
|
||||||
void DMA1_Stream5_IRQHandler() {
|
extern"C" void DMA1_Stream5_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 5);
|
GENERIC_DMA_IRQ_HANDLER(1, 5);
|
||||||
}
|
}
|
||||||
void DMA1_Stream6_IRQHandler() {
|
extern"C" void DMA1_Stream6_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 6);
|
GENERIC_DMA_IRQ_HANDLER(1, 6);
|
||||||
}
|
}
|
||||||
void DMA1_Stream7_IRQHandler() {
|
extern"C" void DMA1_Stream7_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(1, 7);
|
GENERIC_DMA_IRQ_HANDLER(1, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMA2_Stream0_IRQHandler() {
|
extern"C" void DMA2_Stream0_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 0);
|
GENERIC_DMA_IRQ_HANDLER(2, 0);
|
||||||
}
|
}
|
||||||
void DMA2_Stream1_IRQHandler() {
|
extern"C" void DMA2_Stream1_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 1);
|
GENERIC_DMA_IRQ_HANDLER(2, 1);
|
||||||
}
|
}
|
||||||
void DMA2_Stream2_IRQHandler() {
|
extern"C" void DMA2_Stream2_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 2);
|
GENERIC_DMA_IRQ_HANDLER(2, 2);
|
||||||
}
|
}
|
||||||
void DMA2_Stream3_IRQHandler() {
|
extern"C" void DMA2_Stream3_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 3);
|
GENERIC_DMA_IRQ_HANDLER(2, 3);
|
||||||
}
|
}
|
||||||
void DMA2_Stream4_IRQHandler() {
|
extern"C" void DMA2_Stream4_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 4);
|
GENERIC_DMA_IRQ_HANDLER(2, 4);
|
||||||
}
|
}
|
||||||
void DMA2_Stream5_IRQHandler() {
|
extern"C" void DMA2_Stream5_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 5);
|
GENERIC_DMA_IRQ_HANDLER(2, 5);
|
||||||
}
|
}
|
||||||
void DMA2_Stream6_IRQHandler() {
|
extern"C" void DMA2_Stream6_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 6);
|
GENERIC_DMA_IRQ_HANDLER(2, 6);
|
||||||
}
|
}
|
||||||
void DMA2_Stream7_IRQHandler() {
|
extern"C" void DMA2_Stream7_IRQHandler() {
|
||||||
GENERIC_DMA_IRQ_HANDLER(2, 7);
|
GENERIC_DMA_IRQ_HANDLER(2, 7);
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FSFW_HAL_STM32H7_DMA_INTERRUPTS_H_
|
#ifndef FSFW_HAL_STM32H7_DMAINTERRUPTS_H_
|
||||||
#define FSFW_HAL_STM32H7_DMA_INTERRUPTS_H_
|
#define FSFW_HAL_STM32H7_DMAINTERRUPTS_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -7,12 +7,14 @@ extern "C" {
|
|||||||
|
|
||||||
#include "interrupts.h"
|
#include "interrupts.h"
|
||||||
|
|
||||||
typedef enum {
|
namespace dma {
|
||||||
|
|
||||||
|
enum DMAIndexes {
|
||||||
DMA_1 = 0,
|
DMA_1 = 0,
|
||||||
DMA_2 = 1
|
DMA_2 = 1
|
||||||
} DMAIndexes;
|
} ;
|
||||||
|
|
||||||
typedef enum {
|
enum DMAStreams {
|
||||||
STREAM_0 = 0,
|
STREAM_0 = 0,
|
||||||
STREAM_1 = 1,
|
STREAM_1 = 1,
|
||||||
STREAM_2 = 2,
|
STREAM_2 = 2,
|
||||||
@ -21,7 +23,7 @@ typedef enum {
|
|||||||
STREAM_5 = 5,
|
STREAM_5 = 5,
|
||||||
STREAM_6 = 6,
|
STREAM_6 = 6,
|
||||||
STREAM_7 = 7,
|
STREAM_7 = 7,
|
||||||
} DMAStreams;
|
} ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign user interrupt handlers for DMA streams, allowing to pass an
|
* Assign user interrupt handlers for DMA streams, allowing to pass an
|
||||||
@ -29,11 +31,13 @@ typedef enum {
|
|||||||
* @param user_handler
|
* @param user_handler
|
||||||
* @param user_args
|
* @param user_args
|
||||||
*/
|
*/
|
||||||
void assign_dma_user_handler(DMAIndexes dma_idx, DMAStreams stream_idx,
|
void assignDmaUserHandler(DMAIndexes dma_idx, DMAStreams stream_idx,
|
||||||
user_handler_t user_handler, user_args_t user_args);
|
user_handler_t user_handler, user_args_t user_args);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* FSFW_HAL_STM32H7_DMA_INTERRUPTS_H_ */
|
#endif /* FSFW_HAL_STM32H7_DMAINTERRUPTS_H_ */
|
@ -37,14 +37,14 @@ void SpiComIF::configureCacheMaintenanceOnTxBuffer(bool enable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpiComIF::addDmaHandles(DMA_HandleTypeDef *txHandle, DMA_HandleTypeDef *rxHandle) {
|
void SpiComIF::addDmaHandles(DMA_HandleTypeDef *txHandle, DMA_HandleTypeDef *rxHandle) {
|
||||||
set_dma_handles(txHandle, rxHandle);
|
spi::setDmaHandles(txHandle, rxHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t SpiComIF::initialize() {
|
ReturnValue_t SpiComIF::initialize() {
|
||||||
if(transferMode == spi::TransferModes::DMA) {
|
if(transferMode == spi::TransferModes::DMA) {
|
||||||
DMA_HandleTypeDef *txHandle = nullptr;
|
DMA_HandleTypeDef *txHandle = nullptr;
|
||||||
DMA_HandleTypeDef *rxHandle = nullptr;
|
DMA_HandleTypeDef *rxHandle = nullptr;
|
||||||
get_dma_handles(&txHandle, &rxHandle);
|
spi::getDmaHandles(&txHandle, &rxHandle);
|
||||||
if(txHandle == nullptr or rxHandle == nullptr) {
|
if(txHandle == nullptr or rxHandle == nullptr) {
|
||||||
sif::printError("SpiComIF::initialize: DMA handles not set!\n");
|
sif::printError("SpiComIF::initialize: DMA handles not set!\n");
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
@ -197,6 +197,10 @@ ReturnValue_t SpiComIF::handlePollingSendOperation(uint8_t* recvPtr, SpiCookie *
|
|||||||
|
|
||||||
ReturnValue_t SpiComIF::handleInterruptSendOperation(uint8_t* recvPtr, SpiCookie* spiCookie,
|
ReturnValue_t SpiComIF::handleInterruptSendOperation(uint8_t* recvPtr, SpiCookie* spiCookie,
|
||||||
const uint8_t * sendData, size_t sendLen) {
|
const uint8_t * sendData, size_t sendLen) {
|
||||||
|
auto gpioPort = spiCookie->getChipSelectGpioPort();
|
||||||
|
auto gpioPin = spiCookie->getChipSelectGpioPin();
|
||||||
|
spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||||
|
HAL_GPIO_WritePin(gpioPort, gpioPin, GPIO_PIN_RESET);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
#include <fsfw_hal/stm32h7/dmaInterrupts.h>
|
||||||
#include "mspInit.h"
|
#include "mspInit.h"
|
||||||
#include "spiConf.h"
|
#include "spiConf.h"
|
||||||
#include "spiCore.h"
|
#include "spiCore.h"
|
||||||
#include "spiInterrupts.h"
|
#include "spiInterrupts.h"
|
||||||
#include "../dma_interrupts.h"
|
|
||||||
|
|
||||||
#include "stm32h743xx.h"
|
#include "stm32h743xx.h"
|
||||||
#include "stm32h7xx_hal_spi.h"
|
#include "stm32h7xx_hal_spi.h"
|
||||||
#include "stm32h7xx_hal_dma.h"
|
#include "stm32h7xx_hal_dma.h"
|
||||||
@ -21,7 +20,7 @@
|
|||||||
* @param hspi: SPI handle pointer
|
* @param hspi: SPI handle pointer
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void hal_spi_msp_init_dma(void *spi_handle) {
|
void spi::halMspInitDma(void *spi_handle) {
|
||||||
SPI_HandleTypeDef* hspi = (SPI_HandleTypeDef*) spi_handle;
|
SPI_HandleTypeDef* hspi = (SPI_HandleTypeDef*) spi_handle;
|
||||||
if(hspi == NULL) {
|
if(hspi == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -30,17 +29,17 @@ void hal_spi_msp_init_dma(void *spi_handle) {
|
|||||||
printf("HAL_SPI_MspInit: Invalid SPI handle!\n");
|
printf("HAL_SPI_MspInit: Invalid SPI handle!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assign_spi_handle(hspi);
|
setSpiHandle(hspi);
|
||||||
|
|
||||||
DMA_HandleTypeDef* hdma_tx = NULL;
|
DMA_HandleTypeDef* hdma_tx = NULL;
|
||||||
DMA_HandleTypeDef* hdma_rx = 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) {
|
if(hdma_tx == NULL || hdma_rx == NULL) {
|
||||||
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hal_spi_msp_init_polling(spi_handle);
|
spi::halMspInitPolling(spi_handle);
|
||||||
if (hspi->Instance == SPI1) {
|
if (hspi->Instance == SPI1) {
|
||||||
// DMA setup
|
// DMA setup
|
||||||
DMAx_CLK_ENABLE();
|
DMAx_CLK_ENABLE();
|
||||||
@ -90,20 +89,22 @@ void hal_spi_msp_init_dma(void *spi_handle) {
|
|||||||
/*##-4- Configure the NVIC for DMA #########################################*/
|
/*##-4- Configure the NVIC for DMA #########################################*/
|
||||||
/* NVIC configuration for DMA transfer complete interrupt (SPI1_RX) */
|
/* NVIC configuration for DMA transfer complete interrupt (SPI1_RX) */
|
||||||
// Assign the interrupt handler
|
// 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_SetPriority(SPIx_DMA_RX_IRQn, 1, 0);
|
||||||
HAL_NVIC_EnableIRQ(SPIx_DMA_RX_IRQn);
|
HAL_NVIC_EnableIRQ(SPIx_DMA_RX_IRQn);
|
||||||
|
|
||||||
/* NVIC configuration for DMA transfer complete interrupt (SPI1_TX) */
|
/* NVIC configuration for DMA transfer complete interrupt (SPI1_TX) */
|
||||||
// Assign the interrupt handler
|
// 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_SetPriority(SPIx_DMA_TX_IRQn, 1, 1);
|
||||||
HAL_NVIC_EnableIRQ(SPIx_DMA_TX_IRQn);
|
HAL_NVIC_EnableIRQ(SPIx_DMA_TX_IRQn);
|
||||||
|
|
||||||
/*##-5- Configure the NVIC for SPI #########################################*/
|
/*##-5- Configure the NVIC for SPI #########################################*/
|
||||||
/* NVIC configuration for SPI transfer complete interrupt (SPI1) */
|
/* NVIC configuration for SPI transfer complete interrupt (SPI1) */
|
||||||
// Assign the interrupt handler
|
// 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_SetPriority(SPIx_IRQn, 1, 0);
|
||||||
HAL_NVIC_EnableIRQ(SPIx_IRQn);
|
HAL_NVIC_EnableIRQ(SPIx_IRQn);
|
||||||
}
|
}
|
||||||
@ -117,17 +118,17 @@ void hal_spi_msp_init_dma(void *spi_handle) {
|
|||||||
* @param hspi: SPI handle pointer
|
* @param hspi: SPI handle pointer
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void hal_spi_msp_deinit_dma(void *spi_handle)
|
void spi::halMspDeinitDma(void *spi_handle)
|
||||||
{
|
{
|
||||||
SPI_HandleTypeDef* hspi = (SPI_HandleTypeDef*) spi_handle;
|
SPI_HandleTypeDef* hspi = (SPI_HandleTypeDef*) spi_handle;
|
||||||
if(hspi == NULL) {
|
if(hspi == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hal_spi_msp_deinit_polling(spi_handle);
|
spi::halMspDeinitPolling(spi_handle);
|
||||||
if(hspi->Instance == SPIx) {
|
if(hspi->Instance == SPIx) {
|
||||||
DMA_HandleTypeDef* hdma_tx = NULL;
|
DMA_HandleTypeDef* hdma_tx = NULL;
|
||||||
DMA_HandleTypeDef* hdma_rx = 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) {
|
if(hdma_tx == NULL || hdma_rx == NULL) {
|
||||||
printf("HAL_SPI_MspInit: Invalid DMA handles. Make sure to call setDmaHandles!\n");
|
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 = {};
|
GPIO_InitTypeDef GPIO_InitStruct = {};
|
||||||
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
||||||
/* Enable GPIO TX/RX clock */
|
/* 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);
|
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 ##################################################*/
|
/*##-1- Reset peripherals ##################################################*/
|
||||||
SPIx_FORCE_RESET();
|
SPIx_FORCE_RESET();
|
||||||
SPIx_RELEASE_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);
|
HAL_GPIO_DeInit(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_spi_msp_init_interrupt(void *hspi) {
|
void spi::halMspInitInterrupt(void *hspi) {
|
||||||
hal_spi_msp_init_polling(hspi);
|
spi::halMspInitPolling(hspi);
|
||||||
// Configure the NVIC for SPI
|
// 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_SetPriority(SPIx_IRQn, 1, 0);
|
||||||
HAL_NVIC_EnableIRQ(SPIx_IRQn);
|
HAL_NVIC_EnableIRQ(SPIx_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_spi_msp_deinit_interrupt(void *hspi) {
|
void spi::halMspDeinitInterrupt(void *hspi) {
|
||||||
hal_spi_msp_deinit_polling(hspi);
|
spi::halMspDeinitPolling(hspi);
|
||||||
// Disable the NVIC for SPI
|
// Disable the NVIC for SPI
|
||||||
HAL_NVIC_DisableIRQ(SPIx_IRQn);
|
HAL_NVIC_DisableIRQ(SPIx_IRQn);
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,19 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void hal_spi_msp_init_dma(void *hspi);
|
namespace spi {
|
||||||
void hal_spi_msp_deinit_dma(void *hspi);
|
|
||||||
|
|
||||||
void hal_spi_msp_init_polling(void *hspi);
|
void halMspInitDma(void *hspi);
|
||||||
void hal_spi_msp_deinit_polling(void *hspi);
|
void halMspDeinitDma(void *hspi);
|
||||||
|
|
||||||
|
void halMspInitPolling(void *hspi);
|
||||||
|
void halMspDeinitPolling(void *hspi);
|
||||||
|
|
||||||
|
void halMspInitInterrupt(void *hspi);
|
||||||
|
void halMspDeinitInterrupt(void *hspi);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void hal_spi_msp_init_interrupt(void *hspi);
|
|
||||||
void hal_spi_msp_deinit_interrupt(void *hspi);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -2,55 +2,84 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
SPI_HandleTypeDef* spiHandle = nullptr;
|
SPI_HandleTypeDef* spiHandle = nullptr;
|
||||||
DMA_HandleTypeDef* hdma_tx = nullptr;
|
DMA_HandleTypeDef* hdmaTx = nullptr;
|
||||||
DMA_HandleTypeDef* hdma_rx = nullptr;
|
DMA_HandleTypeDef* hdmaRx = nullptr;
|
||||||
|
|
||||||
msp_func_t msp_init_func = nullptr;
|
msp_func_t mspInitFunc = nullptr;
|
||||||
void* msp_init_args = nullptr;
|
void* mspInitArgs = nullptr;
|
||||||
|
|
||||||
msp_func_t msp_deinit_func = nullptr;
|
msp_func_t mspDeinitFunc = nullptr;
|
||||||
void* msp_deinit_args = nullptr;
|
void* mspDeinitArgs = nullptr;
|
||||||
|
|
||||||
void set_dma_handles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle) {
|
spi_transfer_cb_t rxTxCb = nullptr;
|
||||||
hdma_tx = txHandle;
|
void* rxTxArgs = nullptr;
|
||||||
hdma_rx = rxHandle;
|
spi_transfer_cb_t txCb = nullptr;
|
||||||
|
void* txArgs = nullptr;
|
||||||
|
spi_transfer_cb_t rxCb = nullptr;
|
||||||
|
void* rxArgs = nullptr;
|
||||||
|
spi_transfer_cb_t errorCb = nullptr;
|
||||||
|
void* errorArgs = nullptr;
|
||||||
|
|
||||||
|
void spi::setDmaHandles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle) {
|
||||||
|
hdmaTx = txHandle;
|
||||||
|
hdmaRx = rxHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_dma_handles(DMA_HandleTypeDef** txHandle, DMA_HandleTypeDef** rxHandle) {
|
void spi::getDmaHandles(DMA_HandleTypeDef** txHandle, DMA_HandleTypeDef** rxHandle) {
|
||||||
*txHandle = hdma_tx;
|
*txHandle = hdmaTx;
|
||||||
*rxHandle = hdma_rx;
|
*rxHandle = hdmaRx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assign_spi_handle(SPI_HandleTypeDef *spiHandle_) {
|
void spi::setSpiHandle(SPI_HandleTypeDef *spiHandle_) {
|
||||||
if(spiHandle_ == NULL) {
|
if(spiHandle_ == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
spiHandle = spiHandle_;
|
spiHandle = spiHandle_;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPI_HandleTypeDef* get_spi_handle() {
|
void spi::assignTransferRxTxCompleteCallback(spi_transfer_cb_t callback, void *userArgs) {
|
||||||
|
rxTxCb = callback;
|
||||||
|
rxTxArgs = userArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spi::assignTransferRxCompleteCallback(spi_transfer_cb_t callback, void *userArgs) {
|
||||||
|
rxCb = callback;
|
||||||
|
rxArgs = userArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spi::assignTransferTxCompleteCallback(spi_transfer_cb_t callback, void *userArgs) {
|
||||||
|
txCb = callback;
|
||||||
|
txArgs = userArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spi::assignTransferErrorCallback(spi_transfer_cb_t callback, void *userArgs) {
|
||||||
|
errorCb = callback;
|
||||||
|
errorArgs = userArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPI_HandleTypeDef* spi::getSpiHandle() {
|
||||||
return spiHandle;
|
return spiHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_spi_msp_functions(msp_func_t init_func, void* init_args, msp_func_t deinit_func,
|
void spi::setSpiMspFunctions(msp_func_t init_func, void* init_args, msp_func_t deinit_func,
|
||||||
void* deinit_args) {
|
void* deinit_args) {
|
||||||
msp_init_func = init_func;
|
mspInitFunc = init_func;
|
||||||
msp_init_args = init_args;
|
mspInitArgs = init_args;
|
||||||
msp_deinit_func = deinit_func;
|
mspDeinitFunc = deinit_func;
|
||||||
msp_deinit_args = deinit_args;
|
mspDeinitArgs = deinit_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_msp_init_function(msp_func_t* init_func, void **args) {
|
void spi::getMspInitFunction(msp_func_t* init_func, void **args) {
|
||||||
if(init_func != NULL && args != NULL) {
|
if(init_func != NULL && args != NULL) {
|
||||||
*init_func = msp_init_func;
|
*init_func = mspInitFunc;
|
||||||
*args = msp_init_args;
|
*args = mspInitArgs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_msp_deinit_function(msp_func_t* deinit_func, void **args) {
|
void spi::getMspDeinitFunction(msp_func_t* deinit_func, void **args) {
|
||||||
if(deinit_func != NULL && args != NULL) {
|
if(deinit_func != NULL && args != NULL) {
|
||||||
*deinit_func = msp_deinit_func;
|
*deinit_func = mspDeinitFunc;
|
||||||
*args = msp_deinit_args;
|
*args = mspDeinitArgs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,8 +94,8 @@ void get_msp_deinit_function(msp_func_t* deinit_func, void **args) {
|
|||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
extern "C" void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) {
|
extern "C" void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) {
|
||||||
if(msp_init_func != NULL) {
|
if(mspInitFunc != NULL) {
|
||||||
msp_init_func(msp_init_args);
|
mspInitFunc(mspInitArgs);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("HAL_SPI_MspInit: Please call set_msp_functions to assign SPI MSP functions\n");
|
printf("HAL_SPI_MspInit: Please call set_msp_functions to assign SPI MSP functions\n");
|
||||||
@ -82,10 +111,66 @@ extern "C" void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) {
|
|||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
extern "C" void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) {
|
extern "C" void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) {
|
||||||
if(msp_deinit_func != NULL) {
|
if(mspDeinitFunc != NULL) {
|
||||||
msp_deinit_func(msp_deinit_args);
|
mspDeinitFunc(mspDeinitArgs);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("HAL_SPI_MspDeInit: Please call set_msp_functions to assign SPI MSP functions\n");
|
printf("HAL_SPI_MspDeInit: Please call set_msp_functions to assign SPI MSP functions\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TxRx Transfer completed callback.
|
||||||
|
* @param hspi: SPI handle
|
||||||
|
*/
|
||||||
|
extern "C" void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) {
|
||||||
|
if(rxTxCb != NULL) {
|
||||||
|
rxTxCb(hspi, rxTxArgs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("HAL_SPI_TxRxCpltCallback: No user callback specified\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TxRx Transfer completed callback.
|
||||||
|
* @param hspi: SPI handle
|
||||||
|
*/
|
||||||
|
extern "C" void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) {
|
||||||
|
if(txCb != NULL) {
|
||||||
|
txCb(hspi, txArgs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("HAL_SPI_TxCpltCallback: No user callback specified\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TxRx Transfer completed callback.
|
||||||
|
* @param hspi: SPI handle
|
||||||
|
*/
|
||||||
|
extern "C" void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi) {
|
||||||
|
if(rxCb != nullptr) {
|
||||||
|
rxCb(hspi, rxArgs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("HAL_SPI_RxCpltCallback: No user callback specified\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SPI error callbacks.
|
||||||
|
* @param hspi: SPI handle
|
||||||
|
* @note This example shows a simple way to report transfer error, and you can
|
||||||
|
* add your own implementation.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
extern "C" void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi) {
|
||||||
|
if(errorCb != nullptr) {
|
||||||
|
errorCb(hspi, rxArgs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("HAL_SPI_ErrorCallback: No user callback specified\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using msp_func_t = void (*) (void* args);
|
using msp_func_t = void (*) (void* args);
|
||||||
|
using spi_transfer_cb_t = void (*) (SPI_HandleTypeDef *hspi, void* userArgs);
|
||||||
|
|
||||||
|
namespace spi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign MSP init functions. Important for SPI configuration
|
* Assign MSP init functions. Important for SPI configuration
|
||||||
@ -17,7 +20,7 @@ using msp_func_t = void (*) (void* args);
|
|||||||
* @param deinit_func
|
* @param deinit_func
|
||||||
* @param deinit_args
|
* @param deinit_args
|
||||||
*/
|
*/
|
||||||
void set_spi_msp_functions(msp_func_t init_func, void* init_args, msp_func_t deinit_func,
|
void setSpiMspFunctions(msp_func_t init_func, void* init_args, msp_func_t deinit_func,
|
||||||
void* deinit_args);
|
void* deinit_args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,23 +28,30 @@ void set_spi_msp_functions(msp_func_t init_func, void* init_args, msp_func_t dei
|
|||||||
* @param txHandle
|
* @param txHandle
|
||||||
* @param rxHandle
|
* @param rxHandle
|
||||||
*/
|
*/
|
||||||
void set_dma_handles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle);
|
void setDmaHandles(DMA_HandleTypeDef* txHandle, DMA_HandleTypeDef* rxHandle);
|
||||||
|
void getDmaHandles(DMA_HandleTypeDef** txHandle, DMA_HandleTypeDef** rxHandle);
|
||||||
|
|
||||||
void get_dma_handles(DMA_HandleTypeDef** txHandle, DMA_HandleTypeDef** rxHandle);
|
void getMspInitFunction(msp_func_t* init_func, void **args);
|
||||||
void get_msp_init_function(msp_func_t* init_func, void **args);
|
void getMspDeinitFunction(msp_func_t* deinit_func, void **args);
|
||||||
void get_msp_deinit_function(msp_func_t* deinit_func, void **args);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign SPI handle. Needs to be done before using the SPI
|
* Assign SPI handle. Needs to be done before using the SPI
|
||||||
* @param spiHandle
|
* @param spiHandle
|
||||||
*/
|
*/
|
||||||
void assign_spi_handle(SPI_HandleTypeDef *spiHandle);
|
void setSpiHandle(SPI_HandleTypeDef *spiHandle);
|
||||||
|
|
||||||
|
void assignTransferRxTxCompleteCallback(spi_transfer_cb_t callback, void* userArgs);
|
||||||
|
void assignTransferRxCompleteCallback(spi_transfer_cb_t callback, void* userArgs);
|
||||||
|
void assignTransferTxCompleteCallback(spi_transfer_cb_t callback, void* userArgs);
|
||||||
|
void assignTransferErrorCallback(spi_transfer_cb_t callback, void* userArgs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the assigned SPI handle.
|
* Get the assigned SPI handle.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SPI_HandleTypeDef* get_spi_handle();
|
SPI_HandleTypeDef* getSpiHandle();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -6,21 +6,19 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
user_handler_t spi1UserHandler = nullptr;
|
||||||
|
user_args_t spi1UserArgs = nullptr;
|
||||||
|
|
||||||
void (*spi1_user_handler) (void* args) = nullptr;
|
user_handler_t spi2UserHandler = nullptr;
|
||||||
void * spi1_user_args = nullptr;
|
user_args_t spi2UserArgs = nullptr;
|
||||||
|
|
||||||
void (*spi2_user_handler) (void* args) = nullptr;
|
|
||||||
void * spi2_user_args = nullptr;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA Rx interrupt request.
|
* @brief This function handles DMA Rx interrupt request.
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void dma_rx_irq_handler(void* dma_handle) {
|
void spi::dmaRxIrqHandler(void* dmaHandle) {
|
||||||
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dma_handle);
|
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dmaHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,8 +26,8 @@ void dma_rx_irq_handler(void* dma_handle) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void dma_tx_irq_handler(void* dma_handle) {
|
void spi::dmaTxIrqHandler(void* dmaHandle) {
|
||||||
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dma_handle);
|
HAL_DMA_IRQHandler((DMA_HandleTypeDef *) dmaHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,20 +35,20 @@ void dma_tx_irq_handler(void* dma_handle) {
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void spi1_irq_handler(void* spi_handle)
|
void spi::spi1IrqHandler(void* spiHandle)
|
||||||
{
|
{
|
||||||
HAL_SPI_IRQHandler((SPI_HandleTypeDef *) spi_handle);
|
HAL_SPI_IRQHandler((SPI_HandleTypeDef *) spiHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void assign_spi_user_handler(spi::SpiBus spi_idx, user_handler_t user_handler,
|
void spi::assignSpiUserHandler(spi::SpiBus spiIdx, user_handler_t userHandler,
|
||||||
user_args_t user_args) {
|
user_args_t userArgs) {
|
||||||
if(spi_idx == spi::SpiBus::SPI_1) {
|
if(spiIdx == spi::SpiBus::SPI_1) {
|
||||||
spi1_user_handler = user_handler;
|
spi1UserHandler = userHandler;
|
||||||
spi1_user_args = user_args;
|
spi1UserArgs = userArgs;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
spi2_user_handler = user_handler;
|
spi2UserHandler = userHandler;
|
||||||
spi2_user_args = user_args;
|
spi2UserArgs = userArgs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,16 +56,16 @@ void assign_spi_user_handler(spi::SpiBus spi_idx, user_handler_t user_handler,
|
|||||||
defined in the startup_stm32h743xx.s files! */
|
defined in the startup_stm32h743xx.s files! */
|
||||||
|
|
||||||
extern "C" void SPI1_IRQHandler() {
|
extern "C" void SPI1_IRQHandler() {
|
||||||
if(spi1_user_handler != NULL) {
|
if(spi1UserHandler != NULL) {
|
||||||
spi1_user_handler(spi1_user_args);
|
spi1UserHandler(spi1UserArgs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Default_Handler();
|
Default_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void SPI2_IRQHandler() {
|
extern "C" void SPI2_IRQHandler() {
|
||||||
if(spi2_user_handler != NULL) {
|
if(spi2UserHandler != nullptr) {
|
||||||
spi2_user_handler(spi2_user_args);
|
spi2UserHandler(spi2UserArgs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Default_Handler();
|
Default_Handler();
|
||||||
|
@ -8,13 +8,15 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace spi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a user interrupt handler for SPI bus 1, allowing to pass an arbitrary argument as well.
|
* Assign a user interrupt handler for SPI bus 1, allowing to pass an arbitrary argument as well.
|
||||||
* Generally, this argument will be the related SPI handle.
|
* Generally, this argument will be the related SPI handle.
|
||||||
* @param user_handler
|
* @param user_handler
|
||||||
* @param user_args
|
* @param user_args
|
||||||
*/
|
*/
|
||||||
void assign_spi_user_handler(spi::SpiBus spiBus, user_handler_t user_handler,
|
void assignSpiUserHandler(spi::SpiBus spiBus, user_handler_t user_handler,
|
||||||
user_args_t user_args);
|
user_args_t user_args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,9 +24,11 @@ void assign_spi_user_handler(spi::SpiBus spiBus, user_handler_t user_handler,
|
|||||||
* instead with assign_dma_user_handler and assign_spi_user_handler functions.
|
* instead with assign_dma_user_handler and assign_spi_user_handler functions.
|
||||||
* @param dma_handle
|
* @param dma_handle
|
||||||
*/
|
*/
|
||||||
void dma_rx_irq_handler(void* dma_handle);
|
void dmaRxIrqHandler(void* dma_handle);
|
||||||
void dma_tx_irq_handler(void* dma_handle);
|
void dmaTxIrqHandler(void* dma_handle);
|
||||||
void spi1_irq_handler(void* spi_handle);
|
void spi1IrqHandler(void* spi_handle);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user