Loading...
Searching...
No Matches
sx126x_internal.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 HAW Hamburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
20#ifndef SX126X_INTERNAL_H
21#define SX126X_INTERNAL_H
22
23#include <assert.h>
24#include "sx126x.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
38static inline bool sx126x_is_sx1261(sx126x_t *dev)
39{
40 assert(dev);
41 if (SX126X_SINGLE) {
42 return IS_USED(MODULE_SX1261);
43 }
44 else {
45 return dev->params->type == SX126X_TYPE_SX1261;
46 }
47}
48
57static inline bool sx126x_is_sx1262(sx126x_t *dev)
58{
59 assert(dev);
60 if (SX126X_SINGLE) {
61 return IS_USED(MODULE_SX1262);
62 }
63 else {
64 return dev->params->type == SX126X_TYPE_SX1262;
65 }
66}
67
76static inline bool sx126x_is_llcc68(sx126x_t *dev)
77{
78 assert(dev);
79 if (SX126X_SINGLE) {
80 return IS_USED(MODULE_LLCC68);
81 }
82 else {
83 return dev->params->type == SX126X_TYPE_LLCC68;
84 }
85}
86
95static inline bool sx126x_is_sx1268(sx126x_t *dev)
96{
97 assert(dev);
98 if (SX126X_SINGLE) {
99 return IS_USED(MODULE_SX1268);
100 }
101 else {
102 return dev->params->type == SX126X_TYPE_SX1268;
103 }
104}
105
114static inline bool sx126x_is_stm32wl(sx126x_t *dev)
115{
116 assert(dev);
117 if (SX126X_SINGLE) {
118 return IS_USED(MODULE_SX126X_STM32WL);
119 }
120 else {
121 return dev->params->type == SX126X_TYPE_STM32WL;
122 }
123}
124
125#ifdef __cplusplus
126}
127#endif
128
129#endif /* SX126X_INTERNAL_H */
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition assert.h:137
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)
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:55
#define IS_USED(module)
Checks whether a module is being used or not.
Definition modules.h:71
sx126x_type_t type
Variant of sx126x.
Definition sx126x.h:92
Device descriptor for the driver.
Definition sx126x.h:105
sx126x_params_t * params
Initialization parameters.
Definition sx126x.h:107