o Clock calibration and station ID no longer get erased by a factory reset:
The only way to set these values is using the CAL and ID serial commands.
They still get initialized on an erased EEPROM, but never thereafter.
o MIT license added to all files.
Dev1
DigitalConfections 2020-05-30 09:48:04 -04:00
rodzic b9f99029db
commit 6fafb8d453
6 zmienionych plików z 194 dodań i 99 usunięć

Wyświetl plik

@ -1,3 +1,26 @@
/*
* MIT License
*
* Copyright (c) 2020 DigitalConfections
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Microfox Arduino nano version. Converted from PIC C November 2019
* Jerry Boyd WB8WFK
@ -24,6 +47,7 @@
#define MAX_PATTERN_TEXT_LENGTH 20
#define TEMP_STRING_LENGTH (MAX_PATTERN_TEXT_LENGTH + 10)
volatile int g_seconds = 0; /* Init timer to first second. Set in ISR checked by main. */
volatile int g_minutes = 1; /* Init timer to cycle 1. */
@ -93,7 +117,7 @@ static volatile uint8_t g_override_DIP_switches = EEPROM_OVERRIDE_DIP_SW_DEFAULT
static volatile uint8_t g_enable_LEDs;
static volatile uint8_t g_enable_sync;
static char g_tempStr[21] = { '\0' };
static char g_tempStr[TEMP_STRING_LENGTH] = { '\0' };
static volatile uint8_t g_start_override = FALSE;
@ -101,7 +125,7 @@ static volatile uint8_t g_start_override = FALSE;
* Function Prototypes
*/
void handleLinkBusMsgs(void);
void initializeEEPROMVars(void);
BOOL initializeEEPROMVars(void);
void saveAllEEPROM(void);
float getTemp(void);
uint16_t readADC();
@ -212,7 +236,10 @@ void setUpTemp(void);
sei(); /*allow interrupts. Arm and run */
initializeEEPROMVars(); /* Initialize variables stored in EEPROM */
while(initializeEEPROMVars())
{
; /* Initialize variables stored in EEPROM */
}
linkbus_init(BAUD); /* Start the Link Bus serial comms */
setUpTemp();
@ -846,9 +873,8 @@ void __attribute__((optimize("O0"))) handleLinkBusMsgs()
{
g_clock_calibration = c;
OCR1A = g_clock_calibration;
eeprom_update_word(&ee_clock_calibration, g_clock_calibration);
}
saveAllEEPROM();
}
sprintf(g_tempStr, "Cal=%u\n", g_clock_calibration);
@ -860,16 +886,27 @@ void __attribute__((optimize("O0"))) handleLinkBusMsgs()
{
if(lb_buff->fields[FIELD1][0])
{
strcpy(g_messages_text[STATION_ID], " "); /* Space before ID gets sent */
strcat(g_messages_text[STATION_ID], lb_buff->fields[FIELD1]);
strcpy(g_tempStr, " "); /* Space before ID gets sent */
strcat(g_tempStr, lb_buff->fields[FIELD1]);
if(lb_buff->fields[FIELD2][0])
{
strcat(g_messages_text[STATION_ID], " ");
strcat(g_messages_text[STATION_ID], lb_buff->fields[FIELD2]);
strcat(g_tempStr, " ");
strcat(g_tempStr, lb_buff->fields[FIELD2]);
}
saveAllEEPROM();
if(strlen(g_tempStr) <= MAX_PATTERN_TEXT_LENGTH)
{
uint8_t i;
strcpy(g_messages_text[STATION_ID], g_tempStr);
for(i = 0; i < strlen(g_messages_text[STATION_ID]); i++)
{
eeprom_update_byte((uint8_t*)&ee_stationID_text[i], (uint8_t)g_messages_text[STATION_ID][i]);
}
eeprom_update_byte((uint8_t*)&ee_stationID_text[i], 0);
}
}
if(g_messages_text[STATION_ID][0])
@ -946,8 +983,8 @@ void __attribute__((optimize("O0"))) handleLinkBusMsgs()
lb_send_string(g_tempStr, FALSE);
}
float temp = getTemp();
sprintf(g_tempStr, "Temp: %dC\n", (int)temp);
float temp = 10. * getTemp();
sprintf(g_tempStr, "Temp: %d.%dC\n", (int)temp / 10, (int)temp % 10);
lb_send_string(g_tempStr, FALSE);
}
break;
@ -971,8 +1008,9 @@ void __attribute__((optimize("O0"))) handleLinkBusMsgs()
/*
* Set non-volatile variables to their values stored in EEPROM
*/
void initializeEEPROMVars()
BOOL initializeEEPROMVars()
{
BOOL flagNotSet = FALSE;
uint8_t i;
if(eeprom_read_byte(&ee_interface_eeprom_initialization_flag) == EEPROM_INITIALIZED_FLAG)
@ -1006,6 +1044,7 @@ void initializeEEPROMVars()
}
else
{
flagNotSet = TRUE;
g_id_codespeed = EEPROM_ID_CODE_SPEED_DEFAULT;
g_pattern_codespeed = EEPROM_PATTERN_CODE_SPEED_DEFAULT;
g_ID_period_seconds = EEPROM_ID_TIME_INTERVAL_DEFAULT;
@ -1019,6 +1058,8 @@ void initializeEEPROMVars()
saveAllEEPROM();
eeprom_write_byte(&ee_interface_eeprom_initialization_flag, EEPROM_INITIALIZED_FLAG);
}
return(flagNotSet);
}
/*
@ -1027,11 +1068,16 @@ void initializeEEPROMVars()
void saveAllEEPROM()
{
uint8_t i;
BOOL initialize = TRUE;
eeprom_update_byte(&ee_id_codespeed, g_id_codespeed);
eeprom_update_byte(&ee_pattern_codespeed, g_pattern_codespeed);
eeprom_update_word(&ee_ID_time, g_ID_period_seconds);
eeprom_update_word(&ee_clock_calibration, g_clock_calibration);
uint16_t x = eeprom_read_word(&ee_clock_calibration);
if(x == 0xFFFF) /* Never overwrite a valid calibration value */
{
eeprom_update_word(&ee_clock_calibration, g_clock_calibration);
}
eeprom_update_word((uint16_t*)&ee_temp_calibration, (uint16_t)g_temp_calibration);
eeprom_update_byte(&ee_override_DIP_switches, g_override_DIP_switches);
eeprom_update_byte(&ee_enable_LEDs, g_enable_LEDs);
@ -1039,10 +1085,22 @@ void saveAllEEPROM()
for(i = 0; i < strlen(g_messages_text[STATION_ID]); i++)
{
eeprom_update_byte((uint8_t*)&ee_stationID_text[i], (uint8_t)g_messages_text[STATION_ID][i]);
if(eeprom_read_byte((uint8_t*)&ee_stationID_text) != 0xFF)
{
initialize = FALSE;
break;
}
}
eeprom_update_byte((uint8_t*)&ee_stationID_text[i], 0);
if(initialize)
{
for(i = 0; i < strlen(g_messages_text[STATION_ID]); i++)
{
eeprom_update_byte((uint8_t*)&ee_stationID_text[i], (uint8_t)g_messages_text[STATION_ID][i]);
}
eeprom_update_byte((uint8_t*)&ee_stationID_text[i], 0);
}
for(i = 0; i < strlen(g_messages_text[PATTERN_TEXT]); i++)
{

Wyświetl plik

@ -1,25 +1,27 @@
/**********************************************************************************************
* Copyright <EFBFBD> 2017 Digital Confections LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
**********************************************************************************************/
/*
* MIT License
*
* Copyright (c) 2020 DigitalConfections
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef DEFS_H
#define DEFS_H
@ -57,7 +59,7 @@
/******************************************************
* Set the text that gets displayed to the user */
#define SW_REVISION "0.4"
#define SW_REVISION "0.5"
//#define TRANQUILIZE_WATCHDOG
@ -113,7 +115,7 @@ INVALID_FOX
/******************************************************
* EEPROM definitions */
#define EEPROM_INITIALIZED_FLAG 0xAF
#define EEPROM_INITIALIZED_FLAG 0xB0
#define EEPROM_UNINITIALIZED 0x00
#define EEPROM_STATION_ID_DEFAULT "FOXBOX"
@ -127,7 +129,7 @@ INVALID_FOX
#define EEPROM_ON_AIR_TIME_DEFAULT 60
#define EEPROM_OFF_AIR_TIME_DEFAULT 240
#define EEPROM_INTRA_CYCLE_DELAY_TIME_DEFAULT 0
#define EEPROM_ID_TIME_INTERVAL_DEFAULT 300
#define EEPROM_ID_TIME_INTERVAL_DEFAULT 60
#define EEPROM_CLOCK_CALIBRATION_DEFAULT 15629
#define EEPROM_TEMP_CALIBRATION_DEFAULT 147
#define EEPROM_OVERRIDE_DIP_SW_DEFAULT 0

Wyświetl plik

@ -1,25 +1,27 @@
/**********************************************************************************************
* Copyright © 2017 Digital Confections LLC
/*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
* Copyright (c) 2020 DigitalConfections
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
**********************************************************************************************
* linkbus.c
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* linkbus.c
*
*/
@ -344,12 +346,12 @@ BOOL lb_send_string(char* str, BOOL wait)
{
return( TRUE);
}
if(strlen(str) > LINKBUS_MAX_TX_MSG_LENGTH)
{
return( TRUE);
}
strncpy(g_tempMsgBuff, str, LINKBUS_MAX_TX_MSG_LENGTH);
if(wait)

Wyświetl plik

@ -1,25 +1,27 @@
/**********************************************************************************************
* Copyright <EFBFBD> 2017 Digital Confections LLC
/*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
* Copyright (c) 2020 DigitalConfections
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
**********************************************************************************************
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* linkbus.h - a simple serial inter-processor communication protocol.
*/
@ -27,8 +29,6 @@
#define LINKBUS_H_
#include "defs.h"
//#include "transmitter.h"
//#include "si5351.h"
#define LINKBUS_MAX_MSG_LENGTH 50
#define LINKBUS_MIN_MSG_LENGTH 2 /* shortest message: GO */
@ -42,7 +42,7 @@
#define LINKBUS_MIN_TX_INTERVAL_MS 100
#define FOSC 16000000 /* Clock Speed */
#define FOSC 16000000 /* Clock Speed */
#define BAUD 57600
#define MYUBRR(b) (FOSC / 16 / (b) - 1)
@ -90,21 +90,21 @@ typedef enum
MESSAGE_EMPTY = 0,
/* DUAL-BAND TX MESSAGE FAMILY (FUNCTIONAL MESSAGING) */
MESSAGE_CLOCK_CAL = 'C' * 100 + 'A' * 10 + 'L', /* Set Jerry's clock calibration value */
MESSAGE_CLOCK_CAL = 'C' * 100 + 'A' * 10 + 'L', /* Set Jerry's clock calibration value */
MESSAGE_FACTORY_RESET = 'F' * 100 + 'A' * 10 + 'C', /* Sets EEPROM back to defaults */
MESSAGE_OVERRIDE_DIP = 'D' *100 + 'I' * 10 + 'P', /* Override DIP switch settings using this value */
MESSAGE_LEDS = 'L' * 100 + 'E' * 10 + 'D', /* Turn on or off LEDs - accepts 1 or 0 or ON or OFF */
MESSAGE_SYNC_ENABLE = 'S' * 100 + 'Y' * 10 + 'N', /* Enable or disable transmitter syncing */
MESSAGE_TEMP = 'T' * 100 + 'E' * 10 + 'M', /* Temperature data */
MESSAGE_SET_STATION_ID = 'I' * 10 + 'D', /* Sets amateur radio callsign text */
MESSAGE_GO = 'G' * 10 + 'O', /* Synchronizes clock */
MESSAGE_CODE_SPEED = 'S' * 100 + 'P' * 10 + 'D', /* Set Morse code speeds */
MESSAGE_OVERRIDE_DIP = 'D' * 100 + 'I' * 10 + 'P', /* Override DIP switch settings using this value */
MESSAGE_LEDS = 'L' * 100 + 'E' * 10 + 'D', /* Turn on or off LEDs - accepts 1 or 0 or ON or OFF */
MESSAGE_SYNC_ENABLE = 'S' * 100 + 'Y' * 10 + 'N', /* Enable or disable transmitter syncing */
MESSAGE_TEMP = 'T' * 100 + 'E' * 10 + 'M', /* Temperature data */
MESSAGE_SET_STATION_ID = 'I' * 10 + 'D', /* Sets amateur radio callsign text */
MESSAGE_GO = 'G' * 10 + 'O', /* Synchronizes clock */
MESSAGE_CODE_SPEED = 'S' * 100 + 'P' * 10 + 'D', /* Set Morse code speeds */
/* UTILITY MESSAGES */
MESSAGE_RESET = 'R' * 100 + 'S' * 10 + 'T', /* Processor reset */
MESSAGE_VERSION = 'V' * 100 + 'E' * 10 + + 'R', /* S/W version number */
MESSAGE_RESET = 'R' * 100 + 'S' * 10 + 'T', /* Processor reset */
MESSAGE_VERSION = 'V' * 100 + 'E' * 10 + +'R', /* S/W version number */
INVALID_MESSAGE = UINT16_MAX /* This value must never overlap a valid message ID */
INVALID_MESSAGE = UINT16_MAX /* This value must never overlap a valid message ID */
} LBMessageID;
typedef enum

Wyświetl plik

@ -1,8 +1,25 @@
/*
* morse.c
* MIT License
*
* Created: 3/19/2018 3:15:40 PM
* Author: charl
* Copyright (c) 2020 DigitalConfections
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "morse.h"

Wyświetl plik

@ -1,11 +1,27 @@
/*
* morse.h
* MIT License
*
* Created: 3/19/2018 3:16:02 PM
* Author: charl
* Copyright (c) 2020 DigitalConfections
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef MORSE_H_
#define MORSE_H_