mirror of
https://github.com/travisgoodspeed/goodwatch
synced 2024-11-21 23:58:31 +00:00
Beginnings of codeplug support. #50
This commit is contained in:
parent
6c6c6dc0fc
commit
0b3accc9c5
@ -5,7 +5,7 @@ CC = msp430-gcc -mmcu=cc430f6137 -Wall -I. -Os
|
||||
BSL = ../bin/cc430-bsl.py
|
||||
|
||||
modules=rtcasm.o main.o lcd.o lcdtext.o rtc.o keypad.o apps.o sidebutton.o radio.o power.o \
|
||||
dmesg.o \
|
||||
dmesg.o codeplug.o \
|
||||
libs/assembler.o libs/morse.o
|
||||
apps= apps/clock.o apps/rpn.o apps/hex.o apps/stopwatch.o \
|
||||
apps/morse.o apps/rssi.o
|
||||
@ -36,3 +36,6 @@ dmesg:
|
||||
run:
|
||||
sleep 5
|
||||
../bin/cc430-bsl.py -P goodwatch.hex -uD
|
||||
|
||||
codeplug.hex: codeplug.txt
|
||||
../bin/goodwatch-txt2cp.py -i codeplug.txt -o codeplug.hex
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "sidebutton.h"
|
||||
#include "radio.h"
|
||||
#include "power.h"
|
||||
#include "codeplug.h"
|
||||
#include "gittag.h" //Autogenerated
|
||||
|
||||
//Handy libraries. These are tested host-side.
|
||||
|
@ -1,5 +1,4 @@
|
||||
/*! \file apps.h
|
||||
|
||||
\brief These are functions for working with applications and the task switcher.
|
||||
|
||||
*/
|
||||
|
49
firmware/codeplug.c
Normal file
49
firmware/codeplug.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*! \file codeplug.c
|
||||
\brief Codeplug for stored radio frequencies.
|
||||
|
||||
The codeplug itself is stored in info flash at 0x1800, as a sequence
|
||||
of twelve-byte entries as defined in codeplug.h.
|
||||
*/
|
||||
|
||||
#include "codeplug.h"
|
||||
#include "radio.h"
|
||||
|
||||
//! Array of codeplug entries in info flash.
|
||||
struct codeplugentry *codeplug = (struct codeplugentry*) 0x1800;
|
||||
|
||||
//! Index of entry in the codeplug.
|
||||
static int codeplugi=0;
|
||||
|
||||
//! Next codeplug entry.
|
||||
void codeplug_next(){
|
||||
if(codeplug[++codeplugi].flags==0xFF)
|
||||
codeplugi=0;
|
||||
}
|
||||
|
||||
//! Previous codeplug entry.
|
||||
void codeplug_prev(){
|
||||
/* If we run beneath the beginning of the codeplug, we need to walk
|
||||
all the way to the end and then back one.
|
||||
*/
|
||||
if(--codeplugi<0){
|
||||
//Walk to the end.
|
||||
while(codeplug[++codeplugi].flags!=0xFF);
|
||||
//Jump back one.
|
||||
codeplug--;
|
||||
}
|
||||
}
|
||||
|
||||
//! Return the name of the codeplug entry. 8 bytes, no null terminator!
|
||||
const char *codeplug_name(){
|
||||
return codeplug[codeplugi].name;
|
||||
}
|
||||
|
||||
//! Sets the codeplug frequency.
|
||||
void codeplug_setfreq(){
|
||||
radio_setrawfreq(
|
||||
codeplug[codeplugi].freq2,
|
||||
codeplug[codeplugi].freq1,
|
||||
codeplug[codeplugi].freq0);
|
||||
}
|
||||
|
||||
|
33
firmware/codeplug.h
Normal file
33
firmware/codeplug.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*! \file codeplug.h
|
||||
\brief Codeplug for stored radio frequencies.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define CODEPLUGLEN 512
|
||||
|
||||
//! Single entry in the codeplug database.
|
||||
struct codeplugentry {
|
||||
/* The flags byte is undefined; keep at zero for now. */
|
||||
const uint8_t flags;
|
||||
|
||||
/* The frequency is stored in the CC1101-based radio's internal
|
||||
format. See radio.c for example calculations.
|
||||
*/
|
||||
const uint8_t freq2;
|
||||
const uint8_t freq1;
|
||||
const uint8_t freq0;
|
||||
|
||||
/* The eight character name is *NOT* null terminated. */
|
||||
const char name[8];
|
||||
};
|
||||
|
||||
//! Next codeplug entry.
|
||||
void codeplug_next();
|
||||
//! Previous codeplug entry.
|
||||
void codeplug_prev();
|
||||
|
||||
//! Return the name of the codeplug entry. 8 bytes, no null terminator!
|
||||
const char *codeplug_name();
|
||||
//! Sets the codeplug frequency.
|
||||
void codeplug_setfreq();
|
11
firmware/codeplug.txt
Normal file
11
firmware/codeplug.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Example GoodWatch codeplug.
|
||||
# freq name [flags]
|
||||
|
||||
#Handy frequencies in our band.
|
||||
433.000 433.00
|
||||
433.450 433.45
|
||||
434.000 434.00
|
||||
|
||||
#DMR Simplex, slightly out of band.
|
||||
441.000 DMR441.0
|
||||
|
@ -52,6 +52,19 @@ void radio_setfreq(float freq){
|
||||
while(radio_getstate()!=1);
|
||||
}
|
||||
|
||||
//! Sets the raw radio frequency registers.
|
||||
void radio_setrawfreq(uint8_t freq2, uint8_t freq1, uint8_t freq0){
|
||||
//Store the frequency.
|
||||
radio_writereg(FREQ2, freq2);
|
||||
radio_writereg(FREQ1, freq1);
|
||||
radio_writereg(FREQ0, freq0);
|
||||
|
||||
//Strobe a calibration to make it count.
|
||||
radio_strobe(RF_SCAL);
|
||||
//Wait for it to take effect.
|
||||
while(radio_getstate()!=1);
|
||||
}
|
||||
|
||||
//! Gets the radio frequency.
|
||||
uint32_t radio_getfreq(){
|
||||
static uint32_t oldhex=0, oldnum=0;
|
||||
|
@ -54,6 +54,8 @@ int radio_on();
|
||||
|
||||
//! Sets the radio frequency.
|
||||
void radio_setfreq(float freq);
|
||||
//! Sets the raw radio frequency registers.
|
||||
void radio_setrawfreq(uint8_t freq2, uint8_t freq1, uint8_t freq0);
|
||||
//! Gets the radio frequency.
|
||||
uint32_t radio_getfreq();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user