b.liu | 778645e | 2024-06-21 16:47:42 +0800 | [diff] [blame] | 1 | #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.wang | af363dc | 2024-08-06 20:16:00 -0700 | [diff] [blame^] | 19 | #include "mbtk_log.h"
|
b.liu | 778645e | 2024-06-21 16:47:42 +0800 | [diff] [blame] | 20 | #define SUCCESS 0
|
| 21 | #define FAIL -1
|
| 22 |
|
| 23 | #ifndef HDBD_LOG
|
yq.wang | af363dc | 2024-08-06 20:16:00 -0700 | [diff] [blame^] | 24 | #define HDBD_LOG LOGE
|
b.liu | 778645e | 2024-06-21 16:47:42 +0800 | [diff] [blame] | 25 | #endif
|
| 26 |
|
| 27 | typedef unsigned char uint8_t;
|
| 28 | typedef unsigned short int uint16_t;
|
| 29 | typedef 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 */
|
| 42 | extern int uart_set(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);
|
| 43 | extern int uart_init(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);
|
| 44 | extern int uart_send(int fd, const uint8_t *cmd, int cmd_len);
|
| 45 | extern int uart_recv(int fd, uint8_t *buf, int *actual_length, int timeout);
|
| 46 | extern void clearBuffer(int fd, int selector);
|
| 47 | extern int uart_open(unsigned char * GPS_DEVICE);
|
| 48 | extern int uart_close(int fd);
|
| 49 | extern int OpenUart(char* UART_DEV);
|
| 50 | extern int set_baudrate(int fd, uint8_t baud);
|
| 51 | #endif
|