Skip to content

Commit 690ea58

Browse files
committed
Fix #568: update radio API docs
1 parent 59df2fa commit 690ea58

File tree

1 file changed

+57
-8
lines changed

1 file changed

+57
-8
lines changed

src/lmic/radio.c

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828

29+
//! \file
30+
2931
#define LMIC_DR_LEGACY 0
3032

3133
#include "lmic.h"
@@ -1070,7 +1072,23 @@ static void startrx (u1_t rxmode) {
10701072
// or timed out, and the corresponding IRQ will inform us about completion.
10711073
}
10721074

1073-
// get random seed from wideband noise rssi
1075+
//! \brief Initialize radio at system startup.
1076+
//!
1077+
//! \details This procedure is called during initialization by the `os_init()`
1078+
//! routine. It does a hardware reset of the radio, checks the version and confirms
1079+
//! that we're operating a suitable chip, and gets a random seed from wideband
1080+
//! noise rssi. It then puts the radio to sleep.
1081+
//!
1082+
//! \result True if successful, false if it doesn't look like the right radio is attached.
1083+
//!
1084+
//! \pre
1085+
//! Preconditions must be observed, or you'll get hangs during initialization.
1086+
//!
1087+
//! - The `hal_pin_..()` functions must be ready for use.
1088+
//! - The `hal_waitUntl()` function must be ready for use. This may mean that interrupts
1089+
//! are enabled.
1090+
//! - The `hal_spi_..()` functions must be ready for use.
1091+
//!
10741092
int radio_init () {
10751093
hal_disableIRQs();
10761094

@@ -1161,13 +1179,19 @@ u1_t radio_rssi () {
11611179
return r;
11621180
}
11631181

1164-
// monitor rssi for specified number of ostime_t ticks, and return statistics
1165-
// This puts the radio into RX continuous mode, waits long enough for the
1166-
// oscillators to start and the PLL to lock, and then measures for the specified
1167-
// period of time. The radio is then returned to idle.
1168-
//
1169-
// RSSI returned is expressed in units of dB, and is offset according to the
1170-
// current radio setting per section 5.5.5 of Semtech 1276 datasheet.
1182+
/// \brief get the current RSSI on the current channel.
1183+
///
1184+
/// monitor rssi for specified number of ostime_t ticks, and return statistics
1185+
/// This puts the radio into RX continuous mode, waits long enough for the
1186+
/// oscillators to start and the PLL to lock, and then measures for the specified
1187+
/// period of time. The radio is then returned to idle.
1188+
///
1189+
/// RSSI returned is expressed in units of dB, and is offset according to the
1190+
/// current radio setting per section 5.5.5 of Semtech 1276 datasheet.
1191+
///
1192+
/// \param nTicks How long to monitor
1193+
/// \param pRssi pointer to structure to fill in with RSSI data.
1194+
///
11711195
void radio_monitor_rssi(ostime_t nTicks, oslmic_radio_rssi_t *pRssi) {
11721196
uint8_t rssiMax, rssiMin;
11731197
uint16_t rssiSum;
@@ -1369,6 +1393,31 @@ void radio_irq_handler_v2 (u1_t dio, ostime_t now) {
13691393
#endif /* ! CFG_TxContinuousMode */
13701394
}
13711395

1396+
/*!
1397+
1398+
\brief Initiate a radio operation.
1399+
1400+
\param mode Selects the operation to be performed.
1401+
1402+
The requested radio operation is initiated. Some operations complete
1403+
immediately; others require hardware to do work, and don't complete until
1404+
an interrupt occurs. In that case, `LMIC.osjob` is scheduled. Because the
1405+
interrupt may occur right away, it's important that the caller initialize
1406+
`LMIC.osjob` before calling this routine.
1407+
1408+
- `RADIO_RST` causes the radio to be put to sleep. No interrupt follows;
1409+
when control returns, the radio is ready for the next operation.
1410+
1411+
- `RADIO_TX` and `RADIO_TX_AT` launch the transmission of a frame. An interrupt will
1412+
occur, which will cause `LMIC.osjob` to be scheduled with its current
1413+
function.
1414+
1415+
- `RADIO_RX` and `RADIO_RX_ON` launch either single or continuous receives.
1416+
An interrupt will occur when a packet is recieved or the receive times out,
1417+
which will cause `LMIC.osjob` to be scheduled with its current function.
1418+
1419+
*/
1420+
13721421
void os_radio (u1_t mode) {
13731422
hal_disableIRQs();
13741423
switch (mode) {

0 commit comments

Comments
 (0)