|
26 | 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27 | 27 | */
|
28 | 28 |
|
| 29 | +//! \file |
| 30 | + |
29 | 31 | #define LMIC_DR_LEGACY 0
|
30 | 32 |
|
31 | 33 | #include "lmic.h"
|
@@ -1070,7 +1072,23 @@ static void startrx (u1_t rxmode) {
|
1070 | 1072 | // or timed out, and the corresponding IRQ will inform us about completion.
|
1071 | 1073 | }
|
1072 | 1074 |
|
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 | +//! |
1074 | 1092 | int radio_init () {
|
1075 | 1093 | hal_disableIRQs();
|
1076 | 1094 |
|
@@ -1161,13 +1179,19 @@ u1_t radio_rssi () {
|
1161 | 1179 | return r;
|
1162 | 1180 | }
|
1163 | 1181 |
|
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 | +/// |
1171 | 1195 | void radio_monitor_rssi(ostime_t nTicks, oslmic_radio_rssi_t *pRssi) {
|
1172 | 1196 | uint8_t rssiMax, rssiMin;
|
1173 | 1197 | uint16_t rssiSum;
|
@@ -1369,6 +1393,31 @@ void radio_irq_handler_v2 (u1_t dio, ostime_t now) {
|
1369 | 1393 | #endif /* ! CFG_TxContinuousMode */
|
1370 | 1394 | }
|
1371 | 1395 |
|
| 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 | + |
1372 | 1421 | void os_radio (u1_t mode) {
|
1373 | 1422 | hal_disableIRQs();
|
1374 | 1423 | switch (mode) {
|
|
0 commit comments