mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
fix rtc6705 drive (#14296)
* fix rtc6705 drive * Update rt6705 request suggestion
This commit is contained in:
parent
609533a737
commit
fd3a131797
1 changed files with 8 additions and 6 deletions
|
@ -95,7 +95,6 @@ static uint32_t reverse32(uint32_t in)
|
|||
bool rtc6705IOInit(const vtxIOConfig_t *vtxIOConfig)
|
||||
{
|
||||
static extDevice_t devInstance;
|
||||
|
||||
IO_t csnPin = IOGetByTag(vtxIOConfig->csTag);
|
||||
if (!csnPin) {
|
||||
return false;
|
||||
|
@ -112,15 +111,16 @@ bool rtc6705IOInit(const vtxIOConfig_t *vtxIOConfig)
|
|||
|
||||
// RTC6705 when using SOFT SPI driver doesn't use an SPI device, so don't attempt to initialise an spiInstance.
|
||||
SPI_TypeDef *spiInstance = spiInstanceByDevice(SPI_CFG_TO_DEV(vtxIOConfig->spiDevice));
|
||||
if (spiInstance && spiSetBusInstance(dev, vtxIOConfig->spiDevice)) {
|
||||
devInstance.busType_u.spi.csnPin = csnPin;
|
||||
IOInit(devInstance.busType_u.spi.csnPin, OWNER_VTX_CS, 0);
|
||||
|
||||
if (spiInstance && spiSetBusInstance(&devInstance, vtxIOConfig->spiDevice)) {
|
||||
dev = &devInstance;
|
||||
dev->busType_u.spi.csnPin = csnPin;
|
||||
IOInit(dev->busType_u.spi.csnPin, OWNER_VTX_CS, 0);
|
||||
DISABLE_RTC6705();
|
||||
// GPIO bit is enabled so here so the output is not pulled low when the GPIO is set in output mode.
|
||||
// Note: It's critical to ensure that incorrect signals are not sent to the VTX.
|
||||
IOConfigGPIO(devInstance.busType_u.spi.csnPin, IOCFG_OUT_PP);
|
||||
IOConfigGPIO(dev->busType_u.spi.csnPin, IOCFG_OUT_PP);
|
||||
|
||||
spiSetBusInstance(dev, vtxIOConfig->spiDevice);
|
||||
return true;
|
||||
#if defined(USE_VTX_RTC6705_SOFTSPI)
|
||||
} else {
|
||||
|
@ -141,6 +141,8 @@ static void rtc6705Transfer(uint32_t command)
|
|||
// Perform bitwise reverse of the command.
|
||||
command = reverse32(command);
|
||||
|
||||
command = ((command >> 24) & 0xFF) | (((command >> 16) & 0xFF) << 8) | (((command >> 8) & 0xFF) << 16) | (((command >> 0) & 0xFF) << 24);
|
||||
|
||||
spiReadWriteBuf(dev, (uint8_t *)&command, NULL, sizeof(command));
|
||||
|
||||
delayMicroseconds(2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue