Edgar Barranco / DRA818lib

DRA818 VHF or UHF radio module library. http://www.dorji.com/docs/data/DRA818V.pdf

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?

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