driver for sx1280
Dependents: alarm_slave_extended_SX1280 alarm_master_extended_Vance_SX1280
Diff: sx1280.cpp
- Revision:
- 5:aba2d8b29702
- Parent:
- 4:ac55132283cb
- Child:
- 7:aa7047cdf47b
diff -r ac55132283cb -r aba2d8b29702 sx1280.cpp --- a/sx1280.cpp Wed Jul 18 18:07:29 2018 -0700 +++ b/sx1280.cpp Tue Aug 21 17:16:12 2018 -0700 @@ -211,6 +211,34 @@ chipModeChange.call(); } +void SX128x::setCAD() +{ + IrqFlags_t irqEnable; + uint8_t buf[8]; + + irqEnable.word = 0; + irqEnable.bits.CadDone = 1; + irqEnable.bits.CadDetected = 1; + irqEnable.bits.RxDone = 1; + irqEnable.bits.RxTxTimeout = 1; + + buf[0] = irqEnable.word >> 8; // enable bits + buf[1] = irqEnable.word; // enable bits + buf[2] = irqEnable.word >> 8; // dio1 + buf[3] = irqEnable.word; // dio1 + buf[4] = 0; // dio2 + buf[5] = 0; // dio2 + buf[6] = 0; // dio3 + buf[7] = 0; // dio3 + xfer(OPCODE_SET_DIO_IRQ_PARAMS, 8, 0, buf); + + xfer(OPCODE_SET_CAD, 0, 0, NULL); + + chipMode = CHIPMODE_RX; + if (chipModeChange) + chipModeChange.call(); +} + void SX128x::setFS() { xfer(OPCODE_SET_FS, 0, 0, NULL); @@ -369,6 +397,14 @@ clearIrqFlags.bits.RxTxTimeout = 1; } + if (irqFlags.bits.CadDone) { + if (cadDone) + cadDone(irqFlags.bits.CadDetected ); + + clearIrqFlags.bits.CadDone = 1; + clearIrqFlags.bits.CadDetected = irqFlags.bits.CadDetected; + } + if (clearIrqFlags.word != 0) { buf[0] = clearIrqFlags.word >> 8; buf[1] = (uint8_t)clearIrqFlags.word;