@@ -107,6 +107,7 @@ modm::Dw3110Phy<SpiMaster, Cs>::initialize(Dw3110::Channel channel, Dw3110::Prea
107
107
RF_CALL (setEnableLongFrames (false ));
108
108
RF_CALL (setSendHeaderFast (false ));
109
109
RF_CALL (setCCATimeout (256 ));
110
+ RF_CALL (reloadSTSIV ());
110
111
RF_END_RETURN (true );
111
112
}
112
113
@@ -1044,9 +1045,11 @@ modm::Dw3110Phy<SpiMaster, Cs>::fetchPacket(std::span<uint8_t> payload, size_t &
1044
1045
if (payload.size () < payload_len) { RF_RETURN (false ); }
1045
1046
RF_CALL (readRegisterBank<Dw3110::RX_BUFFER_0_BANK>(payload, payload_len));
1046
1047
1047
- // Clear RXFR RXPHE RXFCG and RXFCE flag
1048
+ // Clear most rx flags
1048
1049
RF_CALL (clearStatusBits (Dw3110::SystemStatus::RXFR | Dw3110::SystemStatus::RXPHE |
1049
- Dw3110::SystemStatus::RXFCG | Dw3110::SystemStatus::RXFCE));
1050
+ Dw3110::SystemStatus::RXFCG | Dw3110::SystemStatus::RXFCE |
1051
+ Dw3110::SystemStatus::RXSFDD | Dw3110::SystemStatus::RXPRD |
1052
+ Dw3110::SystemStatus::RXPHD | Dw3110::SystemStatus::RXFSL));
1050
1053
RF_END_RETURN (true );
1051
1054
}
1052
1055
@@ -1312,3 +1315,101 @@ modm::Dw3110Phy<SpiMaster, Cs>::setIRQPolarity(bool high)
1312
1315
}
1313
1316
RF_END ();
1314
1317
}
1318
+
1319
+ template <typename SpiMaster, typename Cs>
1320
+ modm::ResumableResult<bool >
1321
+ modm::Dw3110Phy<SpiMaster, Cs>::setSTSLength(uint8_t len)
1322
+ {
1323
+ RF_BEGIN ();
1324
+ if (len < 3 ) { RF_RETURN (false ); }
1325
+ scratch[0 ] = len;
1326
+ RF_CALL (writeRegister<Dw3110::STS_CFG, 1 >(std::span<const uint8_t >(scratch).first <1 >()));
1327
+ RF_END_RETURN (true );
1328
+ }
1329
+
1330
+ template <typename SpiMaster, typename Cs>
1331
+ modm::ResumableResult<void >
1332
+ modm::Dw3110Phy<SpiMaster, Cs>::setSTSMode(Dw3110::STSMode mode, bool sdc)
1333
+ {
1334
+ RF_BEGIN ();
1335
+ scratch[0 ] = ((uint8_t )mode << 4 ) | (sdc ? 0x80 : 0x00 );
1336
+ scratch[1 ] = 0x4F | scratch[0 ];
1337
+ RF_CALL (writeRegisterMasked<Dw3110::SYS_CFG, 1 , 1 >(
1338
+ std::span<const uint8_t >(scratch).first <1 >(),
1339
+ std::span<const uint8_t >(scratch).subspan <1 , 1 >()));
1340
+ RF_END ();
1341
+ }
1342
+
1343
+ template <typename SpiMaster, typename Cs>
1344
+ modm::ResumableResult<uint16_t >
1345
+ modm::Dw3110Phy<SpiMaster, Cs>::getSTSQuality()
1346
+ {
1347
+ RF_BEGIN ();
1348
+ RF_CALL (readRegister<Dw3110::STS_STS, 2 >(std::span<uint8_t >(scratch).first <2 >()));
1349
+ RF_END_RETURN ((uint16_t )(scratch[0 ] << 0 | (scratch[1 ] & 0x0F ) << 8 ));
1350
+ }
1351
+
1352
+ template <typename SpiMaster, typename Cs>
1353
+ modm::ResumableResult<bool >
1354
+ modm::Dw3110Phy<SpiMaster, Cs>::getSTSGood()
1355
+ {
1356
+ RF_BEGIN ();
1357
+ RF_CALL (readRegister<Dw3110::STS_CFG, 1 >(std::span<uint8_t >(scratch).first <1 >()));
1358
+ RF_CALL (readRegister<Dw3110::STS_STS, 2 >(std::span<uint8_t >(scratch).subspan <1 , 2 >()));
1359
+ RF_END_RETURN ((scratch[0 ] + 1 ) * 8 .0f * 0 .6f < (scratch[1 ] | (scratch[2 ] << 8 )));
1360
+ }
1361
+
1362
+ template <typename SpiMaster, typename Cs>
1363
+ modm::ResumableResult<void >
1364
+ modm::Dw3110Phy<SpiMaster, Cs>::setSTSKey(std::span<const uint8_t , 16 > key)
1365
+ {
1366
+ return writeRegister<Dw3110::STS_KEY, 16 , 0 >(key);
1367
+ }
1368
+
1369
+ template <typename SpiMaster, typename Cs>
1370
+ modm::ResumableResult<void >
1371
+ modm::Dw3110Phy<SpiMaster, Cs>::setSTSIV(std::span<const uint8_t , 16 > iv)
1372
+ {
1373
+ return writeRegister<Dw3110::STS_IV, 16 , 0 >(iv);
1374
+ }
1375
+
1376
+ template <typename SpiMaster, typename Cs>
1377
+ modm::ResumableResult<void >
1378
+ modm::Dw3110Phy<SpiMaster, Cs>::getSTSKey(std::span<uint8_t , 16 > key)
1379
+ {
1380
+ return readRegister<Dw3110::STS_KEY, 16 , 0 >(key);
1381
+ }
1382
+
1383
+ template <typename SpiMaster, typename Cs>
1384
+ modm::ResumableResult<void >
1385
+ modm::Dw3110Phy<SpiMaster, Cs>::getSTSIV(std::span<uint8_t , 16 > iv)
1386
+ {
1387
+ return readRegister<Dw3110::STS_IV, 16 , 0 >(iv);
1388
+ }
1389
+
1390
+ template <typename SpiMaster, typename Cs>
1391
+ modm::ResumableResult<uint32_t >
1392
+ modm::Dw3110Phy<SpiMaster, Cs>::getCurrentCounter()
1393
+ {
1394
+ RF_BEGIN ();
1395
+ RF_CALL (readRegister<Dw3110::CTR_DBG, 4 , 0 >(std::span<uint8_t >(scratch).first <4 >()));
1396
+ RF_END_RETURN ((uint32_t )scratch[0 ] | (uint32_t )scratch[1 ] << 8 | (uint32_t )scratch[2 ] << 16 |
1397
+ (uint32_t )scratch[3 ] << 24 );
1398
+ }
1399
+
1400
+ template <typename SpiMaster, typename Cs>
1401
+ modm::ResumableResult<void >
1402
+ modm::Dw3110Phy<SpiMaster, Cs>::reloadSTSIV()
1403
+ {
1404
+ constexpr static uint8_t sts_ctrl[] = {0x01 };
1405
+ return writeRegister<Dw3110::STS_CTRL, 1 >(sts_ctrl);
1406
+ }
1407
+
1408
+ template <typename SpiMaster, typename Cs>
1409
+ modm::ResumableResult<void >
1410
+ modm::Dw3110Phy<SpiMaster, Cs>::reuseLastSTSIV()
1411
+ {
1412
+
1413
+ constexpr static uint8_t sts_ctrl[] = {0x02 };
1414
+ return writeRegister<Dw3110::STS_CTRL, 1 >(sts_ctrl);
1415
+ }
0 commit comments