C-Libs/CBus.h
2021-07-01 11:55:32 +00:00

48 lines
900 B
C

/*
* CBus.h
*
* Created on: Jun 14, 2021
* Author: angoosh
*/
#ifndef INC_CBUS_H_
#define INC_CBUS_H_
#include <stdbool.h>
#include <string.h>
#include "main.h"
//buffers
#define DataSize 32 //max size of packet data
#define RX_BUFFER_SIZE 255 //size of RX buffer
//packet properties
#define PREFIX 0xBA //packet start byte
#define ADDRESS 0x01 //device address
//#define PREFIXINPACKETACTION
//commands
#define TEST_CMD 0x50 //test command for testing out communication
#define ACK 0xFA //acknowledge command, in data command which it reacts to
UART_HandleTypeDef huart3;
typedef struct
{
uint8_t RxAddr; //Receiver address
uint8_t Sender; //Sender address
uint8_t Command; //Command
uint8_t Length; //Length of message
uint8_t Data[DataSize]; //Data
uint8_t Crc; //Crc
bool IsOk;
}CBusPacket;
void ReadRxBuffer();
#endif /* INC_CBUS_H_ */