串口ok
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* drv_i2c.h
|
||||
*
|
||||
* Created on: Mar 31, 2023
|
||||
* Author: gxms0
|
||||
*/
|
||||
|
||||
#ifndef BSP_DRV_I2C_H_
|
||||
#define BSP_DRV_I2C_H_
|
||||
|
||||
#include "i2c.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
typedef enum {
|
||||
i2c_Address_8bit = 0,
|
||||
i2c_Address_16bit = 1
|
||||
}i2c_addr_enum;
|
||||
|
||||
|
||||
typedef enum {
|
||||
i2c_trams_mode_poll = 0,
|
||||
i2c_trams_mode_dma = 1,
|
||||
i2c_trams_mode_it = 2
|
||||
}i2c_trams_mode_enum;
|
||||
|
||||
|
||||
typedef struct sI2C
|
||||
{
|
||||
I2C_HandleTypeDef *hi2c;
|
||||
|
||||
char *name;
|
||||
uint16_t channel;
|
||||
uint16_t address;
|
||||
uint8_t addr_len;
|
||||
|
||||
uint8_t mode;
|
||||
|
||||
struct sI2C *next_ptr;
|
||||
|
||||
}I2C_t;
|
||||
|
||||
typedef I2C_t* I2C_ptr;
|
||||
|
||||
void i2c_init();
|
||||
|
||||
void i2c_config(I2C_ptr ptr,char *name, I2C_HandleTypeDef *hi2c, uint8_t addr_len);
|
||||
|
||||
uint16_t i2c_read(I2C_ptr ptr, uint16_t address, uint16_t reg,uint8_t *data, uint16_t len);
|
||||
|
||||
uint16_t i2c_write(I2C_ptr ptr, uint16_t address, uint16_t reg,uint8_t *data, uint16_t len);
|
||||
|
||||
|
||||
#endif /* BSP_DRV_I2C_H_ */
|
||||
Reference in New Issue
Block a user