Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ubx.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/kernel.h>
8#include <zephyr/types.h>
9#include <zephyr/sys/atomic.h>
10
11#include <zephyr/modem/pipe.h>
12
13#ifndef ZEPHYR_MODEM_UBX_
14#define ZEPHYR_MODEM_UBX_
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
27#define UBX_FRM_HEADER_SZ 6
28#define UBX_FRM_FOOTER_SZ 2
29#define UBX_FRM_SZ_WITHOUT_PAYLOAD (UBX_FRM_HEADER_SZ + UBX_FRM_FOOTER_SZ)
30#define UBX_FRM_SZ(payload_size) (payload_size + UBX_FRM_SZ_WITHOUT_PAYLOAD)
31
32#define UBX_PREAMBLE_SYNC_CHAR_1 0xB5
33#define UBX_PREAMBLE_SYNC_CHAR_2 0x62
34
35#define UBX_FRM_PREAMBLE_SYNC_CHAR_1_IDX 0
36#define UBX_FRM_PREAMBLE_SYNC_CHAR_2_IDX 1
37#define UBX_FRM_MSG_CLASS_IDX 2
38#define UBX_FRM_MSG_ID_IDX 3
39#define UBX_FRM_PAYLOAD_SZ_L_IDX 4
40#define UBX_FRM_PAYLOAD_SZ_H_IDX 5
41#define UBX_FRM_PAYLOAD_IDX 6
42#define UBX_FRM_CHECKSUM_START_IDX 2
43#define UBX_FRM_CHECKSUM_STOP_IDX(frame_len) (frame_len - 2)
44
45#define UBX_PAYLOAD_SZ_MAX 256
46#define UBX_FRM_SZ_MAX UBX_FRM_SZ(UBX_PAYLOAD_SZ_MAX)
47
57
66
89
98
108int modem_ubx_attach(struct modem_ubx *ubx, struct modem_pipe *pipe);
109
115void modem_ubx_release(struct modem_ubx *ubx);
116
123int modem_ubx_init(struct modem_ubx *ubx, const struct modem_ubx_config *config);
124
152int modem_ubx_run_script(struct modem_ubx *ubx, const struct modem_ubx_script *script);
153
166 uint8_t msg_id, const void *payload, uint16_t payload_size);
171#ifdef __cplusplus
172}
173#endif
174
175#endif /* ZEPHYR_MODEM_UBX_ */
long atomic_t
Definition atomic_types.h:15
int modem_ubx_run_script(struct modem_ubx *ubx, const struct modem_ubx_script *script)
Writes the ubx frame in script.request and reads back its response (if available)
int modem_ubx_attach(struct modem_ubx *ubx, struct modem_pipe *pipe)
Attach pipe to Modem Ubx.
int modem_ubx_create_frame(uint8_t *ubx_frame, uint16_t ubx_frame_size, uint8_t msg_cls, uint8_t msg_id, const void *payload, uint16_t payload_size)
Initialize ubx frame.
void modem_ubx_release(struct modem_ubx *ubx)
Release pipe from Modem Ubx instance.
int modem_ubx_init(struct modem_ubx *ubx, const struct modem_ubx_config *config)
Initialize Modem Ubx instance.
Public kernel APIs.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Kernel timeout type.
Definition sys_clock.h:65
A structure used to submit work.
Definition kernel.h:3957
Definition ubx.h:90
uint8_t * work_buf
Definition ubx.h:95
uint16_t receive_buf_size
Definition ubx.h:94
uint8_t * receive_buf
Definition ubx.h:93
uint16_t work_buf_size
Definition ubx.h:96
void * user_data
Definition ubx.h:91
Definition ubx.h:58
k_timeout_t timeout
Definition ubx.h:64
uint16_t retry_count
Definition ubx.h:63
struct ubx_frame * response
Definition ubx.h:60
struct ubx_frame * request
Definition ubx.h:59
struct ubx_frame * match
Definition ubx.h:61
Definition ubx.h:67
struct k_sem script_running_sem
Definition ubx.h:87
uint8_t * receive_buf
Definition ubx.h:72
struct modem_pipe * pipe
Definition ubx.h:82
uint16_t work_buf_size
Definition ubx.h:76
uint16_t receive_buf_size
Definition ubx.h:73
atomic_t state
Definition ubx.h:70
bool ubx_preamble_sync_chars_received
Definition ubx.h:78
uint16_t work_buf_len
Definition ubx.h:77
const struct modem_ubx_script * script
Definition ubx.h:80
uint8_t * work_buf
Definition ubx.h:75
void * user_data
Definition ubx.h:68
struct k_work process_work
Definition ubx.h:85
struct k_sem script_stopped_sem
Definition ubx.h:86
struct k_work send_work
Definition ubx.h:84
Definition ubx.h:48
uint8_t payload_size_high
Definition ubx.h:54
uint8_t payload_and_checksum[]
Definition ubx.h:55
uint8_t payload_size_low
Definition ubx.h:53
uint8_t message_class
Definition ubx.h:51
uint8_t preamble_sync_char_2
Definition ubx.h:50
uint8_t message_id
Definition ubx.h:52
uint8_t preamble_sync_char_1
Definition ubx.h:49