iic驱动重写

This commit is contained in:
2024-12-04 18:43:16 +08:00
parent 828721759d
commit 7a3e93f5d8
6 changed files with 131 additions and 10 deletions

View File

@@ -21,7 +21,7 @@
#define LED_IRQ TIMER16_IRQn
#define I2C_SPEED 100000
#define IR_I2C I2C0
#define RCU_IR_GPIO RCU_GPIOF
#define RCU_I2C RCU_I2C0
#define I2C_SCL_PORT GPIOF
@@ -30,13 +30,19 @@
#define I2C_SDA_PIN GPIO_PIN_0
#define I2C_GPIO_AF GPIO_AF_1
#define I2C_TIME_OUT (uint16_t)(5000)
#define SLAVE_ADDR (0x5A << 1)
#define LDC1612_ADDR (0x2A << 1)
// LDC1612 寄存器地址
#define RCOUNT0_ADDR 0x08
#define SETTLECOUNT0_ADDR 0x10
#define CLOCK_DIVIDERS0_ADDR 0x14
#define ERROR_CONFIG_ADDR 0x19
#define MUX_CONFIG_ADDR 0x1B
#define DRIVE_CURRENT0_ADDR 0x1E
#define CONFIG_ADDR 0x1A
void led_config(void);
void LDC1612_I2CConfig(void);
void LDC1612_Init(void);
#endif //LDC1612_H

15
inc/i2c.h Normal file
View File

@@ -0,0 +1,15 @@
//
// Created by dell on 24-12-4.
//
#ifndef I2C_H
#define I2C_H
#include "gd32e23x_i2c.h"
#include "LDC1612.h"
#define I2C_TIME_OUT (uint16_t)(5000)
#define LDC_I2C I2C0
int i2c_write_reg(uint8_t device_address, uint8_t *data);
#endif //I2C_H