From 280265c566fb430eb6947c64a7f9c4153b0e47d6 Mon Sep 17 00:00:00 2001 From: Friedl Ulrich Date: Sun, 8 Feb 2015 22:15:34 +0100 Subject: [PATCH] Power handling --- rfm69device.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rfm69device.go b/rfm69device.go index 2ff23a1..e1c5d92 100644 --- a/rfm69device.go +++ b/rfm69device.go @@ -196,18 +196,18 @@ func (r *Device) SetMode(newMode byte) error { return nil } - err := r.readWriteReg(REG_OPMODE, 0xE3, newMode) - if err != nil { - return err - } - if r.isRFM69HW && (newMode == RF_OPMODE_RECEIVER || newMode == RF_OPMODE_TRANSMITTER) { - err = r.setHighPowerRegs(newMode == RF_OPMODE_TRANSMITTER) + err := r.setHighPowerRegs(newMode == RF_OPMODE_TRANSMITTER) if err != nil { return err } } + err := r.readWriteReg(REG_OPMODE, 0xE3, newMode) + if err != nil { + return err + } + // we are using packet mode, so this check is not really needed // but waiting for mode ready is necessary when going from sleep because the FIFO may not be immediately available from previous mode if r.mode == RF_OPMODE_SLEEP {