blob: 56ea1e9cea3dc6179f75634a43c68a4e9f330151 [file] [log] [blame]
b.liu778645e2024-06-21 16:47:42 +08001#ifndef __HD8040_PORT_H
2#define __HD8040_PORT_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <unistd.h>
7#include <string.h>
8#include <errno.h>
9#include <fcntl.h>
10#include <termios.h>
11#include <sys/types.h>
12#include <sys/wait.h>
13#include <sys/un.h>
14//#include <sys/prctl.h>
15#include <sys/time.h>
16#include <dirent.h>
17#include <sys/stat.h>
18
19#define SUCCESS 0
20#define FAIL -1
21
22#ifndef HDBD_LOG
23#define HDBD_LOG printf
24#endif
25
26typedef unsigned char uint8_t;
27typedef unsigned short int uint16_t;
28typedef unsigned int uint32_t;
29/* For communication buadrate */
30#define COMM_BAUDRATE_PHONE 115200
31
32/* For upgrade baudrate */
33#define UPGRADE_BAUDRATE_PHONE 460800
34
35/* <Function define Config begin */
36#define DEBUG_RUN_TIME 0
37/* Function define Config end> */
38
39/* Function Declaration */
40/* Basic operation for serial port */
41extern int uart_set(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);
42extern int uart_init(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);
43extern int uart_send(int fd, const uint8_t *cmd, int cmd_len);
44extern int uart_recv(int fd, uint8_t *buf, int *actual_length, int timeout);
45extern void clearBuffer(int fd, int selector);
46extern int uart_open(unsigned char * GPS_DEVICE);
47extern int uart_close(int fd);
48extern int OpenUart(char* UART_DEV);
49extern int set_baudrate(int fd, uint8_t baud);
50#endif