Revert "test"

This reverts commit fecaa256ca.
This commit is contained in:
2024-12-30 22:23:47 +08:00
parent fecaa256ca
commit 7fa633805b
19 changed files with 117 additions and 1079 deletions

View File

@@ -1,44 +0,0 @@
//
// Created by dell on 24-12-28.
//
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H
#define SOFTWARE_IIC
// #define DEBUG_VERBOES
/******************************************************************************/
#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 RS485_RCU RCU_USART0
#define RS485_GPIO_RCU RCU_GPIOA
#define RS485_GPIO_PORT GPIOA
#define RS485_TX_PIN GPIO_PIN_2
#define RS485_RX_PIN GPIO_PIN_3
#define RS485_PHY USART0
#define RS485_BAUDRATE 115200U
#define RS485_EN_PIN GPIO_PIN_1
/******************************************************************************/
#define LED_PORT GPIOA
#define LED_PIN GPIO_PIN_7
#define LED_RCU RCU_GPIOA
#define LED_BLINK_TIMER_RCU RCU_TIMER16
#define LED_BLINK_TIMER TIMER16
#define LED_BLINK_IRQ TIMER16_IRQn
/******************************************************************************/
#endif //BOARD_CONFIG_H

View File

@@ -1,15 +0,0 @@
//
// Created by yelv1 on 24-12-29.
//
#ifndef FWDGT_H
#define FWDGT_H
#include "gd32e23x.h"
#include "board_config.h"
void watchdog_init(void);
void fwdgt_reset_mcu(void);
#endif //FWDGT_H

View File

@@ -1,48 +0,0 @@
//
// Created by dell on 24-12-20.
//
#ifndef I2C_H
#define I2C_H
#include "gd32e23x_it.h"
#include "gd32e23x.h"
#include "systick.h"
#include "main.h"
#include "board_config.h"
/******************************************************************************/
#define I2C_SPEED 20000
#define I2C_TIME_OUT (uint16_t)(5000)
#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

View File

@@ -1,13 +0,0 @@
//
// Created by dell on 24-12-20.
//
#ifndef LED_H
#define LED_H
#include "gd32e23x_it.h"
#include "board_config.h"
void led_config(void);
#endif //LED_H

View File

@@ -35,20 +35,4 @@ OF SUCH DAMAGE.
#ifndef MAIN_H
#define MAIN_H
#include <stdio.h>
#include "gd32e23x.h"
#include "systick.h"
#include "gd32e23x_libopt.h"
#include "rs485.h"
#include "led.h"
#include "fwdgt.h"
#include "board_config.h"
#ifdef SOFTWARE_IIC
#include "soft_i2c.h"
#else
#include "i2c.h"
#endif
#endif /* MAIN_H */

11
inc/peripheral.h Normal file
View File

@@ -0,0 +1,11 @@
//
// 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

View File

@@ -1,22 +0,0 @@
//
// Created by dell on 24-12-3.
//
#ifndef RS485_H
#define RS485_H
#include "gd32e23x_it.h"
#include "gd32e23x.h"
#include "board_config.h"
/******************************************************************************/
#define RX_BUFFER_SIZE 32
/******************************************************************************/
void usart_config(void);
void rs485_config(void);
#endif //RS485_H

View File

@@ -1,53 +0,0 @@
//
// 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)
/******************************************************************************/
#define SOFT_I2C_OK 1
#define SOFT_I2C_FAIL 0
#define SOFT_I2C_END 1
/******************************************************************************/
void soft_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);
uint8_t soft_i2c_write_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t data[2]);
uint8_t soft_i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data);
#endif //SOFT_I2C_H