kopia lustrzana https://github.com/SP8EBC/ParaTNC
changed linkerscript for parameteo
rodzic
c619539500
commit
d4f723b7fe
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "stdint.h"
|
||||
|
||||
#define KISS_BUFFER_LN 300
|
||||
#define KISS_BUFFER_LN 256
|
||||
|
||||
#define KISS_TOO_LONG_FRM -1
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
|||
#endif
|
||||
|
||||
int32_t SendKISSToHost(uint8_t* input_frame, uint16_t input_frame_len, uint8_t* output, uint16_t output_len);
|
||||
short ParseReceivedKISS(uint8_t* input_frame_from_host, uint16_t input_len, AX25Ctx* ax25, Afsk* a);
|
||||
int32_t kiss_parse_received(uint8_t* input_frame_from_host, uint16_t input_len, AX25Ctx* ax25, Afsk* a);
|
||||
|
||||
void kiss_reset_buffer(uint8_t* output, uint16_t output_len, uint16_t* current_len);
|
||||
uint8_t kiss_put_char(uint8_t c, uint8_t* output, uint16_t output_len, uint16_t* current_len, uint16_t* crc);
|
||||
|
|
|
@ -16,6 +16,8 @@ typedef enum configuration_handler_region_t {
|
|||
REGION_SECOND
|
||||
} configuration_handler_region_t;
|
||||
|
||||
extern configuration_handler_region_t configuration_handler_loaded;
|
||||
|
||||
uint32_t configuration_handler_check_crc(void);
|
||||
uint32_t configuration_handler_restore_default_first(void);
|
||||
uint32_t configuration_handler_restore_default_second(void);
|
||||
|
@ -27,4 +29,6 @@ void configuration_set_register(uint32_t value);
|
|||
void configuration_set_bits_register(uint32_t value);
|
||||
void configuration_clear_bits_register(uint32_t value);
|
||||
|
||||
int32_t configuration_kiss_parse_get_running_config(uint8_t* input_frame_from_host, uint16_t input_len);
|
||||
|
||||
#endif /* CONFIGURATION_HANDLER_H_ */
|
||||
|
|
|
@ -236,10 +236,36 @@ SECTIONS
|
|||
_etext = .;
|
||||
__etext = .;
|
||||
|
||||
__config_section_first_start = 0x0801E800;
|
||||
__config_section_second_start = 0x0801F000;
|
||||
__config_section_third_start = 0x0801F800;
|
||||
__config_section_default_start = 0x0801E000; /* Page 120 and 121 */
|
||||
__config_section_first_start = 0x0801E800; /* Page 122 and 123 */
|
||||
__config_section_second_start = 0x0801F000; /* Page 124 and 125 */
|
||||
__config_section_third_start = 0x0801F800; /* Page 126 and 127 */
|
||||
|
||||
.config_section_default __config_section_default_start :
|
||||
{
|
||||
FILL(0xDD)
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
start = .;
|
||||
|
||||
KEEP(*(.config_section_default));
|
||||
|
||||
. = start + 0x10;
|
||||
KEEP(*(.config_section_default.mode));
|
||||
|
||||
. = start + 0x20;
|
||||
KEEP(*(.config_section_default.basic));
|
||||
|
||||
. = start + 0x100;
|
||||
KEEP(*(.config_section_default.sources));
|
||||
|
||||
. = start + 0x120;
|
||||
KEEP(*(.config_section_default.umb));
|
||||
|
||||
. = start + 0x140;
|
||||
KEEP(*(.config_section_default.rtu));
|
||||
}
|
||||
|
||||
.config_section_first __config_section_first_start :
|
||||
{
|
||||
|
|
|
@ -144,6 +144,102 @@ SECTIONS
|
|||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
. = ALIGN(8);
|
||||
} >FLASH
|
||||
|
||||
__config_section_default_start = 0x0801E000; /* Page 120 and 121 */
|
||||
__config_section_first_start = 0x0801E800; /* Page 122 and 123 */
|
||||
__config_section_second_start = 0x0801F000; /* Page 124 and 125 */
|
||||
__config_section_third_start = 0x0801F800; /* Page 126 and 127 */
|
||||
|
||||
.config_section_default __config_section_default_start :
|
||||
{
|
||||
FILL(0xDD)
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
start = .;
|
||||
|
||||
KEEP(*(.config_section_default));
|
||||
|
||||
. = start + 0x10;
|
||||
KEEP(*(.config_section_default.mode));
|
||||
|
||||
. = start + 0x20;
|
||||
KEEP(*(.config_section_default.basic));
|
||||
|
||||
. = start + 0x100;
|
||||
KEEP(*(.config_section_default.sources));
|
||||
|
||||
. = start + 0x120;
|
||||
KEEP(*(.config_section_default.umb));
|
||||
|
||||
. = start + 0x140;
|
||||
KEEP(*(.config_section_default.rtu));
|
||||
}
|
||||
|
||||
.config_section_first __config_section_first_start :
|
||||
{
|
||||
FILL(0xAA)
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
start = .;
|
||||
|
||||
KEEP(*(.config_section_first));
|
||||
|
||||
. = start + 0x10;
|
||||
KEEP(*(.config_section_first.mode));
|
||||
|
||||
. = start + 0x20;
|
||||
KEEP(*(.config_section_first.basic));
|
||||
|
||||
. = start + 0x100;
|
||||
KEEP(*(.config_section_first.sources));
|
||||
|
||||
. = start + 0x120;
|
||||
KEEP(*(.config_section_first.umb));
|
||||
|
||||
. = start + 0x140;
|
||||
KEEP(*(.config_section_first.rtu));
|
||||
|
||||
. = 0x7FC;
|
||||
KEEP(*(.config_section_first.crc));
|
||||
|
||||
} >FLASH
|
||||
|
||||
.config_section_second __config_section_second_start :
|
||||
{
|
||||
FILL(0xBB)
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
start = .;
|
||||
|
||||
KEEP(*(.config_section_second));
|
||||
|
||||
. = start + 0x10;
|
||||
KEEP(*(.config_section_second.mode));
|
||||
|
||||
. = start + 0x20;
|
||||
KEEP(*(.config_section_second.basic));
|
||||
|
||||
. = start + 0x100;
|
||||
KEEP(*(.config_section_second.sources));
|
||||
|
||||
. = start + 0x120;
|
||||
KEEP(*(.config_section_second.umb));
|
||||
|
||||
. = start + 0x140;
|
||||
KEEP(*(.config_section_second.rtu));
|
||||
|
||||
. = 0x7FC;
|
||||
KEEP(*(.config_section_second.crc));
|
||||
|
||||
} >FLASH
|
||||
|
||||
.config_section_third __config_section_third_start : ALIGN(4)
|
||||
{
|
||||
KEEP(*(.config_section_third))
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
|
|
@ -6,20 +6,25 @@
|
|||
*/
|
||||
|
||||
#include "KissCommunication.h"
|
||||
//#include "main.h"
|
||||
|
||||
|
||||
#include "main.h"
|
||||
#include "config_data_externs.h"
|
||||
#include "configuration_handler.h"
|
||||
|
||||
#include "drivers/serial.h"
|
||||
|
||||
#include "diag/Trace.h"
|
||||
#include "station_config.h"
|
||||
#include "TimerConfig.h"
|
||||
|
||||
|
||||
#include <crc.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern unsigned short tx10m;
|
||||
|
||||
#define KISS_DATA (uint8_t) 0x00
|
||||
#define KISS_GET_RUNNING_CONFIG (uint8_t) 0x20
|
||||
#define KISS_RUNNING_CONFIG (uint8_t) 0x70
|
||||
|
||||
uint8_t kiss_buffer[KISS_BUFFER_LN];
|
||||
|
||||
|
@ -64,50 +69,71 @@ int32_t SendKISSToHost(uint8_t* input_frame, uint16_t input_frame_len, uint8_t*
|
|||
return j;
|
||||
}
|
||||
|
||||
short ParseReceivedKISS(uint8_t* input_frame_from_host, uint16_t input_len, AX25Ctx* ax25, Afsk* a) {
|
||||
int32_t kiss_parse_received(uint8_t* input_frame_from_host, uint16_t input_len, AX25Ctx* ax25, Afsk* a) {
|
||||
int i/* zmienna do poruszania sie po buforze odbiorczym usart */;
|
||||
int j/* zmienna do poruszania sie po lokalnej tablicy do przepisywania*/;
|
||||
// uint8_t FrameBuff[100];
|
||||
|
||||
if (input_frame_from_host == 0x00 || ax25 == 0x00 || a == 0x00) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
uint8_t *FrameBuff = kiss_buffer;
|
||||
|
||||
uint8_t frame_type = *(input_frame_from_host+1);
|
||||
|
||||
// check if frame from host is not too long
|
||||
if (input_len >= KISS_BUFFER_LN)
|
||||
return 1;
|
||||
|
||||
if (*(input_frame_from_host) != FEND)
|
||||
if (*(input_frame_from_host) != FEND) {
|
||||
return 1;
|
||||
if (*(input_frame_from_host+1) != 0x00)
|
||||
return 1;
|
||||
for (i=2, j=0; (i<input_len && *(input_frame_from_host+i) != FEND); i++, j++) {
|
||||
if (*(input_frame_from_host+i) == FESC) {
|
||||
if(*(input_frame_from_host+i+1) == TFEND)
|
||||
FrameBuff[j]=FEND;
|
||||
else if(*(input_frame_from_host+i+1) == TFESC)
|
||||
FrameBuff[j]=FESC;
|
||||
else {
|
||||
;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
else
|
||||
FrameBuff[j] = *(input_frame_from_host+i);
|
||||
}
|
||||
#ifdef _DBG_TRACE
|
||||
trace_printf("KISS-FromHost:Ln=%d;Content=%s\r\n", j, FrameBuff);
|
||||
#endif
|
||||
tx10m++;
|
||||
|
||||
// keep this commented until reseting the DCD variable will be moved outside main for (;;) loop
|
||||
// while(ax25->dcd == true);
|
||||
while(a->sending == true);
|
||||
// check input frame type
|
||||
switch (frame_type != 0x00) {
|
||||
|
||||
case KISS_DATA: {
|
||||
// if this is data frame
|
||||
for (i=2, j=0; (i<input_len && *(input_frame_from_host+i) != FEND); i++, j++) {
|
||||
if (*(input_frame_from_host+i) == FESC) {
|
||||
if(*(input_frame_from_host+i+1) == TFEND)
|
||||
FrameBuff[j]=FEND;
|
||||
else if(*(input_frame_from_host+i+1) == TFESC)
|
||||
FrameBuff[j]=FESC;
|
||||
else {
|
||||
;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
else
|
||||
FrameBuff[j] = *(input_frame_from_host+i);
|
||||
}
|
||||
|
||||
tx10m++;
|
||||
|
||||
// keep this commented until reseting the DCD variable will be moved outside main for (;;) loop
|
||||
// while(ax25->dcd == true);
|
||||
while(a->sending == true);
|
||||
|
||||
|
||||
ax25_sendRaw(ax25,FrameBuff,j);
|
||||
afsk_txStart(a);
|
||||
} break;
|
||||
|
||||
case KISS_RUNNING_CONFIG: {
|
||||
|
||||
} break;
|
||||
|
||||
|
||||
default: return 1;
|
||||
}
|
||||
|
||||
|
||||
ax25_sendRaw(ax25,FrameBuff,j);
|
||||
afsk_txStart(a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void kiss_reset_buffer(uint8_t* output, uint16_t output_len, uint16_t* current_len) {
|
||||
memset(output, 0x00, sizeof(output_len));
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_mode_t config_data_mode_default = {
|
||||
volatile const config_data_mode_t __attribute__((section(".config_section_default.mode"))) config_data_mode_default = {
|
||||
#ifdef _DIGI
|
||||
.digi = 1,
|
||||
#else
|
||||
|
@ -126,7 +126,7 @@ volatile const config_data_mode_t config_data_mode_default = {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_basic_t config_data_basic_default = {
|
||||
volatile const config_data_basic_t __attribute__((section(".config_section_default.basic"))) config_data_basic_default = {
|
||||
.callsign = _CALL,
|
||||
.ssid = _SSID,
|
||||
.latitude = _LAT,
|
||||
|
@ -194,7 +194,7 @@ volatile const config_data_basic_t config_data_basic_default = {
|
|||
* Data sources for different parameters
|
||||
*
|
||||
*/
|
||||
volatile const config_data_wx_sources_t config_data_wx_sources_default = {
|
||||
volatile const config_data_wx_sources_t __attribute__((section(".config_section_default.sources"))) config_data_wx_sources_default = {
|
||||
#ifdef _TEMPERATURE_INTERNAL
|
||||
.temperature = WX_SOURCE_INTERNAL,
|
||||
#endif
|
||||
|
@ -259,7 +259,7 @@ volatile const config_data_wx_sources_t config_data_wx_sources_default = {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_umb_t config_data_umb_default = {
|
||||
volatile const config_data_umb_t __attribute__((section(".config_section_default.umb"))) config_data_umb_default = {
|
||||
#ifdef _UMB_SLAVE_ID
|
||||
.slave_id = _UMB_SLAVE_ID,
|
||||
#else
|
||||
|
@ -291,7 +291,7 @@ volatile const config_data_umb_t config_data_umb_default = {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_rtu_t config_data_rtu_default = {
|
||||
volatile const config_data_rtu_t __attribute__((section(".config_section_default.rtu"))) config_data_rtu_default = {
|
||||
.slave_speed = _RTU_SLAVE_SPEED,
|
||||
|
||||
.slave_parity = _RTU_SLAVE_PARITY,
|
||||
|
|
|
@ -37,6 +37,13 @@ const uint32_t * config_section_second_start = (uint32_t *)0x0801F000;
|
|||
|
||||
#define CONFIG_SECTION_LN 0x7FF
|
||||
|
||||
#define FEND (uint8_t)0xC0
|
||||
#define FESC (uint8_t)0xDB
|
||||
#define TFEND (uint8_t)0xDC
|
||||
#define TFESC (uint8_t)0xDD
|
||||
|
||||
#define KISS_GET_RUNNING_CONFIG (uint8_t) 0x20
|
||||
#define KISS_RUNNING_CONFIG (uint8_t) 0x70
|
||||
|
||||
volatile extern const config_data_basic_t config_data_basic_default;
|
||||
volatile extern const config_data_mode_t config_data_mode_default;
|
||||
|
@ -44,6 +51,10 @@ volatile extern const config_data_umb_t config_data_umb_default;
|
|||
volatile extern const config_data_rtu_t config_data_rtu_default;
|
||||
volatile extern const config_data_wx_sources_t config_data_wx_sources_default;
|
||||
|
||||
configuration_handler_region_t configuration_handler_loaded;
|
||||
|
||||
static const uint8_t kiss_config_preamble[] = {FEND, KISS_RUNNING_CONFIG};
|
||||
|
||||
uint32_t configuration_handler_check_crc(void) {
|
||||
|
||||
uint32_t out = 0;
|
||||
|
@ -462,6 +473,8 @@ void configuration_handler_load_configuration(configuration_handler_region_t reg
|
|||
;
|
||||
}
|
||||
|
||||
configuration_handler_loaded = region;
|
||||
|
||||
}
|
||||
|
||||
uint32_t configuration_handler_program(uint8_t* data, uint16_t data_ln, uint8_t config_idx) {
|
||||
|
@ -516,3 +529,35 @@ void configuration_clear_bits_register(uint32_t value) {
|
|||
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t configuration_kiss_parse_get_running_config(uint8_t* input_frame_from_host, uint16_t input_len) {
|
||||
|
||||
// check if current configuration is set to something which make sense
|
||||
if (configuration_handler_loaded != REGION_DEFAULT &&
|
||||
configuration_handler_loaded != REGION_FIRST &&
|
||||
configuration_handler_loaded != REGION_SECOND)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// send the KISS preamble
|
||||
srl_send_data(main_kiss_srl_ctx_ptr, kiss_config_preamble, 1, 2, 1);
|
||||
|
||||
// wait for preamble to send completely
|
||||
srl_wait_for_tx_completion(main_kiss_srl_ctx_ptr);
|
||||
|
||||
// check which configuration is in use now
|
||||
switch(configuration_handler_loaded) {
|
||||
case REGION_DEFAULT: {
|
||||
break;
|
||||
}
|
||||
case REGION_FIRST: {
|
||||
break;
|
||||
}
|
||||
case REGION_SECOND: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -984,8 +984,8 @@ int main(int argc, char* argv[]){
|
|||
// if new KISS message has been received from the host
|
||||
if (main_kiss_srl_ctx_ptr->srl_rx_state == SRL_RX_DONE && main_kiss_enabled == 1) {
|
||||
// parse i ncoming data and then transmit on radio freq
|
||||
short res = ParseReceivedKISS(srl_get_rx_buffer(main_kiss_srl_ctx_ptr), srl_get_num_bytes_rxed(main_kiss_srl_ctx_ptr), &main_ax25, &main_afsk);
|
||||
if (res == 0)
|
||||
ln = kiss_parse_received(srl_get_rx_buffer(main_kiss_srl_ctx_ptr), srl_get_num_bytes_rxed(main_kiss_srl_ctx_ptr), &main_ax25, &main_afsk);
|
||||
if (ln == 0)
|
||||
kiss10m++; // increase kiss messages counter
|
||||
|
||||
// restart KISS receiving to be ready for next frame
|
||||
|
|
|
@ -164,7 +164,7 @@ extern "C" {
|
|||
|
||||
void srl_init(srl_context_t *ctx, USART_TypeDef *port, uint8_t *rx_buffer, uint16_t rx_buffer_size, uint8_t *tx_buffer, uint16_t tx_buffer_size, uint32_t baudrate, uint8_t stop_bits);
|
||||
void srl_close(srl_context_t *ctx);
|
||||
uint8_t srl_send_data(srl_context_t *ctx, uint8_t* data, uint8_t mode, uint16_t leng, uint8_t internal_external);
|
||||
uint8_t srl_send_data(srl_context_t *ctx, const uint8_t* data, uint8_t mode, uint16_t leng, uint8_t internal_external);
|
||||
uint8_t srl_start_tx(srl_context_t *ctx, short leng);
|
||||
void srl_wait_for_tx_completion(srl_context_t *ctx);
|
||||
uint8_t srl_wait_for_rx_completion_or_timeout(srl_context_t *ctx, uint8_t* output);
|
||||
|
|
|
@ -161,7 +161,7 @@ void srl_keep_timeout(srl_context_t *ctx) {
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t srl_send_data(srl_context_t *ctx, uint8_t* data, uint8_t mode, uint16_t leng, uint8_t internal_external) {
|
||||
uint8_t srl_send_data(srl_context_t *ctx, const uint8_t* data, uint8_t mode, uint16_t leng, uint8_t internal_external) {
|
||||
if (ctx->srl_tx_state == SRL_TXING)
|
||||
return SRL_BUSY;
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ void srl_keep_timeout(srl_context_t *ctx) {
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t srl_send_data(srl_context_t *ctx, uint8_t* data, uint8_t mode, uint16_t leng, uint8_t internal_external) {
|
||||
uint8_t srl_send_data(srl_context_t *ctx, const uint8_t* data, uint8_t mode, uint16_t leng, uint8_t internal_external) {
|
||||
if (ctx->srl_tx_state == SRL_TXING)
|
||||
return SRL_BUSY;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue