2021-06-21 09:50:26 +02:00
|
|
|
#ifndef BSP_Q7S_RW_SPI_CALLBACK_H_
|
|
|
|
#define BSP_Q7S_RW_SPI_CALLBACK_H_
|
|
|
|
|
2021-09-07 16:11:02 +02:00
|
|
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
|
|
|
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
2022-01-17 13:48:55 +01:00
|
|
|
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
2021-07-01 10:53:50 +02:00
|
|
|
|
|
|
|
namespace rwSpiCallback {
|
2021-06-21 09:50:26 +02:00
|
|
|
|
2021-11-30 16:45:33 +01:00
|
|
|
//! This is the end and start marker of the frame datalinklayer
|
|
|
|
static constexpr uint8_t FLAG_BYTE = 0x7E;
|
|
|
|
|
2021-06-21 09:50:26 +02:00
|
|
|
/**
|
|
|
|
* @brief This is the callback function to send commands to the nano avionics reaction wheels and
|
|
|
|
* receive the replies.
|
|
|
|
*
|
|
|
|
* @details The data to sent are additionally encoded according to the HDLC framing defined in the
|
|
|
|
* datasheet of the reaction wheels:
|
|
|
|
* https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/
|
|
|
|
* Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622
|
|
|
|
* Each command entails exactly one reply which will also be read in and decoded by this
|
|
|
|
* function.
|
2021-07-01 10:53:50 +02:00
|
|
|
* Because the reaction wheels require a spi clock frequency of maximum 300 kHZ and minimum
|
|
|
|
* 150 kHz which is not supported by the processing system SPI peripheral an AXI SPI core
|
|
|
|
* has been implemented in the programmable logic. This AXI SPI core works with a fixed
|
|
|
|
* frequency of 250 kHz.
|
|
|
|
* To allow the parallel usage of the same physical SPI bus, a VHDL module has been
|
|
|
|
* implemented which is able to disconnect the hard-wired SPI peripheral of the PS and
|
|
|
|
* route the AXI SPI to the SPI lines.
|
|
|
|
* To switch between the to SPI peripherals, an EMIO is used which will also be controlled
|
|
|
|
* by this function.
|
2021-06-21 09:50:26 +02:00
|
|
|
*/
|
2022-01-17 13:48:55 +01:00
|
|
|
ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData,
|
|
|
|
size_t sendLen, void* args);
|
2021-06-21 09:50:26 +02:00
|
|
|
|
2021-06-24 17:32:42 +02:00
|
|
|
/**
|
|
|
|
* @brief This function closes a spi session. Pulls the chip select to high an releases the
|
|
|
|
* mutex.
|
|
|
|
* @param gpioId Gpio ID of chip select
|
|
|
|
* @param gpioIF Pointer to gpio interface to drive the chip select
|
|
|
|
* @param mutex The spi mutex
|
|
|
|
*/
|
|
|
|
void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex);
|
|
|
|
|
2022-01-17 13:48:55 +01:00
|
|
|
} // namespace rwSpiCallback
|
2021-06-21 09:50:26 +02:00
|
|
|
#endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */
|