generated from hulk/gd32e23x_template
完成LED、RS485、IIC初始化部分代码。
This commit is contained in:
42
inc/LDC1612.h
Normal file
42
inc/LDC1612.h
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by dell on 24-12-3.
|
||||
//
|
||||
|
||||
#ifndef LDC1612_H
|
||||
#define LDC1612_H
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.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
|
||||
|
||||
#define I2C_SPEED 100000
|
||||
#define IR_I2C I2C0
|
||||
#define RCU_IR_GPIO 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)(5000)
|
||||
|
||||
#define SLAVE_ADDR (0x5A << 1)
|
||||
|
||||
|
||||
void led_config(void);
|
||||
void LDC1612_I2CConfig(void);
|
||||
|
||||
|
||||
#endif //LDC1612_H
|
31
inc/RS485.h
Normal file
31
inc/RS485.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by dell on 24-12-3.
|
||||
//
|
||||
|
||||
#ifndef RS485_H
|
||||
#define RS485_H
|
||||
|
||||
#include "gd32e23x_it.h"
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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 RX_BUFFER_SIZE 64
|
||||
|
||||
void RS485_config(void);
|
||||
void process_command(char *cmd);
|
||||
|
||||
#endif //RS485_H
|
Reference in New Issue
Block a user