mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
PICO: Preparing for I2C device using I2C0 (#14422)
This commit is contained in:
parent
8853356e71
commit
31887f84b1
8 changed files with 48 additions and 20 deletions
|
@ -31,20 +31,18 @@
|
|||
|
||||
typedef enum I2CDevice {
|
||||
I2CINVALID = -1,
|
||||
I2CDEV_1 = 0,
|
||||
I2CDEV_FIRST = 0,
|
||||
#if defined(USE_I2C_DEVICE_0)
|
||||
I2CDEV_0 = I2CDEV_FIRST,
|
||||
I2CDEV_1,
|
||||
#else
|
||||
I2CDEV_1 = I2CDEV_FIRST,
|
||||
#endif
|
||||
I2CDEV_2,
|
||||
I2CDEV_3,
|
||||
I2CDEV_4,
|
||||
} I2CDevice;
|
||||
|
||||
#if defined(STM32F4) || defined(APM32F4)
|
||||
#define I2CDEV_COUNT 3
|
||||
#elif defined(STM32F7)
|
||||
#define I2CDEV_COUNT 4
|
||||
#else
|
||||
#define I2CDEV_COUNT 4
|
||||
#endif
|
||||
|
||||
// Macros to convert between CLI bus number and I2CDevice.
|
||||
#define I2C_CFG_TO_DEV(x) ((x) - 1)
|
||||
#define I2C_DEV_TO_CFG(x) ((x) + 1)
|
||||
|
|
|
@ -32,12 +32,12 @@
|
|||
|
||||
typedef struct i2cPinDef_s {
|
||||
ioTag_t ioTag;
|
||||
#if defined(STM32F4) || defined(STM32H7) || defined(STM32G4) || defined(AT32F4) || defined(APM32F4)
|
||||
#if I2C_TRAIT_AF_PIN
|
||||
uint8_t af;
|
||||
#endif
|
||||
} i2cPinDef_t;
|
||||
|
||||
#if defined(STM32F4) || defined(STM32H7) || defined(STM32G4) || defined(AT32F4) || defined(APM32F4)
|
||||
#if I2C_TRAIT_AF_PIN
|
||||
#define I2CPINDEF(pin, af) { DEFIO_TAG_E(pin), af }
|
||||
#else
|
||||
#define I2CPINDEF(pin) { DEFIO_TAG_E(pin) }
|
||||
|
@ -48,14 +48,16 @@ typedef struct i2cHardware_s {
|
|||
I2C_TypeDef *reg;
|
||||
i2cPinDef_t sclPins[I2C_PIN_SEL_MAX];
|
||||
i2cPinDef_t sdaPins[I2C_PIN_SEL_MAX];
|
||||
#if PLATFORM_TRAIT_RCC
|
||||
rccPeriphTag_t rcc;
|
||||
#endif
|
||||
uint8_t ev_irq;
|
||||
uint8_t er_irq;
|
||||
} i2cHardware_t;
|
||||
|
||||
extern const i2cHardware_t i2cHardware[];
|
||||
|
||||
#if defined(STM32F4)
|
||||
#if I2C_TRAIT_STATE
|
||||
typedef struct i2cState_s {
|
||||
volatile bool error;
|
||||
volatile bool busy;
|
||||
|
@ -74,7 +76,7 @@ typedef struct i2cDevice_s {
|
|||
I2C_TypeDef *reg;
|
||||
IO_t scl;
|
||||
IO_t sda;
|
||||
#if defined(STM32F4) || defined(STM32H7) || defined(STM32G4) || defined(AT32F4) || defined(APM32F4)
|
||||
#if I2C_TRAIT_AF_PIN
|
||||
uint8_t sclAF;
|
||||
uint8_t sdaAF;
|
||||
#endif
|
||||
|
@ -82,10 +84,10 @@ typedef struct i2cDevice_s {
|
|||
uint16_t clockSpeed;
|
||||
|
||||
// MCU/Driver dependent member follows
|
||||
#if defined(STM32F4)
|
||||
#if I2C_TRAIT_STATE
|
||||
i2cState_t state;
|
||||
#endif
|
||||
#if defined(USE_HAL_DRIVER) || defined(AT32F4)
|
||||
#if I2C_TRAIT_HANDLE
|
||||
I2C_HandleTypeDef handle;
|
||||
#endif
|
||||
} i2cDevice_t;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "target/common_pre.h"
|
||||
|
||||
// MCU specific platform from platform/X
|
||||
#include "platform_mcu.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#include "target.h"
|
||||
#include "target/common_post.h"
|
||||
|
|
|
@ -193,6 +193,9 @@
|
|||
#define PLATFORM_TRAIT_RCC 1
|
||||
#define UART_TRAIT_AF_PORT 1
|
||||
#define SERIAL_TRAIT_PIN_CONFIG 1
|
||||
#define I2C_TRAIT_AF_PIN 1
|
||||
#define I2CDEV_COUNT 3
|
||||
#define I2C_TRAIT_HANDLE 1
|
||||
|
||||
#define UARTHARDWARE_MAX_PINS 4
|
||||
|
|
@ -144,12 +144,15 @@ typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
|
|||
#define UART_TX_BUFFER_ATTRIBUTE // NONE
|
||||
#define UART_RX_BUFFER_ATTRIBUTE // NONE
|
||||
|
||||
#define PLATFORM_TRAIT_RCC 1
|
||||
#define UART_TRAIT_AF_PIN 1
|
||||
#define UART_TRAIT_PINSWAP 1
|
||||
#define PLATFORM_TRAIT_RCC 1
|
||||
#define UART_TRAIT_AF_PIN 1
|
||||
#define UART_TRAIT_PINSWAP 1
|
||||
#define SERIAL_TRAIT_PIN_CONFIG 1
|
||||
#define I2C_TRAIT_AF_PIN 1
|
||||
#define I2CDEV_COUNT 4
|
||||
#define I2C_TRAIT_HANDLE 1
|
||||
|
||||
#define UARTHARDWARE_MAX_PINS 5
|
||||
#define UARTHARDWARE_MAX_PINS 5
|
||||
|
||||
#define UART_REG_RXD(base) ((base)->dt)
|
||||
#define UART_REG_TXD(base) ((base)->dt)
|
|
@ -33,3 +33,5 @@
|
|||
|
||||
// no serial pins are defined for the simulator
|
||||
#define SERIAL_TRAIT_PIN_CONFIG 0
|
||||
|
||||
#define I2CDEV_COUNT 0
|
|
@ -419,3 +419,21 @@ extern uint8_t _dmaram_end__;
|
|||
|
||||
#define SERIAL_TRAIT_PIN_CONFIG 1
|
||||
#define USB_DP_PIN PA12
|
||||
|
||||
#if defined(STM32F4)
|
||||
#define I2C_TRAIT_STATE 1
|
||||
#endif
|
||||
|
||||
#if defined(STM32F4) || defined(STM32H7) || defined(STM32G4)
|
||||
#define I2C_TRAIT_AF_PIN 1
|
||||
#endif
|
||||
|
||||
#if defined(USE_HAL_DRIVER)
|
||||
#define I2C_TRAIT_HANDLE 1
|
||||
#endif
|
||||
|
||||
#if defined(STM32F4)
|
||||
#define I2CDEV_COUNT 3
|
||||
#else
|
||||
#define I2CDEV_COUNT 4
|
||||
#endif
|
|
@ -124,6 +124,8 @@ typedef struct
|
|||
} ADC_TypeDef;
|
||||
|
||||
#define SPIDEV_COUNT 0
|
||||
#define I2CDEV_COUNT 0
|
||||
|
||||
#define WS2811_DMA_TC_FLAG (void *)1
|
||||
#define WS2811_DMA_HANDLER_IDENTIFER 0
|
||||
#define NVIC_PriorityGroup_2 0x500
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue