generated from hulk/gd32e23x_template
	添加board_config.h作为全部板上IO的宏定义位置,独立soft_i2c为单独文件
This commit is contained in:
		
							
								
								
									
										21
									
								
								inc/board_config.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								inc/board_config.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| // | ||||
| // Created by dell on 24-12-28. | ||||
| // | ||||
|  | ||||
| #ifndef BOARD_CONFIG_H | ||||
| #define BOARD_CONFIG_H | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| #define I2C_SPEED       20000 | ||||
| #define RCU_GPIO_I2C    RCU_GPIOF | ||||
| #define RCU_I2C         RCU_I2C0 | ||||
| #define I2C_SCL_PORT    GPIOF | ||||
| #define I2C_SCL_PIN     GPIO_PIN_1 | ||||
| #define I2C_SDA_PORT    GPIOF | ||||
| #define I2C_SDA_PIN     GPIO_PIN_0 | ||||
| #define I2C_GPIO_AF     GPIO_AF_1 | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| #endif //BOARD_CONFIG_H | ||||
							
								
								
									
										29
									
								
								inc/i2c.h
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								inc/i2c.h
									
									
									
									
									
								
							| @@ -15,16 +15,7 @@ | ||||
| #include <stdlib.h> | ||||
| #include <math.h> | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| #define I2C_SPEED       20000 | ||||
| #define RCU_GPIO_I2C    RCU_GPIOF | ||||
| #define RCU_I2C         RCU_I2C0 | ||||
| #define I2C_SCL_PORT    GPIOF | ||||
| #define I2C_SCL_PIN     GPIO_PIN_1 | ||||
| #define I2C_SDA_PORT    GPIOF | ||||
| #define I2C_SDA_PIN     GPIO_PIN_0 | ||||
| #define I2C_GPIO_AF     GPIO_AF_1 | ||||
| #include "board_config.h" | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| @@ -55,24 +46,6 @@ typedef enum { | ||||
|  | ||||
| void i2c_gpio_config(void); | ||||
|  | ||||
| void si2c_config(void); | ||||
|  | ||||
| void i2c_delay(void); | ||||
|  | ||||
| void i2c_start(void); | ||||
|  | ||||
| void i2c_stop(void); | ||||
|  | ||||
| void i2c_send_ack(void); | ||||
|  | ||||
| void i2c_send_nack(void); | ||||
|  | ||||
| uint8_t i2c_wait_ack(void); | ||||
|  | ||||
| void i2c_send_byte(uint8_t byte); | ||||
|  | ||||
| uint8_t i2c_receive_byte(uint8_t ack); | ||||
|  | ||||
| void i2c_config(void); | ||||
|  | ||||
| void i2c_bus_reset(void); | ||||
|   | ||||
							
								
								
									
										37
									
								
								inc/soft_i2c.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								inc/soft_i2c.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| // | ||||
| // Created by dell on 24-12-28. | ||||
| // | ||||
|  | ||||
| #ifndef SOFT_I2C_H | ||||
| #define SOFT_I2C_H | ||||
|  | ||||
| #include "gd32e23x_it.h" | ||||
| #include "gd32e23x.h" | ||||
| #include "systick.h" | ||||
| #include "main.h" | ||||
|  | ||||
| #include "board_config.h" | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| #define I2C_SCL_HIGH()      gpio_bit_set(I2C_SCL_PORT, I2C_SCL_PIN) | ||||
| #define I2C_SCL_LOW()       gpio_bit_reset(I2C_SCL_PORT, I2C_SCL_PIN) | ||||
| #define I2C_SDA_HIGH()      gpio_bit_set(I2C_SDA_PORT, I2C_SDA_PIN) | ||||
| #define I2C_SDA_LOW()       gpio_bit_reset(I2C_SDA_PORT, I2C_SDA_PIN) | ||||
| #define I2C_SDA_READ()      gpio_input_bit_get(I2C_SDA_PORT, I2C_SDA_PIN) | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| void i2c_delay(void); | ||||
|  | ||||
| void soft_i2c_config(void); | ||||
|  | ||||
| void soft_i2c_start(void); | ||||
| void soft_i2c_stop(void); | ||||
| void soft_i2c_send_ack(void); | ||||
| void soft_i2c_send_nack(void); | ||||
| uint8_t soft_i2c_wait_ack(void); | ||||
| void soft_i2c_send_byte(uint8_t data); | ||||
| uint8_t soft_i2c_receive_byte(uint8_t ack); | ||||
|  | ||||
| #endif //SOFT_I2C_H | ||||
		Reference in New Issue
	
	Block a user