代码美化

This commit is contained in:
2024-12-25 00:37:53 +08:00
parent ed8b6b3f6d
commit 6702703031
6 changed files with 26 additions and 14 deletions

View File

@@ -14,6 +14,8 @@
#include <stdlib.h>
#include <math.h>
/******************************************************************************/
#define I2C_SPEED 20000
#define RCU_GPIO_I2C RCU_GPIOF
#define RCU_I2C RCU_I2C0
@@ -23,11 +25,15 @@
#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,
@@ -36,6 +42,8 @@ typedef enum {
I2C_STOP
} i2c_process_enum;
/******************************************************************************/
void i2c_gpio_config(void);
void i2c_config(void);

View File

@@ -19,6 +19,7 @@
/*Register Rddr*/
/***************************************************************************/
#define CONVERTION_RESULT_REG_START 0X00
#define SET_CONVERSION_TIME_REG_START 0X08
#define SET_CONVERSION_OFFSET_REG_START 0X0C

View File

@@ -14,6 +14,8 @@
#include <stdlib.h>
#include <math.h>
/******************************************************************************/
#define LED_PORT GPIOA
#define LED_PIN GPIO_PIN_7
#define LED_RCU RCU_GPIOA
@@ -21,6 +23,8 @@
#define LED_TIMER TIMER16
#define LED_IRQ TIMER16_IRQn
/******************************************************************************/
void led_config(void);
#endif //LED_H

View File

@@ -14,6 +14,8 @@
#include <stdlib.h>
#include <sys/types.h>
/******************************************************************************/
#define RS485_RCU RCU_USART0
#define RS485_GPIO_RCU RCU_GPIOA
#define RS485_GPIO_PORT GPIOA
@@ -21,15 +23,18 @@
#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 32
/******************************************************************************/
#define RX_BUFFER_SIZE 32
#define LDC1612_PACKAGE_HEADER 0xD5
#define LDC1612_BOARD_TYPE 0x03
#define LDC1612_PACKAGE_LENGTH 0x02
/******************************************************************************/
typedef enum
{
VALIDATION_SUCCESS = 0,
@@ -39,6 +44,8 @@ typedef enum
VALIDATION_LENGTH_ERROR = 8
} validation_result_t;
/******************************************************************************/
void rs485_config(void);
void process_command(uint8_t* cmd, size_t length);
uint8_t calculate_crc(uint8_t data[], uint8_t data_length);

View File

@@ -15,8 +15,12 @@
#include <math.h>
#include "i2c.h"
/******************************************************************************/
#define TMP112A_ADDR (0x49 << 1)
/******************************************************************************/
uint32_t tmp112a_get_raw_channel_result(void);
#endif //TMP112_H