diff --git a/librfm.c b/librfm.c index db96cf5..991aae1 100644 --- a/librfm.c +++ b/librfm.c @@ -72,7 +72,7 @@ } } -void rfmInit(uint64_t freq, uint8_t node) { +bool rfmInit(uint64_t freq, uint8_t node) { // wait a bit after power on _rfmDelay5(); _rfmDelay5(); @@ -82,9 +82,12 @@ _rfmDelay5(); - // uint8_t version = regRead(0x10); + uint8_t version = regRead(0x10); // printString("Version: "); // printHex(version); + if (version == 0x00) { + return false; + } // packet mode, FSK modulation, no shaping (default) regWrite(DATA_MOD, 0x00); @@ -180,6 +183,8 @@ regWrite(TEST_DAGC, 0x30); // printString("Radio init done\r\n"); + + return true; } void rfmIrq(void) { diff --git a/librfm.h b/librfm.h index f921684..4db5714 100644 --- a/librfm.h +++ b/librfm.h @@ -124,9 +124,11 @@ /** * Initializes the radio module with the given carrier frequency in kilohertz - * and node address. + * and node address. Returns true on success, false otherwise. + * + * @return success */ -void rfmInit(uint64_t freq, uint8_t node); +bool rfmInit(uint64_t freq, uint8_t node); /** * Reads interrupt flags. Should be called when any interrupt occurs