2020-05-17 00:48:39 -04:00
|
|
|
//======================================================================
|
|
|
|
// iopcomm.h
|
|
|
|
//======================================================================
|
|
|
|
|
|
|
|
#ifndef __iopcomm_h__
|
|
|
|
#define __iopcomm_h__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/* Message prefixes, starting with the ACK message (0). Message format
|
|
|
|
* consists of 1 or more bytes, where:
|
|
|
|
* b[0] - leftmost 3 bits == prefix
|
|
|
|
* - rightmost 5 bits == length of data (0-31)
|
|
|
|
* b[1]...b[31] (if present) - data bits
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum PrefixID {
|
|
|
|
ACK = 0,
|
|
|
|
CAT_PREFIX,
|
|
|
|
IOP_PREFIX,
|
|
|
|
RAD_EEPROM_READ_PREFIX,
|
|
|
|
RAD_EEPROM_WRITE_PREFIX,
|
|
|
|
IOP_EEPROM_READ_PREFIX,
|
|
|
|
IOP_EEPROM_WRITE_PREFIX,
|
|
|
|
NUM_PREFIX_IDS
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Masks for the leftmost 3 bits (prefix) and rightmost 5 bits (length)
|
|
|
|
* of a message.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PREFIX_MASK 0xE0
|
|
|
|
#define LENGTH_MASK 0x1F
|
|
|
|
|
|
|
|
/* Convert a prefix and length to a byte, by shifting the prefix left
|
|
|
|
* 5 bits and OR-ing with the 5 bits of length.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline uint8_t prefixAndLengthToByte(PrefixID id, uint8_t len)
|
|
|
|
{
|
|
|
|
return (uint8_t(id) << 5) | (len & LENGTH_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract the prefix (leftmost 3 bits) from a byte.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline PrefixID byteToPrefix(uint8_t b)
|
|
|
|
{
|
|
|
|
return PrefixID(b >> 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract the length (rightmost 5 bits) from a byte.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline uint8_t byteToLength(byte b)
|
|
|
|
{
|
|
|
|
return uint8_t(b & LENGTH_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Message IDs/types, for IOP messages (messages between the Raduino and
|
|
|
|
* the IOP, not including CAT messages to be passed through).
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum MessageID {
|
|
|
|
// Commands
|
|
|
|
IOP_MODE_COMMAND = 0,
|
|
|
|
IOP_START_TX_COMMAND,
|
|
|
|
IOP_STOP_TX_COMMAND,
|
|
|
|
IOP_CW_CONFIG_MSG,
|
2020-06-07 16:27:27 -04:00
|
|
|
IOP_DEBUG_MSG,
|
2020-05-17 00:48:39 -04:00
|
|
|
|
|
|
|
// Requests
|
|
|
|
IOP_MODE_REQUEST,
|
2020-05-18 09:16:54 -04:00
|
|
|
IOP_SSB_STATUS_MSG,
|
2020-05-26 00:08:55 -04:00
|
|
|
IOP_DGT_STATUS_MSG,
|
2020-05-17 00:48:39 -04:00
|
|
|
IOP_CW_STATUS_MSG,
|
2020-05-18 09:16:54 -04:00
|
|
|
IOP_TEST_STATUS_MSG,
|
2020-06-06 01:06:45 -04:00
|
|
|
IOP_MENU_DISPLAY_MSG,
|
2020-06-07 16:27:27 -04:00
|
|
|
IOP_MENU_INACTIVE_MSG,
|
2020-05-17 00:48:39 -04:00
|
|
|
|
|
|
|
// add any new elements here
|
|
|
|
NUM_MESSAGE_IDS
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Max length of an IOP message payload (data), based on the following
|
|
|
|
* message format:
|
|
|
|
*
|
|
|
|
* byte 0: prefix (3 bits) + length (5 bits)
|
|
|
|
* byte 1: message ID (type)
|
|
|
|
* bytes 2-31: data bytes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IOP_MESSAGE_MAX_LEN 30
|
|
|
|
|
|
|
|
/* Rig modes. Currently just defined as what the IOP cares about, but
|
|
|
|
* maybe these need to be expanded to encompass all of the rig modes.
|
|
|
|
* (e.g. USB, LSB, etc.)
|
|
|
|
*/
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
enum rig_mode {
|
|
|
|
lsb = 0,
|
|
|
|
usb,
|
|
|
|
cw,
|
|
|
|
cwr,
|
|
|
|
dig,
|
2020-05-26 00:08:55 -04:00
|
|
|
// add new items here
|
2020-06-13 10:59:11 -04:00
|
|
|
num_rig_modes
|
2020-05-17 00:48:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Keyer modes.
|
|
|
|
*/
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
enum keyer_mode {
|
|
|
|
straight = 0,
|
|
|
|
iambic_a,
|
|
|
|
iambic_b,
|
|
|
|
//ultimatic,
|
|
|
|
//bug,
|
|
|
|
// add any new items here
|
|
|
|
num_keyer_modes
|
2020-05-17 00:48:39 -04:00
|
|
|
};
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
enum rx_filter {
|
|
|
|
wide = 0,
|
|
|
|
medium,
|
|
|
|
narrow,
|
|
|
|
num_rx_filters
|
2020-05-18 09:16:54 -04:00
|
|
|
};
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
enum digi_mode {
|
|
|
|
rtty = 0,
|
|
|
|
psk31,
|
|
|
|
user_defined,
|
|
|
|
num_digi_modes
|
|
|
|
};
|
|
|
|
|
|
|
|
//const unsigned char RIG_MODE_LETTER[num_rig_modes] = {'s', 'S', 'c', 'C', 'd', 'D', 't', 'T'};
|
|
|
|
//const unsigned char KEYER_MODE_LETTER[num_keyer_modes] = {'S', 'A', 'B'};
|
|
|
|
//const unsigned char RX_FILTER_LETTER[num_rx_filters] = {'W', 'M', 'N'};
|
2020-05-17 00:48:39 -04:00
|
|
|
|
|
|
|
const uint8_t NO_FLAGS = 0;
|
|
|
|
const uint8_t REVERSED = 1;
|
|
|
|
|
|
|
|
struct IOPMessage {
|
2020-06-07 16:27:27 -04:00
|
|
|
IOPMessage() { memset(data, 0, IOP_MESSAGE_MAX_LEN); }
|
|
|
|
uint8_t id;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t data[IOP_MESSAGE_MAX_LEN];
|
2020-05-17 00:48:39 -04:00
|
|
|
};
|
|
|
|
|
2020-05-26 00:08:55 -04:00
|
|
|
//======================================================================
|
|
|
|
// IConfig
|
|
|
|
//
|
|
|
|
// Interface to a configuration object.
|
|
|
|
//======================================================================
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
struct filter_config {
|
|
|
|
float lo;
|
|
|
|
float hi;
|
|
|
|
float gain;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mode_config {
|
|
|
|
mode_config(bool usb, rx_filter f, const filter_config *fc) : is_usb(usb), filter(f) {
|
|
|
|
for (int i = 0; i < num_rx_filters; i++) {
|
|
|
|
filtercfg[i] = fc[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool is_usb;
|
|
|
|
rx_filter filter;
|
|
|
|
filter_config filtercfg[num_rx_filters];
|
2020-05-26 00:08:55 -04:00
|
|
|
};
|
|
|
|
|
2020-05-18 09:16:54 -04:00
|
|
|
//======================================================================
|
|
|
|
// SSB CONFIGURATION
|
|
|
|
//======================================================================
|
2020-05-17 00:48:39 -04:00
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
const filter_config ssb_filter_config[num_rx_filters] =
|
|
|
|
{filter_config{ 300.0, 3100.0, 1.0},
|
|
|
|
filter_config{ 500.0, 2900.0, 1.0},
|
|
|
|
filter_config{ 700.0, 2500.0, 1.0}};
|
|
|
|
|
|
|
|
struct ssb_config : public mode_config {
|
|
|
|
ssb_config() : mode_config(true, wide, ssb_filter_config) {}
|
|
|
|
// speech compressor parameters
|
|
|
|
bool comp_enable = false;
|
|
|
|
float comp_threshold = 0.1;
|
|
|
|
float comp_ratio = 20.0;
|
|
|
|
float comp_gain = 2.0;
|
2020-05-18 09:16:54 -04:00
|
|
|
};
|
2020-05-17 00:48:39 -04:00
|
|
|
|
2020-05-18 09:16:54 -04:00
|
|
|
//======================================================================
|
2020-06-13 10:59:11 -04:00
|
|
|
// DIG CONFIGURATION
|
2020-05-18 09:16:54 -04:00
|
|
|
//======================================================================
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
const filter_config dig_filter_config[num_rx_filters] =
|
|
|
|
{filter_config{ 300.0, 3100.0, 1.0},
|
|
|
|
filter_config{ 500.0, 2900.0, 1.0},
|
|
|
|
filter_config{1250.0, 1750.0, 1.0}};
|
|
|
|
|
|
|
|
struct dig_config : public mode_config {
|
|
|
|
dig_config() : mode_config(true, wide, dig_filter_config) {}
|
|
|
|
digi_mode submode = user_defined;
|
2020-05-18 09:16:54 -04:00
|
|
|
};
|
2020-05-17 00:48:39 -04:00
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
// CW CONFIGURATION
|
|
|
|
//======================================================================
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
const filter_config cw_filter_config[num_rx_filters] =
|
|
|
|
{filter_config{ 300.0, 1300.0, 1.0},
|
|
|
|
filter_config{ 450.0, 950.0, 1.0},
|
|
|
|
filter_config{ 575.0, 825.0, 1.0}};
|
|
|
|
|
|
|
|
struct cw_config : public mode_config {
|
|
|
|
cw_config() : mode_config(true, wide, cw_filter_config) {}
|
|
|
|
keyer_mode mode = iambic_a;
|
2020-05-18 09:16:54 -04:00
|
|
|
// flags
|
|
|
|
bool reversed = false;
|
|
|
|
// parameters
|
|
|
|
uint8_t wpm = 15;
|
|
|
|
float weight = 3.0;
|
|
|
|
uint16_t sidetone = 700;
|
2020-05-26 00:08:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
// TT CONFIGURATION
|
|
|
|
//======================================================================
|
2020-06-13 10:59:11 -04:00
|
|
|
/*
|
|
|
|
struct TTConfig : public IConfig {
|
2020-05-26 00:08:55 -04:00
|
|
|
public:
|
|
|
|
TTConfig(RxFilter f): filter(f) {}
|
|
|
|
// parameters
|
2020-06-11 00:23:15 -04:00
|
|
|
RxFilter filter = RX_FILTER_MEDIUM;
|
2020-05-17 00:48:39 -04:00
|
|
|
};
|
2020-06-13 10:59:11 -04:00
|
|
|
*/
|
2020-05-18 09:16:54 -04:00
|
|
|
//======================================================================
|
|
|
|
// FUNCTION PROTOTYPES
|
|
|
|
//======================================================================
|
|
|
|
|
|
|
|
void sendCATMessage(const uint8_t*);
|
|
|
|
void sendIOPMessage(IOPMessage const&);
|
|
|
|
void recvIOPMessage(IOPMessage&, const uint8_t*, int);
|
|
|
|
|
2020-06-13 10:59:11 -04:00
|
|
|
void sendIOPModeCommand(rig_mode);
|
2020-05-18 09:16:54 -04:00
|
|
|
void sendIOPStartTxCommand();
|
|
|
|
void sendIOPStopTxCommand();
|
2020-06-07 16:27:27 -04:00
|
|
|
void sendIOPDebugMessage(const char*);
|
2020-05-18 09:16:54 -04:00
|
|
|
|
|
|
|
void sendIOPModeRequest();
|
2020-06-13 10:59:11 -04:00
|
|
|
//void sendIOPSSBStatus(SSBConfig const&);
|
|
|
|
//void sendIOPDGTStatus(DGTConfig const&);
|
|
|
|
//void sendIOPCWStatus(CWConfig const&);
|
|
|
|
//void sendIOPTestStatus();
|
2020-06-07 16:27:27 -04:00
|
|
|
void sendIOPMenuDisplay(const char*);
|
|
|
|
void sendIOPMenuInactive();
|
2020-05-18 09:16:54 -04:00
|
|
|
|
2020-05-17 00:48:39 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
// EOF
|
|
|
|
//======================================================================
|