Loading...
Searching...
No Matches
sx126x_internal.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 HAW Hamburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include <assert.h>
21#include "sx126x.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
35static inline bool sx126x_is_sx1261(sx126x_t *dev)
36{
37 assert(dev);
38 if (SX126X_SINGLE) {
39 return IS_USED(MODULE_SX1261);
40 }
41 else {
42 return dev->params->type == SX126X_TYPE_SX1261;
43 }
44}
45
54static inline bool sx126x_is_sx1262(sx126x_t *dev)
55{
56 assert(dev);
57 if (SX126X_SINGLE) {
58 return IS_USED(MODULE_SX1262);
59 }
60 else {
61 return dev->params->type == SX126X_TYPE_SX1262;
62 }
63}
64
73static inline bool sx126x_is_llcc68(sx126x_t *dev)
74{
75 assert(dev);
76 if (SX126X_SINGLE) {
77 return IS_USED(MODULE_LLCC68);
78 }
79 else {
80 return dev->params->type == SX126X_TYPE_LLCC68;
81 }
82}
83
92static inline bool sx126x_is_sx1268(sx126x_t *dev)
93{
94 assert(dev);
95 if (SX126X_SINGLE) {
96 return IS_USED(MODULE_SX1268);
97 }
98 else {
99 return dev->params->type == SX126X_TYPE_SX1268;
100 }
101}
102
111static inline bool sx126x_is_stm32wl(sx126x_t *dev)
112{
113 assert(dev);
114 if (SX126X_SINGLE) {
115 return IS_USED(MODULE_SX126X_STM32WL);
116 }
117 else {
118 return dev->params->type == SX126X_TYPE_STM32WL;
119 }
120}
121
129sx126x_chip_modes_t sx126x_get_state(const sx126x_t *dev);
130
137void sx126x_set_state(sx126x_t *dev, sx126x_chip_modes_t state);
138
139#ifdef __cplusplus
140}
141#endif
142
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition assert.h:143
static bool sx126x_is_sx1268(sx126x_t *dev)
Check whether the device model is sx1268.
static bool sx126x_is_stm32wl(sx126x_t *dev)
Check whether the device model is stm32wl (onboard radio)
sx126x_chip_modes_t sx126x_get_state(const sx126x_t *dev)
Get the current chip state.
void sx126x_set_state(sx126x_t *dev, sx126x_chip_modes_t state)
Set the internal chip state.
static bool sx126x_is_llcc68(sx126x_t *dev)
Check whether the device model is llcc68.
static bool sx126x_is_sx1261(sx126x_t *dev)
Check whether the device model is sx1261.
static bool sx126x_is_sx1262(sx126x_t *dev)
Check whether the device model is sx1262.
#define SX126X_SINGLE
Whether there's only one variant of this driver at compile time or not.
Definition sx126x.h:70
struct sx126x sx126x_t
Definition sx126x.h:55
#define IS_USED(module)
Checks whether a module is being used or not.
Definition modules.h:67
sx126x_type_t type
Variant of sx126x.
Definition sx126x.h:145
sx126x_params_t * params
Initialization parameters.
Definition sx126x.h:160