Scary commit. I've taken baby steps toward passing rig status between the Raduino and the TeensyDSP using I2C. Compiles, but has not been tested. Need to create a branch.

This commit is contained in:
Rob French 2021-02-05 22:59:31 -06:00
parent e62e3ef548
commit 4186fdcdd4
11 changed files with 191 additions and 8 deletions

View File

@ -1,4 +1,4 @@
//Firmware Version
//Firmware Version
//+ : This symbol identifies the firmware.
// It was originally called 'CEC V1.072' but it is too long to waste the LCD window.
// I do not want to make this Firmware users's uBITX messy with my callsign.
@ -122,7 +122,9 @@ char vfoActive = VFO_A;
int8_t meter_reading = 0; // a -1 on meter makes it invisible
unsigned long vfoA=7150000L, vfoB=14200000L, sideTone=800, usbCarrier, cwmCarrier;
unsigned long vfoA_eeprom, vfoB_eeprom; //for protect eeprom life
unsigned long frequency, ritRxFrequency, ritTxFrequency; //frequency is the current frequency on the dial
unsigned long frequency;
unsigned long ritRxFrequency, ritTxFrequency; //frequency is the current frequency on the dial
unsigned int cwSpeed = 100; //this is actuall the dot period in milliseconds
extern int32_t calibration;

1
Raduino/RigState.h Symbolic link
View File

@ -0,0 +1 @@
../TeensyDSP/RigState.h

View File

@ -19,6 +19,8 @@
#include <Arduino.h> //for Linux, On Linux it is case sensitive.
#include "RigState.h"
//==============================================================================
// Compile Option
//==============================================================================
@ -253,6 +255,12 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode
#define I2CMETER_CALCR 0x55 //Calculated SWR Meter
#define I2CMETER_UNCALCR 0x54 //Uncalculated SWR Meter
// Raduino provides updated data to TeensyDSP
#define I2CMETER_RIGINF 0x50
// Raduino requests any CAT updates from TeensyDSP
#define I2CMETER_REQCAT 0x51
//==============================================================================
// for public, Variable, functions
//==============================================================================
@ -332,4 +340,6 @@ extern void DisplayVersionInfo(const char* fwVersionInfo);
//I2C Signal Meter, Version 1.097
extern int GetI2CSmeterValue(int valueType); //ubitx_ui.ino
extern void doRaduinoToTeensy(UBitxRigState* r);
#endif //end of if header define

View File

@ -990,9 +990,18 @@ void SWS_Process(void)
char checkCount = 0;
char checkCountSMeter = 0;
UBitxRigState rigState;
UBitxRigState catState;
//execute interval : 0.25sec
void idle_process()
{
// KC4UPR 2021-02-05 added update process for Raduino-TeensyDSP coordination
// Note, need to not have to copy this every time...
rigState.vfo[0] = vfoA;
rigState.vfo[1] = vfoB;
doRaduinoToTeensy(&rigState);
//S-Meter Display
if (((displayOption1 & 0x08) == 0x08 && (sdrModeOn == 0)) && (++checkCountSMeter > SMeterLatency))
{

View File

@ -18,6 +18,8 @@ const PROGMEM uint8_t meters_bitmap[] = {
};
*/
#include "RigState.h"
//SWR GRAPH, DrawMeter and drawingMeter Logic function by VK2ETA
#ifdef OPTION_SKINNYBARS //We want skninny bars with more text
@ -296,4 +298,27 @@ int GetI2CSmeterValue(int valueType)
}
}
//======================================================================
void doRaduinoToTeensy(UBitxRigState* r) {
uint8_t* ptr = (uint8_t*)r;
Wire.beginTransmission(I2CMETER_ADDR);
Wire.write(I2CMETER_RIGINF);
Wire.write(ptr, sizeof(UBitxRigState));
Wire.endTransmission();
Wire.requestFrom(I2CMETER_ADDR, sizeof(UBitxRigState));
UBitxRigState tmp;
int len = 0;
ptr = (uint8_t*)&tmp;
while (Wire.available() > 0) {
uint8_t b = Wire.read();
if (len < sizeof(UBitxRigState)) {
ptr[len++] = b;
}
}
}

View File

@ -3,7 +3,7 @@ EELAYER 30 0
EELAYER END
$Descr USLetter 11000 8500
encoding utf-8
Sheet 1 1
Sheet 1 2
Title "uBitx V5 I/O Board"
Date ""
Rev ""
@ -1102,4 +1102,10 @@ Text Notes 7750 3900 0 118 ~ 0
RX Audio Output
Text Notes 10200 1800 2 50 Italic 0
Unused op-amp section
$Sheet
S 9400 4500 500 400
U 607D96BA
F0 "I/O Board Wiring" 50
F1 "IO_Board_Wiring.sch" 50
$EndSheet
$EndSCHEMATC

View File

@ -1100,4 +1100,6 @@ Text Notes 4900 1550 0 59 Italic 0
Spare 2 (pin 31)\nS-Meter (pin 28)\nSupply Voltage (pin 21)\nREV PWR (pin 20)\nFWD PWR (pin 26)\nSpare 1 (pin 27)
Text Notes 7750 3900 0 118 ~ 0
RX Audio Output
Text Notes 10200 1800 2 50 Italic 0
Unused op-amp section
$EndSCHEMATC

View File

@ -0,0 +1,16 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 2 2
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$EndSCHEMATC

76
TeensyDSP/RigState.h Normal file
View File

@ -0,0 +1,76 @@
#ifndef __RigState_h__
#define __RigState_h__
#define UBITX_VFOA_UPDATE 0x01
#define UBITX_VFOB_UPDATE 0x02
#define UBITX_RIT_UPDATE 0x04
#define UBITX_XIT_UPDATE 0x08
#define UBITX_FLAGS_UPDATE 0x10
#define UBITX_VFOB_FLAG 0x01
#define UBITX_SPLIT_FLAG 0x02
#define UBITX_RIT_FLAG 0x04
#define UBITX_XIT_FLAG 0x08
#define UBITX_CW_FLAG 0x10
#define UBITX_USB_FLAG 0x20
#define UBITX_TX_FLAG 0x40
struct UBitxRigState {
uint8_t header = 0;
uint32_t vfo[2];
uint16_t rit;
uint16_t xit;
uint8_t flags = 0;
};
/*
class UBitxRig {
public:
inline int freqA() const { return state.vfo[0]; }
inline int freqB() const { return state.vfo[1]; }
inline int freqRIT() const { return state.rit; }
inline int freqXIT() const { return state.xit; }
inline char vfo() const { return (state.flags & UBITX_VFOB_FLAG) == UBITX_VFOB_FLAG; }
inline char isSplit() const { return (state.flags & UBITX_SPLIT_FLAG) == UBITX_SPLIT_FLAG; }
inline char isRIT() const { return (state.flags & UBITX_RIT_FLAG) == UBITX_RIT_FLAG; }
inline char isXIT() const { return (state.flags & UBITX_XIT_FLAG) == UBITX_XIT_FLAG; }
inline char isCW() const { return (state.flags & UBITX_CW_FLAG) == UBITX_CW_FLAG; }
inline char isLSB() const { return (state.flags & UBITX_USB_FLAG) != UBITX_USB_FLAG; }
inline char isUSB() const { return (state.flags & UBITX_USB_FLAG) == UBITX_USB_FLAG; }
char* packDelta() {
buflen = 0;
// first byte: what fields have changed
buf[buflen++] = uint8_t(state.dirty);
// next (if req'd): VFO A frequency
if (state.dirty & UBITX_VFOA_UPDATE) {
packInt(state.vfo[0];
}
// next (if req'd): VFO B frequency
if (state.dirty & UBITX_VFOB_UPDATE) {
packInt(state.vfo[0];
}
private:
inline void packByte(uint8_t b) { buf[buflen++] = uint8_t(state.dirty);
inline void packInt(int i) {
int tmp = i;
for (int j = 0; j < 32; j+=8) {
tmp = tmp >> j;
buf[buflen++] = uint8_t(tmp & 0x000000FF);
}
}
UBitxRigState state;
uint8_t buf[sizeof(uint8_t) + sizeof(UBitxRigState)];
int buflen = 0;
};
*/
#endif

View File

@ -11,6 +11,7 @@ KD8CEC, Ian Lee
#include "Debug.h"
#include "DSP.h"
#include "Nextion.h"
#include "RigState.h"
#include "Sensors.h"
#include "TR.h"
@ -63,3 +64,9 @@ extern int magnitudelimit_low;
//SWR
#define I2CMETER_CALCR 0x55 //Calculated SWR Meter
#define I2CMETER_UNCALCR 0x54 //Uncalculated SWR Meter
// Raduino provides updated data to TeensyDSP
#define I2CMETER_RIGINF 0x50
// Raduino requests any CAT updates from TeensyDSP
#define I2CMETER_REQCAT 0x51

View File

@ -47,6 +47,11 @@ bool isTX = false;
/**********************************************************************/
UBitxRigState catState;
UBitxRigState rigState;
/**********************************************************************/
void responseConfig()
{
if (responseCommand == 2)
@ -371,16 +376,30 @@ void setup()
Number of bytes received--not used in this procedure.
*/
void i2cReceiveEvent(size_t numBytes)
{
{
int readCommand = 0;
while (Wire1.available() > 0) // for Last command
{
while (Wire1.available() > 0) {
readCommand = Wire1.read();
// KC4UPR: Note that this looks to be only reading the last command, i.e.
// if multiple commands have been queued up, only the last will get executed.
if (readCommand == I2CMETER_RIGINF) {
size_t len = 0;
uint8_t* ptr = (uint8_t*)&rigState;
while (Wire.available() > 0) {
uint8_t b = Wire.read();
if (len < sizeof(UBitxRigState)) {
ptr[len++] = b;
}
}
}
}
// while (Wire1.available() > 0) // for Last command
// {
// readCommand = Wire1.read();
// // KC4UPR: Note that this looks to be only reading the last command, i.e.
// // if multiple commands have been queued up, only the last will get executed.
// }
if (0x50 <= readCommand && readCommand <= 0x59)
{
#ifdef DEBUG
@ -434,6 +453,16 @@ void i2cRequestEvent(void)
#endif
break;
case I2CMETER_RIGINF:
// Receive current rig state; transmit any CAT updates, if required.
Wire1.write(catState.header); // temporary - just writing a single, null byte
break;
case I2CMETER_REQCAT:
// Provide latest CAT updates, if any.
break;
default:
break;
}