generated from hulk/gd32e23x_template
	Merge remote-tracking branch 'origin/feature-rs485' into dev
# Conflicts: # inc/rs485.h # src/gd32e23x_it.c # src/rs485.c
This commit is contained in:
		| @@ -15,6 +15,8 @@ | ||||
| #include <stdlib.h> | ||||
| #include <math.h> | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| #define I2C_SPEED 20000 | ||||
| #define RCU_GPIO_I2C RCU_GPIOF | ||||
| #define RCU_I2C RCU_I2C0 | ||||
| @@ -24,11 +26,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, | ||||
| @@ -37,6 +43,8 @@ typedef enum { | ||||
|     I2C_STOP | ||||
| } i2c_process_enum; | ||||
|  | ||||
| /******************************************************************************/ | ||||
|  | ||||
| void i2c_gpio_config(void); | ||||
|  | ||||
| void i2c_config(void); | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
							
								
								
									
										39
									
								
								inc/rs485.h
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								inc/rs485.h
									
									
									
									
									
								
							| @@ -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,28 +23,37 @@ | ||||
| #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 | ||||
| /******************************************************************************/ | ||||
|  | ||||
| typedef enum { | ||||
| #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, | ||||
|     VALIDATION_CRC_ERROR = 1 | ||||
|     VALIDATION_CRC_ERROR = 1, | ||||
|     VALIDATION_HEADER_ERROR = 2, | ||||
|     VALIDATION_TYPE_ERROR = 4, | ||||
|     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[], size_t data_length); | ||||
| validation_result_t validate_package_crc(uint8_t *data, size_t data_length); | ||||
| validation_result_t validate_package_header(uint8_t *data); | ||||
|  | ||||
| validation_result_t validate_package_type(uint8_t *data); | ||||
|  | ||||
| void process_command(uint8_t* cmd, size_t length); | ||||
| uint8_t calculate_crc(uint8_t data[], uint8_t data_length); | ||||
| validation_result_t validate_package_crc(uint8_t* data, uint8_t data_length); | ||||
| validation_result_t validate_package_header(uint8_t* data); | ||||
| validation_result_t validate_package_type(uint8_t* data); | ||||
| validation_result_t validate_data_length(uint8_t* data); | ||||
| void eddy_current_value_report(void); | ||||
|  | ||||
| void tempture_value_report(void); | ||||
|  | ||||
| #endif //RS485_H | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user