|
Arduino LMIC 6.0.1
Arduino LoRaWAN(r) MAC in C
|
#include "config.h"#include "lmic_env.h"#include "oslmic_types.h"#include <string.h>#include "hal.h"#include <inttypes.h>Go to the source code of this file.
Data Structures | |
| struct | osjob_t |
| struct | oslmic_radio_rssi_s |
Macros | |
| #define | os_clearMem(pDest, nDest) |
| Clear buffer. | |
| #define | os_copyMem(pDest, pSrc, nSrc) |
| Copy buffer. | |
| #define | os_getRndU2() |
| Get random number (default impl for u2_t). | |
| #define | RX_RAMPUP_DEFAULT (us2osticks(10000)) |
| RX_RAMPUP_DEFAULT specifies the extra time we must allow to set up an RX event due to platform issues. It's specified in units of ostime_t. It must reflect platform jitter and latency, as well as the speed of the LMIC when running on this plaform. It's not used directly; clients call os_getRadioRxRampup(), which might adaptively vary this based on observed timeouts. | |
Typedefs | |
| typedef osjobcbfn_t * | osjobcb_t |
| the pointer-to-function for osjob_t callbacks | |
| typedef void | osjobcbfn_t(struct osjob_t *) |
| the function type for osjob_t callbacks | |
Functions | |
| bit_t | os_queryTimeCriticalJobs (ostime_t time) |
| Return non-zero if any jobs are scheduled between now and now+time. | |
| u2_t | os_rlsbf2 (xref2cu1_t buf) |
| Read 16-bit quantity from given pointer in little endian byte order. | |
| u4_t | os_rlsbf4 (xref2cu1_t buf) |
| Read 32-bit quantity from given pointer in little endian byte order. | |
| u4_t | os_rmsbf4 (xref2cu1_t buf) |
| Read 32-bit quantity from given pointer in big endian byte order. | |
| bit_t | os_setIdleJobFunction (osjob_t *job, osjobcb_t cb) |
| set function in idle job (for future use) | |
| void | os_wlsbf2 (xref2u1_t buf, u2_t value) |
| Write 16-bit quantity into buffer in little endian byte order. | |
| void | os_wlsbf4 (xref2u1_t buf, u4_t value) |
| Write 32-bit quantity into buffer in little endian byte order. | |
| void | os_wmsbf4 (xref2u1_t buf, u4_t value) |
| Write 32-bit quantity into buffer in big endian byte order. | |
| int | radio_init (void) |
| Initialize radio at system startup. | |
| void | radio_irq_handler (u1_t dio) |
| legacy radio IRQ handler | |
| void | radio_irq_handler_v2 (u1_t dio, ostime_t tref) |
| Radio IRQ handler. | |
| void | radio_monitor_rssi (ostime_t n, oslmic_radio_rssi_t *pRssi) |
| Measure the current broadband RSSI for the current channel. | |
| u1_t | radio_rand1 (void) |
| Generate an 8-bit uniformly-distributed integer. | |
| #define os_copyMem | ( | pDest, | |
| pSrc, | |||
| nSrc ) |
Copy buffer.
| pDest | [out] receives data to be copied |
| pSrc | [in] source of data |
| nSrc | [in] number of bytes of data |
Referenced by LMIC_SecureElement_Default_aes128Encrypt(), LMIC_SecureElement_Default_decodeJoinAccept(), LMIC_SecureElement_Default_decodeMessage(), LMIC_SecureElement_Default_encodeMessage(), LMIC_SecureElement_Default_getAppSKey(), LMIC_SecureElement_Default_getNwkSKey(), and LMIC_setSession().
set function in idle job (for future use)
| [in,out] | job | points to the job block to be updated. |
| [in] | cb | is the desired new callback. |
We make sure that the job is idle, and then we set its function pointer. If the job was not idle, we log a message.
| int radio_init | ( | void | ) |
Initialize radio at system startup.
This procedure is called during initialization by the os_init() routine. It does a hardware reset of the radio, checks the version and confirms that we're operating a suitable chip, and gets a random seed from wideband noise rssi. It then puts the radio to sleep.
Preconditions must be observed, or you'll get hangs during initialization.
Generally, all these are satisfied by a call to lmic_hal_init_with_pinmap().
| void radio_irq_handler | ( | u1_t | dio | ) |
legacy radio IRQ handler
| [in] | dio | is the image of the DIO0..n pins observed by the primary ISR. |
The HAL is responsible for detecting transitions on the SX127x DIO pins, and scheduling this routine. This routine must run as part of os_runloop_once(); it must not be called directly from a primary ISR.
This routine is for legacy use only; it is for use by older HALs that cannot capture the interrupt time in the primary ISR.
References radio_irq_handler_v2().
| void radio_irq_handler_v2 | ( | u1_t | dio, |
| ostime_t | now ) |
Radio IRQ handler.
| [in] | dio | is the image of the DIO0..n pins observed by the primary ISR. |
| [in] | now | is the HALs best estimate of the time of teh interrupt. |
The HAL is responsible for detecting transitions on the SX127x DIO pins, and scheduling this routine. This routine must run as part of os_runloop_once(); it must not be called directly from a primary ISR.
The radio registers are interrogated, and the interrupt is processed. The radio is then put back to sleep, and the background is scheduled.
References LMIC_RADIO_EV_NONE, LMIC_RADIO_EV_RXDONE, LMIC_RADIO_EV_RXTIMEOUT, LMIC_RADIO_EV_RXUNKNOWN, LMIC_RADIO_EV_TXDONE, and LMIC_RADIO_EV_TXUNKNOWN.
Referenced by radio_irq_handler().
| void radio_monitor_rssi | ( | ostime_t | nTicks, |
| oslmic_radio_rssi_t * | pRssi ) |
Measure the current broadband RSSI for the current channel.
This funtion monitors RSSI for specified number of ostime_t ticks, and return statistics. It first puts the radio into RX continuous mode, waits long enough for the oscillators to start and the PLL to lock, and then measures for the specified period of time. The radio is then returned to idle.
| nTicks | How long to monitor |
| pRssi | pointer to structure to fill in with RSSI data. |
| u1_t radio_rand1 | ( | void | ) |
Generate an 8-bit uniformly-distributed integer.
If there are any bytes remaining in the random buffer, the next byte is returned. Otherwise, sixteen new random bytes are generated, and the first is returned.
References os_wlsbf4().