41 lines
841 B
C
41 lines
841 B
C
|
#ifndef _APP_UART_H_
|
||
|
#define _APP_UART_H_
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include "uart.h"
|
||
|
|
||
|
//数据帧头
|
||
|
#define FRAME_HEADER 0xA100
|
||
|
|
||
|
#define MAX_LEN 127
|
||
|
|
||
|
//失能数据校验
|
||
|
#define DISABLE_CRC8 1
|
||
|
|
||
|
typedef struct uart_daraframe
|
||
|
{
|
||
|
volatile uint16_t header;//0xA100
|
||
|
volatile uint8_t cmd_id;
|
||
|
volatile uint8_t reg_addr;
|
||
|
volatile uint8_t length;
|
||
|
volatile uint8_t data[MAX_LEN];
|
||
|
volatile uint8_t crc;
|
||
|
} uart_daraframe_t;
|
||
|
|
||
|
typedef struct radar_daraframe
|
||
|
{
|
||
|
uint8_t header;
|
||
|
uint8_t Left_data;
|
||
|
uint8_t Right_data;
|
||
|
} radar_daraframe_t;
|
||
|
|
||
|
|
||
|
//初始化
|
||
|
void app_uart_Init(uint8_t port, uint32_t baudrate, uint8_t io_tx, uint8_t io_rx);
|
||
|
//发送命令
|
||
|
void app_uart_Sendcmd(uint8_t port, volatile uint8_t cmd_id ,volatile uint8_t reg_addr ,volatile uint8_t *data, volatile uint8_t length);
|
||
|
|
||
|
uint8_t crc8_checkout(uint8_t *buff, uint8_t length);
|
||
|
|
||
|
#endif
|