Skip to content

Commit dbb4d00

Browse files
committed
deprecate maskIRQ() and whatHappened()
doc review
1 parent 981b8db commit dbb4d00

File tree

1 file changed

+101
-84
lines changed

1 file changed

+101
-84
lines changed

RF24.h

+101-84
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,13 @@ class RF24
402402
* that received the next available payload. According to the datasheet,
403403
* the data about the pipe number that received the next available payload
404404
* is "unreliable" during a FALLING transition on the IRQ pin. This means
405-
* you should call whatHappened() before calling this function
405+
* you should call clearStatusFlags() before calling this function
406406
* during an ISR (Interrupt Service Routine). For example:
407407
* @code
408408
* void isrCallbackFunction() {
409409
* bool tx_ds, tx_df, rx_dr;
410-
* radio.whatHappened(tx_ds, tx_df, rx_dr); // resets the IRQ pin to HIGH
411-
* radio.available(); // returned data should now be reliable
410+
* uint8_t flags = radio.clearStatusFlags(); // resets the IRQ pin to HIGH
411+
* radio.available(); // returned data should now be reliable
412412
* }
413413
*
414414
* void setup() {
@@ -823,14 +823,13 @@ class RF24
823823
*
824824
* @warning According to the datasheet, the data saved to `pipe_num` is
825825
* "unreliable" during a FALLING transition on the IRQ pin. This means you
826-
* should call whatHappened() before calling this function during
826+
* should call clearStatusFlags() before calling this function during
827827
* an ISR (Interrupt Service Routine). For example:
828828
* @code
829829
* void isrCallbackFunction() {
830-
* bool tx_ds, tx_df, rx_dr;
831-
* radio.whatHappened(tx_ds, tx_df, rx_dr); // resets the IRQ pin to HIGH
832-
* uint8_t pipe; // initialize pipe data
833-
* radio.available(&pipe); // pipe data should now be reliable
830+
* radio.clearStatusFlags(); // resets the IRQ pin to inactive HIGH
831+
* uint8_t pipe = 7; // initialize pipe data
832+
* radio.available(&pipe); // pipe data should now be reliable
834833
* }
835834
*
836835
* void setup() {
@@ -1181,51 +1180,22 @@ class RF24
11811180
bool writeAckPayload(uint8_t pipe, const void* buf, uint8_t len);
11821181

11831182
/**
1184-
* Call this when you get an Interrupt Request (IRQ) to find out why
1185-
*
1186-
* This function describes what event triggered the IRQ pin to go active
1187-
* LOW and clears the status of all events.
1188-
*
1189-
* @see maskIRQ()
1190-
*
1191-
* @param[out] tx_ok The transmission attempt completed (TX_DS). This does
1192-
* not imply that the transmitted data was received by another radio, rather
1193-
* this only reports if the attempt to send was completed. This will
1194-
* always be `true` when the auto-ack feature is disabled.
1195-
* @param[out] tx_fail The transmission failed to be acknowledged, meaning
1196-
* too many retries (MAX_RT) were made while expecting an ACK packet. This
1197-
* event is only triggered when auto-ack feature is enabled.
1198-
* @param[out] rx_ready There is a newly received payload (RX_DR) saved to
1199-
* RX FIFO buffers. Remember that the RX FIFO can only hold up to 3
1200-
* payloads. Once the RX FIFO is full, all further received transmissions
1201-
* are rejected until there is space to save new data in the RX FIFO
1202-
* buffers.
1203-
*
1204-
* @note This function expects no parameters in the python wrapper.
1205-
* Instead, this function returns a 3 item tuple describing the IRQ
1206-
* events' status. To use this function in the python wrapper:
1207-
* @code{.py}
1208-
* # let`radio` be the instantiated RF24 object
1209-
* tx_ds, tx_df, rx_dr = radio.whatHappened() # get IRQ status flags
1210-
* print("tx_ds: {}, tx_df: {}, rx_dr: {}".format(tx_ds, tx_df, rx_dr))
1211-
* @endcode
1212-
*/
1213-
void whatHappened(bool& tx_ok, bool& tx_fail, bool& rx_ready);
1214-
1215-
/**
1216-
* Clear the StatusFlags that caused an interrupt event.
1183+
* Clear the Status flags that caused an interrupt event.
12171184
*
12181185
* @remark This function is similar to `whatHappened()` because it also returns the
1219-
* StatusFlags that caused the interrupt event. However, this function returns
1220-
* a 1-byte struct (@ref StatusFlags) instead of bit-banging 3 1-byte booleans
1186+
* Status flags that caused the interrupt event. However, this function returns
1187+
* a STATUS byte instead of bit-banging into 3 1-byte booleans
12211188
* passed by reference.
12221189
*
12231190
* @note When used in an ISR (Interrupt Service routine), there is a chance that the
12241191
* returned bits 0b1110 (rx_pipe number) is inaccurate. See available(uint8_t*) (or the
12251192
* datasheet) for more detail.
12261193
*
1227-
* @param flags The IRQ flags to clear. Default value is all of them (@ref RF24_IRQ_ALL).
1228-
* Multiple flags can be cleared by OR-ing @ref rf24_irq_flags_e values together.
1194+
* @param flags The IRQ flags to clear. Default value is all of them (`RF24_IRQ_ALL`).
1195+
* Multiple flags can be cleared by OR-ing rf24_irq_flags_e values together.
1196+
*
1197+
* @returns The STATUS byte from the radio's register before it was modified. Use
1198+
* enumerations of rf24_irq_flags_e as masks to interpret the STATUS byte's meaning(s).
12291199
*
12301200
* @ingroup StatusFlags
12311201
*/
@@ -1234,11 +1204,16 @@ class RF24
12341204
/**
12351205
* Set which flags shall be reflected on the radio's IRQ pin.
12361206
*
1237-
* This is similar to maskIRQ(), but with less confusing parameters.
1207+
* @remarks This function is similar to maskIRQ() but with less confusing parameters.
12381208
*
1239-
* @param flags The value of @ref rf24_irq_flags_e to influence the radio's IRQ pin.
1240-
* The default value (@ref RF24_IRQ_NONE) will disable the radio's IRQ pin.
1241-
* Multiple events can be enabled by OR-ing @ref rf24_irq_flags_e values together.
1209+
* @param flags A value of rf24_irq_flags_e to influence the radio's IRQ pin.
1210+
* The default value (`RF24_IRQ_NONE`) will disable the radio's IRQ pin.
1211+
* Multiple events can be enabled by OR-ing rf24_irq_flags_e values together.
1212+
* ```cpp
1213+
* radio.setStatusFlags(RF24_IRQ_ALL);
1214+
* // is equivalent to
1215+
* radio.setStatusFlags(RF24_RX_DR | RF24_TX_DS | RF24_TX_DF);
1216+
* ```
12421217
*
12431218
* @ingroup StatusFlags
12441219
*/
@@ -1251,14 +1226,18 @@ class RF24
12511226
* Use `RF24::update()` instead to get a fresh copy of the Status flags at
12521227
* the slight cost of performance.
12531228
*
1229+
* @returns The STATUS byte from the radio's register as the latest SPI transaction. Use
1230+
* enumerations of rf24_irq_flags_e as masks to interpret the STATUS byte's meaning(s).
1231+
*
12541232
* @ingroup StatusFlags
12551233
*/
12561234
uint8_t getStatusFlags();
12571235

12581236
/**
12591237
* Get an updated STATUS byte from the radio.
12601238
*
1261-
* @returns The StatusFlags fetched directly from the radio.
1239+
* @returns The STATUS byte fetched from the radio's register. Use enumerations of
1240+
* rf24_irq_flags_e as masks to interpret the STATUS byte's meaning(s).
12621241
*
12631242
* @ingroup StatusFlags
12641243
*/
@@ -1308,13 +1287,13 @@ class RF24
13081287
* Non-blocking write to the open writing pipe
13091288
*
13101289
* Just like write(), but it returns immediately. To find out what happened
1311-
* to the send, catch the IRQ and then call whatHappened().
1290+
* to the send, catch the IRQ and then call clearStatusFlags() or getStatusFlags().
13121291
*
13131292
* @see
13141293
* - write()
13151294
* - writeFast()
13161295
* - startFastWrite()
1317-
* - whatHappened()
1296+
* - clearStatusFlags()
13181297
* - setAutoAck() (for single noAck writes)
13191298
*
13201299
* @param buf Pointer to the data to be sent
@@ -1831,38 +1810,6 @@ class RF24
18311810
*/
18321811
void disableCRC(void);
18331812

1834-
/**
1835-
* This function is used to configure what events will trigger the Interrupt
1836-
* Request (IRQ) pin active LOW.
1837-
* The following events can be configured:
1838-
* 1. "data sent": This does not mean that the data transmitted was
1839-
* received, only that the attempt to send it was complete.
1840-
* 2. "data failed": This means the data being sent was not received. This
1841-
* event is only triggered when the auto-ack feature is enabled.
1842-
* 3. "data received": This means that data from a receiving payload has
1843-
* been loaded into the RX FIFO buffers. Remember that there are only 3
1844-
* levels available in the RX FIFO buffers.
1845-
*
1846-
* By default, all events are configured to trigger the IRQ pin active LOW.
1847-
* When the IRQ pin is active, use whatHappened() to determine what events
1848-
* triggered it. Remember that calling whatHappened() also clears these
1849-
* events' status, and the IRQ pin will then be reset to inactive HIGH.
1850-
*
1851-
* The following code configures the IRQ pin to only reflect the "data received"
1852-
* event:
1853-
* @code
1854-
* radio.maskIRQ(1, 1, 0);
1855-
* @endcode
1856-
*
1857-
* @param tx_ok `true` ignores the "data sent" event, `false` reflects the
1858-
* "data sent" event on the IRQ pin.
1859-
* @param tx_fail `true` ignores the "data failed" event, `false` reflects the
1860-
* "data failed" event on the IRQ pin.
1861-
* @param rx_ready `true` ignores the "data received" event, `false` reflects the
1862-
* "data received" event on the IRQ pin.
1863-
*/
1864-
void maskIRQ(bool tx_ok, bool tx_fail, bool rx_ready);
1865-
18661813
/**
18671814
*
18681815
* The driver will delay for this duration when stopListening() is called
@@ -1998,6 +1945,76 @@ class RF24
19981945
*/
19991946
bool isAckPayloadAvailable(void);
20001947

1948+
/**
1949+
* This function is used to configure what events will trigger the Interrupt
1950+
* Request (IRQ) pin active LOW.
1951+
*
1952+
* @deprecated Use setStatusFlags() instead.
1953+
*
1954+
* The following events can be configured:
1955+
* 1. "data sent": This does not mean that the data transmitted was
1956+
* received, only that the attempt to send it was complete.
1957+
* 2. "data failed": This means the data being sent was not received. This
1958+
* event is only triggered when the auto-ack feature is enabled.
1959+
* 3. "data received": This means that data from a receiving payload has
1960+
* been loaded into the RX FIFO buffers. Remember that there are only 3
1961+
* levels available in the RX FIFO buffers.
1962+
*
1963+
* By default, all events are configured to trigger the IRQ pin active LOW.
1964+
* When the IRQ pin is active, use clearStatusFlags() or getStatusFlags() to
1965+
* determine what events triggered it.
1966+
* Remember that calling clearStatusFlags() also clears these
1967+
* events' status, and the IRQ pin will then be reset to inactive HIGH.
1968+
*
1969+
* The following code configures the IRQ pin to only reflect the "data received"
1970+
* event:
1971+
* @code
1972+
* radio.maskIRQ(1, 1, 0);
1973+
* @endcode
1974+
*
1975+
* @param tx_ok `true` ignores the "data sent" event, `false` reflects the
1976+
* "data sent" event on the IRQ pin.
1977+
* @param tx_fail `true` ignores the "data failed" event, `false` reflects the
1978+
* "data failed" event on the IRQ pin.
1979+
* @param rx_ready `true` ignores the "data received" event, `false` reflects the
1980+
* "data received" event on the IRQ pin.
1981+
*/
1982+
void maskIRQ(bool tx_ok, bool tx_fail, bool rx_ready);
1983+
1984+
/**
1985+
* Call this when you get an Interrupt Request (IRQ) to find out why
1986+
*
1987+
* This function describes what event triggered the IRQ pin to go active
1988+
* LOW and clears the status of all events.
1989+
*
1990+
* @deprecated Use clearStatusFlags() instead.
1991+
*
1992+
* @see setStatusFlags()
1993+
*
1994+
* @param[out] tx_ok The transmission attempt completed (TX_DS). This does
1995+
* not imply that the transmitted data was received by another radio, rather
1996+
* this only reports if the attempt to send was completed. This will
1997+
* always be `true` when the auto-ack feature is disabled.
1998+
* @param[out] tx_fail The transmission failed to be acknowledged, meaning
1999+
* too many retries (MAX_RT) were made while expecting an ACK packet. This
2000+
* event is only triggered when auto-ack feature is enabled.
2001+
* @param[out] rx_ready There is a newly received payload (RX_DR) saved to
2002+
* RX FIFO buffers. Remember that the RX FIFO can only hold up to 3
2003+
* payloads. Once the RX FIFO is full, all further received transmissions
2004+
* are rejected until there is space to save new data in the RX FIFO
2005+
* buffers.
2006+
*
2007+
* @note This function expects no parameters in the python wrapper.
2008+
* Instead, this function returns a 3 item tuple describing the IRQ
2009+
* events' status. To use this function in the python wrapper:
2010+
* @code{.py}
2011+
* # let`radio` be the instantiated RF24 object
2012+
* tx_ds, tx_df, rx_dr = radio.whatHappened() # get IRQ status flags
2013+
* print("tx_ds: {}, tx_df: {}, rx_dr: {}".format(tx_ds, tx_df, rx_dr))
2014+
* @endcode
2015+
*/
2016+
void whatHappened(bool& tx_ok, bool& tx_fail, bool& rx_ready);
2017+
20012018
private:
20022019
/**@}*/
20032020
/**

0 commit comments

Comments
 (0)