You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#ifndef _P_SERIAL_MGR_H_
|
|
|
|
#define _P_SERIAL_MGR_H_
|
|
|
|
|
|
|
|
#include "p_cbuffer.h"
|
|
|
|
#include "stm32l4xx_hal.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
// start byte
|
|
|
|
// src_addr {1} +
|
|
|
|
// dest_addr {1} +
|
|
|
|
// frame_length {1} +
|
|
|
|
// checksum {1} +
|
|
|
|
// frame_data {510} -- making it 510 instead of 511 so it is easily divisible
|
|
|
|
#define MAX_MESSAGE_LEN (516)
|
|
|
|
#define MAX_FRAME_DATA_LEN (510)
|
|
|
|
// motor controller
|
|
|
|
#define DEVICE_ADDR (0x02)
|
|
|
|
// pi
|
|
|
|
#define MASTER_ADDR (0x01)
|
|
|
|
|
|
|
|
typedef struct serial_pkt_t
|
|
|
|
{
|
|
|
|
uint8_t *src_addr;
|
|
|
|
uint8_t *dest_addr;
|
|
|
|
uint8_t *frame_data_len;
|
|
|
|
uint8_t *checksum;
|
|
|
|
uint8_t *frame_data;
|
|
|
|
uint8_t data[MAX_MESSAGE_LEN];
|
|
|
|
int msg_len;
|
|
|
|
} serial_pkt_t;
|
|
|
|
|
|
|
|
void p_serial_mgr_init(UART_HandleTypeDef *huart);
|
|
|
|
|
|
|
|
void p_serial_mgr_service(void);
|
|
|
|
|
|
|
|
void p_serial_mgr_start();
|
|
|
|
|
|
|
|
#endif
|