Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
peripherals/lora_radio.cpp@14:900adc64ed43, 2018-09-28 (annotated)
- Committer:
- faydrus
- Date:
- Fri Sep 28 13:28:09 2018 +0000
- Revision:
- 14:900adc64ed43
Added in custom SX1276 driver
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| faydrus | 14:900adc64ed43 | 1 | #include "mbed.h" |
| faydrus | 14:900adc64ed43 | 2 | #include "CircularBuffer.h" |
| faydrus | 14:900adc64ed43 | 3 | #include "sx1276-hal.h" |
| faydrus | 14:900adc64ed43 | 4 | |
| faydrus | 14:900adc64ed43 | 5 | |
| faydrus | 14:900adc64ed43 | 6 | static void TxDoneCb(void) {}; |
| faydrus | 14:900adc64ed43 | 7 | static void TxTimeoutCb(void) {}; |
| faydrus | 14:900adc64ed43 | 8 | static void RxDoneCb(uint8_t *pld, uint16_t size, int16_t rssi, int8_t snr); |
| faydrus | 14:900adc64ed43 | 9 | static void RxTimeoutCb(void) {}; |
| faydrus | 14:900adc64ed43 | 10 | static void RxErrorCb(void) {}; |
| faydrus | 14:900adc64ed43 | 11 | static void FhssChangeChannelCb(uint8_t currentChannel) {}; |
| faydrus | 14:900adc64ed43 | 12 | static void CadDoneCb(bool ChannelActivityDetected) {}; |
| faydrus | 14:900adc64ed43 | 13 | |
| faydrus | 14:900adc64ed43 | 14 | |
| faydrus | 14:900adc64ed43 | 15 | SX1276MB1xAS Radio( NULL ); |
| faydrus | 14:900adc64ed43 | 16 | |
| faydrus | 14:900adc64ed43 | 17 | void initLoRaRadio() { |
| faydrus | 14:900adc64ed43 | 18 | // Set up the RadioEvents |
| faydrus | 14:900adc64ed43 | 19 | static RadioEvents_t events; |
| faydrus | 14:900adc64ed43 | 20 | events.TxDone = TxDoneCb; |
| faydrus | 14:900adc64ed43 | 21 | events.TxTimeout = TxTimeoutCb; |
| faydrus | 14:900adc64ed43 | 22 | events.RxDone = RxDoneCb; |
| faydrus | 14:900adc64ed43 | 23 | events.RxTimeout = RxTimeoutCb; |
| faydrus | 14:900adc64ed43 | 24 | events.RxError = RxErrorCb; |
| faydrus | 14:900adc64ed43 | 25 | events.FhssChangeChannel = FhssChangeChannelCb; |
| faydrus | 14:900adc64ed43 | 26 | events.CadDone = CadDoneCb; |
| faydrus | 14:900adc64ed43 | 27 | |
| faydrus | 14:900adc64ed43 | 28 | Radio.Init(&events); |
| faydrus | 14:900adc64ed43 | 29 | } |
| faydrus | 14:900adc64ed43 | 30 | |
| faydrus | 14:900adc64ed43 | 31 | typedef struct { |
| faydrus | 14:900adc64ed43 | 32 | uint8_t pld[128]; |
| faydrus | 14:900adc64ed43 | 33 | } pkt_t; |
| faydrus | 14:900adc64ed43 | 34 | CircularBuffer<pkt_t, 32, uint32_t> rx_plds; |
| faydrus | 14:900adc64ed43 | 35 | CircularBuffer<uint16_t, 32, uint32_t> rssi_vals; |
| faydrus | 14:900adc64ed43 | 36 | CircularBuffer<uint16_t, 32, uint32_t> snr_vals; |
| faydrus | 14:900adc64ed43 | 37 | static pkt_t mesh_pkt; |
| faydrus | 14:900adc64ed43 | 38 | static void RxDoneCb(uint8_t *pld, uint16_t size, int16_t rssi, int8_t snr) { |
| faydrus | 14:900adc64ed43 | 39 | static pkt_t tmp_pld; |
| faydrus | 14:900adc64ed43 | 40 | memcpy((void *) &tmp_pld, (void *) pld, size); |
| faydrus | 14:900adc64ed43 | 41 | memcpy((void *) &mesh_pkt, (void *) pld, size); |
| faydrus | 14:900adc64ed43 | 42 | rx_plds.push(tmp_pld); |
| faydrus | 14:900adc64ed43 | 43 | rssi_vals.push(rssi); |
| faydrus | 14:900adc64ed43 | 44 | snr_vals.push(snr); |
| faydrus | 14:900adc64ed43 | 45 | } |