Raduino changes are getting to TeensyDSP over I2C. TeensyDSP successfully receiving some CAT.
This commit is contained in:
parent
702f370d1b
commit
aeeec69daf
|
@ -125,7 +125,6 @@ unsigned long vfoA_eeprom, vfoB_eeprom; //for protect eeprom life
|
||||||
unsigned long frequency;
|
unsigned long frequency;
|
||||||
unsigned long ritRxFrequency, ritTxFrequency; //frequency is the current frequency on the dial
|
unsigned long ritRxFrequency, ritTxFrequency; //frequency is the current frequency on the dial
|
||||||
|
|
||||||
|
|
||||||
unsigned int cwSpeed = 100; //this is actuall the dot period in milliseconds
|
unsigned int cwSpeed = 100; //this is actuall the dot period in milliseconds
|
||||||
extern int32_t calibration;
|
extern int32_t calibration;
|
||||||
|
|
||||||
|
@ -1473,6 +1472,9 @@ void checkAutoSaveFreqMode()
|
||||||
saveCheckTime = 0; //for reduce cpu use rate
|
saveCheckTime = 0; //for reduce cpu use rate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rigState.vfo[0] = vfoA;
|
||||||
|
rigState.vfo[1] = vfoB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
|
|
|
@ -342,4 +342,6 @@ extern int GetI2CSmeterValue(int valueType); //ubitx_ui.ino
|
||||||
|
|
||||||
extern void doRaduinoToTeensy(UBitxRigState* r);
|
extern void doRaduinoToTeensy(UBitxRigState* r);
|
||||||
|
|
||||||
|
extern UBitxRigState rigState;
|
||||||
|
|
||||||
#endif //end of if header define
|
#endif //end of if header define
|
||||||
|
|
|
@ -998,8 +998,13 @@ void idle_process()
|
||||||
{
|
{
|
||||||
// KC4UPR 2021-02-05 added update process for Raduino-TeensyDSP coordination
|
// KC4UPR 2021-02-05 added update process for Raduino-TeensyDSP coordination
|
||||||
// Note, need to not have to copy this every time...
|
// Note, need to not have to copy this every time...
|
||||||
rigState.vfo[0] = vfoA;
|
if (vfoActive == VFO_A) {
|
||||||
rigState.vfo[1] = vfoB;
|
rigState.vfo[0] = frequency;
|
||||||
|
rigState.flags &= ~UBITX_VFOB_FLAG;
|
||||||
|
} else if (vfoActive == VFO_B) {
|
||||||
|
rigState.vfo[1] = frequency;
|
||||||
|
rigState.flags |= UBITX_VFOB_FLAG;
|
||||||
|
}
|
||||||
doRaduinoToTeensy(&rigState);
|
doRaduinoToTeensy(&rigState);
|
||||||
|
|
||||||
//S-Meter Display
|
//S-Meter Display
|
||||||
|
|
|
@ -305,9 +305,21 @@ void doRaduinoToTeensy(UBitxRigState* r) {
|
||||||
|
|
||||||
Wire.beginTransmission(I2CMETER_ADDR);
|
Wire.beginTransmission(I2CMETER_ADDR);
|
||||||
Wire.write(I2CMETER_RIGINF);
|
Wire.write(I2CMETER_RIGINF);
|
||||||
|
//for (size_t i = 0; i < sizeof(UBitxRigState); i++) {
|
||||||
|
// Wire.write(ptr[i]);
|
||||||
|
//}
|
||||||
|
//Note, I can switch this back...
|
||||||
Wire.write(ptr, sizeof(UBitxRigState));
|
Wire.write(ptr, sizeof(UBitxRigState));
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
|
|
||||||
|
Serial.print("VFO A: ");
|
||||||
|
Serial.print(r->vfo[0]);
|
||||||
|
Serial.print(", VFO B: ");
|
||||||
|
Serial.print(r->vfo[1]);
|
||||||
|
Serial.print(", Data Size: ");
|
||||||
|
Serial.print(sizeof(UBitxRigState));
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.requestFrom(I2CMETER_ADDR, sizeof(UBitxRigState));
|
Wire.requestFrom(I2CMETER_ADDR, sizeof(UBitxRigState));
|
||||||
|
|
||||||
UBitxRigState tmp;
|
UBitxRigState tmp;
|
||||||
|
|
|
@ -86,6 +86,10 @@ void UBitxDSP::begin() {
|
||||||
rx();
|
rx();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UBitxDSP::update() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void UBitxDSP::end() {
|
void UBitxDSP::end() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ class UBitxDSP {
|
||||||
public:
|
public:
|
||||||
UBitxDSP() {};
|
UBitxDSP() {};
|
||||||
void begin();
|
void begin();
|
||||||
|
void update();
|
||||||
void end();
|
void end();
|
||||||
void rx();
|
void rx();
|
||||||
void txMicIn();
|
void txMicIn();
|
||||||
|
|
|
@ -11,10 +11,12 @@ enum UpdateSource {
|
||||||
|
|
||||||
class UBitxRig {
|
class UBitxRig {
|
||||||
public:
|
public:
|
||||||
|
inline void begin() {}
|
||||||
|
inline void update() {}
|
||||||
inline unsigned long getFreqA() const { return state.vfo[0]; }
|
inline unsigned long getFreqA() const { return state.vfo[0]; }
|
||||||
inline unsigned long getFreqB() const { return state.vfo[1]; }
|
inline unsigned long getFreqB() const { return state.vfo[1]; }
|
||||||
inline short getRIT() const { return state.rit; }
|
inline long getRIT() const { return state.rit; }
|
||||||
inline short getXIT() const { return state.xit; }
|
inline long getXIT() const { return state.xit; }
|
||||||
inline bool isVFOA() const { return (state.flags & UBITX_VFOB_FLAG) != UBITX_VFOB_FLAG; }
|
inline bool isVFOA() const { return (state.flags & UBITX_VFOB_FLAG) != UBITX_VFOB_FLAG; }
|
||||||
inline bool isVFOB() const { return (state.flags & UBITX_VFOB_FLAG) == UBITX_VFOB_FLAG; }
|
inline bool isVFOB() const { return (state.flags & UBITX_VFOB_FLAG) == UBITX_VFOB_FLAG; }
|
||||||
inline bool isSplit() const { return (state.flags & UBITX_SPLIT_FLAG) == UBITX_SPLIT_FLAG; }
|
inline bool isSplit() const { return (state.flags & UBITX_SPLIT_FLAG) == UBITX_SPLIT_FLAG; }
|
||||||
|
|
|
@ -3,26 +3,26 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define UBITX_VFOA_UPDATE 0x01
|
#define UBITX_VFOA_UPDATE 0x00000001
|
||||||
#define UBITX_VFOB_UPDATE 0x02
|
#define UBITX_VFOB_UPDATE 0x00000002
|
||||||
#define UBITX_RIT_UPDATE 0x04
|
#define UBITX_RIT_UPDATE 0x00000004
|
||||||
#define UBITX_XIT_UPDATE 0x08
|
#define UBITX_XIT_UPDATE 0x00000008
|
||||||
#define UBITX_FLAGS_UPDATE 0x10
|
#define UBITX_FLAGS_UPDATE 0x00000010
|
||||||
|
|
||||||
#define UBITX_VFOB_FLAG 0x01
|
#define UBITX_VFOB_FLAG 0x00000001
|
||||||
#define UBITX_SPLIT_FLAG 0x02
|
#define UBITX_SPLIT_FLAG 0x00000002
|
||||||
#define UBITX_RIT_FLAG 0x04
|
#define UBITX_RIT_FLAG 0x00000004
|
||||||
#define UBITX_XIT_FLAG 0x08
|
#define UBITX_XIT_FLAG 0x00000008
|
||||||
#define UBITX_CW_FLAG 0x10
|
#define UBITX_CW_FLAG 0x00000010
|
||||||
#define UBITX_USB_FLAG 0x20
|
#define UBITX_USB_FLAG 0x00000020
|
||||||
#define UBITX_TX_FLAG 0x40
|
#define UBITX_TX_FLAG 0x00000040
|
||||||
|
|
||||||
struct UBitxRigState {
|
struct UBitxRigState {
|
||||||
uint8_t header = 0;
|
uint32_t header = 0;
|
||||||
uint32_t vfo[2];
|
uint32_t vfo[2];
|
||||||
int16_t rit;
|
int32_t rit;
|
||||||
int16_t xit;
|
int32_t xit;
|
||||||
uint8_t flags = 0;
|
uint32_t flags = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "TS590.h"
|
#include "TS590.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
@ -71,26 +72,26 @@ void TS590Command::process(const char* cmd) {
|
||||||
theError = NoError;
|
theError = NoError;
|
||||||
|
|
||||||
if (isReadCommand(cmd)) {
|
if (isReadCommand(cmd)) {
|
||||||
sendResponse(cmd);
|
DBGCMD( sendResponse(cmd) );
|
||||||
} else {
|
} else {
|
||||||
handleCommand(cmd);
|
DBGCMD( handleCommand(cmd) );
|
||||||
switch(theError) {
|
switch(theError) {
|
||||||
case NoError:
|
case NoError:
|
||||||
if (theRig->getAI()) {
|
if (theRig->getAI()) {
|
||||||
sendResponse(cmd);
|
DBGCMD( sendResponse(cmd) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SyntaxError:
|
case SyntaxError:
|
||||||
ts590SyntaxError();
|
DBGCMD( ts590SyntaxError() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CommError:
|
case CommError:
|
||||||
ts590CommError();
|
DBGCMD( ts590CommError() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ProcessError:
|
case ProcessError:
|
||||||
ts590ProcessError();
|
DBGCMD( ts590ProcessError() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,9 +226,24 @@ TS590Command* catCommands[] = {
|
||||||
&cmdFR,
|
&cmdFR,
|
||||||
&cmdFT
|
&cmdFT
|
||||||
};
|
};
|
||||||
|
int numCatCommands = sizeof(catCommands) / sizeof(catCommands[0]);
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
void UBitxTS590::begin() {
|
||||||
|
Serial.begin(9600); // USB is always 12 Mbit/sec
|
||||||
|
#ifdef DEBUG
|
||||||
|
delay(500);
|
||||||
|
Serial.print("DBG: Number of CAT commands: ");
|
||||||
|
Serial.println(numCommands);
|
||||||
|
for (int i = 0; i < numCommands; i++) {
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(commands[i]->prefix());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void UBitxTS590::update() {
|
void UBitxTS590::update() {
|
||||||
char incomingChar;
|
char incomingChar;
|
||||||
|
|
||||||
|
@ -236,7 +252,10 @@ void UBitxTS590::update() {
|
||||||
incomingChar = Serial.read();
|
incomingChar = Serial.read();
|
||||||
if (incomingChar == ';') {
|
if (incomingChar == ';') {
|
||||||
buf[bufLen++] = '\0';
|
buf[bufLen++] = '\0';
|
||||||
|
strupr(buf);
|
||||||
processCommand();
|
processCommand();
|
||||||
|
} else if (incomingChar == '\n' && bufLen == 0) {
|
||||||
|
;
|
||||||
} else {
|
} else {
|
||||||
buf[bufLen++] = incomingChar;
|
buf[bufLen++] = incomingChar;
|
||||||
}
|
}
|
||||||
|
@ -248,19 +267,32 @@ void UBitxTS590::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef class TS590Command* PCmd;
|
||||||
|
|
||||||
int compareCATCommands(const void* a, const void* b) {
|
int compareCATCommands(const void* a, const void* b) {
|
||||||
return strcmp(((TS590Command*)a)->prefix(), ((TS590Command*)b)->prefix());
|
TS590Command const *B = *(TS590Command const **)b;
|
||||||
|
int cmp = strncmp((char*)a, (char*)B->prefix(), 2);
|
||||||
|
#ifdef DEBUG
|
||||||
|
Serial.print("Comparison: ");
|
||||||
|
Serial.print((char*)a);
|
||||||
|
Serial.print(" ? ");
|
||||||
|
Serial.print((char*)B->prefix());
|
||||||
|
Serial.print(" --> ");
|
||||||
|
Serial.println(cmp);
|
||||||
|
#endif
|
||||||
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBitxTS590::processCommand() {
|
void UBitxTS590::processCommand() {
|
||||||
TS590Command* cmd = (TS590Command*)bsearch((void*)buf, (void*)commands, sizeof(commands) / sizeof(commands[0]), sizeof(commands[0]), compareCATCommands);
|
TS590Command** cmd = (TS590Command**)bsearch(buf, commands, numCommands, sizeof(TS590Command*), compareCATCommands);
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
ts590SyntaxError();
|
ts590SyntaxError();
|
||||||
} else {
|
} else {
|
||||||
cmd->process(buf);
|
(*cmd)->process(buf);
|
||||||
}
|
}
|
||||||
|
bufLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UBitxTS590 TS590(catCommands);
|
UBitxTS590 TS590(catCommands, numCatCommands);
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
|
@ -150,12 +150,9 @@ class TS590_FT : public TS590Command {
|
||||||
|
|
||||||
class UBitxTS590 {
|
class UBitxTS590 {
|
||||||
public:
|
public:
|
||||||
UBitxTS590(TS590Command** cmds): commands(cmds) {}
|
UBitxTS590(TS590Command** cmds, int len): commands(cmds), numCommands(len) {}
|
||||||
|
|
||||||
inline void begin() {
|
|
||||||
Serial.begin(9600); // USB is always 12 Mbit/sec
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void begin();
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -164,6 +161,7 @@ class UBitxTS590 {
|
||||||
char buf[ts590CommandMaxLength] = {0};
|
char buf[ts590CommandMaxLength] = {0};
|
||||||
int bufLen = 0;
|
int bufLen = 0;
|
||||||
TS590Command** commands;
|
TS590Command** commands;
|
||||||
|
int numCommands;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern UBitxTS590 TS590;
|
extern UBitxTS590 TS590;
|
||||||
|
|
|
@ -15,6 +15,7 @@ KD8CEC, Ian Lee
|
||||||
#include "RigState.h"
|
#include "RigState.h"
|
||||||
#include "Sensors.h"
|
#include "Sensors.h"
|
||||||
#include "TR.h"
|
#include "TR.h"
|
||||||
|
#include "TS590.h"
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
//COMMUNICATION SECTION
|
//COMMUNICATION SECTION
|
||||||
|
|
|
@ -313,9 +313,11 @@ void sendMeterData(uint8_t isSend)
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
// Startup each of the subsystems, beginning with CAT.
|
||||||
DBGCMD( DSP.begin() );
|
DBGCMD( TS590.begin() );
|
||||||
DBGCMD( TR.begin() );
|
DBGCMD( TR.begin() );
|
||||||
|
DBGCMD( Rig.begin() );
|
||||||
|
DBGCMD( DSP.begin() );
|
||||||
|
|
||||||
// load configuration
|
// load configuration
|
||||||
EEPROM.get(EEPROM_DSPTYPE, DSPType);
|
EEPROM.get(EEPROM_DSPTYPE, DSPType);
|
||||||
|
@ -370,19 +372,18 @@ void setup()
|
||||||
void i2cReceiveEvent(size_t numBytes)
|
void i2cReceiveEvent(size_t numBytes)
|
||||||
{
|
{
|
||||||
int readCommand = 0;
|
int readCommand = 0;
|
||||||
|
bool exitLoop = false;
|
||||||
|
|
||||||
while (Wire1.available() > 0) {
|
while (Wire1.available() > 0 && !exitLoop) {
|
||||||
readCommand = Wire1.read();
|
readCommand = Wire1.read();
|
||||||
if (readCommand == I2CMETER_RIGINF) {
|
if (readCommand == I2CMETER_RIGINF) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint8_t* const ptr = Rig.stateAsBytes();
|
uint8_t* const ptr = Rig.stateAsBytes();
|
||||||
while (Wire.available() > 0) {
|
while ((Wire1.available() > 0) && (len < sizeof(UBitxRigState))) {
|
||||||
uint8_t b = Wire.read();
|
ptr[len++] = Wire1.read();
|
||||||
if (len < sizeof(UBitxRigState)) {
|
|
||||||
ptr[len++] = b;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Rig.setRaduinoUpdate();
|
Rig.setRaduinoUpdate();
|
||||||
|
exitLoop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,6 +461,9 @@ void i2cRequestEvent(void)
|
||||||
} else {
|
} else {
|
||||||
Wire1.write(Rig.stateAsBytes(), sizeof(uint8_t));
|
Wire1.write(Rig.stateAsBytes(), sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
i2cRespCounter[i2cCommand - 0x50]++;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -501,16 +505,18 @@ const int adcIntervalMillis = ADC_INTERVAL_MS;
|
||||||
int frameCounter = 0;
|
int frameCounter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**********************************************************************/
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//char isProcess = 0; // 0: init, 1: complete ADC sampling, 2: complete FFT
|
//char isProcess = 0; // 0: init, 1: complete ADC sampling, 2: complete FFT
|
||||||
//isProcess = 0;
|
//isProcess = 0;
|
||||||
|
|
||||||
forwardData();
|
// One-shot delay to ensure everything is booted up (primarily, the
|
||||||
|
// Nextion, and secondarily the Raduino.
|
||||||
if (isBooted < 100)
|
if (isBooted < 100)
|
||||||
{
|
{
|
||||||
//Delay 20msec
|
// delay 20msec
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
forwardData();
|
forwardData();
|
||||||
|
@ -520,11 +526,21 @@ void loop()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start out by forwarding any data sitting in the RX buffer. We will
|
||||||
|
// do this as often as possible.
|
||||||
|
forwardData();
|
||||||
|
|
||||||
if (sinceFrameMillis > frameIntervalMillis) {
|
if (sinceFrameMillis > frameIntervalMillis) {
|
||||||
// Do stuff that we do once per frame--I/O.
|
// Do stuff that we do once per frame--I/O.
|
||||||
// TODO: debug output (frame skipping / utilization).
|
// TODO: debug output (frame skipping / utilization).
|
||||||
sinceFrameMillis = 0;
|
sinceFrameMillis = 0;
|
||||||
|
|
||||||
|
// Update each of the subsystems, beginning with CAT control.
|
||||||
|
TS590.update();
|
||||||
|
TR.update();
|
||||||
|
Rig.update();
|
||||||
|
DSP.update();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// For debugging, output some debug info every 1.0" (40 frames @ 40 Hz).
|
// For debugging, output some debug info every 1.0" (40 frames @ 40 Hz).
|
||||||
frameCounter++;
|
frameCounter++;
|
||||||
|
@ -542,6 +558,14 @@ void loop()
|
||||||
} else {
|
} else {
|
||||||
Serial.println(", TR State: RX");
|
Serial.println(", TR State: RX");
|
||||||
}
|
}
|
||||||
|
Serial.print("VFO A: ");
|
||||||
|
Serial.print(Rig.getFreqA());
|
||||||
|
Serial.print(", VFO B: ");
|
||||||
|
Serial.print(Rig.getFreqB());
|
||||||
|
Serial.print(", Data Size: ");
|
||||||
|
Serial.print(sizeof(UBitxRigState));
|
||||||
|
Serial.println();
|
||||||
|
Serial.println("----------------------------------------------------------------------");
|
||||||
Serial.print("DBG: S-Meter Raw: ");
|
Serial.print("DBG: S-Meter Raw: ");
|
||||||
Serial.print(Sensors.sMeterUnscaled());
|
Serial.print(Sensors.sMeterUnscaled());
|
||||||
Serial.print(", S-Meter Scaled: ");
|
Serial.print(", S-Meter Scaled: ");
|
||||||
|
@ -578,8 +602,6 @@ void loop()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TR.update();
|
|
||||||
|
|
||||||
if (isTX) {
|
if (isTX) {
|
||||||
calcVSWR = Sensors.VSWR();
|
calcVSWR = Sensors.VSWR();
|
||||||
scaledVSWR = byte(Sensors.scaledVSWR());
|
scaledVSWR = byte(Sensors.scaledVSWR());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user