mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 17:55:30 +03:00
Platform-dependent IO_GPIO.. functions, IO tags allow single port, more pins. (#14407)
This commit is contained in:
parent
f217ba6d19
commit
e74b362341
3 changed files with 50 additions and 40 deletions
|
@ -26,10 +26,7 @@
|
|||
|
||||
#include "common/utils.h"
|
||||
|
||||
// io ports defs are stored in array by index now
|
||||
struct ioPortDef_s {
|
||||
rccPeriphTag_t rcc;
|
||||
};
|
||||
// io ports defs are stored by index in array ioRecs of ioRec_t
|
||||
|
||||
ioRec_t* IO_Rec(IO_t io)
|
||||
{
|
||||
|
@ -48,39 +45,6 @@ uint16_t IO_Pin(IO_t io)
|
|||
return ioRec->pin;
|
||||
}
|
||||
|
||||
#if defined(STM32F4) || defined(APM32F4)
|
||||
int IO_EXTI_PortSourceGPIO(IO_t io)
|
||||
{
|
||||
return IO_GPIOPortIdx(io);
|
||||
}
|
||||
#endif
|
||||
|
||||
int IO_GPIO_PortSource(IO_t io)
|
||||
{
|
||||
return IO_GPIOPortIdx(io);
|
||||
}
|
||||
|
||||
// zero based pin index
|
||||
int IO_GPIOPinIdx(IO_t io)
|
||||
{
|
||||
if (!io) {
|
||||
return -1;
|
||||
}
|
||||
return 31 - __builtin_clz(IO_Pin(io));
|
||||
}
|
||||
|
||||
#if defined(STM32F4) || defined(APM32F4)
|
||||
int IO_EXTI_PinSource(IO_t io)
|
||||
{
|
||||
return IO_GPIOPinIdx(io);
|
||||
}
|
||||
#endif
|
||||
|
||||
int IO_GPIO_PinSource(IO_t io)
|
||||
{
|
||||
return IO_GPIOPinIdx(io);
|
||||
}
|
||||
|
||||
// claim IO pin, set owner and resources
|
||||
void IOInit(IO_t io, resourceOwner_e owner, uint8_t index)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue