Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
u_blox_i2c.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Embeint Holdings Pty Ltd
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/kernel.h>
8#include <zephyr/device.h>
9#include <zephyr/drivers/i2c.h>
10#include <zephyr/drivers/gpio.h>
11#include <zephyr/sys/ring_buffer.h>
12
13#include <zephyr/modem/pipe.h>
14
15#ifndef INFUSE_MODEM_BACKEND_U_BLOX_I2C_
16#define INFUSE_MODEM_BACKEND_U_BLOX_I2C_
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
23 /* Pointer to I2C configuration */
24 const struct i2c_dt_spec *i2c;
25 /* Pointer to data ready pin configuration */
26 const struct gpio_dt_spec *data_ready;
27 /* Communication pipe */
28 struct modem_pipe pipe;
29 /* Ring buffer for holding pipe data stream */
30 struct ring_buf pipe_ring_buf;
31 /* Worker that reads the FIFO */
32 struct k_work_delayable fifo_read;
33 /* Signal to notify when FIFO read completes */
34 struct k_poll_signal read_result;
35 /* Callback for data ready GPIO */
36 struct gpio_callback data_ready_cb;
37 /* Bus (RTIO SQE) contention semaphore */
38 struct k_sem bus_sem;
39 /* Duration between polls */
40 k_timeout_t poll_period;
41 /* Number of bytes pending on FIFO */
42 uint16_t bytes_pending;
43 /* Internal state flags */
44 uint8_t flags;
45 /* Backing memory for pipe data stream */
46 uint8_t pipe_memory[CONFIG_GNSS_U_BLOX_PIPE_SIZE];
47};
48
50 /* Bus to use */
51 const struct i2c_dt_spec *i2c;
52 /* GPIO that will transition to active when data is ready after @ref
53 * modem_backend_ublox_i2c_use_data_ready_gpio
54 */
55 const struct gpio_dt_spec *data_ready;
56 /* Period to poll for data before @ref modem_backend_ublox_i2c_use_data_ready_gpio */
57 k_timeout_t poll_period;
58};
59
68struct modem_pipe *
70 const struct modem_backend_ublox_i2c_config *config);
71
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* INFUSE_MODEM_BACKEND_U_BLOX_I2C_ */
Definition u_blox_i2c.h:49
const struct gpio_dt_spec * data_ready
Definition u_blox_i2c.h:55
k_timeout_t poll_period
Definition u_blox_i2c.h:57
const struct i2c_dt_spec * i2c
Definition u_blox_i2c.h:51
Definition u_blox_i2c.h:22
struct k_poll_signal read_result
Definition u_blox_i2c.h:34
uint8_t pipe_memory[CONFIG_GNSS_U_BLOX_PIPE_SIZE]
Definition u_blox_i2c.h:46
struct k_work_delayable fifo_read
Definition u_blox_i2c.h:32
struct k_sem bus_sem
Definition u_blox_i2c.h:38
struct modem_pipe pipe
Definition u_blox_i2c.h:28
uint8_t flags
Definition u_blox_i2c.h:44
k_timeout_t poll_period
Definition u_blox_i2c.h:40
uint16_t bytes_pending
Definition u_blox_i2c.h:42
struct ring_buf pipe_ring_buf
Definition u_blox_i2c.h:30
struct gpio_callback data_ready_cb
Definition u_blox_i2c.h:36
const struct i2c_dt_spec * i2c
Definition u_blox_i2c.h:24
const struct gpio_dt_spec * data_ready
Definition u_blox_i2c.h:26
void modem_backend_ublox_i2c_use_data_ready_gpio(struct modem_backend_ublox_i2c *backend)
Transition from polling to interrupt driven mode.
struct modem_pipe * modem_backend_ublox_i2c_init(struct modem_backend_ublox_i2c *backend, const struct modem_backend_ublox_i2c_config *config)
Initialize modem backend.