mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
Changed naming of SPI DMA resources to reflect the SPI bus number.
This commit is contained in:
parent
864cf3f3b4
commit
f4d840f5f8
11 changed files with 14 additions and 16 deletions
|
@ -250,7 +250,7 @@ static gyroSpiDetectFn_t gyroSpiDetectFnTable[] = {
|
|||
|
||||
static bool detectSPISensorsAndUpdateDetectionResult(gyroDev_t *gyro, const gyroDeviceConfig_t *config)
|
||||
{
|
||||
if (!config->csnTag || !spiSetBusInstance(&gyro->dev, config->spiBus, OWNER_GYRO_CS)) {
|
||||
if (!config->csnTag || !spiSetBusInstance(&gyro->dev, config->spiBus)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ typedef struct busDevice_s {
|
|||
bool useDMA;
|
||||
bool useAtomicWait;
|
||||
uint8_t deviceCount;
|
||||
resourceOwner_e owner; // owner of first device to use this bus
|
||||
dmaChannelDescriptor_t *dmaTx;
|
||||
dmaChannelDescriptor_t *dmaRx;
|
||||
uint32_t dmaTxChannel;
|
||||
|
|
|
@ -471,8 +471,8 @@ static void spiRxIrqHandler(dmaChannelDescriptor_t* descriptor)
|
|||
}
|
||||
}
|
||||
|
||||
// Mark this bus as being SPI and record the first owner to use it
|
||||
bool spiSetBusInstance(extDevice_t *dev, uint32_t device, resourceOwner_e owner)
|
||||
// Mark this bus as being SPI
|
||||
bool spiSetBusInstance(extDevice_t *dev, uint32_t device)
|
||||
{
|
||||
if (device > SPIDEV_COUNT) {
|
||||
return false;
|
||||
|
@ -499,7 +499,6 @@ bool spiSetBusInstance(extDevice_t *dev, uint32_t device, resourceOwner_e owner)
|
|||
bus->useDMA = false;
|
||||
bus->useAtomicWait = false;
|
||||
bus->deviceCount = 1;
|
||||
bus->owner = owner;
|
||||
bus->initTx = &dev->initTx;
|
||||
bus->initRx = &dev->initRx;
|
||||
|
||||
|
@ -545,7 +544,7 @@ void spiInitBusDMA()
|
|||
}
|
||||
#endif
|
||||
bus->dmaTxChannel = dmaTxChannelSpec->channel;
|
||||
dmaInit(dmaTxIdentifier, bus->owner, 0);
|
||||
dmaInit(dmaTxIdentifier, OWNER_SPI_MOSI, device + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -566,7 +565,7 @@ void spiInitBusDMA()
|
|||
}
|
||||
#endif
|
||||
bus->dmaRxChannel = dmaRxChannelSpec->channel;
|
||||
dmaInit(dmaRxIdentifier, bus->owner, 0);
|
||||
dmaInit(dmaRxIdentifier, OWNER_SPI_MISO, device + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ SPI_TypeDef *spiInstanceByDevice(SPIDevice device);
|
|||
|
||||
// BusDevice API
|
||||
|
||||
// Mark a device's associated bus as being SPI and record the first owner to use it
|
||||
bool spiSetBusInstance(extDevice_t *dev, uint32_t device, resourceOwner_e owner);
|
||||
// Mark a device's associated bus as being SPI
|
||||
bool spiSetBusInstance(extDevice_t *dev, uint32_t device);
|
||||
// Determine the divisor to use for a given bus frequency
|
||||
uint16_t spiCalculateDivider(uint32_t freq);
|
||||
// Set the clock divisor to be used for accesses by the given device
|
||||
|
|
|
@ -147,7 +147,7 @@ static bool flashSpiInit(const flashConfig_t *flashConfig)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!spiSetBusInstance(dev, flashConfig->spiDevice, OWNER_FLASH_CS)) {
|
||||
if (!spiSetBusInstance(dev, flashConfig->spiDevice)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ max7456InitStatus_e max7456Init(const max7456Config_t *max7456Config, const vcdP
|
|||
|
||||
max7456HardwareReset();
|
||||
|
||||
if (!max7456Config->csTag || !spiSetBusInstance(dev, max7456Config->spiDevice, OWNER_OSD_CS)) {
|
||||
if (!max7456Config->csTag || !spiSetBusInstance(dev, max7456Config->spiDevice)) {
|
||||
return MAX7456_INIT_NOT_CONFIGURED;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ void rxSpiStartupSpeed()
|
|||
|
||||
bool rxSpiDeviceInit(const rxSpiConfig_t *rxSpiConfig)
|
||||
{
|
||||
if (!spiSetBusInstance(dev, rxSpiConfig->spibus, OWNER_RX_SPI_CS)) {
|
||||
if (!spiSetBusInstance(dev, rxSpiConfig->spibus)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -549,7 +549,7 @@ static void sdcardSpi_init(const sdcardConfig_t *config, const spiPinConfig_t *s
|
|||
return;
|
||||
}
|
||||
|
||||
spiSetBusInstance(&sdcard.dev, config->device, OWNER_SDCARD_CS);
|
||||
spiSetBusInstance(&sdcard.dev, config->device);
|
||||
|
||||
IO_t chipSelectIO;
|
||||
if (config->chipSelectTag) {
|
||||
|
|
|
@ -110,7 +110,7 @@ bool rtc6705IOInit(const vtxIOConfig_t *vtxIOConfig)
|
|||
IOConfigGPIO(vtxPowerPin, IOCFG_OUT_PP);
|
||||
}
|
||||
|
||||
if (vtxIOConfig->csTag && spiSetBusInstance(dev, vtxIOConfig->spiDevice, OWNER_VTX_CS)) {
|
||||
if (vtxIOConfig->csTag && spiSetBusInstance(dev, vtxIOConfig->spiDevice)) {
|
||||
devInstance.busType_u.spi.csnPin = csnPin;
|
||||
IOInit(devInstance.busType_u.spi.csnPin, OWNER_VTX_CS, 0);
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ bool baroDetect(baroDev_t *baroDev, baroSensor_e baroHardwareToUse)
|
|||
#ifdef USE_SPI
|
||||
case BUS_TYPE_SPI:
|
||||
{
|
||||
if (!spiSetBusInstance(dev, barometerConfig()->baro_spi_device, OWNER_BARO_CS)) {
|
||||
if (!spiSetBusInstance(dev, barometerConfig()->baro_spi_device)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ bool compassDetect(magDev_t *magDev, uint8_t *alignment)
|
|||
#ifdef USE_SPI
|
||||
case BUS_TYPE_SPI:
|
||||
{
|
||||
if (!spiSetBusInstance(dev, compassConfig()->mag_spi_device, OWNER_COMPASS_CS)) {
|
||||
if (!spiSetBusInstance(dev, compassConfig()->mag_spi_device)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue