Compare commits
6 Commits
8ff09c95a6
...
master
Author | SHA1 | Date | |
---|---|---|---|
9d20b8878e | |||
ee875460e7 | |||
![]() |
88769bb46c | ||
![]() |
9c98f41a96 | ||
![]() |
323008c64a | ||
![]() |
866868b25f |
@@ -79,6 +79,7 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
|||||||
setStopBitOptions(&options, uartCookie);
|
setStopBitOptions(&options, uartCookie);
|
||||||
setDatasizeOptions(&options, uartCookie);
|
setDatasizeOptions(&options, uartCookie);
|
||||||
setFixedOptions(&options);
|
setFixedOptions(&options);
|
||||||
|
setUartMode(&options, *uartCookie);
|
||||||
if(uartCookie->getInputShouldBeFlushed()) {
|
if(uartCookie->getInputShouldBeFlushed()) {
|
||||||
tcflush(fd, TCIFLUSH);
|
tcflush(fd, TCIFLUSH);
|
||||||
}
|
}
|
||||||
@@ -403,13 +404,13 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie &uartCookie, UartDevi
|
|||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
else if (bytesRead != static_cast<int>(requestLen)) {
|
else if (bytesRead != static_cast<int>(requestLen)) {
|
||||||
sif::debug << "UartComIF::requestReceiveMessage: Only read " << bytesRead <<
|
if(uartCookie.isReplySizeFixed()) {
|
||||||
" of " << requestLen << " bytes" << std::endl;
|
sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead <<
|
||||||
return RETURN_FAILED;
|
" of " << requestLen << " bytes" << std::endl;
|
||||||
}
|
return RETURN_FAILED;
|
||||||
else {
|
}
|
||||||
iter->second.replyLen = bytesRead;
|
|
||||||
}
|
}
|
||||||
|
iter->second.replyLen = bytesRead;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,3 +87,11 @@ bool UartCookie::getInputShouldBeFlushed() {
|
|||||||
object_id_t UartCookie::getHandlerId() const {
|
object_id_t UartCookie::getHandlerId() const {
|
||||||
return this->handlerId;
|
return this->handlerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UartCookie::setNoFixedSizeReply() {
|
||||||
|
replySizeFixed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UartCookie::isReplySizeFixed() {
|
||||||
|
return replySizeFixed;
|
||||||
|
}
|
||||||
|
@@ -95,6 +95,14 @@ public:
|
|||||||
void setTwoStopBits();
|
void setTwoStopBits();
|
||||||
void setOneStopBit();
|
void setOneStopBit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calling this function prevents the UartComIF to return failed if not all requested bytes
|
||||||
|
* could be read. This is required by a device handler when the size of a reply is not known.
|
||||||
|
*/
|
||||||
|
void setNoFixedSizeReply();
|
||||||
|
|
||||||
|
bool isReplySizeFixed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const object_id_t handlerId;
|
const object_id_t handlerId;
|
||||||
@@ -107,6 +115,7 @@ private:
|
|||||||
uint8_t bitsPerWord = 8;
|
uint8_t bitsPerWord = 8;
|
||||||
uint8_t readCycles = 1;
|
uint8_t readCycles = 1;
|
||||||
StopBits stopBits = StopBits::ONE_STOP_BIT;
|
StopBits stopBits = StopBits::ONE_STOP_BIT;
|
||||||
|
bool replySizeFixed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -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) {
|
||||||
|
@@ -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