@@ -166,11 +166,16 @@ Sx128x< Transport, Busy >::setTx(PeriodBase periodBase, uint16_t periodBaseCount
166
166
{
167
167
RF_BEGIN ();
168
168
169
+ // Clear IRQ status before using this command
170
+ RF_CALL (clearIrqStatus (Irq_t (0xFF )));
171
+
169
172
buffer[0 ] = uint8_t (periodBase);
170
173
buffer[1 ] = (periodBaseCount >> 8 ) & 0xFF ;
171
174
buffer[2 ] = periodBaseCount & 0xFF ;
172
175
RF_WAIT_WHILE (isBusy ());
173
176
177
+ // / TODO: Determine if ranging role should be set here
178
+
174
179
RF_END_RETURN_CALL (this ->writeCommand (Opcode::SetTx, std::span{buffer, 3 }));
175
180
}
176
181
@@ -182,11 +187,16 @@ Sx128x< Transport, Busy >::setRx(PeriodBase periodBase, uint16_t periodBaseCount
182
187
{
183
188
RF_BEGIN ();
184
189
190
+ // Clear IRQ status before using this command
191
+ RF_CALL (clearIrqStatus (Irq_t (0xFF )));
192
+
185
193
buffer[0 ] = uint8_t (periodBase);
186
194
buffer[1 ] = (periodBaseCount >> 8 ) & 0xFF ;
187
195
buffer[2 ] = periodBaseCount & 0xFF ;
188
196
RF_WAIT_WHILE (isBusy ());
189
197
198
+ // / TODO: Determine if ranging role should be set here
199
+
190
200
RF_END_RETURN_CALL (this ->writeCommand (Opcode::SetRx, std::span{buffer, 3 }) );
191
201
}
192
202
@@ -302,7 +312,8 @@ Sx128x< Transport, Busy >::setTxParams(uint8_t power, RampTime rampTime)
302
312
{
303
313
RF_BEGIN ();
304
314
305
- buffer[0 ] = power;
315
+ // Compenstate for offset Pout = 18 – power
316
+ buffer[0 ] = 18 + power;
306
317
buffer[1 ] = uint8_t (rampTime);
307
318
RF_WAIT_WHILE (isBusy ());
308
319
@@ -374,6 +385,8 @@ Sx128x< Transport, Busy >::getRxBufferStatus(RxBufferStatus *rxBufferStatus)
374
385
375
386
RF_WAIT_WHILE (isBusy ());
376
387
388
+ // / TODO: Determine if logic is different for different packet types
389
+
377
390
RF_END_RETURN_CALL (this ->readCommand (Opcode::GetRxBufferStatus, std::span{(uint8_t *) rxBufferStatus, 2 }));
378
391
}
379
392
@@ -387,6 +400,8 @@ Sx128x< Transport, Busy >::getPacketStatus(PacketStatus *packetStatus)
387
400
388
401
RF_WAIT_WHILE (isBusy ());
389
402
403
+ // / TODO: Determine if logic is different for different packet types
404
+
390
405
RF_END_RETURN_CALL (this ->readCommand (Opcode::GetPacketStatus, std::span{(uint8_t *) packetStatus, 5 }));
391
406
}
392
407
@@ -509,10 +524,13 @@ template < class Transport, class Busy >
509
524
modm::ResumableResult<bool >
510
525
Sx128x< Transport, Busy >::setAutoTx(uint16_t time)
511
526
{
527
+ // / The delay between reception end and transmission start is offset by 33 us
528
+ uint16_t delay = time - 33 ;
529
+
512
530
RF_BEGIN ();
513
531
514
- buffer[0 ] = (time >> 8 ) & 0xFF ;
515
- buffer[1 ] = time & 0xFF ;
532
+ buffer[0 ] = (delay >> 8 ) & 0xFF ;
533
+ buffer[1 ] = delay & 0xFF ;
516
534
RF_WAIT_WHILE (isBusy ());
517
535
518
536
RF_END_RETURN_CALL (this ->writeCommand (Opcode::SetAutoTx, std::span{buffer, 2 }));
0 commit comments