generated from hulk/gd32e23x_template
Organize files
This commit is contained in:
51
inc/i2c.h
Normal file
51
inc/i2c.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Created by dell on 24-12-20.
|
||||
//
|
||||
|
||||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#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
|
||||
|
||||
#define I2C_TIME_OUT (uint16_t)(10000)
|
||||
#define I2C_OK 1
|
||||
#define I2C_FAIL 0
|
||||
#define I2C_END 1
|
||||
|
||||
typedef enum {
|
||||
I2C_START = 0,
|
||||
I2C_SEND_ADDRESS,
|
||||
I2C_CLEAR_ADDRESS_FLAG,
|
||||
I2C_TRANSMIT_DATA,
|
||||
I2C_STOP
|
||||
} i2c_process_enum;
|
||||
|
||||
void i2c_gpio_config(void);
|
||||
|
||||
void i2c_config(void);
|
||||
|
||||
void i2c_bus_reset(void);
|
||||
|
||||
void i2c_scan(void);
|
||||
|
||||
uint8_t i2c_write_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t data[2]);
|
||||
|
||||
uint8_t i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data);
|
||||
|
||||
#endif //I2C_H
|
@@ -13,9 +13,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#define LDC1612_ADDR (0x2B << 1)
|
||||
#define TMP112A_ADDR (0x49 << 1)
|
||||
|
||||
/*Register Rddr*/
|
||||
/***************************************************************************/
|
||||
@@ -51,40 +51,12 @@
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define COIL_RP_KOM 15.727
|
||||
#define COIL_L_UH 33
|
||||
#define COIL_C_PF 150
|
||||
#define COIL_Q_FACTOR 35.97
|
||||
#define COIL_RP_KOM 15.727
|
||||
#define COIL_L_UH 33
|
||||
#define COIL_C_PF 150
|
||||
#define COIL_Q_FACTOR 35.97
|
||||
|
||||
typedef enum {
|
||||
I2C_START = 0,
|
||||
I2C_SEND_ADDRESS,
|
||||
I2C_CLEAR_ADDRESS_FLAG,
|
||||
I2C_TRANSMIT_DATA,
|
||||
I2C_STOP
|
||||
} i2c_process_enum;
|
||||
|
||||
#define I2C_TIME_OUT (uint16_t)(10000)
|
||||
#define I2C_OK 1
|
||||
#define I2C_FAIL 0
|
||||
#define I2C_END 1
|
||||
|
||||
#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
|
||||
|
||||
void i2c_gpio_config(void);
|
||||
|
||||
void i2c_config(void);
|
||||
|
||||
void i2c_bus_reset(void);
|
||||
|
||||
void i2c_scan(void);
|
||||
/******************************************************************************/
|
||||
|
||||
void ldc1612_set_conversion_time(uint8_t channel, uint16_t result);
|
||||
|
||||
@@ -116,10 +88,4 @@ uint32_t ldc1612_get_raw_channel_result(uint8_t channel);
|
||||
|
||||
uint32_t ldc1612_parse_raw_result(uint32_t raw_result);
|
||||
|
||||
uint8_t ldc1612_iic_read_16bits(uint8_t reg_addr, uint8_t *data);
|
||||
|
||||
uint8_t ldc1612_iic_write_16bits(uint8_t reg_addr, uint8_t data[2]);
|
||||
|
||||
uint32_t TMP112A_ReadTemperature(void);
|
||||
|
||||
#endif //LDC1612_H
|
26
inc/led.h
Normal file
26
inc/led.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by dell on 24-12-20.
|
||||
//
|
||||
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#define LED_PORT GPIOA
|
||||
#define LED_PIN GPIO_PIN_7
|
||||
#define LED_RCU RCU_GPIOA
|
||||
#define LED_TIMER_RCU RCU_TIMER16
|
||||
#define LED_TIMER TIMER16
|
||||
#define LED_IRQ TIMER16_IRQn
|
||||
|
||||
void led_config(void);
|
||||
|
||||
#endif //LED_H
|
@@ -35,13 +35,4 @@ OF SUCH DAMAGE.
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#define LED_PORT GPIOA
|
||||
#define LED_PIN GPIO_PIN_7
|
||||
#define LED_RCU RCU_GPIOA
|
||||
#define LED_TIMER_RCU RCU_TIMER16
|
||||
#define LED_TIMER TIMER16
|
||||
#define LED_IRQ TIMER16_IRQn
|
||||
|
||||
void led_config(void);
|
||||
|
||||
#endif /* MAIN_H */
|
||||
|
@@ -1,11 +0,0 @@
|
||||
//
|
||||
// Created by yelv1 on 24-9-22.
|
||||
//
|
||||
|
||||
#ifndef PERIPHERAL_H
|
||||
#define PERIPHERAL_H
|
||||
|
||||
void usart_config(void);
|
||||
void led_blink_config(void);
|
||||
|
||||
#endif //PERIPHERAL_H
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#define RX_BUFFER_SIZE 64
|
||||
|
||||
void RS485_config(void);
|
||||
void rs485_config(void);
|
||||
void process_command(char *cmd);
|
||||
|
||||
#endif //RS485_H
|
22
inc/tmp112.h
Normal file
22
inc/tmp112.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by dell on 24-12-20.
|
||||
//
|
||||
|
||||
#ifndef TMP112_H
|
||||
#define TMP112_H
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#define TMP112A_ADDR (0x49 << 1)
|
||||
|
||||
uint32_t tmp112a_get_raw_channel_result(void);
|
||||
|
||||
#endif //TMP112_H
|
Reference in New Issue
Block a user