hello world
Fork of lmic_MOTE_L152RC by
Embed:
(wiki syntax)
Show/hide line numbers
oslmic.h
Go to the documentation of this file.
00001 /******************************************************************************* 00002 * Copyright (c) 2014-2015 IBM Corporation. 00003 * All rights reserved. This program and the accompanying materials 00004 * are made available under the terms of the Eclipse Public License v1.0 00005 * which accompanies this distribution, and is available at 00006 * http://www.eclipse.org/legal/epl-v10.html 00007 * 00008 * Contributors: 00009 * IBM Zurich Research Lab - initial API, implementation and documentation 00010 *******************************************************************************/ 00011 00012 //! \file 00013 #ifndef _oslmic_h_ 00014 #define _oslmic_h_ 00015 00016 // Dependencies required for the LoRa MAC in C to run. 00017 // These settings can be adapted to the underlying system. 00018 // You should not, however, change the lmic.[hc] 00019 00020 00021 00022 //================================================================================ 00023 //================================================================================ 00024 // Target platform as C library 00025 typedef unsigned char bit_t; 00026 typedef unsigned char u1_t; 00027 typedef signed char s1_t; 00028 typedef unsigned short u2_t; 00029 typedef short s2_t; 00030 typedef unsigned int u4_t; 00031 typedef int s4_t; 00032 typedef unsigned long long u8_t; 00033 typedef long long s8_t; 00034 typedef unsigned int uint; 00035 typedef const char* str_t; 00036 00037 #include <string.h> 00038 #include "hal.h" 00039 #define EV(a,b,c) /**/ 00040 #define DO_DEVDB(field1,field2) /**/ 00041 #if !defined(CFG_noassert) 00042 #define ASSERT(cond) if(!(cond)) hal_failed() 00043 #else 00044 #define ASSERT(cond) /**/ 00045 #endif 00046 00047 #define os_clearMem(a,b) memset(a,0,b) 00048 #define os_copyMem(a,b,c) memcpy(a,b,c) 00049 00050 typedef struct osjob_t osjob_t; 00051 typedef struct band_t band_t; 00052 typedef struct chnldef_t chnldef_t; 00053 typedef struct rxsched_t rxsched_t; 00054 typedef struct bcninfo_t bcninfo_t; 00055 typedef const u1_t* xref2cu1_t; 00056 typedef u1_t* xref2u1_t; 00057 #define TYPEDEF_xref2rps_t typedef rps_t* xref2rps_t 00058 #define TYPEDEF_xref2rxsched_t typedef rxsched_t* xref2rxsched_t 00059 #define TYPEDEF_xref2chnldef_t typedef chnldef_t* xref2chnldef_t 00060 #define TYPEDEF_xref2band_t typedef band_t* xref2band_t 00061 #define TYPEDEF_xref2osjob_t typedef osjob_t* xref2osjob_t 00062 00063 #define SIZEOFEXPR(x) sizeof(x) 00064 00065 #define ON_LMIC_EVENT(ev) onEvent(ev) 00066 #define DECL_ON_LMIC_EVENT void onEvent(ev_t e) 00067 00068 extern u4_t AESAUX[]; 00069 extern u4_t AESKEY[]; 00070 #define AESkey ((u1_t*)AESKEY) 00071 #define AESaux ((u1_t*)AESAUX) 00072 #define FUNC_ADDR(func) (&(func)) 00073 00074 u1_t radio_rand1 (void); 00075 #define os_getRndU1() radio_rand1() 00076 00077 #define DEFINE_LMIC struct lmic_t LMIC 00078 #define DECLARE_LMIC extern struct lmic_t LMIC 00079 00080 void radio_init (void); 00081 void radio_irq_handler (u1_t dio); 00082 void os_init (void); 00083 void os_runloop (void); 00084 00085 //================================================================================ 00086 00087 00088 #ifndef RX_RAMPUP 00089 #define RX_RAMPUP (us2osticks(2000)) 00090 #endif 00091 #ifndef TX_RAMPUP 00092 #define TX_RAMPUP (us2osticks(2000)) 00093 #endif 00094 00095 /* OSTICKS_PER_SEC is platform specific. Moved to hal.h */ 00096 00097 typedef s4_t ostime_t; 00098 00099 #if !HAS_ostick_conv 00100 #define us2osticks(us) ((ostime_t)( ((s8_t)(us) * OSTICKS_PER_SEC) / 1000000)) 00101 #define ms2osticks(ms) ((ostime_t)( ((s8_t)(ms) * OSTICKS_PER_SEC) / 1000)) 00102 #define sec2osticks(sec) ((ostime_t)( (s8_t)(sec) * OSTICKS_PER_SEC)) 00103 #define osticks2ms(os) ((s4_t)(((os)*(s8_t)1000 ) / OSTICKS_PER_SEC)) 00104 #define osticks2us(os) ((s4_t)(((os)*(s8_t)1000000 ) / OSTICKS_PER_SEC)) 00105 // Special versions 00106 #define us2osticksCeil(us) ((ostime_t)( ((s8_t)(us) * OSTICKS_PER_SEC + 999999) / 1000000)) 00107 #define us2osticksRound(us) ((ostime_t)( ((s8_t)(us) * OSTICKS_PER_SEC + 500000) / 1000000)) 00108 #define ms2osticksCeil(ms) ((ostime_t)( ((s8_t)(ms) * OSTICKS_PER_SEC + 999) / 1000)) 00109 #define ms2osticksRound(ms) ((ostime_t)( ((s8_t)(ms) * OSTICKS_PER_SEC + 500) / 1000)) 00110 #endif 00111 00112 00113 struct osjob_t; // fwd decl. 00114 typedef void (*osjobcb_t) (struct osjob_t*); 00115 struct osjob_t { 00116 struct osjob_t* next; 00117 ostime_t deadline; 00118 osjobcb_t func; 00119 }; 00120 TYPEDEF_xref2osjob_t; 00121 00122 00123 #ifndef HAS_os_calls 00124 00125 #ifndef os_getDevKey 00126 void os_getDevKey (xref2u1_t buf); 00127 #endif 00128 #ifndef os_getArtEui 00129 void os_getArtEui (xref2u1_t buf); 00130 #endif 00131 #ifndef os_getDevEui 00132 void os_getDevEui (xref2u1_t buf); 00133 #endif 00134 #ifndef os_setCallback 00135 void os_setCallback (xref2osjob_t job, osjobcb_t cb); 00136 #endif 00137 #ifndef os_setTimedCallback 00138 void os_setTimedCallback (xref2osjob_t job, ostime_t time, osjobcb_t cb); 00139 #endif 00140 #ifndef os_clearCallback 00141 void os_clearCallback (xref2osjob_t job); 00142 #endif 00143 #ifndef os_getTime 00144 ostime_t os_getTime (void); 00145 #endif 00146 #ifndef os_getTimeSecs 00147 uint os_getTimeSecs (void); 00148 #endif 00149 #ifndef os_radio 00150 void os_radio (u1_t mode); 00151 #endif 00152 #ifndef os_getBattLevel 00153 u1_t os_getBattLevel (void); 00154 #endif 00155 00156 #ifndef os_rlsbf4 00157 //! Read 32-bit quantity from given pointer in little endian byte order. 00158 u4_t os_rlsbf4 (xref2cu1_t buf); 00159 #endif 00160 #ifndef os_wlsbf4 00161 //! Write 32-bit quntity into buffer in little endian byte order. 00162 void os_wlsbf4 (xref2u1_t buf, u4_t value); 00163 #endif 00164 #ifndef os_rmsbf4 00165 //! Read 32-bit quantity from given pointer in big endian byte order. 00166 u4_t os_rmsbf4 (xref2cu1_t buf); 00167 #endif 00168 #ifndef os_wmsbf4 00169 //! Write 32-bit quntity into buffer in big endian byte order. 00170 void os_wmsbf4 (xref2u1_t buf, u4_t value); 00171 #endif 00172 #ifndef os_rlsbf2 00173 //! Read 16-bit quantity from given pointer in little endian byte order. 00174 u2_t os_rlsbf2 (xref2cu1_t buf); 00175 #endif 00176 #ifndef os_wlsbf2 00177 //! Write 16-bit quntity into buffer in little endian byte order. 00178 void os_wlsbf2 (xref2u1_t buf, u2_t value); 00179 #endif 00180 00181 //! Get random number (default impl for u2_t). 00182 #ifndef os_getRndU2 00183 #define os_getRndU2() ((u2_t)((os_getRndU1()<<8)|os_getRndU1())) 00184 #endif 00185 #ifndef os_crc16 00186 u2_t os_crc16 (xref2u1_t d, uint len); 00187 #endif 00188 00189 #endif // !HAS_os_calls 00190 00191 // ====================================================================== 00192 // AES support 00193 // !!Keep in sync with lorabase.hpp!! 00194 00195 #ifndef AES_ENC // if AES_ENC is defined as macro all other values must be too 00196 #define AES_ENC 0x00 00197 #define AES_DEC 0x01 00198 #define AES_MIC 0x02 00199 #define AES_CTR 0x04 00200 #define AES_MICNOAUX 0x08 00201 #endif 00202 #ifndef AESkey // if AESkey is defined as macro all other values must be too 00203 extern xref2u1_t AESkey; 00204 extern xref2u1_t AESaux; 00205 #endif 00206 #ifndef os_aes 00207 u4_t os_aes (u1_t mode, xref2u1_t buf, u2_t len); 00208 #endif 00209 00210 00211 00212 #endif // _oslmic_h_
Generated on Mon Jul 18 2022 04:23:42 by 1.7.2