43#ifndef _oslmic_types_h_
44# include "oslmic_types.h"
53#define DO_DEVDB(field1,field2)
54#if !defined(CFG_noassert)
55#define ASSERT(cond) if(!(cond)) lmic_hal_failed(__FILE__, __LINE__)
62#define os_clearMem(pDest,nDest) memset(pDest,0,nDest)
70#define os_copyMem(pDest,pSrc,nSrc) memcpy(pDest,pSrc,nSrc)
73typedef struct band_t band_t;
74typedef struct chnldef_t chnldef_t;
81#ifndef LMIC_PRId_ostime_t
83# define LMIC_PRId_ostime_t PRId32
86#define TYPEDEF_xref2rps_t typedef rps_t* xref2rps_t
87#define TYPEDEF_xref2rxsched_t typedef rxsched_t* xref2rxsched_t
88#define TYPEDEF_xref2chnldef_t typedef chnldef_t* xref2chnldef_t
89#define TYPEDEF_xref2band_t typedef band_t* xref2band_t
90#define TYPEDEF_xref2osjob_t typedef osjob_t* xref2osjob_t
92#define SIZEOFEXPR(x) sizeof(x)
94#define DECL_ON_LMIC_EVENT LMIC_DECLARE_FUNCTION_WEAK(void, onEvent, (ev_t e))
96#define FUNC_ADDR(func) (&(func))
99#define os_getRndU1() radio_rand1()
101#define DEFINE_LMIC struct lmic_t LMIC
102#define DECLARE_LMIC extern struct lmic_t LMIC
117int os_init_ex (
const void *pPinMap);
118void os_runloop (
void);
119void os_runloop_once (
void);
120u1_t radio_rssi (
void);
125#ifndef RX_RAMPUP_DEFAULT
131#define RX_RAMPUP_DEFAULT (us2osticks(10000))
139#define TX_RAMPUP (us2osticks(10000))
142#ifndef OSTICKS_PER_SEC
143#define OSTICKS_PER_SEC 32768
144#elif OSTICKS_PER_SEC < 10000 || OSTICKS_PER_SEC > 64516
145#error Illegal OSTICKS_PER_SEC - must be in range [10000:64516]. One tick must be 15.5us .. 100us long.
149#define us2osticks(us) ((ostime_t)( ((int64_t)(us) * OSTICKS_PER_SEC) / 1000000))
150#define ms2osticks(ms) ((ostime_t)( ((int64_t)(ms) * OSTICKS_PER_SEC) / 1000))
151#define sec2osticks(sec) ((ostime_t)( (int64_t)(sec) * OSTICKS_PER_SEC))
152#define osticks2ms(os) ((s4_t)(((os)*(int64_t)1000 ) / OSTICKS_PER_SEC))
153#define osticks2us(os) ((s4_t)(((os)*(int64_t)1000000 ) / OSTICKS_PER_SEC))
155#define us2osticksCeil(us) ((ostime_t)( ((int64_t)(us) * OSTICKS_PER_SEC + 999999) / 1000000))
156#define us2osticksRound(us) ((ostime_t)( ((int64_t)(us) * OSTICKS_PER_SEC + 500000) / 1000000))
157#define ms2osticksCeil(ms) ((ostime_t)( ((int64_t)(ms) * OSTICKS_PER_SEC + 999) / 1000))
158#define ms2osticksRound(ms) ((ostime_t)( ((int64_t)(ms) * OSTICKS_PER_SEC + 500) / 1000))
179static inline int os_jobIsTimed(xref2osjob_t job) {
180 return (job->deadline != 0);
186void os_getDevKey (xref2u1_t buf);
189void os_getArtEui (xref2u1_t buf);
192void os_getDevEui (xref2u1_t buf);
194#ifndef os_setCallback
195void os_setCallback (xref2osjob_t job,
osjobcb_t cb);
197#ifndef os_setTimedCallback
198void os_setTimedCallback (xref2osjob_t job, ostime_t time,
osjobcb_t cb);
200#ifndef os_setIdleJobFunction
203#ifndef os_clearCallback
204void os_clearCallback (xref2osjob_t job);
206#ifndef os_getRadioRxRampup
207ostime_t os_getRadioRxRampup (
void);
210ostime_t os_getTime (
void);
212#ifndef os_getTimeSecs
213uint os_getTimeSecs (
void);
216void os_radio (u1_t mode);
219void os_radio_v2 (u1_t mode, xref2osjob_t job);
221#ifndef os_getBattLevel
222u1_t os_getBattLevel (
void);
224#ifndef os_queryTimeCriticalJobs
235void os_wlsbf4 (xref2u1_t buf, u4_t value);
243void os_wmsbf4 (xref2u1_t buf, u4_t value);
251void os_wlsbf2 (xref2u1_t buf, u2_t value);
256#define os_getRndU2() ((u2_t)((os_getRndU1()<<8)|os_getRndU1()))
259u2_t os_crc16 (xref2cu1_t d, uint len);
276#define RESOLVE_TABLE(table) constant_table_ ## table
279#define LENOF_TABLE(table) (sizeof(RESOLVE_TABLE(table)) / sizeof(RESOLVE_TABLE(table)[0]))
282#define TABLE_GET_U1(table, index) table_get_u1(RESOLVE_TABLE(table), index)
283#define TABLE_GET_S1(table, index) table_get_s1(RESOLVE_TABLE(table), index)
284#define TABLE_GET_U2(table, index) table_get_u2(RESOLVE_TABLE(table), index)
285#define TABLE_GET_S2(table, index) table_get_s2(RESOLVE_TABLE(table), index)
286#define TABLE_GET_U4(table, index) table_get_u4(RESOLVE_TABLE(table), index)
287#define TABLE_GET_S4(table, index) table_get_s4(RESOLVE_TABLE(table), index)
288#define TABLE_GET_OSTIME(table, index) table_get_ostime(RESOLVE_TABLE(table), index)
289#define TABLE_GET_U1_TWODIM(table, index1, index2) table_get_u1(RESOLVE_TABLE(table)[index1], index2)
292 #include <avr/pgmspace.h>
296 #define TABLE_GETTER(postfix, type, pgm_type) \
297 static inline type table_get ## postfix(const type *table, size_t index) { \
298 if (__builtin_constant_p(table[index])) \
299 return table[index]; \
300 return pgm_read_ ## pgm_type(&table[index]); \
303 TABLE_GETTER(_u1, u1_t,
byte);
304 TABLE_GETTER(_s1, s1_t,
byte);
305 TABLE_GETTER(_u2, u2_t, word);
306 TABLE_GETTER(_s2, s2_t, word);
307 TABLE_GETTER(_u4, u4_t, dword);
308 TABLE_GETTER(_s4, s4_t, dword);
311 typedef int check_sizeof_ostime_t[(
sizeof(ostime_t) == 4) ? 0 : -1];
312 TABLE_GETTER(_ostime, ostime_t, dword);
315 #define CONST_TABLE(type, name) const type PROGMEM RESOLVE_TABLE(name)
317 static inline u1_t table_get_u1(
const u1_t *table,
size_t index) {
return table[index]; }
318 static inline s1_t table_get_s1(
const s1_t *table,
size_t index) {
return table[index]; }
319 static inline u2_t table_get_u2(
const u2_t *table,
size_t index) {
return table[index]; }
320 static inline s2_t table_get_s2(
const s2_t *table,
size_t index) {
return table[index]; }
321 static inline u4_t table_get_u4(
const u4_t *table,
size_t index) {
return table[index]; }
322 static inline s4_t table_get_s4(
const s4_t *table,
size_t index) {
return table[index]; }
323 static inline ostime_t table_get_ostime(
const ostime_t *table,
size_t index) {
return table[index]; }
326 #define CONST_TABLE(type, name) const type RESOLVE_TABLE(name)
332#if LMIC_ENABLE_event_logging
333extern void LMICOS_logEvent(
const char *pMessage);
334extern void LMICOS_logEventUint32(
const char *pMessage, uint32_t datum);
336# define LMICOS_logEvent(m) do { ; } while (0)
337# define LMICOS_logEventUint32(m, d) do { ; } while (0)
osjobcbfn_t * osjobcb_t
the pointer-to-function for osjob_t callbacks
Definition oslmic.h:168
u4_t os_rlsbf4(xref2cu1_t buf)
Read 32-bit quantity from given pointer in little endian byte order.
Definition lmic.c:86
void osjobcbfn_t(struct osjob_t *)
the function type for osjob_t callbacks
Definition oslmic.h:165
void os_wmsbf4(xref2u1_t buf, u4_t value)
Write 32-bit quantity into buffer in big endian byte order.
Definition lmic.c:116
u1_t radio_rand1(void)
Generate an 8-bit uniformly-distributed integer.
Definition radio_sx127x.c:1236
void os_wlsbf2(xref2u1_t buf, u2_t value)
Write 16-bit quantity into buffer in little endian byte order.
Definition lmic.c:100
void radio_irq_handler(u1_t dio)
legacy radio IRQ handler
Definition radio_sx127x.c:1361
bit_t os_queryTimeCriticalJobs(ostime_t time)
Return non-zero if any jobs are scheduled between now and now+time.
Definition oslmic.c:182
int radio_init(void)
Initialize radio at system startup.
Definition radio_sx127x.c:1148
void radio_irq_handler_v2(u1_t dio, ostime_t tref)
Radio IRQ handler.
Definition radio_sx127x.c:1386
void radio_monitor_rssi(ostime_t n, oslmic_radio_rssi_t *pRssi)
Measure the current broadband RSSI for the current channel.
Definition radio_sx127x.c:1270
u4_t os_rmsbf4(xref2cu1_t buf)
Read 32-bit quantity from given pointer in big endian byte order.
Definition lmic.c:93
void os_wlsbf4(xref2u1_t buf, u4_t value)
Write 32-bit quantity into buffer in little endian byte order.
Definition lmic.c:107
bit_t os_setIdleJobFunction(osjob_t *job, osjobcb_t cb)
set function in idle job (for future use)
Definition oslmic.c:112
u2_t os_rlsbf2(xref2cu1_t buf)
Read 16-bit quantity from given pointer in little endian byte order.
Definition lmic.c:80
Information about the last and previous beacons.
Definition lmic.h:239