Inital working code
This commit is contained in:
		
							
								
								
									
										53
									
								
								commons.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								commons.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| #ifndef COMMONS_H | ||||
| #define	COMMONS_H | ||||
|  | ||||
| // Pins | ||||
| #define LED_PIN             19 | ||||
| #define RS485_RX_TX_SELECT  22 | ||||
|  | ||||
| // Config | ||||
| #define MASTER_ID           0xF0 | ||||
| #define MY_ID               0x00 | ||||
| // #define DEBUG | ||||
| #ifndef MASTER_ID | ||||
| #define IS_MASTER | ||||
| #endif | ||||
|  | ||||
| #define DELAY_TO_REPLY      5 | ||||
|  | ||||
| // Proto | ||||
| #define START_DEL           '[' | ||||
| #define END_DEL             ']' | ||||
|  | ||||
| // General indexes | ||||
| #define ID_INDEX            1 | ||||
| #define CMD_INDEX           (ID_INDEX + 1) | ||||
| #define PAYLOAD_INDEX       (CMD_INDEX + CMD_NAME_LEN) | ||||
|  | ||||
| // GET | ||||
| #define GET_CMD_ID          0 | ||||
| // SET | ||||
| #define SET_CMD_ID          1 | ||||
| #define LED1_INDEX          3 | ||||
| #define LED2_INDEX          5 | ||||
| // DATA | ||||
| #define DATA_CMD_ID         2 | ||||
| #define SENSOR_INDEX        3 | ||||
| // ERROR | ||||
| #define ERROR_CMD_ID        3 | ||||
| #define ERR_INDEX           3 | ||||
|  | ||||
| #define RET_SUCCESS(ret)    (ret <= 1) | ||||
| #define RET_FAILURE(ret)    (ret > 1) | ||||
|  | ||||
| typedef enum errors | ||||
| { | ||||
|     SUCCESS = 0, | ||||
|     NO_RX, | ||||
|     UNSUPPORTED_CMD, | ||||
|     TX_DONE_ERR, | ||||
|     TX_READY_ERR, | ||||
| } errors_t; | ||||
|  | ||||
| #endif	/* COMMONS_H */ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user