DRA818 VHF or UHF radio module library. http://www.dorji.com/docs/data/DRA818V.pdf
Example.txt@3:b822fbac58f4, 2016-05-26 (annotated)
- Committer:
- ebarranco
- Date:
- Thu May 26 18:50:36 2016 +0000
- Revision:
- 3:b822fbac58f4
Rename example to avoid main conflicts. Maybe there is a better way to do this?
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ebarranco | 3:b822fbac58f4 | 1 | // Lib for http://www.dorji.com/docs/data/DRA818V.pdf |
ebarranco | 3:b822fbac58f4 | 2 | #include "mbed.h" |
ebarranco | 3:b822fbac58f4 | 3 | #include "dra818.h" |
ebarranco | 3:b822fbac58f4 | 4 | |
ebarranco | 3:b822fbac58f4 | 5 | #define PTT PB_4 // PTT pin. This is active low. |
ebarranco | 3:b822fbac58f4 | 6 | #define PD PB_5 // Power Down pin. This need to start low, then be set high before programming. |
ebarranco | 3:b822fbac58f4 | 7 | |
ebarranco | 3:b822fbac58f4 | 8 | #define DRA_TXD PA_9 |
ebarranco | 3:b822fbac58f4 | 9 | #define DRA_RXD PA_10 |
ebarranco | 3:b822fbac58f4 | 10 | |
ebarranco | 3:b822fbac58f4 | 11 | Serial dra_serial(DRA_TXD, DRA_RXD); |
ebarranco | 3:b822fbac58f4 | 12 | DRA818 dra(&dra_serial, PTT); |
ebarranco | 3:b822fbac58f4 | 13 | DigitalOut PowerDown=(PD); |
ebarranco | 3:b822fbac58f4 | 14 | DigitalOut PushToTalk=(PTT); |
ebarranco | 3:b822fbac58f4 | 15 | |
ebarranco | 3:b822fbac58f4 | 16 | int main() { |
ebarranco | 3:b822fbac58f4 | 17 | PowerDown=1; // PD is Active HIGH, so this turns the DRA818 on. |
ebarranco | 3:b822fbac58f4 | 18 | |
ebarranco | 3:b822fbac58f4 | 19 | // The following functions are not instantaneously set, you need to call writeFreq to program them after a PowerDown. |
ebarranco | 3:b822fbac58f4 | 20 | dra.setGWB(0); // Channels space. 0 = 12.5k 1 = 25k |
ebarranco | 3:b822fbac58f4 | 21 | dra.setTXFreq(146.525); // TX Frequency |
ebarranco | 3:b822fbac58f4 | 22 | dra.setRXFreq(146.525); // RX Freqency |
ebarranco | 3:b822fbac58f4 | 23 | dra.setTXCTCSS(0); // 9 = 91.5 Hz, See https://en.wikipedia.org/wiki/CTCSS for a list. |
ebarranco | 3:b822fbac58f4 | 24 | dra.setSquelch(3); // Squelch level 3. |
ebarranco | 3:b822fbac58f4 | 25 | dra.setRXCTCSS(0); // No CTCSS on RX. |
ebarranco | 3:b822fbac58f4 | 26 | dra.writeFreq(); // Write out frequency settings to the DRA module. |
ebarranco | 3:b822fbac58f4 | 27 | |
ebarranco | 3:b822fbac58f4 | 28 | // These functions are instantaneously written to the DRA module. |
ebarranco | 3:b822fbac58f4 | 29 | dra.setVolume(4); // Set output volume to '4'. |
ebarranco | 3:b822fbac58f4 | 30 | dra.setFilters(true, true, true); // Sets all filters (Pre/De-Emphasis, High-Pass, Low-Pass) on. |
ebarranco | 3:b822fbac58f4 | 31 | |
ebarranco | 3:b822fbac58f4 | 32 | while(1) { |
ebarranco | 3:b822fbac58f4 | 33 | PushToTalk = 0; // PTT is Active low, so this turns the PTT on. |
ebarranco | 3:b822fbac58f4 | 34 | wait(10); |
ebarranco | 3:b822fbac58f4 | 35 | PushToTalk = 1; |
ebarranco | 3:b822fbac58f4 | 36 | wait(120); |
ebarranco | 3:b822fbac58f4 | 37 | } |
ebarranco | 3:b822fbac58f4 | 38 | } |