b.liu | f9fbfa1 | 2024-06-14 15:53:59 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * gnss_hd8122.c |
| 3 | * |
| 4 | * HD8122 GNSS source. |
| 5 | * |
| 6 | */ |
| 7 | /****************************************************************************** |
| 8 | |
| 9 | EDIT HISTORY FOR FILE |
| 10 | |
| 11 | WHEN WHO WHAT,WHERE,WHY |
| 12 | -------- -------- ------------------------------------------------------- |
| 13 | 2024/6/14 LiuBin Initial version |
| 14 | |
| 15 | ******************************************************************************/ |
| 16 | #include <stdio.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <unistd.h> |
| 19 | #include <errno.h> |
| 20 | #include <fcntl.h> |
| 21 | |
| 22 | #include "mbtk_log.h" |
| 23 | #include "mbtk_type.h" |
| 24 | #include "mbtk_gpio.h" |
| 25 | #include "gnss_utils.h" |
| 26 | #include "gnss_hd8122.h" |
| 27 | |
| 28 | #define UART_BITRATE_NMEA_DEF_FW 115200 // Default bitrate. |
| 29 | #define GNSS_POWER_GPIO 43 |
| 30 | |
| 31 | static pthread_cond_t read_cond; |
| 32 | static pthread_mutex_t read_mutex; |
| 33 | |
| 34 | |
| 35 | int gnss_8122_dev_open() |
| 36 | { |
| 37 | return mbtk_gpio_value_set(GNSS_POWER_GPIO, MBTK_GPIO_DIRECT_OUT, 1); |
| 38 | } |
| 39 | |
| 40 | int gnss_8122_dev_close() |
| 41 | { |
| 42 | return mbtk_gpio_value_set(GNSS_POWER_GPIO, MBTK_GPIO_DIRECT_OUT, 0); |
| 43 | } |
| 44 | |
| 45 | int gnss_8122_open(const char *dev) |
| 46 | { |
| 47 | pthread_mutex_init(&read_mutex, NULL); |
| 48 | pthread_cond_init(&read_cond, NULL); |
| 49 | return gnss_port_open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY, UART_BITRATE_NMEA_DEF_FW, TRUE); |
| 50 | } |
| 51 | |
| 52 | int gnss_8122_close(int fd) |
| 53 | { |
| 54 | pthread_mutex_destroy(&read_mutex); |
| 55 | pthread_cond_destroy(&read_cond); |
| 56 | return gnss_port_close(fd); |
| 57 | } |
| 58 | |
| 59 | int gnss_8122_fw_dl() |
| 60 | { |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | gnss_err_enum gnss_8122_set(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len) |
| 66 | { |
| 67 | return GNSS_ERR_OK; |
| 68 | } |
| 69 | |