blob: 5e55db8a2ca43cb1edfe01997408e072bd43cb6f [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
yq.wangaf363dc2024-08-06 20:16:00 -070019#include "mbtk_log.h"
b.liu778645e2024-06-21 16:47:42 +080020#define SUCCESS 0
21#define FAIL -1
22
23#ifndef HDBD_LOG
yq.wangaf363dc2024-08-06 20:16:00 -070024#define HDBD_LOG LOGE
b.liu778645e2024-06-21 16:47:42 +080025#endif
26
27typedef unsigned char uint8_t;
28typedef unsigned short int uint16_t;
29typedef unsigned int uint32_t;
30/* For communication buadrate */
31#define COMM_BAUDRATE_PHONE 115200
32
33/* For upgrade baudrate */
34#define UPGRADE_BAUDRATE_PHONE 460800
35
36/* <Function define Config begin */
37#define DEBUG_RUN_TIME 0
38/* Function define Config end> */
39
40/* Function Declaration */
41/* Basic operation for serial port */
42extern int uart_set(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);
43extern int uart_init(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);
44extern int uart_send(int fd, const uint8_t *cmd, int cmd_len);
45extern int uart_recv(int fd, uint8_t *buf, int *actual_length, int timeout);
46extern void clearBuffer(int fd, int selector);
47extern int uart_open(unsigned char * GPS_DEVICE);
48extern int uart_close(int fd);
49extern int OpenUart(char* UART_DEV);
50extern int set_baudrate(int fd, uint8_t baud);
51#endif