Compare commits
3 Commits
meier/uart
...
mueller/ma
Author | SHA1 | Date | |
---|---|---|---|
1eda4874cd | |||
9d20b8878e | |||
ee875460e7 |
@@ -443,51 +443,6 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF *cookie,
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF *cookie) {
|
|
||||||
std::string deviceFile;
|
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
|
||||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
|
||||||
if(uartCookie == nullptr) {
|
|
||||||
sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl;
|
|
||||||
return NULLPOINTER;
|
|
||||||
}
|
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
|
||||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
|
||||||
int fd = uartDeviceMapIter->second.fileDescriptor;
|
|
||||||
tcflush(fd, TCIFLUSH);
|
|
||||||
return RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF *cookie) {
|
|
||||||
std::string deviceFile;
|
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
|
||||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
|
||||||
if(uartCookie == nullptr) {
|
|
||||||
sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl;
|
|
||||||
return NULLPOINTER;
|
|
||||||
}
|
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
|
||||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
|
||||||
int fd = uartDeviceMapIter->second.fileDescriptor;
|
|
||||||
tcflush(fd, TCOFLUSH);
|
|
||||||
return RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF *cookie) {
|
|
||||||
std::string deviceFile;
|
|
||||||
UartDeviceMapIter uartDeviceMapIter;
|
|
||||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
|
||||||
if(uartCookie == nullptr) {
|
|
||||||
sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl;
|
|
||||||
return NULLPOINTER;
|
|
||||||
}
|
|
||||||
deviceFile = uartCookie->getDeviceFile();
|
|
||||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
|
||||||
int fd = uartDeviceMapIter->second.fileDescriptor;
|
|
||||||
tcflush(fd, TCIOFLUSH);
|
|
||||||
return RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UartComIF::setUartMode(struct termios *options, UartCookie &uartCookie) {
|
void UartComIF::setUartMode(struct termios *options, UartCookie &uartCookie) {
|
||||||
UartModes uartMode = uartCookie.getUartMode();
|
UartModes uartMode = uartCookie.getUartMode();
|
||||||
if(uartMode == UartModes::NON_CANONICAL) {
|
if(uartMode == UartModes::NON_CANONICAL) {
|
||||||
|
@@ -41,21 +41,6 @@ public:
|
|||||||
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||||
size_t *size) override;
|
size_t *size) override;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function discards all data received but not read in the UART buffer.
|
|
||||||
*/
|
|
||||||
ReturnValue_t flushUartRxBuffer(CookieIF *cookie);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function discards all data in the transmit buffer of the UART driver.
|
|
||||||
*/
|
|
||||||
ReturnValue_t flushUartTxBuffer(CookieIF *cookie);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function discards both data in the transmit and receive buffer of the UART.
|
|
||||||
*/
|
|
||||||
ReturnValue_t flushUartTxAndRxBuf(CookieIF *cookie);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
using UartDeviceFile_t = std::string;
|
using UartDeviceFile_t = std::string;
|
||||||
|
@@ -517,6 +517,7 @@ uint8_t GyroL3GD20H::readRegPolling(uint8_t reg) {
|
|||||||
txBuf[0] = reg | STM_READ_MASK;
|
txBuf[0] = reg | STM_READ_MASK;
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||||
auto result = HAL_SPI_TransmitReceive(spiHandle, txBuf, rxBuf, 2, 1000);
|
auto result = HAL_SPI_TransmitReceive(spiHandle, txBuf, rxBuf, 2, 1000);
|
||||||
|
if(result) {};
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);
|
||||||
return rxBuf[1];
|
return rxBuf[1];
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
|
#include "stm32h7xx_hal_rcc.h"
|
||||||
|
|
||||||
void gpio::initializeGpioClock(GPIO_TypeDef* gpioPort) {
|
void gpio::initializeGpioClock(GPIO_TypeDef* gpioPort) {
|
||||||
#ifdef GPIOA
|
#ifdef GPIOA
|
||||||
if(gpioPort == GPIOA) {
|
if(gpioPort == GPIOA) {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#include "SpiCookie.h"
|
#include "SpiCookie.h"
|
||||||
|
|
||||||
#include "fsfw/tasks/SemaphoreFactory.h"
|
#include "fsfw/tasks/SemaphoreFactory.h"
|
||||||
#include "fsfw/osal/FreeRTOS/TaskManagement.h"
|
#include "fsfw/osal/freertos/TaskManagement.h"
|
||||||
#include "fsfw_hal/stm32h7/spi/spiCore.h"
|
#include "fsfw_hal/stm32h7/spi/spiCore.h"
|
||||||
#include "fsfw_hal/stm32h7/spi/spiInterrupts.h"
|
#include "fsfw_hal/stm32h7/spi/spiInterrupts.h"
|
||||||
#include "fsfw_hal/stm32h7/spi/mspInit.h"
|
#include "fsfw_hal/stm32h7/spi/mspInit.h"
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#include "fsfw/devicehandlers/DeviceCommunicationIF.h"
|
#include "fsfw/devicehandlers/DeviceCommunicationIF.h"
|
||||||
#include "fsfw/objectmanager/SystemObject.h"
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
|
|
||||||
#include "fsfw/osal/FreeRTOS/BinarySemaphore.h"
|
#include "fsfw/osal/freertos/BinarySemaphore.h"
|
||||||
#include "fsfw_hal/stm32h7/spi/spiDefinitions.h"
|
#include "fsfw_hal/stm32h7/spi/spiDefinitions.h"
|
||||||
#include "stm32h7xx_hal_spi.h"
|
#include "stm32h7xx_hal_spi.h"
|
||||||
#include "stm32h743xx.h"
|
#include "stm32h743xx.h"
|
||||||
|
@@ -4,8 +4,8 @@
|
|||||||
SpiCookie::SpiCookie(address_t deviceAddress, spi::SpiBus spiIdx, spi::TransferModes transferMode,
|
SpiCookie::SpiCookie(address_t deviceAddress, spi::SpiBus spiIdx, spi::TransferModes transferMode,
|
||||||
spi::MspCfgBase* mspCfg, uint32_t spiSpeed, spi::SpiModes spiMode,
|
spi::MspCfgBase* mspCfg, uint32_t spiSpeed, spi::SpiModes spiMode,
|
||||||
uint16_t chipSelectGpioPin, GPIO_TypeDef* chipSelectGpioPort, size_t maxRecvSize):
|
uint16_t chipSelectGpioPin, GPIO_TypeDef* chipSelectGpioPort, size_t maxRecvSize):
|
||||||
deviceAddress(deviceAddress), spiIdx(spiIdx), transferMode(transferMode),
|
deviceAddress(deviceAddress), spiIdx(spiIdx), spiSpeed(spiSpeed), spiMode(spiMode),
|
||||||
spiSpeed(spiSpeed), spiMode(spiMode), chipSelectGpioPin(chipSelectGpioPin),
|
transferMode(transferMode), chipSelectGpioPin(chipSelectGpioPin),
|
||||||
chipSelectGpioPort(chipSelectGpioPort), mspCfg(mspCfg), maxRecvSize(maxRecvSize) {
|
chipSelectGpioPort(chipSelectGpioPort), mspCfg(mspCfg), maxRecvSize(maxRecvSize) {
|
||||||
spiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
|
spiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||||
spiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
spiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||||
|
Reference in New Issue
Block a user