Skip to content

Commit acb75c5

Browse files
Use macros for all constant table definitions and lookups
This should not change any behaviour right now, but makes it easier to introduce custom constant lookup code in a single spot (e.g. to put tables in PROGMEM on AVR). To prevent accidental direct access of the tables, their name is mangled by the macros. To prevent using the wrong accessor macro (for another array element type), the accessor macros use an inline function to actually return the values. Note that the generated code is not totally identical, since the inline functions seem to cause gcc to take different optimization decisions. On AVR, this commit actually shrinks the compiled program by hundred bytes or so.
1 parent 06aa91d commit acb75c5

File tree

5 files changed

+82
-47
lines changed

5 files changed

+82
-47
lines changed

src/lmic/aes.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
#define AES_MICSUB 0x30 // internal use only
1515

16-
static const u4_t AES_RCON[10] = {
16+
static CONST_TABLE(u4_t, AES_RCON)[10] = {
1717
0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
1818
0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000
1919
};
2020

21-
static const u1_t AES_S[256] = {
21+
static CONST_TABLE(u1_t, AES_S)[256] = {
2222
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
2323
0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
2424
0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
@@ -37,7 +37,7 @@ static const u1_t AES_S[256] = {
3737
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16,
3838
};
3939

40-
static const u4_t AES_E1[256] = {
40+
static CONST_TABLE(u4_t, AES_E1)[256] = {
4141
0xC66363A5, 0xF87C7C84, 0xEE777799, 0xF67B7B8D, 0xFFF2F20D, 0xD66B6BBD, 0xDE6F6FB1, 0x91C5C554,
4242
0x60303050, 0x02010103, 0xCE6767A9, 0x562B2B7D, 0xE7FEFE19, 0xB5D7D762, 0x4DABABE6, 0xEC76769A,
4343
0x8FCACA45, 0x1F82829D, 0x89C9C940, 0xFA7D7D87, 0xEFFAFA15, 0xB25959EB, 0x8E4747C9, 0xFBF0F00B,
@@ -72,7 +72,7 @@ static const u4_t AES_E1[256] = {
7272
0x824141C3, 0x299999B0, 0x5A2D2D77, 0x1E0F0F11, 0x7BB0B0CB, 0xA85454FC, 0x6DBBBBD6, 0x2C16163A,
7373
};
7474

75-
static const u4_t AES_E2[256] = {
75+
static CONST_TABLE(u4_t, AES_E2)[256] = {
7676
0xA5C66363, 0x84F87C7C, 0x99EE7777, 0x8DF67B7B, 0x0DFFF2F2, 0xBDD66B6B, 0xB1DE6F6F, 0x5491C5C5,
7777
0x50603030, 0x03020101, 0xA9CE6767, 0x7D562B2B, 0x19E7FEFE, 0x62B5D7D7, 0xE64DABAB, 0x9AEC7676,
7878
0x458FCACA, 0x9D1F8282, 0x4089C9C9, 0x87FA7D7D, 0x15EFFAFA, 0xEBB25959, 0xC98E4747, 0x0BFBF0F0,
@@ -107,7 +107,7 @@ static const u4_t AES_E2[256] = {
107107
0xC3824141, 0xB0299999, 0x775A2D2D, 0x111E0F0F, 0xCB7BB0B0, 0xFCA85454, 0xD66DBBBB, 0x3A2C1616,
108108
};
109109

110-
static const u4_t AES_E3[256] = {
110+
static CONST_TABLE(u4_t, AES_E3)[256] = {
111111
0x63A5C663, 0x7C84F87C, 0x7799EE77, 0x7B8DF67B, 0xF20DFFF2, 0x6BBDD66B, 0x6FB1DE6F, 0xC55491C5,
112112
0x30506030, 0x01030201, 0x67A9CE67, 0x2B7D562B, 0xFE19E7FE, 0xD762B5D7, 0xABE64DAB, 0x769AEC76,
113113
0xCA458FCA, 0x829D1F82, 0xC94089C9, 0x7D87FA7D, 0xFA15EFFA, 0x59EBB259, 0x47C98E47, 0xF00BFBF0,
@@ -142,7 +142,7 @@ static const u4_t AES_E3[256] = {
142142
0x41C38241, 0x99B02999, 0x2D775A2D, 0x0F111E0F, 0xB0CB7BB0, 0x54FCA854, 0xBBD66DBB, 0x163A2C16,
143143
};
144144

145-
static const u4_t AES_E4[256] = {
145+
static CONST_TABLE(u4_t, AES_E4)[256] = {
146146
0x6363A5C6, 0x7C7C84F8, 0x777799EE, 0x7B7B8DF6, 0xF2F20DFF, 0x6B6BBDD6, 0x6F6FB1DE, 0xC5C55491,
147147
0x30305060, 0x01010302, 0x6767A9CE, 0x2B2B7D56, 0xFEFE19E7, 0xD7D762B5, 0xABABE64D, 0x76769AEC,
148148
0xCACA458F, 0x82829D1F, 0xC9C94089, 0x7D7D87FA, 0xFAFA15EF, 0x5959EBB2, 0x4747C98E, 0xF0F00BFB,
@@ -188,16 +188,16 @@ static const u4_t AES_E4[256] = {
188188
r3 = ki[i+3]; \
189189
r0 = ki[i]
190190

191-
#define AES_expr4(r1,r2,r3,r0,i) r1 ^= AES_E4[u1(i)]; \
192-
r2 ^= AES_E3[u1(i>>8)]; \
193-
r3 ^= AES_E2[u1(i>>16)]; \
194-
r0 ^= AES_E1[ (i>>24)]
191+
#define AES_expr4(r1,r2,r3,r0,i) r1 ^= TABLE_GET_U4(AES_E4, u1(i)); \
192+
r2 ^= TABLE_GET_U4(AES_E3, u1(i>>8)); \
193+
r3 ^= TABLE_GET_U4(AES_E2, u1(i>>16)); \
194+
r0 ^= TABLE_GET_U4(AES_E1, (i>>24))
195195

196196
#define AES_expr(a,r0,r1,r2,r3,i) a = ki[i]; \
197-
a ^= ((u4_t)AES_S[ r0>>24 ]<<24); \
198-
a ^= ((u4_t)AES_S[u1(r1>>16)]<<16); \
199-
a ^= ((u4_t)AES_S[u1(r2>> 8)]<< 8); \
200-
a ^= (u4_t)AES_S[u1(r3) ]
197+
a ^= ((u4_t)TABLE_GET_U1(AES_S, r0>>24 )<<24); \
198+
a ^= ((u4_t)TABLE_GET_U1(AES_S, u1(r1>>16))<<16); \
199+
a ^= ((u4_t)TABLE_GET_U1(AES_S, u1(r2>> 8))<< 8); \
200+
a ^= (u4_t)TABLE_GET_U1(AES_S, u1(r3) )
201201

202202
// global area for passing parameters (aux, key) and for storing round keys
203203
u4_t AESAUX[16/sizeof(u4_t)];
@@ -217,11 +217,11 @@ static void aesroundkeys () {
217217
for( ; i<44; i++ ) {
218218
if( i%4==0 ) {
219219
// b = SubWord(RotWord(b)) xor Rcon[i/4]
220-
b = ((u4_t)AES_S[u1(b >> 16)] << 24) ^
221-
((u4_t)AES_S[u1(b >> 8)] << 16) ^
222-
((u4_t)AES_S[u1(b) ] << 8) ^
223-
((u4_t)AES_S[ b >> 24 ] ) ^
224-
AES_RCON[(i-4)/4];
220+
b = ((u4_t)TABLE_GET_U1(AES_S, u1(b >> 16)) << 24) ^
221+
((u4_t)TABLE_GET_U1(AES_S, u1(b >> 8)) << 16) ^
222+
((u4_t)TABLE_GET_U1(AES_S, u1(b) ) << 8) ^
223+
((u4_t)TABLE_GET_U1(AES_S, b >> 24 ) ) ^
224+
TABLE_GET_U4(AES_RCON, (i-4)/4);
225225
}
226226
AESKEY[i] = b ^= AESKEY[i-4];
227227
}

src/lmic/lmic.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ static void aes_sessKeys (u2_t devnonce, xref2cu1_t artnonce, xref2u1_t nwkkey,
211211

212212
#if defined(CFG_eu868) // ========================================
213213

214-
#define maxFrameLen(dr) ((dr)<=DR_SF9 ? maxFrameLens[(dr)] : 0xFF)
215-
const u1_t maxFrameLens [] = { 64,64,64,123 };
214+
#define maxFrameLen(dr) ((dr)<=DR_SF9 ? TABLE_GET_U1(maxFrameLens, (dr)) : 0xFF)
215+
CONST_TABLE(u1_t, maxFrameLens) [] = { 64,64,64,123 };
216216

217-
const u1_t _DR2RPS_CRC[] = {
217+
CONST_TABLE(u1_t, _DR2RPS_CRC)[] = {
218218
ILLEGAL_RPS,
219219
(u1_t)MAKERPS(SF12, BW125, CR_4_5, 0, 0),
220220
(u1_t)MAKERPS(SF11, BW125, CR_4_5, 0, 0),
@@ -227,17 +227,17 @@ const u1_t _DR2RPS_CRC[] = {
227227
ILLEGAL_RPS
228228
};
229229

230-
static const s1_t TXPOWLEVELS[] = {
230+
static CONST_TABLE(s1_t, TXPOWLEVELS)[] = {
231231
20, 14, 11, 8, 5, 2, 0,0, 0,0,0,0, 0,0,0,0
232232
};
233-
#define pow2dBm(mcmd_ladr_p1) (TXPOWLEVELS[(mcmd_ladr_p1&MCMD_LADR_POW_MASK)>>MCMD_LADR_POW_SHIFT])
233+
#define pow2dBm(mcmd_ladr_p1) (TABLE_GET_S1(TXPOWLEVELS, (mcmd_ladr_p1&MCMD_LADR_POW_MASK)>>MCMD_LADR_POW_SHIFT))
234234

235235
#elif defined(CFG_us915) // ========================================
236236

237-
#define maxFrameLen(dr) ((dr)<=DR_SF11CR ? maxFrameLens[(dr)] : 0xFF)
238-
const u1_t maxFrameLens [] = { 24,66,142,255,255,255,255,255, 66,142 };
237+
#define maxFrameLen(dr) ((dr)<=DR_SF11CR ? TABLE_GET_U1(maxFrameLens, (dr)) : 0xFF)
238+
CONST_TABLE(u1_t, maxFrameLens) [] = { 24,66,142,255,255,255,255,255, 66,142 };
239239

240-
const u1_t _DR2RPS_CRC[] = {
240+
CONST_TABLE(u1_t, _DR2RPS_CRC)[] = {
241241
ILLEGAL_RPS,
242242
MAKERPS(SF10, BW125, CR_4_5, 0, 0),
243243
MAKERPS(SF9 , BW125, CR_4_5, 0, 0),
@@ -260,7 +260,7 @@ const u1_t _DR2RPS_CRC[] = {
260260

261261
#endif // ================================================
262262

263-
static const u1_t SENSITIVITY[7][3] = {
263+
static CONST_TABLE(u1_t, SENSITIVITY)[7][3] = {
264264
// ------------bw----------
265265
// 125kHz 250kHz 500kHz
266266
{ 141-109, 141-109, 141-109 }, // FSK
@@ -273,7 +273,7 @@ static const u1_t SENSITIVITY[7][3] = {
273273
};
274274

275275
int getSensitivity (rps_t rps) {
276-
return -141 + SENSITIVITY[getSf(rps)][getBw(rps)];
276+
return -141 + TABLE_GET_U1_TWODIM(SENSITIVITY, getSf(rps), getBw(rps));
277277
}
278278

279279
ostime_t calcAirTime (rps_t rps, u1_t plen) {
@@ -344,7 +344,7 @@ extern inline int sameSfBw (rps_t r1, rps_t r2);
344344
// Adjust DR for TX retries
345345
// - indexed by retry count
346346
// - return steps to lower DR
347-
static const u1_t DRADJUST[2+TXCONF_ATTEMPTS] = {
347+
static CONST_TABLE(u1_t, DRADJUST)[2+TXCONF_ATTEMPTS] = {
348348
// normal frames - 1st try / no retry
349349
0,
350350
// confirmed frames
@@ -363,9 +363,9 @@ static const u1_t DRADJUST[2+TXCONF_ATTEMPTS] = {
363363
//
364364
// Times for half symbol per DR
365365
// Per DR table to minimize rounding errors
366-
static const ostime_t DR2HSYM_osticks[] = {
366+
static CONST_TABLE(ostime_t, DR2HSYM_osticks)[] = {
367367
#if defined(CFG_eu868)
368-
#define dr2hsym(dr) (DR2HSYM_osticks[(dr)])
368+
#define dr2hsym(dr) (TABLE_GET_OSTIME(DR2HSYM_osticks, (dr)))
369369
us2osticksRound(128<<7), // DR_SF12
370370
us2osticksRound(128<<6), // DR_SF11
371371
us2osticksRound(128<<5), // DR_SF10
@@ -375,7 +375,7 @@ static const ostime_t DR2HSYM_osticks[] = {
375375
us2osticksRound(128<<1), // DR_SF7B
376376
us2osticksRound(80) // FSK -- not used (time for 1/2 byte)
377377
#elif defined(CFG_us915)
378-
#define dr2hsym(dr) (DR2HSYM_osticks[(dr)&7]) // map DR_SFnCR -> 0-6
378+
#define dr2hsym(dr) (TABLE_GET_OSTIME(DR2HSYM_osticks, (dr)&7)) // map DR_SFnCR -> 0-6
379379
us2osticksRound(128<<5), // DR_SF10 DR_SF12CR
380380
us2osticksRound(128<<4), // DR_SF9 DR_SF11CR
381381
us2osticksRound(128<<3), // DR_SF8 DR_SF10CR
@@ -527,7 +527,7 @@ void LMIC_setPingable (u1_t intvExp) {
527527
// BEG: EU868 related stuff
528528
//
529529
enum { NUM_DEFAULT_CHANNELS=6 };
530-
static const u4_t iniChannelFreq[12] = {
530+
static CONST_TABLE(u4_t, iniChannelFreq)[12] = {
531531
// Join frequencies and duty cycle limit (0.1%)
532532
EU868_F1|BAND_MILLI, EU868_J4|BAND_MILLI,
533533
EU868_F2|BAND_MILLI, EU868_J5|BAND_MILLI,
@@ -545,7 +545,7 @@ static void initDefaultChannels (bit_t join) {
545545
LMIC.channelMap = 0x3F;
546546
u1_t su = join ? 0 : 6;
547547
for( u1_t fu=0; fu<6; fu++,su++ ) {
548-
LMIC.channelFreq[fu] = iniChannelFreq[su];
548+
LMIC.channelFreq[fu] = TABLE_GET_U4(iniChannelFreq, su);
549549
LMIC.channelDrMap[fu] = DR_RANGE_MAP(DR_SF12,DR_SF7);
550550
}
551551
if( !join ) {
@@ -1564,7 +1564,7 @@ static void buildDataFrame (void) {
15641564
e_.eui = MAIN::CDEV->getEui(),
15651565
e_.info = LMIC.seqnoUp-1,
15661566
e_.info2 = ((LMIC.txCnt+1) |
1567-
(DRADJUST[LMIC.txCnt+1] << 8) |
1567+
(TABLE_GET_U1(DRADJUST, LMIC.txCnt+1) << 8) |
15681568
((LMIC.datarate|DR_PAGE)<<16))));
15691569
}
15701570
os_wlsbf2(LMIC.frame+OFF_DAT_SEQNO, LMIC.seqnoUp-1);
@@ -1747,7 +1747,7 @@ static bit_t processDnData (void) {
17471747
if( LMIC.txCnt != 0 ) {
17481748
if( LMIC.txCnt < TXCONF_ATTEMPTS ) {
17491749
LMIC.txCnt += 1;
1750-
setDrTxpow(DRCHG_NOACK, lowerDR(LMIC.datarate, DRADJUST[LMIC.txCnt]), KEEP_TXPOW);
1750+
setDrTxpow(DRCHG_NOACK, lowerDR(LMIC.datarate, TABLE_GET_U1(DRADJUST, LMIC.txCnt)), KEEP_TXPOW);
17511751
// Schedule another retransmission
17521752
txDelay(LMIC.rxtime, RETRY_PERIOD_secs);
17531753
LMIC.opmode &= ~OP_TXRXPEND;

src/lmic/lorabase.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,15 @@ inline rps_t makeRps (sf_t sf, bw_t bw, cr_t cr, int ih, int nocrc) {
361361
// Two frames with params r1/r2 would interfere on air: same SFx + BWx
362362
inline int sameSfBw(rps_t r1, rps_t r2) { return ((r1^r2)&0x1F) == 0; }
363363

364-
extern const u1_t _DR2RPS_CRC[];
365-
inline rps_t updr2rps (dr_t dr) { return (rps_t)_DR2RPS_CRC[dr+1]; }
364+
extern CONST_TABLE(u1_t, _DR2RPS_CRC)[];
365+
inline rps_t updr2rps (dr_t dr) { return (rps_t)TABLE_GET_U1(_DR2RPS_CRC, dr+1); }
366366
inline rps_t dndr2rps (dr_t dr) { return setNocrc(updr2rps(dr),1); }
367367
inline int isFasterDR (dr_t dr1, dr_t dr2) { return dr1 > dr2; }
368368
inline int isSlowerDR (dr_t dr1, dr_t dr2) { return dr1 < dr2; }
369-
inline dr_t incDR (dr_t dr) { return _DR2RPS_CRC[dr+2]==ILLEGAL_RPS ? dr : (dr_t)(dr+1); } // increase data rate
370-
inline dr_t decDR (dr_t dr) { return _DR2RPS_CRC[dr ]==ILLEGAL_RPS ? dr : (dr_t)(dr-1); } // decrease data rate
371-
inline dr_t assertDR (dr_t dr) { return _DR2RPS_CRC[dr+1]==ILLEGAL_RPS ? DR_DFLTMIN : dr; } // force into a valid DR
372-
inline bit_t validDR (dr_t dr) { return _DR2RPS_CRC[dr+1]!=ILLEGAL_RPS; } // in range
369+
inline dr_t incDR (dr_t dr) { return TABLE_GET_U1(_DR2RPS_CRC, dr+2)==ILLEGAL_RPS ? dr : (dr_t)(dr+1); } // increase data rate
370+
inline dr_t decDR (dr_t dr) { return TABLE_GET_U1(_DR2RPS_CRC, dr )==ILLEGAL_RPS ? dr : (dr_t)(dr-1); } // decrease data rate
371+
inline dr_t assertDR (dr_t dr) { return TABLE_GET_U1(_DR2RPS_CRC, dr+1)==ILLEGAL_RPS ? DR_DFLTMIN : dr; } // force into a valid DR
372+
inline bit_t validDR (dr_t dr) { return TABLE_GET_U1(_DR2RPS_CRC, dr+1)!=ILLEGAL_RPS; } // in range
373373
inline dr_t lowerDR (dr_t dr, u1_t n) { while(n--){dr=decDR(dr);} return dr; } // decrease data rate by n steps
374374

375375
//

src/lmic/oslmic.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,41 @@ u2_t os_crc16 (xref2u1_t d, uint len);
198198

199199
#endif // !HAS_os_calls
200200

201+
// ======================================================================
202+
// Table support
203+
// These macros for defining a table of constants and retrieving values
204+
// from it makes it easier for other platforms (like AVR) to optimize
205+
// table accesses.
206+
// Use CONST_TABLE() whenever declaring or defining a table, and
207+
// TABLE_GET_xx whenever accessing its values. The actual name of the
208+
// declared variable will be modified to prevent accidental direct
209+
// access. The accessor macros forward to an inline function to allow
210+
// proper type checking of the array element type.
211+
212+
// Helper to add a prefix to the table name
213+
#define RESOLVE_TABLE(table) constant_table_ ## table
214+
215+
// Accessors for table elements
216+
#define TABLE_GET_U1(table, index) table_get_u1(RESOLVE_TABLE(table), index)
217+
#define TABLE_GET_S1(table, index) table_get_s1(RESOLVE_TABLE(table), index)
218+
#define TABLE_GET_U2(table, index) table_get_u2(RESOLVE_TABLE(table), index)
219+
#define TABLE_GET_S2(table, index) table_get_s2(RESOLVE_TABLE(table), index)
220+
#define TABLE_GET_U4(table, index) table_get_u4(RESOLVE_TABLE(table), index)
221+
#define TABLE_GET_S4(table, index) table_get_s4(RESOLVE_TABLE(table), index)
222+
#define TABLE_GET_OSTIME(table, index) table_get_ostime(RESOLVE_TABLE(table), index)
223+
#define TABLE_GET_U1_TWODIM(table, index1, index2) table_get_u1(RESOLVE_TABLE(table)[index1], index2)
224+
225+
inline u1_t table_get_u1(const u1_t *table, size_t index) { return table[index]; }
226+
inline s1_t table_get_s1(const s1_t *table, size_t index) { return table[index]; }
227+
inline u2_t table_get_u2(const u2_t *table, size_t index) { return table[index]; }
228+
inline s2_t table_get_s2(const s2_t *table, size_t index) { return table[index]; }
229+
inline u4_t table_get_u4(const u4_t *table, size_t index) { return table[index]; }
230+
inline s4_t table_get_s4(const s4_t *table, size_t index) { return table[index]; }
231+
inline ostime_t table_get_ostime(const ostime_t *table, size_t index) { return table[index]; }
232+
233+
// Declare a table
234+
#define CONST_TABLE(type, name) const type RESOLVE_TABLE(name)
235+
201236
// ======================================================================
202237
// AES support
203238
// !!Keep in sync with lorabase.hpp!!

src/lmic/radio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static void starttx () {
520520

521521
enum { RXMODE_SINGLE, RXMODE_SCAN, RXMODE_RSSI };
522522

523-
static const u1_t rxlorairqmask[] = {
523+
static CONST_TABLE(u1_t, rxlorairqmask)[] = {
524524
[RXMODE_SINGLE] = IRQ_LORA_RXDONE_MASK|IRQ_LORA_RXTOUT_MASK,
525525
[RXMODE_SCAN] = IRQ_LORA_RXDONE_MASK,
526526
[RXMODE_RSSI] = 0x00,
@@ -559,7 +559,7 @@ static void rxlora (u1_t rxmode) {
559559
// clear all radio IRQ flags
560560
writeReg(LORARegIrqFlags, 0xFF);
561561
// enable required radio IRQs
562-
writeReg(LORARegIrqFlagsMask, ~rxlorairqmask[rxmode]);
562+
writeReg(LORARegIrqFlagsMask, ~TABLE_GET_U1(rxlorairqmask, rxmode));
563563

564564
// enable antenna switch for RX
565565
hal_pin_rxtx(0);
@@ -717,7 +717,7 @@ u1_t radio_rssi () {
717717
return r;
718718
}
719719

720-
static const u2_t LORA_RXDONE_FIXUP[] = {
720+
static CONST_TABLE(u2_t, LORA_RXDONE_FIXUP)[] = {
721721
[FSK] = us2osticks(0), // ( 0 ticks)
722722
[SF7] = us2osticks(0), // ( 0 ticks)
723723
[SF8] = us2osticks(1648), // ( 54 ticks)
@@ -739,7 +739,7 @@ void radio_irq_handler (u1_t dio) {
739739
} else if( flags & IRQ_LORA_RXDONE_MASK ) {
740740
// save exact rx time
741741
if(getBw(LMIC.rps) == BW125) {
742-
now -= LORA_RXDONE_FIXUP[getSf(LMIC.rps)];
742+
now -= TABLE_GET_U2(LORA_RXDONE_FIXUP, getSf(LMIC.rps));
743743
}
744744
LMIC.rxtime = now;
745745
// read the PDU and inform the MAC that we received something

0 commit comments

Comments
 (0)