Merge pull request #1518 from blckmn/simplified_owners
Simplified owners
This commit is contained in:
commit
c90a0d1a04
1
Makefile
1
Makefile
|
@ -496,6 +496,7 @@ COMMON_SRC = \
|
||||||
drivers/gyro_sync.c \
|
drivers/gyro_sync.c \
|
||||||
drivers/io.c \
|
drivers/io.c \
|
||||||
drivers/light_led.c \
|
drivers/light_led.c \
|
||||||
|
drivers/resource.c \
|
||||||
drivers/rx_nrf24l01.c \
|
drivers/rx_nrf24l01.c \
|
||||||
drivers/rx_spi.c \
|
drivers/rx_spi.c \
|
||||||
drivers/rx_xn297.c \
|
drivers/rx_xn297.c \
|
||||||
|
|
|
@ -76,7 +76,7 @@ static void l3gd20SpiInit(SPI_TypeDef *SPIx)
|
||||||
UNUSED(SPIx); // FIXME
|
UNUSED(SPIx); // FIXME
|
||||||
|
|
||||||
mpul3gd20CsPin = IOGetByTag(IO_TAG(L3GD20_CS_PIN));
|
mpul3gd20CsPin = IOGetByTag(IO_TAG(L3GD20_CS_PIN));
|
||||||
IOInit(mpul3gd20CsPin, OWNER_MPU, RESOURCE_SPI_CS, 0);
|
IOInit(mpul3gd20CsPin, OWNER_MPU_CS, 0);
|
||||||
IOConfigGPIO(mpul3gd20CsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(mpul3gd20CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
DISABLE_L3GD20;
|
DISABLE_L3GD20;
|
||||||
|
|
|
@ -105,7 +105,7 @@ static inline void mma8451ConfigureInterrupt(void)
|
||||||
// PA5 - ACC_INT2 output on NAZE rev3/4 hardware
|
// PA5 - ACC_INT2 output on NAZE rev3/4 hardware
|
||||||
// NAZE rev.5 hardware has PA5 (ADC1_IN5) on breakout pad on bottom of board
|
// NAZE rev.5 hardware has PA5 (ADC1_IN5) on breakout pad on bottom of board
|
||||||
// OLIMEXINO - The PA5 pin is wired up to LED1, if you need to use an mma8452 on an Olimexino use a different pin and provide support in code.
|
// OLIMEXINO - The PA5 pin is wired up to LED1, if you need to use an mma8452 on an Olimexino use a different pin and provide support in code.
|
||||||
IOInit(IOGetByTag(IO_TAG(PA5)), OWNER_MPU, RESOURCE_EXTI, 0);
|
IOInit(IOGetByTag(IO_TAG(PA5)), OWNER_MPU_EXTI, 0);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(PA5)), IOCFG_IN_FLOATING); // TODO - maybe pullup / pulldown ?
|
IOConfigGPIO(IOGetByTag(IO_TAG(PA5)), IOCFG_IN_FLOATING); // TODO - maybe pullup / pulldown ?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -257,12 +257,12 @@ void mpuIntExtiInit(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (STM32F7)
|
#if defined (STM32F7)
|
||||||
IOInit(mpuIntIO, OWNER_MPU, RESOURCE_EXTI, 0);
|
IOInit(mpuIntIO, OWNER_MPU_EXTI, 0);
|
||||||
EXTIHandlerInit(&mpuIntCallbackRec, mpuIntExtiHandler);
|
EXTIHandlerInit(&mpuIntCallbackRec, mpuIntExtiHandler);
|
||||||
EXTIConfig(mpuIntIO, &mpuIntCallbackRec, NVIC_PRIO_MPU_INT_EXTI, IO_CONFIG(GPIO_MODE_INPUT,0,GPIO_NOPULL)); // TODO - maybe pullup / pulldown ?
|
EXTIConfig(mpuIntIO, &mpuIntCallbackRec, NVIC_PRIO_MPU_INT_EXTI, IO_CONFIG(GPIO_MODE_INPUT,0,GPIO_NOPULL)); // TODO - maybe pullup / pulldown ?
|
||||||
#else
|
#else
|
||||||
|
|
||||||
IOInit(mpuIntIO, OWNER_MPU, RESOURCE_EXTI, 0);
|
IOInit(mpuIntIO, OWNER_MPU_EXTI, 0);
|
||||||
IOConfigGPIO(mpuIntIO, IOCFG_IN_FLOATING); // TODO - maybe pullup / pulldown ?
|
IOConfigGPIO(mpuIntIO, IOCFG_IN_FLOATING); // TODO - maybe pullup / pulldown ?
|
||||||
|
|
||||||
EXTIHandlerInit(&mpuIntCallbackRec, mpuIntExtiHandler);
|
EXTIHandlerInit(&mpuIntCallbackRec, mpuIntExtiHandler);
|
||||||
|
|
|
@ -70,7 +70,7 @@ static void icm20689SpiInit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
icmSpi20689CsPin = IOGetByTag(IO_TAG(ICM20689_CS_PIN));
|
icmSpi20689CsPin = IOGetByTag(IO_TAG(ICM20689_CS_PIN));
|
||||||
IOInit(icmSpi20689CsPin, OWNER_MPU, RESOURCE_SPI_CS, 0);
|
IOInit(icmSpi20689CsPin, OWNER_MPU_CS, 0);
|
||||||
IOConfigGPIO(icmSpi20689CsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(icmSpi20689CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
spiSetDivisor(ICM20689_SPI_INSTANCE, SPI_CLOCK_STANDARD);
|
spiSetDivisor(ICM20689_SPI_INSTANCE, SPI_CLOCK_STANDARD);
|
||||||
|
|
|
@ -161,7 +161,7 @@ bool mpu6000SpiDetect(void)
|
||||||
#ifdef MPU6000_CS_PIN
|
#ifdef MPU6000_CS_PIN
|
||||||
mpuSpi6000CsPin = IOGetByTag(IO_TAG(MPU6000_CS_PIN));
|
mpuSpi6000CsPin = IOGetByTag(IO_TAG(MPU6000_CS_PIN));
|
||||||
#endif
|
#endif
|
||||||
IOInit(mpuSpi6000CsPin, OWNER_MPU, RESOURCE_SPI_CS, 0);
|
IOInit(mpuSpi6000CsPin, OWNER_MPU_CS, 0);
|
||||||
IOConfigGPIO(mpuSpi6000CsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(mpuSpi6000CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
spiSetDivisor(MPU6000_SPI_INSTANCE, SPI_CLOCK_INITIALIZATON);
|
spiSetDivisor(MPU6000_SPI_INSTANCE, SPI_CLOCK_INITIALIZATON);
|
||||||
|
|
|
@ -68,7 +68,7 @@ static void mpu6500SpiInit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
mpuSpi6500CsPin = IOGetByTag(IO_TAG(MPU6500_CS_PIN));
|
mpuSpi6500CsPin = IOGetByTag(IO_TAG(MPU6500_CS_PIN));
|
||||||
IOInit(mpuSpi6500CsPin, OWNER_MPU, RESOURCE_SPI_CS, 0);
|
IOInit(mpuSpi6500CsPin, OWNER_MPU_CS, 0);
|
||||||
IOConfigGPIO(mpuSpi6500CsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(mpuSpi6500CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
spiSetDivisor(MPU6500_SPI_INSTANCE, SPI_CLOCK_FAST);
|
spiSetDivisor(MPU6500_SPI_INSTANCE, SPI_CLOCK_FAST);
|
||||||
|
|
|
@ -191,7 +191,7 @@ bool mpu9250SpiDetect(void)
|
||||||
#ifdef MPU9250_CS_PIN
|
#ifdef MPU9250_CS_PIN
|
||||||
mpuSpi9250CsPin = IOGetByTag(IO_TAG(MPU9250_CS_PIN));
|
mpuSpi9250CsPin = IOGetByTag(IO_TAG(MPU9250_CS_PIN));
|
||||||
#endif
|
#endif
|
||||||
IOInit(mpuSpi9250CsPin, OWNER_MPU, RESOURCE_SPI_CS, 0);
|
IOInit(mpuSpi9250CsPin, OWNER_MPU_CS, 0);
|
||||||
IOConfigGPIO(mpuSpi9250CsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(mpuSpi9250CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
spiSetDivisor(MPU9250_SPI_INSTANCE, SPI_CLOCK_INITIALIZATON); //low speed
|
spiSetDivisor(MPU9250_SPI_INSTANCE, SPI_CLOCK_INITIALIZATON); //low speed
|
||||||
|
|
|
@ -118,11 +118,11 @@ void adcInit(drv_adc_config_t *init)
|
||||||
|
|
||||||
const adcDevice_t adc = adcHardware[device];
|
const adcDevice_t adc = adcHardware[device];
|
||||||
|
|
||||||
for (int i = 0; i < ADC_CHANNEL_COUNT; i++) {
|
for (int i = 0; i < ADC_CHANNEL_COUNT; i++) {
|
||||||
if (!adcConfig[i].tag)
|
if (!adcConfig[i].tag)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC, RESOURCE_ADC_BATTERY+i, 0);
|
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC_BATT + i, 0);
|
||||||
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_Mode_AIN, 0));
|
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_Mode_AIN, 0));
|
||||||
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
||||||
adcConfig[i].dmaIndex = configuredAdcChannels++;
|
adcConfig[i].dmaIndex = configuredAdcChannels++;
|
||||||
|
@ -133,7 +133,7 @@ void adcInit(drv_adc_config_t *init)
|
||||||
RCC_ADCCLKConfig(RCC_PCLK2_Div8); // 9MHz from 72MHz APB2 clock(HSE), 8MHz from 64MHz (HSI)
|
RCC_ADCCLKConfig(RCC_PCLK2_Div8); // 9MHz from 72MHz APB2 clock(HSE), 8MHz from 64MHz (HSI)
|
||||||
RCC_ClockCmd(adc.rccADC, ENABLE);
|
RCC_ClockCmd(adc.rccADC, ENABLE);
|
||||||
|
|
||||||
dmaInit(dmaGetIdentifier(adc.DMAy_Channelx), OWNER_ADC, RESOURCE_INDEX(device));
|
dmaInit(dmaGetIdentifier(adc.DMAy_Channelx), OWNER_ADC, 0);
|
||||||
|
|
||||||
DMA_DeInit(adc.DMAy_Channelx);
|
DMA_DeInit(adc.DMAy_Channelx);
|
||||||
DMA_InitTypeDef DMA_InitStructure;
|
DMA_InitTypeDef DMA_InitStructure;
|
||||||
|
|
|
@ -147,7 +147,7 @@ void adcInit(drv_adc_config_t *init)
|
||||||
if (!adcConfig[i].tag)
|
if (!adcConfig[i].tag)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC, RESOURCE_ADC_BATTERY+i,0);
|
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC_BATT + i,0);
|
||||||
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
|
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
|
||||||
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
||||||
adcConfig[i].dmaIndex = adcChannelCount++;
|
adcConfig[i].dmaIndex = adcChannelCount++;
|
||||||
|
@ -158,7 +158,7 @@ void adcInit(drv_adc_config_t *init)
|
||||||
RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div256); // 72 MHz divided by 256 = 281.25 kHz
|
RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div256); // 72 MHz divided by 256 = 281.25 kHz
|
||||||
RCC_ClockCmd(adc.rccADC, ENABLE);
|
RCC_ClockCmd(adc.rccADC, ENABLE);
|
||||||
|
|
||||||
dmaInit(dmaGetIdentifier(adc.DMAy_Channelx), OWNER_ADC, RESOURCE_INDEX(device));
|
dmaInit(dmaGetIdentifier(adc.DMAy_Channelx), OWNER_ADC, 0);
|
||||||
|
|
||||||
DMA_DeInit(adc.DMAy_Channelx);
|
DMA_DeInit(adc.DMAy_Channelx);
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ void adcInit(drv_adc_config_t *init)
|
||||||
if (!adcConfig[i].tag)
|
if (!adcConfig[i].tag)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC, RESOURCE_ADC_BATTERY + i, 0);
|
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC_BATT + i, 0);
|
||||||
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
|
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
|
||||||
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
||||||
adcConfig[i].dmaIndex = configuredAdcChannels++;
|
adcConfig[i].dmaIndex = configuredAdcChannels++;
|
||||||
|
@ -143,7 +143,7 @@ void adcInit(drv_adc_config_t *init)
|
||||||
|
|
||||||
RCC_ClockCmd(adc.rccADC, ENABLE);
|
RCC_ClockCmd(adc.rccADC, ENABLE);
|
||||||
|
|
||||||
dmaInit(dmaGetIdentifier(adc.DMAy_Streamx), OWNER_ADC, RESOURCE_INDEX(device));
|
dmaInit(dmaGetIdentifier(adc.DMAy_Streamx), OWNER_ADC, 0);
|
||||||
|
|
||||||
DMA_DeInit(adc.DMAy_Streamx);
|
DMA_DeInit(adc.DMAy_Streamx);
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ void adcInit(drv_adc_config_t *init)
|
||||||
if (!adcConfig[i].tag)
|
if (!adcConfig[i].tag)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC, RESOURCE_ADC_BATTERY + i, 0);
|
IOInit(IOGetByTag(adcConfig[i].tag), OWNER_ADC_BATT + i, 0);
|
||||||
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_MODE_ANALOG, 0, GPIO_NOPULL));
|
IOConfigGPIO(IOGetByTag(adcConfig[i].tag), IO_CONFIG(GPIO_MODE_ANALOG, 0, GPIO_NOPULL));
|
||||||
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
adcConfig[i].adcChannel = adcChannelByTag(adcConfig[i].tag);
|
||||||
adcConfig[i].dmaIndex = configuredAdcChannels++;
|
adcConfig[i].dmaIndex = configuredAdcChannels++;
|
||||||
|
@ -141,7 +141,7 @@ void adcInit(drv_adc_config_t *init)
|
||||||
|
|
||||||
|
|
||||||
RCC_ClockCmd(adc.rccADC, ENABLE);
|
RCC_ClockCmd(adc.rccADC, ENABLE);
|
||||||
dmaInit(dmaGetIdentifier(adc.DMAy_Streamx), OWNER_ADC, RESOURCE_INDEX(device));
|
dmaInit(dmaGetIdentifier(adc.DMAy_Streamx), OWNER_ADC, 0);
|
||||||
|
|
||||||
ADCHandle.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8;
|
ADCHandle.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8;
|
||||||
ADCHandle.Init.ContinuousConvMode = ENABLE;
|
ADCHandle.Init.ContinuousConvMode = ENABLE;
|
||||||
|
|
|
@ -143,7 +143,7 @@ void bmp085InitXclrIO(const bmp085Config_t *config)
|
||||||
{
|
{
|
||||||
if (!xclrIO && config && config->xclrIO) {
|
if (!xclrIO && config && config->xclrIO) {
|
||||||
xclrIO = IOGetByTag(config->xclrIO);
|
xclrIO = IOGetByTag(config->xclrIO);
|
||||||
IOInit(xclrIO, OWNER_BARO, RESOURCE_OUTPUT, 0);
|
IOInit(xclrIO, OWNER_BARO_CS, 0);
|
||||||
IOConfigGPIO(xclrIO, IOCFG_OUT_PP);
|
IOConfigGPIO(xclrIO, IOCFG_OUT_PP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ bool bmp085Detect(const bmp085Config_t *config, baro_t *baro)
|
||||||
if (config && config->eocIO) {
|
if (config && config->eocIO) {
|
||||||
eocIO = IOGetByTag(config->eocIO);
|
eocIO = IOGetByTag(config->eocIO);
|
||||||
// EXTI interrupt for barometer EOC
|
// EXTI interrupt for barometer EOC
|
||||||
IOInit(eocIO, OWNER_SYSTEM, RESOURCE_INPUT | RESOURCE_EXTI);
|
IOInit(eocIO, OWNER_BARO_EXTI, 0);
|
||||||
IOConfigGPIO(eocIO, Mode_IN_FLOATING);
|
IOConfigGPIO(eocIO, Mode_IN_FLOATING);
|
||||||
EXTIHandlerInit(&bmp085_extiCallbackRec, bmp085_extiHandler);
|
EXTIHandlerInit(&bmp085_extiCallbackRec, bmp085_extiHandler);
|
||||||
EXTIConfig(eocIO, &bmp085_extiCallbackRec, NVIC_PRIO_BARO_EXTI, EXTI_Trigger_Rising);
|
EXTIConfig(eocIO, &bmp085_extiCallbackRec, NVIC_PRIO_BARO_EXTI, EXTI_Trigger_Rising);
|
||||||
|
|
|
@ -65,7 +65,7 @@ void bmp280SpiInit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
bmp280CsPin = IOGetByTag(IO_TAG(BMP280_CS_PIN));
|
bmp280CsPin = IOGetByTag(IO_TAG(BMP280_CS_PIN));
|
||||||
IOInit(bmp280CsPin, OWNER_BARO, RESOURCE_SPI_CS, 0);
|
IOInit(bmp280CsPin, OWNER_BARO_CS, 0);
|
||||||
IOConfigGPIO(bmp280CsPin, IOCFG_OUT_PP);
|
IOConfigGPIO(bmp280CsPin, IOCFG_OUT_PP);
|
||||||
|
|
||||||
DISABLE_BMP280;
|
DISABLE_BMP280;
|
||||||
|
|
|
@ -209,8 +209,8 @@ void i2cInit(I2CDevice device)
|
||||||
IO_t scl = IOGetByTag(i2c->scl);
|
IO_t scl = IOGetByTag(i2c->scl);
|
||||||
IO_t sda = IOGetByTag(i2c->sda);
|
IO_t sda = IOGetByTag(i2c->sda);
|
||||||
|
|
||||||
IOInit(scl, OWNER_I2C, RESOURCE_I2C_SCL, RESOURCE_INDEX(device));
|
IOInit(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device));
|
||||||
IOInit(sda, OWNER_I2C, RESOURCE_I2C_SDA, RESOURCE_INDEX(device));
|
IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));
|
||||||
|
|
||||||
// Enable RCC
|
// Enable RCC
|
||||||
RCC_ClockCmd(i2c->rcc, ENABLE);
|
RCC_ClockCmd(i2c->rcc, ENABLE);
|
||||||
|
|
|
@ -387,8 +387,8 @@ void i2cInit(I2CDevice device)
|
||||||
IO_t scl = IOGetByTag(i2c->scl);
|
IO_t scl = IOGetByTag(i2c->scl);
|
||||||
IO_t sda = IOGetByTag(i2c->sda);
|
IO_t sda = IOGetByTag(i2c->sda);
|
||||||
|
|
||||||
IOInit(scl, OWNER_I2C, RESOURCE_I2C_SCL, RESOURCE_INDEX(device));
|
IOInit(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device));
|
||||||
IOInit(sda, OWNER_I2C, RESOURCE_I2C_SDA, RESOURCE_INDEX(device));
|
IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));
|
||||||
|
|
||||||
// Enable RCC
|
// Enable RCC
|
||||||
RCC_ClockCmd(i2c->rcc, ENABLE);
|
RCC_ClockCmd(i2c->rcc, ENABLE);
|
||||||
|
|
|
@ -90,10 +90,10 @@ void i2cInit(I2CDevice device)
|
||||||
RCC_ClockCmd(i2c->rcc, ENABLE);
|
RCC_ClockCmd(i2c->rcc, ENABLE);
|
||||||
RCC_I2CCLKConfig(I2Cx == I2C2 ? RCC_I2C2CLK_SYSCLK : RCC_I2C1CLK_SYSCLK);
|
RCC_I2CCLKConfig(I2Cx == I2C2 ? RCC_I2C2CLK_SYSCLK : RCC_I2C1CLK_SYSCLK);
|
||||||
|
|
||||||
IOInit(scl, OWNER_I2C, RESOURCE_I2C_SCL, RESOURCE_INDEX(device));
|
IOInit(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(scl, IOCFG_I2C, GPIO_AF_4);
|
IOConfigGPIOAF(scl, IOCFG_I2C, GPIO_AF_4);
|
||||||
|
|
||||||
IOInit(sda, OWNER_I2C, RESOURCE_I2C_SDA, RESOURCE_INDEX(device));
|
IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(sda, IOCFG_I2C, GPIO_AF_4);
|
IOConfigGPIOAF(sda, IOCFG_I2C, GPIO_AF_4);
|
||||||
|
|
||||||
I2C_InitTypeDef i2cInit = {
|
I2C_InitTypeDef i2cInit = {
|
||||||
|
|
|
@ -116,9 +116,9 @@ void spiInitDevice(SPIDevice device)
|
||||||
RCC_ClockCmd(spi->rcc, ENABLE);
|
RCC_ClockCmd(spi->rcc, ENABLE);
|
||||||
RCC_ResetCmd(spi->rcc, ENABLE);
|
RCC_ResetCmd(spi->rcc, ENABLE);
|
||||||
|
|
||||||
IOInit(IOGetByTag(spi->sck), OWNER_SPI, RESOURCE_SPI_SCK, device + 1);
|
IOInit(IOGetByTag(spi->sck), OWNER_SPI_SCK, RESOURCE_INDEX(device));
|
||||||
IOInit(IOGetByTag(spi->miso), OWNER_SPI, RESOURCE_SPI_MISO, device + 1);
|
IOInit(IOGetByTag(spi->miso), OWNER_SPI_MISO, RESOURCE_INDEX(device));
|
||||||
IOInit(IOGetByTag(spi->mosi), OWNER_SPI, RESOURCE_SPI_MOSI, device + 1);
|
IOInit(IOGetByTag(spi->mosi), OWNER_SPI_MOSI, RESOURCE_INDEX(device));
|
||||||
|
|
||||||
#if defined(STM32F3) || defined(STM32F4)
|
#if defined(STM32F3) || defined(STM32F4)
|
||||||
IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_CFG, spi->af);
|
IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_CFG, spi->af);
|
||||||
|
|
|
@ -155,9 +155,9 @@ void spiInitDevice(SPIDevice device)
|
||||||
RCC_ClockCmd(spi->rcc, ENABLE);
|
RCC_ClockCmd(spi->rcc, ENABLE);
|
||||||
RCC_ResetCmd(spi->rcc, ENABLE);
|
RCC_ResetCmd(spi->rcc, ENABLE);
|
||||||
|
|
||||||
IOInit(IOGetByTag(spi->sck), OWNER_SPI, RESOURCE_SPI_SCK, device + 1);
|
IOInit(IOGetByTag(spi->sck), OWNER_SPI_SCK, RESOURCE_INDEX(device));
|
||||||
IOInit(IOGetByTag(spi->miso), OWNER_SPI, RESOURCE_SPI_MISO, device + 1);
|
IOInit(IOGetByTag(spi->miso), OWNER_SPI_MISO, RESOURCE_INDEX(device));
|
||||||
IOInit(IOGetByTag(spi->mosi), OWNER_SPI, RESOURCE_SPI_MOSI, device + 1);
|
IOInit(IOGetByTag(spi->mosi), OWNER_SPI_MOSI, RESOURCE_INDEX(device));
|
||||||
|
|
||||||
#if defined(STM32F3) || defined(STM32F4) || defined(STM32F7)
|
#if defined(STM32F3) || defined(STM32F4) || defined(STM32F7)
|
||||||
IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_CFG, spi->af);
|
IOConfigGPIOAF(IOGetByTag(spi->sck), SPI_IO_AF_CFG, spi->af);
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
void softSpiInit(const softSPIDevice_t *dev)
|
void softSpiInit(const softSPIDevice_t *dev)
|
||||||
{
|
{
|
||||||
// SCK as output
|
// SCK as output
|
||||||
IOInit(IOGetByTag(dev->sckTag), OWNER_SOFTSPI, RESOURCE_SPI_SCK, SOFT_SPIDEV_1 + 1);
|
IOInit(IOGetByTag(dev->sckTag), OWNER_SPI_SCK, RESOURCE_INDEX(SOFT_SPIDEV_1) + 10);
|
||||||
#if defined(STM32F10X)
|
#if defined(STM32F10X)
|
||||||
IOConfigGPIO(IOGetByTag(dev->sckTag), IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_50MHz));
|
IOConfigGPIO(IOGetByTag(dev->sckTag), IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_50MHz));
|
||||||
#elif defined(STM32F3) || defined(STM32F4)
|
#elif defined(STM32F3) || defined(STM32F4)
|
||||||
|
@ -42,7 +42,7 @@ void softSpiInit(const softSPIDevice_t *dev)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MOSI as output
|
// MOSI as output
|
||||||
IOInit(IOGetByTag(dev->mosiTag), OWNER_SOFTSPI, RESOURCE_SPI_MOSI, SOFT_SPIDEV_1 + 1);
|
IOInit(IOGetByTag(dev->mosiTag), OWNER_SPI_MOSI, RESOURCE_INDEX(SOFT_SPIDEV_1) + 10);
|
||||||
#if defined(STM32F10X)
|
#if defined(STM32F10X)
|
||||||
IOConfigGPIO(IOGetByTag(dev->mosiTag), IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_50MHz));
|
IOConfigGPIO(IOGetByTag(dev->mosiTag), IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_50MHz));
|
||||||
#elif defined(STM32F3) || defined(STM32F4)
|
#elif defined(STM32F3) || defined(STM32F4)
|
||||||
|
@ -50,7 +50,7 @@ void softSpiInit(const softSPIDevice_t *dev)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MISO as input
|
// MISO as input
|
||||||
IOInit(IOGetByTag(dev->misoTag), OWNER_SOFTSPI, RESOURCE_SPI_MISO, SOFT_SPIDEV_1 + 1);
|
IOInit(IOGetByTag(dev->misoTag), OWNER_SPI_MISO, RESOURCE_INDEX(SOFT_SPIDEV_1) + 10);
|
||||||
#if defined(STM32F10X)
|
#if defined(STM32F10X)
|
||||||
IOConfigGPIO(IOGetByTag(dev->misoTag), IO_CONFIG(GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz));
|
IOConfigGPIO(IOGetByTag(dev->misoTag), IO_CONFIG(GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz));
|
||||||
#elif defined(STM32F3) || defined(STM32F4)
|
#elif defined(STM32F3) || defined(STM32F4)
|
||||||
|
@ -59,7 +59,7 @@ void softSpiInit(const softSPIDevice_t *dev)
|
||||||
|
|
||||||
// NSS as output
|
// NSS as output
|
||||||
if (dev->nssTag != IOTAG_NONE) {
|
if (dev->nssTag != IOTAG_NONE) {
|
||||||
IOInit(IOGetByTag(dev->nssTag), OWNER_SOFTSPI, RESOURCE_SPI_CS, SOFT_SPIDEV_1 + 1);
|
IOInit(IOGetByTag(dev->nssTag), OWNER_SPI_CS, RESOURCE_INDEX(SOFT_SPIDEV_1) + 10);
|
||||||
#if defined(STM32F10X)
|
#if defined(STM32F10X)
|
||||||
IOConfigGPIO(IOGetByTag(dev->nssTag), IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_50MHz));
|
IOConfigGPIO(IOGetByTag(dev->nssTag), IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_50MHz));
|
||||||
#elif defined(STM32F3) || defined(STM32F4)
|
#elif defined(STM32F3) || defined(STM32F4)
|
||||||
|
|
|
@ -224,7 +224,7 @@ bool m25p16_init(ioTag_t csTag)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
IOInit(m25p16CsPin, OWNER_FLASH, RESOURCE_SPI_CS, 0);
|
IOInit(m25p16CsPin, OWNER_FLASH_CS, 0);
|
||||||
IOConfigGPIO(m25p16CsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(m25p16CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
DISABLE_M25P16;
|
DISABLE_M25P16;
|
||||||
|
|
|
@ -36,7 +36,7 @@ static IO_t pin = IO_NONE;
|
||||||
void initInverter(void)
|
void initInverter(void)
|
||||||
{
|
{
|
||||||
pin = IOGetByTag(IO_TAG(INVERTER));
|
pin = IOGetByTag(IO_TAG(INVERTER));
|
||||||
IOInit(pin, OWNER_INVERTER, RESOURCE_OUTPUT, 1);
|
IOInit(pin, OWNER_INVERTER, 1);
|
||||||
IOConfigGPIO(pin, IOCFG_OUT_PP);
|
IOConfigGPIO(pin, IOCFG_OUT_PP);
|
||||||
|
|
||||||
inverterSet(false);
|
inverterSet(false);
|
||||||
|
|
|
@ -77,19 +77,7 @@ const struct ioPortDef_s ioPortDefs[] = {
|
||||||
{ RCC_AHB1(GPIOE) },
|
{ RCC_AHB1(GPIOE) },
|
||||||
{ RCC_AHB1(GPIOF) },
|
{ RCC_AHB1(GPIOF) },
|
||||||
};
|
};
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
const char * const ownerNames[OWNER_TOTAL_COUNT] = {
|
|
||||||
"FREE", "PWM", "PPM", "MOTOR", "SERVO", "SOFTSERIAL", "ADC", "SERIAL", "DEBUG", "TIMER",
|
|
||||||
"SONAR_TRIGGER", "SONAR_ECHO", "SYSTEM", "SPI", "I2C", "SDCARD", "FLASH", "USB", "BEEPER", "OSD",
|
|
||||||
"BARO", "MPU", "INVERTER", "LED_STRIP", "LED", "RX", "TX", "SOFT_SPI", "RX_SPI", "MAX7456"
|
|
||||||
};
|
|
||||||
|
|
||||||
const char * const resourceNames[RESOURCE_TOTAL_COUNT] = {
|
|
||||||
"", // NONE
|
|
||||||
"IN", "OUT", "IN / OUT", "TIMER","UART TX","UART RX","UART TX/RX","EXTI","SCL",
|
|
||||||
"SDA", "SCK","MOSI","MISO","CS","BATTERY","RSSI","EXT","CURRENT"
|
|
||||||
};
|
|
||||||
|
|
||||||
ioRec_t* IO_Rec(IO_t io)
|
ioRec_t* IO_Rec(IO_t io)
|
||||||
{
|
{
|
||||||
|
@ -248,11 +236,10 @@ void IOToggle(IO_t io)
|
||||||
}
|
}
|
||||||
|
|
||||||
// claim IO pin, set owner and resources
|
// claim IO pin, set owner and resources
|
||||||
void IOInit(IO_t io, resourceOwner_e owner, resourceType_e resource, uint8_t index)
|
void IOInit(IO_t io, resourceOwner_e owner, uint8_t index)
|
||||||
{
|
{
|
||||||
ioRec_t *ioRec = IO_Rec(io);
|
ioRec_t *ioRec = IO_Rec(io);
|
||||||
ioRec->owner = owner;
|
ioRec->owner = owner;
|
||||||
ioRec->resource = resource;
|
|
||||||
ioRec->index = index;
|
ioRec->index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,12 +255,6 @@ resourceOwner_e IOGetOwner(IO_t io)
|
||||||
return ioRec->owner;
|
return ioRec->owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceType_e IOGetResource(IO_t io)
|
|
||||||
{
|
|
||||||
ioRec_t *ioRec = IO_Rec(io);
|
|
||||||
return ioRec->resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(STM32F1)
|
#if defined(STM32F1)
|
||||||
|
|
||||||
void IOConfigGPIO(IO_t io, ioConfig_t cfg)
|
void IOConfigGPIO(IO_t io, ioConfig_t cfg)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -101,10 +101,9 @@ void IOHi(IO_t io);
|
||||||
void IOLo(IO_t io);
|
void IOLo(IO_t io);
|
||||||
void IOToggle(IO_t io);
|
void IOToggle(IO_t io);
|
||||||
|
|
||||||
void IOInit(IO_t io, resourceOwner_e owner, resourceType_e resource, uint8_t index);
|
void IOInit(IO_t io, resourceOwner_e owner, uint8_t index);
|
||||||
void IORelease(IO_t io); // unimplemented
|
void IORelease(IO_t io); // unimplemented
|
||||||
resourceOwner_e IOGetOwner(IO_t io);
|
resourceOwner_e IOGetOwner(IO_t io);
|
||||||
resourceType_e IOGetResources(IO_t io);
|
|
||||||
IO_t IOGetByTag(ioTag_t tag);
|
IO_t IOGetByTag(ioTag_t tag);
|
||||||
|
|
||||||
void IOConfigGPIO(IO_t io, ioConfig_t cfg);
|
void IOConfigGPIO(IO_t io, ioConfig_t cfg);
|
||||||
|
|
|
@ -29,7 +29,6 @@ typedef struct ioRec_s {
|
||||||
GPIO_TypeDef *gpio;
|
GPIO_TypeDef *gpio;
|
||||||
uint16_t pin;
|
uint16_t pin;
|
||||||
resourceOwner_e owner;
|
resourceOwner_e owner;
|
||||||
resourceType_e resource;
|
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
} ioRec_t;
|
} ioRec_t;
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ void ledInit(bool alternative_led)
|
||||||
|
|
||||||
for (int i = 0; i < LED_NUMBER; i++) {
|
for (int i = 0; i < LED_NUMBER; i++) {
|
||||||
if (leds[i + ledOffset]) {
|
if (leds[i + ledOffset]) {
|
||||||
IOInit(leds[i + ledOffset], OWNER_LED, RESOURCE_OUTPUT, RESOURCE_INDEX(i));
|
IOInit(leds[i + ledOffset], OWNER_LED, RESOURCE_INDEX(i));
|
||||||
IOConfigGPIO(leds[i + ledOffset], IOCFG_OUT_PP);
|
IOConfigGPIO(leds[i + ledOffset], IOCFG_OUT_PP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag)
|
||||||
static DMA_HandleTypeDef hdma_tim;
|
static DMA_HandleTypeDef hdma_tim;
|
||||||
|
|
||||||
ws2811IO = IOGetByTag(ioTag);
|
ws2811IO = IOGetByTag(ioTag);
|
||||||
IOInit(ws2811IO, OWNER_LED_STRIP, RESOURCE_OUTPUT, 0);
|
IOInit(ws2811IO, OWNER_LED_STRIP, 0);
|
||||||
IOConfigGPIOAF(ws2811IO, IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, GPIO_PULLUP), timerHardware->alternateFunction);
|
IOConfigGPIOAF(ws2811IO, IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, GPIO_PULLUP), timerHardware->alternateFunction);
|
||||||
|
|
||||||
__DMA1_CLK_ENABLE();
|
__DMA1_CLK_ENABLE();
|
||||||
|
|
|
@ -62,7 +62,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
ws2811IO = IOGetByTag(ioTag);
|
ws2811IO = IOGetByTag(ioTag);
|
||||||
IOInit(ws2811IO, OWNER_LED_STRIP, RESOURCE_OUTPUT, 0);
|
IOInit(ws2811IO, OWNER_LED_STRIP, 0);
|
||||||
IOConfigGPIO(ws2811IO, IO_CONFIG(GPIO_Speed_50MHz, GPIO_Mode_AF_PP));
|
IOConfigGPIO(ws2811IO, IO_CONFIG(GPIO_Speed_50MHz, GPIO_Mode_AF_PP));
|
||||||
|
|
||||||
RCC_ClockCmd(timerRCC(timer), ENABLE);
|
RCC_ClockCmd(timerRCC(timer), ENABLE);
|
||||||
|
|
|
@ -63,7 +63,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
ws2811IO = IOGetByTag(ioTag);
|
ws2811IO = IOGetByTag(ioTag);
|
||||||
IOInit(ws2811IO, OWNER_LED_STRIP, RESOURCE_OUTPUT, 0);
|
IOInit(ws2811IO, OWNER_LED_STRIP, 0);
|
||||||
IOConfigGPIOAF(ws2811IO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
IOConfigGPIOAF(ws2811IO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
||||||
|
|
||||||
dmaInit(timerHardware->dmaIrqHandler, OWNER_LED_STRIP, 0);
|
dmaInit(timerHardware->dmaIrqHandler, OWNER_LED_STRIP, 0);
|
||||||
|
|
|
@ -68,7 +68,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag)
|
||||||
|
|
||||||
ws2811IO = IOGetByTag(ioTag);
|
ws2811IO = IOGetByTag(ioTag);
|
||||||
/* GPIOA Configuration: TIM5 Channel 1 as alternate function push-pull */
|
/* GPIOA Configuration: TIM5 Channel 1 as alternate function push-pull */
|
||||||
IOInit(ws2811IO, OWNER_LED_STRIP, RESOURCE_OUTPUT, 0);
|
IOInit(ws2811IO, OWNER_LED_STRIP, 0);
|
||||||
IOConfigGPIOAF(ws2811IO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
IOConfigGPIOAF(ws2811IO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
||||||
|
|
||||||
// Stop timer
|
// Stop timer
|
||||||
|
|
|
@ -260,7 +260,7 @@ void max7456Init(uint8_t video_system)
|
||||||
#ifdef MAX7456_SPI_CS_PIN
|
#ifdef MAX7456_SPI_CS_PIN
|
||||||
max7456CsPin = IOGetByTag(IO_TAG(MAX7456_SPI_CS_PIN));
|
max7456CsPin = IOGetByTag(IO_TAG(MAX7456_SPI_CS_PIN));
|
||||||
#endif
|
#endif
|
||||||
IOInit(max7456CsPin, OWNER_OSD, RESOURCE_SPI_CS, 0);
|
IOInit(max7456CsPin, OWNER_OSD_CS, 0);
|
||||||
IOConfigGPIO(max7456CsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(max7456CsPin, SPI_IO_CS_CFG);
|
||||||
|
|
||||||
spiSetDivisor(MAX7456_SPI_INSTANCE, SPI_CLOCK_STANDARD);
|
spiSetDivisor(MAX7456_SPI_INSTANCE, SPI_CLOCK_STANDARD);
|
||||||
|
|
|
@ -228,7 +228,7 @@ void motorInit(const motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t mot
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IOInit(motors[motorIndex].io, OWNER_MOTOR, RESOURCE_OUTPUT, RESOURCE_INDEX(motorIndex));
|
IOInit(motors[motorIndex].io, OWNER_MOTOR, RESOURCE_INDEX(motorIndex));
|
||||||
IOConfigGPIO(motors[motorIndex].io, IOCFG_AF_PP);
|
IOConfigGPIO(motors[motorIndex].io, IOCFG_AF_PP);
|
||||||
|
|
||||||
motors[motorIndex].pwmWritePtr = pwmWritePtr;
|
motors[motorIndex].pwmWritePtr = pwmWritePtr;
|
||||||
|
@ -271,7 +271,7 @@ void servoInit(const servoConfig_t *servoConfig)
|
||||||
|
|
||||||
servos[servoIndex].io = IOGetByTag(tag);
|
servos[servoIndex].io = IOGetByTag(tag);
|
||||||
|
|
||||||
IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_OUTPUT, RESOURCE_INDEX(servoIndex));
|
IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_INDEX(servoIndex));
|
||||||
IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP);
|
IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP);
|
||||||
|
|
||||||
const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_ANY);
|
const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_ANY);
|
||||||
|
|
|
@ -238,7 +238,7 @@ void motorInit(const motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t mot
|
||||||
#endif
|
#endif
|
||||||
motors[motorIndex].io = IOGetByTag(tag);
|
motors[motorIndex].io = IOGetByTag(tag);
|
||||||
|
|
||||||
IOInit(motors[motorIndex].io, OWNER_MOTOR, RESOURCE_OUTPUT, RESOURCE_INDEX(motorIndex));
|
IOInit(motors[motorIndex].io, OWNER_MOTOR, RESOURCE_INDEX(motorIndex));
|
||||||
//IOConfigGPIO(motors[motorIndex].io, IOCFG_AF_PP);
|
//IOConfigGPIO(motors[motorIndex].io, IOCFG_AF_PP);
|
||||||
IOConfigGPIOAF(motors[motorIndex].io, IOCFG_AF_PP, timerHardware->alternateFunction);
|
IOConfigGPIOAF(motors[motorIndex].io, IOCFG_AF_PP, timerHardware->alternateFunction);
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ void servoInit(const servoConfig_t *servoConfig)
|
||||||
|
|
||||||
servos[servoIndex].io = IOGetByTag(tag);
|
servos[servoIndex].io = IOGetByTag(tag);
|
||||||
|
|
||||||
IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_OUTPUT, RESOURCE_INDEX(servoIndex));
|
IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_INDEX(servoIndex));
|
||||||
//IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP);
|
//IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP);
|
||||||
|
|
||||||
const timerHardware_t *timer = timerGetByTag(tag, TIMER_OUTPUT_ENABLED);
|
const timerHardware_t *timer = timerGetByTag(tag, TIMER_OUTPUT_ENABLED);
|
||||||
|
|
|
@ -125,7 +125,7 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
|
||||||
const uint8_t timerIndex = getTimerIndex(timer);
|
const uint8_t timerIndex = getTimerIndex(timer);
|
||||||
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
||||||
|
|
||||||
IOInit(motorIO, OWNER_MOTOR, RESOURCE_OUTPUT, 0);
|
IOInit(motorIO, OWNER_MOTOR, 0);
|
||||||
IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
||||||
|
|
||||||
if (configureTimer) {
|
if (configureTimer) {
|
||||||
|
|
|
@ -123,7 +123,7 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
|
||||||
const uint8_t timerIndex = getTimerIndex(timer);
|
const uint8_t timerIndex = getTimerIndex(timer);
|
||||||
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
||||||
|
|
||||||
IOInit(motorIO, OWNER_MOTOR, RESOURCE_OUTPUT, 0);
|
IOInit(motorIO, OWNER_MOTOR, 0);
|
||||||
IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, GPIO_PuPd_UP), timerHardware->alternateFunction);
|
||||||
|
|
||||||
if (configureTimer) {
|
if (configureTimer) {
|
||||||
|
|
|
@ -130,7 +130,7 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
|
||||||
const uint8_t timerIndex = getTimerIndex(timer);
|
const uint8_t timerIndex = getTimerIndex(timer);
|
||||||
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
||||||
|
|
||||||
IOInit(motorIO, OWNER_MOTOR, RESOURCE_OUTPUT, 0);
|
IOInit(motorIO, OWNER_MOTOR, 0);
|
||||||
IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, GPIO_PULLUP), timerHardware->alternateFunction);
|
IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, GPIO_PULLUP), timerHardware->alternateFunction);
|
||||||
|
|
||||||
__DMA1_CLK_ENABLE();
|
__DMA1_CLK_ENABLE();
|
||||||
|
|
|
@ -407,7 +407,7 @@ void pwmRxInit(const pwmConfig_t *pwmConfig)
|
||||||
port->timerHardware = timer;
|
port->timerHardware = timer;
|
||||||
|
|
||||||
IO_t io = IOGetByTag(pwmConfig->ioTags[channel]);
|
IO_t io = IOGetByTag(pwmConfig->ioTags[channel]);
|
||||||
IOInit(io, OWNER_PWMINPUT, RESOURCE_INPUT, RESOURCE_INDEX(channel));
|
IOInit(io, OWNER_PWMINPUT, RESOURCE_INDEX(channel));
|
||||||
IOConfigGPIO(io, IOCFG_IPD);
|
IOConfigGPIO(io, IOCFG_IPD);
|
||||||
|
|
||||||
#if defined(USE_HAL_DRIVER)
|
#if defined(USE_HAL_DRIVER)
|
||||||
|
@ -471,7 +471,7 @@ void ppmRxInit(const ppmConfig_t *ppmConfig, uint8_t pwmProtocol)
|
||||||
port->timerHardware = timer;
|
port->timerHardware = timer;
|
||||||
|
|
||||||
IO_t io = IOGetByTag(ppmConfig->ioTag);
|
IO_t io = IOGetByTag(ppmConfig->ioTag);
|
||||||
IOInit(io, OWNER_PPMINPUT, RESOURCE_INPUT, 0);
|
IOInit(io, OWNER_PPMINPUT, 0);
|
||||||
IOConfigGPIO(io, IOCFG_IPD);
|
IOConfigGPIO(io, IOCFG_IPD);
|
||||||
|
|
||||||
#if defined(USE_HAL_DRIVER)
|
#if defined(USE_HAL_DRIVER)
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation,either version 3 of the License,or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not,see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
const char * const ownerNames[OWNER_TOTAL_COUNT] = {
|
||||||
|
"FREE",
|
||||||
|
"PWM",
|
||||||
|
"PPM",
|
||||||
|
"MOTOR",
|
||||||
|
"SERVO",
|
||||||
|
"LED",
|
||||||
|
"ADC",
|
||||||
|
"ADC_BATT",
|
||||||
|
"ADC_CURR",
|
||||||
|
"ADC_EXT",
|
||||||
|
"ADC_RSSI",
|
||||||
|
"SERIAL_TX",
|
||||||
|
"SERIAL_RX",
|
||||||
|
"DEBUG",
|
||||||
|
"TIMER",
|
||||||
|
"SONAR_TRIGGER",
|
||||||
|
"SONAR_ECHO",
|
||||||
|
"SYSTEM",
|
||||||
|
"SPI_SCK",
|
||||||
|
"SPI_MISO",
|
||||||
|
"SPI_MOSI",
|
||||||
|
"I2C_SDA",
|
||||||
|
"I2C_SCL",
|
||||||
|
"SDCARD_CS",
|
||||||
|
"FLASH_CS",
|
||||||
|
"BARO_CS",
|
||||||
|
"MPU_CS",
|
||||||
|
"OSD_CS",
|
||||||
|
"RX_SPI_CS",
|
||||||
|
"SPI_CS",
|
||||||
|
"MPU_EXTI",
|
||||||
|
"BARO_EXTI",
|
||||||
|
"USB",
|
||||||
|
"USB_DETECT",
|
||||||
|
"BEEPER",
|
||||||
|
"OSD",
|
||||||
|
"SDCARD_DETECT",
|
||||||
|
"RX_BIND",
|
||||||
|
"INVERTER",
|
||||||
|
"LED_STRIP",
|
||||||
|
};
|
||||||
|
|
|
@ -1,57 +1,67 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight.
|
||||||
|
*
|
||||||
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define RESOURCE_INDEX(x) (x + 1)
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OWNER_FREE = 0,
|
OWNER_FREE = 0,
|
||||||
OWNER_PWMINPUT,
|
OWNER_PWMINPUT,
|
||||||
OWNER_PPMINPUT,
|
OWNER_PPMINPUT,
|
||||||
OWNER_MOTOR,
|
OWNER_MOTOR,
|
||||||
OWNER_SERVO,
|
OWNER_SERVO,
|
||||||
OWNER_SOFTSERIAL,
|
OWNER_LED,
|
||||||
OWNER_ADC,
|
OWNER_ADC,
|
||||||
OWNER_SERIAL,
|
OWNER_ADC_BATT,
|
||||||
|
OWNER_ADC_CURR,
|
||||||
|
OWNER_ADC_EXT,
|
||||||
|
OWNER_ADC_RSSI,
|
||||||
|
OWNER_SERIAL_TX,
|
||||||
|
OWNER_SERIAL_RX,
|
||||||
OWNER_PINDEBUG,
|
OWNER_PINDEBUG,
|
||||||
OWNER_TIMER,
|
OWNER_TIMER,
|
||||||
OWNER_SONAR_TRIGGER,
|
OWNER_SONAR_TRIGGER,
|
||||||
OWNER_SONAR_ECHO,
|
OWNER_SONAR_ECHO,
|
||||||
OWNER_SYSTEM,
|
OWNER_SYSTEM,
|
||||||
OWNER_SPI,
|
OWNER_SPI_SCK,
|
||||||
OWNER_I2C,
|
OWNER_SPI_MISO,
|
||||||
OWNER_SDCARD,
|
OWNER_SPI_MOSI,
|
||||||
OWNER_FLASH,
|
OWNER_I2C_SCL,
|
||||||
|
OWNER_I2C_SDA,
|
||||||
|
OWNER_SDCARD_CS,
|
||||||
|
OWNER_FLASH_CS,
|
||||||
|
OWNER_BARO_CS,
|
||||||
|
OWNER_MPU_CS,
|
||||||
|
OWNER_OSD_CS,
|
||||||
|
OWNER_RX_SPI_CS,
|
||||||
|
OWNER_SPI_CS,
|
||||||
|
OWNER_MPU_EXTI,
|
||||||
|
OWNER_BARO_EXTI,
|
||||||
OWNER_USB,
|
OWNER_USB,
|
||||||
|
OWNER_USB_DETECT,
|
||||||
OWNER_BEEPER,
|
OWNER_BEEPER,
|
||||||
OWNER_OSD,
|
OWNER_OSD,
|
||||||
OWNER_BARO,
|
OWNER_SDCARD_DETECT,
|
||||||
OWNER_MPU,
|
OWNER_RX_BIND,
|
||||||
OWNER_INVERTER,
|
OWNER_INVERTER,
|
||||||
OWNER_LED_STRIP,
|
OWNER_LED_STRIP,
|
||||||
OWNER_LED,
|
|
||||||
OWNER_RX,
|
|
||||||
OWNER_TX,
|
|
||||||
OWNER_SOFTSPI,
|
|
||||||
OWNER_RX_SPI,
|
|
||||||
OWNER_MAX7456,
|
|
||||||
OWNER_TOTAL_COUNT
|
OWNER_TOTAL_COUNT
|
||||||
} resourceOwner_e;
|
} resourceOwner_e;
|
||||||
|
|
||||||
extern const char * const ownerNames[OWNER_TOTAL_COUNT];
|
extern const char * const ownerNames[OWNER_TOTAL_COUNT];
|
||||||
|
|
||||||
// Currently TIMER should be shared resource (softserial dualtimer and timerqueue needs to allocate timer channel, but pin can be used for other function)
|
#define RESOURCE_INDEX(x) (x + 1)
|
||||||
// with mode switching (shared serial ports, ...) this will need some improvement
|
#define RESOURCE_SOFT_OFFSET 10
|
||||||
typedef enum {
|
|
||||||
RESOURCE_NONE = 0,
|
|
||||||
RESOURCE_INPUT, RESOURCE_OUTPUT, RESOURCE_IO,
|
|
||||||
RESOURCE_TIMER,
|
|
||||||
RESOURCE_UART_TX, RESOURCE_UART_RX, RESOURCE_UART_TXRX,
|
|
||||||
RESOURCE_EXTI,
|
|
||||||
RESOURCE_I2C_SCL, RESOURCE_I2C_SDA,
|
|
||||||
RESOURCE_SPI_SCK, RESOURCE_SPI_MOSI, RESOURCE_SPI_MISO, RESOURCE_SPI_CS,
|
|
||||||
RESOURCE_ADC_BATTERY, RESOURCE_ADC_RSSI, RESOURCE_ADC_EXTERNAL1, RESOURCE_ADC_CURRENT,
|
|
||||||
RESOURCE_RX_CE,
|
|
||||||
RESOURCE_TOTAL_COUNT
|
|
||||||
} resourceType_e;
|
|
||||||
|
|
||||||
extern const char * const resourceNames[RESOURCE_TOTAL_COUNT];
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ void rxSpiDeviceInit(rx_spi_type_e spiType)
|
||||||
#else
|
#else
|
||||||
UNUSED(spiType);
|
UNUSED(spiType);
|
||||||
const SPIDevice rxSPIDevice = spiDeviceByInstance(RX_SPI_INSTANCE);
|
const SPIDevice rxSPIDevice = spiDeviceByInstance(RX_SPI_INSTANCE);
|
||||||
IOInit(IOGetByTag(IO_TAG(RX_NSS_PIN)), OWNER_SPI, RESOURCE_SPI_CS, rxSPIDevice + 1);
|
IOInit(IOGetByTag(IO_TAG(RX_NSS_PIN)), OWNER_SPI_CS, rxSPIDevice + 1);
|
||||||
#endif // USE_RX_SOFTSPI
|
#endif // USE_RX_SOFTSPI
|
||||||
|
|
||||||
#if defined(STM32F10X)
|
#if defined(STM32F10X)
|
||||||
|
@ -83,7 +83,7 @@ void rxSpiDeviceInit(rx_spi_type_e spiType)
|
||||||
|
|
||||||
#ifdef RX_CE_PIN
|
#ifdef RX_CE_PIN
|
||||||
// CE as OUTPUT
|
// CE as OUTPUT
|
||||||
IOInit(IOGetByTag(IO_TAG(RX_CE_PIN)), OWNER_RX_SPI, RESOURCE_RX_CE, rxSPIDevice + 1);
|
IOInit(IOGetByTag(IO_TAG(RX_CE_PIN)), OWNER_RX_SPI_CS, rxSPIDevice + 1);
|
||||||
#if defined(STM32F10X)
|
#if defined(STM32F10X)
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(RX_CE_PIN)), SPI_IO_CS_CFG);
|
IOConfigGPIO(IOGetByTag(IO_TAG(RX_CE_PIN)), SPI_IO_CS_CFG);
|
||||||
#elif defined(STM32F3) || defined(STM32F4)
|
#elif defined(STM32F3) || defined(STM32F4)
|
||||||
|
|
|
@ -128,7 +128,7 @@ void sdcardInsertionDetectDeinit(void)
|
||||||
{
|
{
|
||||||
#ifdef SDCARD_DETECT_PIN
|
#ifdef SDCARD_DETECT_PIN
|
||||||
sdCardDetectPin = IOGetByTag(IO_TAG(SDCARD_DETECT_PIN));
|
sdCardDetectPin = IOGetByTag(IO_TAG(SDCARD_DETECT_PIN));
|
||||||
IOInit(sdCardDetectPin, OWNER_FREE, RESOURCE_NONE, 0);
|
IOInit(sdCardDetectPin, OWNER_FREE, 0);
|
||||||
IOConfigGPIO(sdCardDetectPin, IOCFG_IN_FLOATING);
|
IOConfigGPIO(sdCardDetectPin, IOCFG_IN_FLOATING);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ void sdcardInsertionDetectInit(void)
|
||||||
{
|
{
|
||||||
#ifdef SDCARD_DETECT_PIN
|
#ifdef SDCARD_DETECT_PIN
|
||||||
sdCardDetectPin = IOGetByTag(IO_TAG(SDCARD_DETECT_PIN));
|
sdCardDetectPin = IOGetByTag(IO_TAG(SDCARD_DETECT_PIN));
|
||||||
IOInit(sdCardDetectPin, OWNER_SDCARD, RESOURCE_INPUT, 0);
|
IOInit(sdCardDetectPin, OWNER_SDCARD_DETECT, 0);
|
||||||
IOConfigGPIO(sdCardDetectPin, IOCFG_IPU);
|
IOConfigGPIO(sdCardDetectPin, IOCFG_IPU);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ void sdcard_init(bool useDMA)
|
||||||
|
|
||||||
#ifdef SDCARD_SPI_CS_PIN
|
#ifdef SDCARD_SPI_CS_PIN
|
||||||
sdCardCsPin = IOGetByTag(IO_TAG(SDCARD_SPI_CS_PIN));
|
sdCardCsPin = IOGetByTag(IO_TAG(SDCARD_SPI_CS_PIN));
|
||||||
IOInit(sdCardCsPin, OWNER_SDCARD, RESOURCE_SPI_CS, 0);
|
IOInit(sdCardCsPin, OWNER_SDCARD_CS, 0);
|
||||||
IOConfigGPIO(sdCardCsPin, SPI_IO_CS_CFG);
|
IOConfigGPIO(sdCardCsPin, SPI_IO_CS_CFG);
|
||||||
#endif // SDCARD_SPI_CS_PIN
|
#endif // SDCARD_SPI_CS_PIN
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ static void escSerialGPIOConfig(ioTag_t tag, ioConfig_t cfg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOInit(IOGetByTag(tag), OWNER_MOTOR, RESOURCE_OUTPUT, 0);
|
IOInit(IOGetByTag(tag), OWNER_MOTOR, 0);
|
||||||
IOConfigGPIO(IOGetByTag(tag), cfg);
|
IOConfigGPIO(IOGetByTag(tag), cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ void setTxSignal(softSerial_t *softSerial, uint8_t state)
|
||||||
|
|
||||||
void serialInputPortConfig(ioTag_t pin, uint8_t portIndex)
|
void serialInputPortConfig(ioTag_t pin, uint8_t portIndex)
|
||||||
{
|
{
|
||||||
IOInit(IOGetByTag(pin), OWNER_SOFTSERIAL, RESOURCE_UART_RX, RESOURCE_INDEX(portIndex));
|
IOInit(IOGetByTag(pin), OWNER_SERIAL_RX, RESOURCE_INDEX(portIndex) + RESOURCE_SOFT_OFFSET);
|
||||||
#ifdef STM32F1
|
#ifdef STM32F1
|
||||||
IOConfigGPIO(IOGetByTag(pin), IOCFG_IPU);
|
IOConfigGPIO(IOGetByTag(pin), IOCFG_IPU);
|
||||||
#else
|
#else
|
||||||
|
@ -111,7 +111,7 @@ void serialInputPortConfig(ioTag_t pin, uint8_t portIndex)
|
||||||
|
|
||||||
static void serialOutputPortConfig(ioTag_t pin, uint8_t portIndex)
|
static void serialOutputPortConfig(ioTag_t pin, uint8_t portIndex)
|
||||||
{
|
{
|
||||||
IOInit(IOGetByTag(pin), OWNER_SOFTSERIAL, RESOURCE_UART_TX, RESOURCE_INDEX(portIndex));
|
IOInit(IOGetByTag(pin), OWNER_SERIAL_TX, RESOURCE_INDEX(portIndex) + RESOURCE_SOFT_OFFSET);
|
||||||
IOConfigGPIO(IOGetByTag(pin), IOCFG_OUT_PP);
|
IOConfigGPIO(IOGetByTag(pin), IOCFG_OUT_PP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ uartPort_t *serialUART1(uint32_t baudRate, portMode_t mode, portOptions_t option
|
||||||
s->USARTx = USART1;
|
s->USARTx = USART1;
|
||||||
|
|
||||||
#ifdef USE_UART1_RX_DMA
|
#ifdef USE_UART1_RX_DMA
|
||||||
dmaInit(DMA1_CH5_HANDLER, OWNER_SERIAL, 1);
|
dmaInit(DMA1_CH5_HANDLER, OWNER_SERIAL_RX, 1);
|
||||||
s->rxDMAChannel = DMA1_Channel5;
|
s->rxDMAChannel = DMA1_Channel5;
|
||||||
s->rxDMAPeripheralBaseAddr = (uint32_t)&s->USARTx->DR;
|
s->rxDMAPeripheralBaseAddr = (uint32_t)&s->USARTx->DR;
|
||||||
#endif
|
#endif
|
||||||
|
@ -122,22 +122,22 @@ uartPort_t *serialUART1(uint32_t baudRate, portMode_t mode, portOptions_t option
|
||||||
// UART1_TX PA9
|
// UART1_TX PA9
|
||||||
// UART1_RX PA10
|
// UART1_RX PA10
|
||||||
if (options & SERIAL_BIDIR) {
|
if (options & SERIAL_BIDIR) {
|
||||||
IOInit(IOGetByTag(IO_TAG(PA9)), OWNER_SERIAL, RESOURCE_UART_TXRX, 1);
|
IOInit(IOGetByTag(IO_TAG(PA9)), OWNER_SERIAL_TX, 1);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(PA9)), IOCFG_AF_OD);
|
IOConfigGPIO(IOGetByTag(IO_TAG(PA9)), IOCFG_AF_OD);
|
||||||
} else {
|
} else {
|
||||||
if (mode & MODE_TX) {
|
if (mode & MODE_TX) {
|
||||||
IOInit(IOGetByTag(IO_TAG(PA9)), OWNER_SERIAL, RESOURCE_UART_TX, 1);
|
IOInit(IOGetByTag(IO_TAG(PA9)), OWNER_SERIAL_TX, 1);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(PA9)), IOCFG_AF_PP);
|
IOConfigGPIO(IOGetByTag(IO_TAG(PA9)), IOCFG_AF_PP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & MODE_RX) {
|
if (mode & MODE_RX) {
|
||||||
IOInit(IOGetByTag(IO_TAG(PA10)), OWNER_SERIAL, RESOURCE_UART_RX, 1);
|
IOInit(IOGetByTag(IO_TAG(PA10)), OWNER_SERIAL_RX, 1);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(PA10)), IOCFG_IPU);
|
IOConfigGPIO(IOGetByTag(IO_TAG(PA10)), IOCFG_IPU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DMA TX Interrupt
|
// DMA TX Interrupt
|
||||||
dmaInit(DMA1_CH4_HANDLER, OWNER_SERIAL, 1);
|
dmaInit(DMA1_CH4_HANDLER, OWNER_SERIAL_TX, 1);
|
||||||
dmaSetHandler(DMA1_CH4_HANDLER, uart_tx_dma_IRQHandler, NVIC_PRIO_SERIALUART1_TXDMA, (uint32_t)&uartPort1);
|
dmaSetHandler(DMA1_CH4_HANDLER, uart_tx_dma_IRQHandler, NVIC_PRIO_SERIALUART1_TXDMA, (uint32_t)&uartPort1);
|
||||||
|
|
||||||
#ifndef USE_UART1_RX_DMA
|
#ifndef USE_UART1_RX_DMA
|
||||||
|
@ -193,16 +193,16 @@ uartPort_t *serialUART2(uint32_t baudRate, portMode_t mode, portOptions_t option
|
||||||
// UART2_TX PA2
|
// UART2_TX PA2
|
||||||
// UART2_RX PA3
|
// UART2_RX PA3
|
||||||
if (options & SERIAL_BIDIR) {
|
if (options & SERIAL_BIDIR) {
|
||||||
IOInit(IOGetByTag(IO_TAG(PA2)), OWNER_SERIAL, RESOURCE_UART_TXRX, 2);
|
IOInit(IOGetByTag(IO_TAG(PA2)), OWNER_SERIAL_TX, 2);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(PA2)), IOCFG_AF_OD);
|
IOConfigGPIO(IOGetByTag(IO_TAG(PA2)), IOCFG_AF_OD);
|
||||||
} else {
|
} else {
|
||||||
if (mode & MODE_TX) {
|
if (mode & MODE_TX) {
|
||||||
IOInit(IOGetByTag(IO_TAG(PA2)), OWNER_SERIAL, RESOURCE_UART_TX, 2);
|
IOInit(IOGetByTag(IO_TAG(PA2)), OWNER_SERIAL_TX, 2);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(PA2)), IOCFG_AF_PP);
|
IOConfigGPIO(IOGetByTag(IO_TAG(PA2)), IOCFG_AF_PP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & MODE_RX) {
|
if (mode & MODE_RX) {
|
||||||
IOInit(IOGetByTag(IO_TAG(PA3)), OWNER_SERIAL, RESOURCE_UART_RX, 2);
|
IOInit(IOGetByTag(IO_TAG(PA3)), OWNER_SERIAL_RX, 2);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(PA3)), IOCFG_IPU);
|
IOConfigGPIO(IOGetByTag(IO_TAG(PA3)), IOCFG_IPU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,16 +255,16 @@ uartPort_t *serialUART3(uint32_t baudRate, portMode_t mode, portOptions_t option
|
||||||
RCC_ClockCmd(RCC_APB1(USART3), ENABLE);
|
RCC_ClockCmd(RCC_APB1(USART3), ENABLE);
|
||||||
|
|
||||||
if (options & SERIAL_BIDIR) {
|
if (options & SERIAL_BIDIR) {
|
||||||
IOInit(IOGetByTag(IO_TAG(UART3_TX_PIN)), OWNER_SERIAL, RESOURCE_UART_TXRX, 3);
|
IOInit(IOGetByTag(IO_TAG(UART3_TX_PIN)), OWNER_SERIAL_TX, 3);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(UART3_TX_PIN)), IOCFG_AF_OD);
|
IOConfigGPIO(IOGetByTag(IO_TAG(UART3_TX_PIN)), IOCFG_AF_OD);
|
||||||
} else {
|
} else {
|
||||||
if (mode & MODE_TX) {
|
if (mode & MODE_TX) {
|
||||||
IOInit(IOGetByTag(IO_TAG(UART3_TX_PIN)), OWNER_SERIAL, RESOURCE_UART_TX, 3);
|
IOInit(IOGetByTag(IO_TAG(UART3_TX_PIN)), OWNER_SERIAL_TX, 3);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(UART3_TX_PIN)), IOCFG_AF_PP);
|
IOConfigGPIO(IOGetByTag(IO_TAG(UART3_TX_PIN)), IOCFG_AF_PP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & MODE_RX) {
|
if (mode & MODE_RX) {
|
||||||
IOInit(IOGetByTag(IO_TAG(UART3_RX_PIN)), OWNER_SERIAL, RESOURCE_UART_RX, 3);
|
IOInit(IOGetByTag(IO_TAG(UART3_RX_PIN)), OWNER_SERIAL_RX, 3);
|
||||||
IOConfigGPIO(IOGetByTag(IO_TAG(UART3_RX_PIN)), IOCFG_IPU);
|
IOConfigGPIO(IOGetByTag(IO_TAG(UART3_RX_PIN)), IOCFG_IPU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ void serialUARTInit(IO_t tx, IO_t rx, portMode_t mode, portOptions_t options, ui
|
||||||
(options & SERIAL_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP
|
(options & SERIAL_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP
|
||||||
);
|
);
|
||||||
|
|
||||||
IOInit(tx, OWNER_SERIAL, RESOURCE_UART_TXRX, index);
|
IOInit(tx, OWNER_SERIAL_TX, index);
|
||||||
IOConfigGPIOAF(tx, ioCfg, af);
|
IOConfigGPIOAF(tx, ioCfg, af);
|
||||||
|
|
||||||
if (!(options & SERIAL_INVERTED))
|
if (!(options & SERIAL_INVERTED))
|
||||||
|
@ -129,12 +129,12 @@ void serialUARTInit(IO_t tx, IO_t rx, portMode_t mode, portOptions_t options, ui
|
||||||
} else {
|
} else {
|
||||||
ioConfig_t ioCfg = IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, (options & SERIAL_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP);
|
ioConfig_t ioCfg = IO_CONFIG(GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_PP, (options & SERIAL_INVERTED) ? GPIO_PuPd_DOWN : GPIO_PuPd_UP);
|
||||||
if (mode & MODE_TX) {
|
if (mode & MODE_TX) {
|
||||||
IOInit(tx, OWNER_SERIAL, RESOURCE_UART_TX, index);
|
IOInit(tx, OWNER_SERIAL_TX, index);
|
||||||
IOConfigGPIOAF(tx, ioCfg, af);
|
IOConfigGPIOAF(tx, ioCfg, af);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & MODE_RX) {
|
if (mode & MODE_RX) {
|
||||||
IOInit(rx, OWNER_SERIAL, RESOURCE_UART_RX, index);
|
IOInit(rx, OWNER_SERIAL_RX, index);
|
||||||
IOConfigGPIOAF(rx, ioCfg, af);
|
IOConfigGPIOAF(rx, ioCfg, af);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,12 +315,12 @@ uartPort_t *serialUART(UARTDevice device, uint32_t baudRate, portMode_t mode, po
|
||||||
if (uart->rxDMAStream) {
|
if (uart->rxDMAStream) {
|
||||||
s->rxDMAChannel = uart->DMAChannel;
|
s->rxDMAChannel = uart->DMAChannel;
|
||||||
s->rxDMAStream = uart->rxDMAStream;
|
s->rxDMAStream = uart->rxDMAStream;
|
||||||
dmaInit(dmaGetIdentifier(uart->rxDMAStream), OWNER_SERIAL, RESOURCE_INDEX(device));
|
dmaInit(dmaGetIdentifier(uart->rxDMAStream), OWNER_SERIAL_RX, RESOURCE_INDEX(device));
|
||||||
}
|
}
|
||||||
if (uart->txDMAStream) {
|
if (uart->txDMAStream) {
|
||||||
s->txDMAChannel = uart->DMAChannel;
|
s->txDMAChannel = uart->DMAChannel;
|
||||||
s->txDMAStream = uart->txDMAStream;
|
s->txDMAStream = uart->txDMAStream;
|
||||||
dmaInit(dmaGetIdentifier(uart->txDMAStream), OWNER_SERIAL, RESOURCE_INDEX(device));
|
dmaInit(dmaGetIdentifier(uart->txDMAStream), OWNER_SERIAL_TX, RESOURCE_INDEX(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
s->txDMAPeripheralBaseAddr = (uint32_t)&s->USARTx->DR;
|
s->txDMAPeripheralBaseAddr = (uint32_t)&s->USARTx->DR;
|
||||||
|
@ -339,17 +339,17 @@ uartPort_t *serialUART(UARTDevice device, uint32_t baudRate, portMode_t mode, po
|
||||||
RCC_AHB1PeriphClockCmd(uart->rcc_ahb1, ENABLE);
|
RCC_AHB1PeriphClockCmd(uart->rcc_ahb1, ENABLE);
|
||||||
|
|
||||||
if (options & SERIAL_BIDIR) {
|
if (options & SERIAL_BIDIR) {
|
||||||
IOInit(tx, OWNER_SERIAL, RESOURCE_UART_TXRX, RESOURCE_INDEX(device));
|
IOInit(tx, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(tx, IOCFG_AF_OD, uart->af);
|
IOConfigGPIOAF(tx, IOCFG_AF_OD, uart->af);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (mode & MODE_TX) {
|
if (mode & MODE_TX) {
|
||||||
IOInit(tx, OWNER_SERIAL, RESOURCE_UART_TX, RESOURCE_INDEX(device));
|
IOInit(tx, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(tx, IOCFG_AF_PP, uart->af);
|
IOConfigGPIOAF(tx, IOCFG_AF_PP, uart->af);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & MODE_RX) {
|
if (mode & MODE_RX) {
|
||||||
IOInit(rx, OWNER_SERIAL, RESOURCE_UART_RX, RESOURCE_INDEX(device));
|
IOInit(rx, OWNER_SERIAL_RX, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(rx, IOCFG_AF_PP, uart->af);
|
IOConfigGPIOAF(rx, IOCFG_AF_PP, uart->af);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,22 +406,23 @@ uartPort_t *serialUART(UARTDevice device, uint32_t baudRate, portMode_t mode, po
|
||||||
IO_t rx = IOGetByTag(uart->rx);
|
IO_t rx = IOGetByTag(uart->rx);
|
||||||
|
|
||||||
if (options & SERIAL_BIDIR) {
|
if (options & SERIAL_BIDIR) {
|
||||||
IOInit(tx, OWNER_SERIAL, RESOURCE_UART_TXRX, RESOURCE_INDEX(device));
|
IOInit(tx, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(tx, IOCFG_AF_PP, uart->af);
|
IOConfigGPIOAF(tx, IOCFG_AF_PP, uart->af);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (mode & MODE_TX) {
|
if (mode & MODE_TX) {
|
||||||
IOInit(tx, OWNER_SERIAL, RESOURCE_UART_TX, RESOURCE_INDEX(device));
|
IOInit(tx, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(tx, IOCFG_AF_PP, uart->af);
|
IOConfigGPIOAF(tx, IOCFG_AF_PP, uart->af);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & MODE_RX) {
|
if (mode & MODE_RX) {
|
||||||
IOInit(rx, OWNER_SERIAL, RESOURCE_UART_RX, RESOURCE_INDEX(device));
|
IOInit(rx, OWNER_SERIAL_RX, RESOURCE_INDEX(device));
|
||||||
IOConfigGPIOAF(rx, IOCFG_AF_PP, uart->af);
|
IOConfigGPIOAF(rx, IOCFG_AF_PP, uart->af);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DMA TX Interrupt
|
// DMA TX Interrupt
|
||||||
|
dmaInit(uart->txIrq, OWNER_SERIAL_TX, (uint32_t)uart);
|
||||||
dmaSetHandler(uart->txIrq, dmaIRQHandler, uart->txPriority, (uint32_t)uart);
|
dmaSetHandler(uart->txIrq, dmaIRQHandler, uart->txPriority, (uint32_t)uart);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,8 @@ serialPort_t *usbVcpOpen(void)
|
||||||
vcpPort_t *s;
|
vcpPort_t *s;
|
||||||
|
|
||||||
#ifdef STM32F4
|
#ifdef STM32F4
|
||||||
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, RESOURCE_INPUT, 0);
|
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
||||||
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, RESOURCE_OUTPUT, 0);
|
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
||||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
|
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
|
||||||
#else
|
#else
|
||||||
Set_System();
|
Set_System();
|
||||||
|
|
|
@ -83,12 +83,12 @@ void hcsr04_init(const sonarConfig_t *sonarConfig, sonarRange_t *sonarRange)
|
||||||
|
|
||||||
// trigger pin
|
// trigger pin
|
||||||
triggerIO = IOGetByTag(sonarConfig->triggerTag);
|
triggerIO = IOGetByTag(sonarConfig->triggerTag);
|
||||||
IOInit(triggerIO, OWNER_SONAR_TRIGGER, RESOURCE_OUTPUT, 0);
|
IOInit(triggerIO, OWNER_SONAR_TRIGGER, 0);
|
||||||
IOConfigGPIO(triggerIO, IOCFG_OUT_PP);
|
IOConfigGPIO(triggerIO, IOCFG_OUT_PP);
|
||||||
|
|
||||||
// echo pin
|
// echo pin
|
||||||
echoIO = IOGetByTag(sonarConfig->echoTag);
|
echoIO = IOGetByTag(sonarConfig->echoTag);
|
||||||
IOInit(echoIO, OWNER_SONAR_ECHO, RESOURCE_INPUT, 0);
|
IOInit(echoIO, OWNER_SONAR_ECHO, 0);
|
||||||
IOConfigGPIO(echoIO, IOCFG_IN_FLOATING);
|
IOConfigGPIO(echoIO, IOCFG_IN_FLOATING);
|
||||||
|
|
||||||
#ifdef USE_EXTI
|
#ifdef USE_EXTI
|
||||||
|
|
|
@ -58,7 +58,7 @@ void beeperInit(const beeperConfig_t *config)
|
||||||
beeperInverted = config->isInverted;
|
beeperInverted = config->isInverted;
|
||||||
|
|
||||||
if (beeperIO) {
|
if (beeperIO) {
|
||||||
IOInit(beeperIO, OWNER_BEEPER, RESOURCE_OUTPUT, 0);
|
IOInit(beeperIO, OWNER_BEEPER, 0);
|
||||||
IOConfigGPIO(beeperIO, config->isOD ? IOCFG_OUT_OD : IOCFG_OUT_PP);
|
IOConfigGPIO(beeperIO, config->isOD ? IOCFG_OUT_OD : IOCFG_OUT_PP);
|
||||||
}
|
}
|
||||||
systemBeep(false);
|
systemBeep(false);
|
||||||
|
|
|
@ -414,7 +414,7 @@ void timerChClearCCFlag(const timerHardware_t *timHw)
|
||||||
// configure timer channel GPIO mode
|
// configure timer channel GPIO mode
|
||||||
void timerChConfigGPIO(const timerHardware_t* timHw, ioConfig_t mode)
|
void timerChConfigGPIO(const timerHardware_t* timHw, ioConfig_t mode)
|
||||||
{
|
{
|
||||||
IOInit(IOGetByTag(timHw->tag), OWNER_TIMER, RESOURCE_TIMER, 0);
|
IOInit(IOGetByTag(timHw->tag), OWNER_TIMER, 0);
|
||||||
IOConfigGPIO(IOGetByTag(timHw->tag), mode);
|
IOConfigGPIO(IOGetByTag(timHw->tag), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ void timerChClearCCFlag(const timerHardware_t *timHw)
|
||||||
// configure timer channel GPIO mode
|
// configure timer channel GPIO mode
|
||||||
void timerChConfigGPIO(const timerHardware_t* timHw, ioConfig_t mode)
|
void timerChConfigGPIO(const timerHardware_t* timHw, ioConfig_t mode)
|
||||||
{
|
{
|
||||||
IOInit(IOGetByTag(timHw->tag), OWNER_TIMER, RESOURCE_TIMER, 0);
|
IOInit(IOGetByTag(timHw->tag), OWNER_TIMER, 0);
|
||||||
IOConfigGPIO(IOGetByTag(timHw->tag), mode);
|
IOConfigGPIO(IOGetByTag(timHw->tag), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ static IO_t usbDetectPin = IO_NONE;
|
||||||
void usbCableDetectDeinit(void)
|
void usbCableDetectDeinit(void)
|
||||||
{
|
{
|
||||||
#ifdef USB_DETECT_PIN
|
#ifdef USB_DETECT_PIN
|
||||||
IOInit(usbDetectPin, OWNER_FREE, RESOURCE_NONE);
|
IOInit(usbDetectPin, OWNER_FREE, 0);
|
||||||
IOConfigGPIO(usbDetectPin, IOCFG_IN_FLOATING);
|
IOConfigGPIO(usbDetectPin, IOCFG_IN_FLOATING);
|
||||||
usbDetectPin = IO_NONE;
|
usbDetectPin = IO_NONE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,7 +38,7 @@ void usbCableDetectInit(void)
|
||||||
#ifdef USB_DETECT_PIN
|
#ifdef USB_DETECT_PIN
|
||||||
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
||||||
|
|
||||||
IOInit(usbDetectPin, OWNER_USB, RESOURCE_INPUT);
|
IOInit(usbDetectPin, OWNER_USB_DETECT, 0);
|
||||||
IOConfigGPIO(usbDetectPin, IOCFG_OUT_PP);
|
IOConfigGPIO(usbDetectPin, IOCFG_OUT_PP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ static IO_t usbDetectPin = IO_NONE;
|
||||||
void usbCableDetectDeinit(void)
|
void usbCableDetectDeinit(void)
|
||||||
{
|
{
|
||||||
#ifdef USB_DETECT_PIN
|
#ifdef USB_DETECT_PIN
|
||||||
IOInit(usbDetectPin, OWNER_FREE, RESOURCE_NONE, 0);
|
IOInit(usbDetectPin, OWNER_FREE, 0);
|
||||||
IOConfigGPIO(usbDetectPin, IOCFG_IN_FLOATING);
|
IOConfigGPIO(usbDetectPin, IOCFG_IN_FLOATING);
|
||||||
usbDetectPin = IO_NONE;
|
usbDetectPin = IO_NONE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,7 +47,7 @@ void usbCableDetectInit(void)
|
||||||
#ifdef USB_DETECT_PIN
|
#ifdef USB_DETECT_PIN
|
||||||
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
||||||
|
|
||||||
IOInit(usbDetectPin, OWNER_USB, RESOURCE_INPUT, 0);
|
IOInit(usbDetectPin, OWNER_USB_DETECT, 0);
|
||||||
IOConfigGPIO(usbDetectPin, IOCFG_OUT_PP);
|
IOConfigGPIO(usbDetectPin, IOCFG_OUT_PP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,13 +59,13 @@ void rtc6705_soft_spi_init(void)
|
||||||
rtc6705LePin = IOGetByTag(IO_TAG(RTC6705_SPILE_PIN));
|
rtc6705LePin = IOGetByTag(IO_TAG(RTC6705_SPILE_PIN));
|
||||||
rtc6705ClkPin = IOGetByTag(IO_TAG(RTC6705_SPICLK_PIN));
|
rtc6705ClkPin = IOGetByTag(IO_TAG(RTC6705_SPICLK_PIN));
|
||||||
|
|
||||||
IOInit(rtc6705DataPin, OWNER_TX, RESOURCE_SPI_MOSI, 0);
|
IOInit(rtc6705DataPin, OWNER_SPI_MOSI, RESOURCE_SOFT_OFFSET);
|
||||||
IOConfigGPIO(rtc6705DataPin, IOCFG_OUT_PP);
|
IOConfigGPIO(rtc6705DataPin, IOCFG_OUT_PP);
|
||||||
|
|
||||||
IOInit(rtc6705LePin, OWNER_TX, RESOURCE_SPI_CS, 0);
|
IOInit(rtc6705LePin, OWNER_SPI_CS, RESOURCE_SOFT_OFFSET);
|
||||||
IOConfigGPIO(rtc6705LePin, IOCFG_OUT_PP);
|
IOConfigGPIO(rtc6705LePin, IOCFG_OUT_PP);
|
||||||
|
|
||||||
IOInit(rtc6705ClkPin, OWNER_TX, RESOURCE_SPI_SCK, 0);
|
IOInit(rtc6705ClkPin, OWNER_SPI_SCK, RESOURCE_SOFT_OFFSET);
|
||||||
IOConfigGPIO(rtc6705ClkPin, IOCFG_OUT_PP);
|
IOConfigGPIO(rtc6705ClkPin, IOCFG_OUT_PP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3842,13 +3842,10 @@ static void cliResource(char *cmdline)
|
||||||
const char* owner;
|
const char* owner;
|
||||||
owner = ownerNames[ioRecs[i].owner];
|
owner = ownerNames[ioRecs[i].owner];
|
||||||
|
|
||||||
const char* resource;
|
|
||||||
resource = resourceNames[ioRecs[i].resource];
|
|
||||||
|
|
||||||
if (ioRecs[i].index > 0) {
|
if (ioRecs[i].index > 0) {
|
||||||
cliPrintf("%c%02d: %s%d %s\r\n", IO_GPIOPortIdx(ioRecs + i) + 'A', IO_GPIOPinIdx(ioRecs + i), owner, ioRecs[i].index, resource);
|
cliPrintf("%c%02d: %s %d\r\n", IO_GPIOPortIdx(ioRecs + i) + 'A', IO_GPIOPinIdx(ioRecs + i), owner, ioRecs[i].index);
|
||||||
} else {
|
} else {
|
||||||
cliPrintf("%c%02d: %s %s\r\n", IO_GPIOPortIdx(ioRecs + i) + 'A', IO_GPIOPinIdx(ioRecs + i), owner, resource);
|
cliPrintf("%c%02d: %s \r\n", IO_GPIOPortIdx(ioRecs + i) + 'A', IO_GPIOPinIdx(ioRecs + i), owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3860,7 +3857,7 @@ static void cliResource(char *cmdline)
|
||||||
cliPrintf(DMA_OUTPUT_STRING, i / DMA_MOD_VALUE + 1, (i % DMA_MOD_VALUE) + DMA_MOD_OFFSET);
|
cliPrintf(DMA_OUTPUT_STRING, i / DMA_MOD_VALUE + 1, (i % DMA_MOD_VALUE) + DMA_MOD_OFFSET);
|
||||||
uint8_t resourceIndex = dmaGetResourceIndex(i);
|
uint8_t resourceIndex = dmaGetResourceIndex(i);
|
||||||
if (resourceIndex > 0) {
|
if (resourceIndex > 0) {
|
||||||
cliPrintf(" %s%d\r\n", owner, resourceIndex);
|
cliPrintf(" %s %d\r\n", owner, resourceIndex);
|
||||||
} else {
|
} else {
|
||||||
cliPrintf(" %s\r\n", owner);
|
cliPrintf(" %s\r\n", owner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ bool spekShouldBind(uint8_t spektrum_sat_bind)
|
||||||
{
|
{
|
||||||
#ifdef HARDWARE_BIND_PLUG
|
#ifdef HARDWARE_BIND_PLUG
|
||||||
BindPlug = IOGetByTag(IO_TAG(BINDPLUG_PIN));
|
BindPlug = IOGetByTag(IO_TAG(BINDPLUG_PIN));
|
||||||
IOInit(BindPlug, OWNER_RX, RESOURCE_INPUT, 0);
|
IOInit(BindPlug, OWNER_RX_BIND, 0);
|
||||||
IOConfigGPIO(BindPlug, IOCFG_IPU);
|
IOConfigGPIO(BindPlug, IOCFG_IPU);
|
||||||
|
|
||||||
// Check status of bind plug and exit if not active
|
// Check status of bind plug and exit if not active
|
||||||
|
@ -203,7 +203,7 @@ void spektrumBind(rxConfig_t *rxConfig)
|
||||||
LED1_ON;
|
LED1_ON;
|
||||||
|
|
||||||
BindPin = IOGetByTag(IO_TAG(BIND_PIN));
|
BindPin = IOGetByTag(IO_TAG(BIND_PIN));
|
||||||
IOInit(BindPin, OWNER_RX, RESOURCE_OUTPUT, 0);
|
IOInit(BindPin, OWNER_RX_BIND, 0);
|
||||||
IOConfigGPIO(BindPin, IOCFG_OUT_PP);
|
IOConfigGPIO(BindPin, IOCFG_OUT_PP);
|
||||||
|
|
||||||
// RX line, set high
|
// RX line, set high
|
||||||
|
|
|
@ -41,7 +41,7 @@ static IO_t HWDetectPin = IO_NONE;
|
||||||
void detectHardwareRevision(void)
|
void detectHardwareRevision(void)
|
||||||
{
|
{
|
||||||
HWDetectPin = IOGetByTag(IO_TAG(HW_PIN));
|
HWDetectPin = IOGetByTag(IO_TAG(HW_PIN));
|
||||||
IOInit(HWDetectPin, OWNER_SYSTEM, RESOURCE_INPUT, 0);
|
IOInit(HWDetectPin, OWNER_SYSTEM, 0);
|
||||||
IOConfigGPIO(HWDetectPin, IOCFG_IPU);
|
IOConfigGPIO(HWDetectPin, IOCFG_IPU);
|
||||||
|
|
||||||
// Check hardware revision
|
// Check hardware revision
|
||||||
|
|
|
@ -42,11 +42,11 @@ uint8_t hardwareRevision = UNKNOWN;
|
||||||
void detectHardwareRevision(void)
|
void detectHardwareRevision(void)
|
||||||
{
|
{
|
||||||
IO_t pin1 = IOGetByTag(IO_TAG(PB12));
|
IO_t pin1 = IOGetByTag(IO_TAG(PB12));
|
||||||
IOInit(pin1, OWNER_SYSTEM, RESOURCE_INPUT, 1);
|
IOInit(pin1, OWNER_SYSTEM, 1);
|
||||||
IOConfigGPIO(pin1, IOCFG_IPU);
|
IOConfigGPIO(pin1, IOCFG_IPU);
|
||||||
|
|
||||||
IO_t pin2 = IOGetByTag(IO_TAG(PB13));
|
IO_t pin2 = IOGetByTag(IO_TAG(PB13));
|
||||||
IOInit(pin2, OWNER_SYSTEM, RESOURCE_INPUT, 2);
|
IOInit(pin2, OWNER_SYSTEM, 2);
|
||||||
IOConfigGPIO(pin2, IOCFG_IPU);
|
IOConfigGPIO(pin2, IOCFG_IPU);
|
||||||
|
|
||||||
// Check hardware revision
|
// Check hardware revision
|
||||||
|
@ -76,7 +76,7 @@ void detectHardwareRevision(void)
|
||||||
HI or LO in configuration.
|
HI or LO in configuration.
|
||||||
*/
|
*/
|
||||||
IO_t uart1invert = IOGetByTag(IO_TAG(PC9));
|
IO_t uart1invert = IOGetByTag(IO_TAG(PC9));
|
||||||
IOInit(uart1invert, OWNER_INVERTER, RESOURCE_OUTPUT, 2);
|
IOInit(uart1invert, OWNER_INVERTER, 2);
|
||||||
IOConfigGPIO(uart1invert, IOCFG_AF_PP);
|
IOConfigGPIO(uart1invert, IOCFG_AF_PP);
|
||||||
IOLo(uart1invert);
|
IOLo(uart1invert);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ void updateHardwareRevision(void)
|
||||||
if (m25p16_init(IO_TAG(PB3))) {
|
if (m25p16_init(IO_TAG(PB3))) {
|
||||||
hardwareRevision = BJF4_REV1;
|
hardwareRevision = BJF4_REV1;
|
||||||
} else {
|
} else {
|
||||||
IOInit(IOGetByTag(IO_TAG(PB3)), OWNER_FREE, RESOURCE_NONE, 0);
|
IOInit(IOGetByTag(IO_TAG(PB3)), OWNER_FREE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue