kopia lustrzana https://github.com/SP8EBC/ParaTNC
working linker script placing the configuration structures in right places in sections
rodzic
0db20888e2
commit
00eba91c2d
|
@ -200,7 +200,7 @@
|
|||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="Timer.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry excluding="src/stm32f1-stdperiph/stm32f10x_rtc.c|src/stm32f1-stdperiph/stm32f10x_adc.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_crc.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_flash.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_cec.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="system"/>
|
||||
<entry excluding="src/stm32f1-stdperiph/stm32f10x_adc.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_cec.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="system"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
@ -381,7 +381,7 @@
|
|||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="Timer.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry excluding="src/stm32f1-stdperiph/stm32f10x_rtc.c|src/stm32f1-stdperiph/stm32f10x_adc.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/stm32f1-stdperiph/stm32f10x_tim.c|src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_crc.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_flash.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_cec.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="system"/>
|
||||
<entry excluding="src/stm32f1-stdperiph/stm32f10x_adc.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/stm32f1-stdperiph/stm32f10x_tim.c|src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_cec.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="system"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
|
|
@ -9,10 +9,12 @@ C_SRCS += \
|
|||
../src/PathConfig.c \
|
||||
../src/TimerConfig.c \
|
||||
../src/_write.c \
|
||||
../src/config_data_default.c \
|
||||
../src/config_data_first.c \
|
||||
../src/config_data_second.c \
|
||||
../src/config_data_third.c \
|
||||
../src/configuration_handler.c \
|
||||
../src/delay.c \
|
||||
../src/dummy.c \
|
||||
../src/io.c \
|
||||
../src/it_handlers.c \
|
||||
../src/main.c \
|
||||
|
@ -32,10 +34,12 @@ OBJS += \
|
|||
./src/PathConfig.o \
|
||||
./src/TimerConfig.o \
|
||||
./src/_write.o \
|
||||
./src/config_data_default.o \
|
||||
./src/config_data_first.o \
|
||||
./src/config_data_second.o \
|
||||
./src/config_data_third.o \
|
||||
./src/configuration_handler.o \
|
||||
./src/delay.o \
|
||||
./src/dummy.o \
|
||||
./src/io.o \
|
||||
./src/it_handlers.o \
|
||||
./src/main.o \
|
||||
|
@ -55,10 +59,12 @@ C_DEPS += \
|
|||
./src/PathConfig.d \
|
||||
./src/TimerConfig.d \
|
||||
./src/_write.d \
|
||||
./src/config_data_default.d \
|
||||
./src/config_data_first.d \
|
||||
./src/config_data_second.d \
|
||||
./src/config_data_third.d \
|
||||
./src/configuration_handler.d \
|
||||
./src/delay.d \
|
||||
./src/dummy.d \
|
||||
./src/io.d \
|
||||
./src/it_handlers.d \
|
||||
./src/main.d \
|
||||
|
|
|
@ -5,37 +5,46 @@
|
|||
# Add inputs and outputs from these tool invocations to the build variables
|
||||
C_SRCS += \
|
||||
../system/src/stm32f1-stdperiph/misc.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_crc.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_dbgmcu.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_dma.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_exti.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_flash.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_gpio.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_i2c.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_iwdg.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_rcc.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_rtc.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_tim.c \
|
||||
../system/src/stm32f1-stdperiph/stm32f10x_usart.c
|
||||
|
||||
OBJS += \
|
||||
./system/src/stm32f1-stdperiph/misc.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_crc.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_dbgmcu.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_dma.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_exti.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_flash.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_gpio.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_i2c.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_iwdg.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_rcc.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_rtc.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_tim.o \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_usart.o
|
||||
|
||||
C_DEPS += \
|
||||
./system/src/stm32f1-stdperiph/misc.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_crc.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_dbgmcu.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_dma.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_exti.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_flash.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_gpio.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_i2c.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_iwdg.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_rcc.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_rtc.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_tim.d \
|
||||
./system/src/stm32f1-stdperiph/stm32f10x_usart.d
|
||||
|
||||
|
|
|
@ -10,11 +10,24 @@
|
|||
|
||||
#include "config_data.h"
|
||||
|
||||
extern const int __config_section_first_crc;
|
||||
extern const int __config_section_second_crc;
|
||||
|
||||
extern const int __config_section_first_pgm_counter;
|
||||
extern const int __config_section_second_pgm_counter;
|
||||
|
||||
|
||||
extern const config_data_basic_t config_data_basic_first;
|
||||
extern const config_data_mode_t config_data_mode_first;
|
||||
extern const config_data_umb_t config_data_umb_first;
|
||||
extern const config_data_rtu_t config_data_rtu_first;
|
||||
extern const config_data_wx_sources_t config_data_wx_sources_first;
|
||||
|
||||
extern const config_data_basic_t config_data_basic_second;
|
||||
extern const config_data_mode_t config_data_mode_second;
|
||||
extern const config_data_umb_t config_data_umb_second;
|
||||
extern const config_data_rtu_t config_data_rtu_second;
|
||||
extern const config_data_wx_sources_t config_data_wx_sources_second;
|
||||
|
||||
|
||||
#endif /* CONFIG_DATA_EXTERNS_H_ */
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* configuration_handler.h
|
||||
*
|
||||
* Created on: Apr 28, 2021
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef CONFIGURATION_HANDLER_H_
|
||||
#define CONFIGURATION_HANDLER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t configuration_handler_check_crc(void);
|
||||
uint32_t configuration_handler_restore_default(void);
|
||||
uint32_t configuration_handler_load_configuration(void);
|
||||
uint32_t configuration_handler_program(uint8_t* data, uint16_t data_ln, uint8_t config_idx);
|
||||
|
||||
#endif /* CONFIGURATION_HANDLER_H_ */
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "aprs/ax25.h"
|
||||
#include "drivers/serial.h"
|
||||
#include "config_data.h"
|
||||
|
||||
#define SW_VER "DF14"
|
||||
#define SW_DATE "22032021"
|
||||
|
@ -17,6 +18,12 @@
|
|||
|
||||
extern uint32_t master_time;
|
||||
|
||||
extern const config_data_mode_t * main_config_data_mode;
|
||||
extern const config_data_basic_t * main_config_data_basic;
|
||||
extern const config_data_wx_sources_t * main_config_data_wx_sources;
|
||||
extern const config_data_umb_t * main_config_data_umb;
|
||||
extern const config_data_rtu_t * main_config_data_rtu;
|
||||
|
||||
extern int32_t main_wx_sensors_pool_timer;
|
||||
extern int32_t main_one_minute_pool_timer;
|
||||
extern int32_t main_one_second_pool_timer;
|
||||
|
|
|
@ -204,6 +204,8 @@ SECTIONS
|
|||
|
||||
KEEP(*(.eh_frame*))
|
||||
|
||||
KEEP(*(.config_section_default))
|
||||
|
||||
/*
|
||||
* Stub sections generated by the linker, to glue together
|
||||
* ARM and Thumb code. .glue_7 is used for ARM code calling
|
||||
|
@ -237,47 +239,74 @@ SECTIONS
|
|||
__config_section_first_start = 0x0801E800;
|
||||
__config_section_second_start = 0x0801F000;
|
||||
__config_section_third_start = 0x0801F800;
|
||||
|
||||
|
||||
__config_section_first_end = __config_section_first_start + 0x7FF;
|
||||
__config_section_second_end = __config_section_second_start + 0x7FF;
|
||||
__config_section_third_end = __config_section_third_start + 0x7FF;
|
||||
|
||||
.config_section_first __config_section_first_start : ALIGN(4)
|
||||
.config_section_first __config_section_first_start :
|
||||
{
|
||||
FILL(0xAB)
|
||||
|
||||
*(.config_section_first) config_data_mode_first = __config_section_first_start;
|
||||
*(.config_section_first) config_data_basic_first = __config_section_first_start + 0x20;
|
||||
*(.config_section_first) config_data_wx_sources_first = __config_section_first_start + 0x100;
|
||||
*(.config_section_first) config_data_umb_first = __config_section_first_start + 0x120;
|
||||
*(.config_section_first) config_data_rtu_first = __config_section_first_start + 0x140;
|
||||
|
||||
__config_section_first_crc = (__config_section_first_end - 0x4);
|
||||
|
||||
KEEP(*(.config_section_first))
|
||||
} >FLASH
|
||||
|
||||
.config_section_second __config_section_second_start : ALIGN(4)
|
||||
{
|
||||
FILL(0xAC)
|
||||
|
||||
|
||||
*(.config_section_second) config_data_mode_second = __config_section_second_start;
|
||||
*(.config_section_second) config_data_basic_second = __config_section_second_start + 0x20;
|
||||
*(.config_section_second) config_data_wx_sources_second = __config_section_second_start + 0x100;
|
||||
*(.config_section_second) config_data_umb_second = __config_section_second_start + 0x120;
|
||||
*(.config_section_second) config_data_rtu_second = __config_section_second_start + 0x140;
|
||||
FILL(0xAA)
|
||||
|
||||
__config_section_second_crc = (__config_section_second_end - 0x4);
|
||||
. = ALIGN(4);
|
||||
|
||||
KEEP(*(.config_section_second))
|
||||
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_third __config_section_third_start : ALIGN(4)
|
||||
.config_section_second __config_section_second_start :
|
||||
{
|
||||
KEEP(*(.config_section_third))
|
||||
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
|
||||
|
||||
|
||||
/* MEMORY_ARRAY */
|
||||
/*
|
||||
.ROarraySection :
|
||||
|
|
|
@ -0,0 +1,431 @@
|
|||
/*
|
||||
* config_data_default.c
|
||||
*
|
||||
* Created on: Apr 27, 2021
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
// this file contains default configuration used if both first and second config_data section doesn't contains valid
|
||||
// configuration data (CRC32 calculated from both sections is wrong). In such case the software erases both sections and
|
||||
// reprogram it from the default set stored somewhere within .code section
|
||||
|
||||
#include "config_data.h"
|
||||
|
||||
#include "station_config.h"
|
||||
|
||||
|
||||
#ifndef _RTU_SLAVE_LENGHT_1
|
||||
#define _RTU_SLAVE_LENGHT_1 0x1
|
||||
#endif
|
||||
|
||||
#ifndef _RTU_SLAVE_LENGHT_2
|
||||
#define _RTU_SLAVE_LENGHT_2 0x1
|
||||
#endif
|
||||
|
||||
#ifndef _RTU_SLAVE_LENGHT_3
|
||||
#define _RTU_SLAVE_LENGHT_3 0x1
|
||||
#endif
|
||||
|
||||
#ifndef _RTU_SLAVE_LENGHT_4
|
||||
#define _RTU_SLAVE_LENGHT_4 0x1
|
||||
#endif
|
||||
|
||||
#ifndef _RTU_SLAVE_LENGHT_5
|
||||
#define _RTU_SLAVE_LENGHT_5 0x1
|
||||
#endif
|
||||
|
||||
#ifndef _RTU_SLAVE_LENGHT_6
|
||||
#define _RTU_SLAVE_LENGHT_6 0x1
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_mode_t config_data_mode_default = {
|
||||
#ifdef _DIGI
|
||||
.digi = 1,
|
||||
#else
|
||||
.digi = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _METEO
|
||||
.wx = 1,
|
||||
#else
|
||||
.wx = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _MODBUS_RTU
|
||||
.wx_modbus = 1,
|
||||
#else
|
||||
.wx_modbus = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _MODBUS_RTU
|
||||
.wx_modbus = 1,
|
||||
#else
|
||||
.wx_modbus = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _UMB_MASTER
|
||||
.wx_umb = 1,
|
||||
#else
|
||||
.wx_umb = 0,
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _VICTRON
|
||||
.victron = 1,
|
||||
#else
|
||||
.victron = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _SENSOR_BME280
|
||||
.wx_ms5611_or_bme = 1,
|
||||
#else
|
||||
.wx_ms5611_or_bme = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _DIGI_ONLY_789
|
||||
.digi_only_ssids = 1,
|
||||
#else
|
||||
.digi_only_ssids = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _DIGI_VISCOUS
|
||||
.digi_viscous = 1,
|
||||
#else
|
||||
.digi_viscous = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _DIGI_VISCOUS_DEALY
|
||||
.digi_viscous_delay_sec = _DIGI_VISCOUS_DEALY
|
||||
#else
|
||||
.digi_viscous_delay_sec = 3
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_basic_t config_data_basic_default = {
|
||||
.callsign = _CALL,
|
||||
.ssid = _SSID,
|
||||
.latitude = _LAT,
|
||||
.longitude = _LON,
|
||||
#if (_LATNS == 'N')
|
||||
.zero_to_n_one_to_s = 0,
|
||||
#else
|
||||
.zero_to_n_one_to_s = 1,
|
||||
#endif
|
||||
|
||||
#if (_LONWE == 'E')
|
||||
.zero_to_e_one_to_w = 0,
|
||||
#else
|
||||
.zero_to_e_one_to_w = 1,
|
||||
#endif
|
||||
|
||||
.comment = _COMMENT,
|
||||
|
||||
#ifdef _SYMBOL_DIGI
|
||||
.symbol = 0,
|
||||
#endif
|
||||
#ifdef _SYMBOL_WIDE1_DIGI
|
||||
.symbol = 1,
|
||||
#endif
|
||||
#ifdef _SYMBOL_HOUSE
|
||||
.symbol = 2,
|
||||
#endif
|
||||
#ifdef _SYMBOL_RXIGATE
|
||||
.symbol = 3,
|
||||
#endif
|
||||
#ifdef _SYMBOL_IGATE
|
||||
.symbol = 4,
|
||||
#endif
|
||||
|
||||
#if defined(_WIDE1_PATH)
|
||||
.path_type = 1,
|
||||
#elif defined(_WIDE21_PATH)
|
||||
.path_type = 2,
|
||||
#else
|
||||
.path_type = 0,
|
||||
#endif
|
||||
|
||||
.wx_transmit_period = _WX_INTERVAL,
|
||||
|
||||
.beacon_transmit_period = _BCN_INTERVAL,
|
||||
|
||||
#ifdef _BCN_ON_STARTUP
|
||||
.beacon_at_bootup = 1
|
||||
#else
|
||||
.beacon_at_bootup = 0
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Data sources for different parameters
|
||||
*
|
||||
*/
|
||||
volatile const config_data_wx_sources_t config_data_wx_sources_default = {
|
||||
#ifdef _TEMPERATURE_INTERNAL
|
||||
.temperature = WX_SOURCE_INTERNAL,
|
||||
#endif
|
||||
#ifdef _TEMPERATURE_UMB
|
||||
.temperature = WX_SOURCE_UMB,
|
||||
#endif
|
||||
#ifdef _TEMPERATURE_RTU
|
||||
.temperature = WX_SOURCE_RTU,
|
||||
#endif
|
||||
#ifdef _TEMPERATURE_DAVIS
|
||||
.temperature = WX_SOURCE_DAVIS_SERIAL,
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef _PRESSURE_INTERNAL
|
||||
.pressure = WX_SOURCE_INTERNAL,
|
||||
#endif
|
||||
#ifdef _PRESSURE_UMB
|
||||
.pressure = WX_SOURCE_UMB,
|
||||
#endif
|
||||
#ifdef _PRESSURE_RTU
|
||||
.pressure = WX_SOURCE_RTU,
|
||||
#endif
|
||||
#ifdef _PRESSURE_DAVIS
|
||||
.pressure = WX_SOURCE_DAVIS_SERIAL,
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _HUMIDITY_INTERNAL
|
||||
.humidity = WX_SOURCE_INTERNAL,
|
||||
#endif
|
||||
#ifdef _HUMIDITY_UMB
|
||||
.humidity = WX_SOURCE_UMB,
|
||||
#endif
|
||||
#ifdef _HUMIDITY_RTU
|
||||
.humidity = WX_SOURCE_RTU,
|
||||
#endif
|
||||
#ifdef _HUMIDITY_DAVIS
|
||||
.humidity = WX_SOURCE_DAVIS_SERIAL,
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef _WIND_INTERNAL
|
||||
.wind = WX_SOURCE_INTERNAL
|
||||
#endif
|
||||
#ifdef _WIND_UMB
|
||||
.wind = WX_SOURCE_UMB
|
||||
#endif
|
||||
#ifdef _WIND_RTU
|
||||
.wind = WX_SOURCE_RTU
|
||||
#endif
|
||||
#ifdef _WIND_FULL_RTU
|
||||
.wind = WX_SOURCE_FULL_RTU
|
||||
#endif
|
||||
#ifdef _WIND_DAVIS
|
||||
.wind = WX_SOURCE_DAVIS_SERIAL
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_umb_t config_data_umb_default = {
|
||||
#ifdef _UMB_SLAVE_ID
|
||||
.slave_id = _UMB_SLAVE_ID,
|
||||
#else
|
||||
.slave_id = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _UMB_SLAVE_CLASS
|
||||
.slave_class = _UMB_SLAVE_CLASS,
|
||||
#else
|
||||
.slave_class = 0,
|
||||
#endif
|
||||
|
||||
#if defined (_UMB_SLAVE_ID) && defined (_UMB_SLAVE_CLASS)
|
||||
.channel_windspeed = _UMB_CHANNEL_WINDSPEED,
|
||||
.channel_wingsusts = _UMB_CHANNEL_WINDGUSTS,
|
||||
.channel_winddirection = _UMB_CHANNEL_WINDDIRECTION,
|
||||
.channel_temperature = _UMB_CHANNEL_TEMPERATURE,
|
||||
.channel_qnh = _UMB_CHANNEL_QFE
|
||||
#else
|
||||
.channel_windspeed = 0xFFFF,
|
||||
.channel_wingsusts = 0xFFFF,
|
||||
.channel_winddirection = 0xFFFF,
|
||||
.channel_temperature = 0xFFFF,
|
||||
.channel_qfe = 0xFFFF
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
volatile const config_data_rtu_t config_data_rtu_default = {
|
||||
.slave_speed = _RTU_SLAVE_SPEED,
|
||||
|
||||
.slave_parity = _RTU_SLAVE_PARITY,
|
||||
|
||||
.slave_stop_bits = _RTU_SLAVE_STOP_BITS,
|
||||
|
||||
#ifdef _RTU_SLAVE_FULL_WIND_DATA
|
||||
.use_full_wind_data = 1,
|
||||
#else
|
||||
.use_full_wind_data = 0,
|
||||
#endif
|
||||
|
||||
// sources
|
||||
#ifdef _RTU_SLAVE_TEMPERATURE_SOURCE
|
||||
.temperature_source = _RTU_SLAVE_TEMPERATURE_SOURCE,
|
||||
#else
|
||||
.temperature_source = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _RTU_SLAVE_HUMIDITY_SOURCE
|
||||
.humidity_source = _RTU_SLAVE_HUMIDITY_SOURCE,
|
||||
#else
|
||||
.humidity_source = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _RTU_SLAVE_PRESSURE_SOURCE
|
||||
.pressure_source = _RTU_SLAVE_PRESSURE_SOURCE,
|
||||
#else
|
||||
.pressure_source = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _RTU_SLAVE_WIND_DIRECTION_SORUCE
|
||||
.wind_direction_source = _RTU_SLAVE_WIND_DIRECTION_SORUCE,
|
||||
#else
|
||||
.wind_direction_source = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _RTU_SLAVE_WIND_SPEED_SOURCE
|
||||
.wind_speed_source = _RTU_SLAVE_WIND_SPEED_SOURCE,
|
||||
#else
|
||||
.wind_speed_source = 0,
|
||||
#endif
|
||||
|
||||
#ifdef _RTU_SLAVE_WIND_GUSTS_SOURCE
|
||||
.wind_gusts_source = _RTU_SLAVE_WIND_GUSTS_SOURCE,
|
||||
#else
|
||||
.wind_gusts_source = 0,
|
||||
#endif
|
||||
|
||||
// channel 1
|
||||
.slave_1_bus_address = _RTU_SLAVE_ID_1,
|
||||
|
||||
.slave_1_function = _RTU_SLAVE_FUNC_1,
|
||||
|
||||
.slave_1_register_address = _RTU_SLAVE_ADDR_1,
|
||||
|
||||
.slave_1_lenght = _RTU_SLAVE_LENGHT_1,
|
||||
|
||||
.slave_1_scaling_a = _RTU_SLAVE_SCALING_A_1,
|
||||
|
||||
.slave_1_scaling_b = _RTU_SLAVE_SCALING_B_1,
|
||||
|
||||
.slave_1_scaling_c = _RTU_SLAVE_SCALING_C_1,
|
||||
|
||||
.slave_1_scaling_d = _RTU_SLAVE_SCALING_D_1,
|
||||
|
||||
.slave_1_unsigned_signed = 0, // 0 - unsigned
|
||||
|
||||
// channel 2
|
||||
.slave_2_bus_address = _RTU_SLAVE_ID_2,
|
||||
|
||||
.slave_2_function = _RTU_SLAVE_FUNC_2,
|
||||
|
||||
.slave_2_register_address = _RTU_SLAVE_ADDR_2,
|
||||
|
||||
.slave_2_lenght = _RTU_SLAVE_LENGHT_2,
|
||||
|
||||
.slave_2_scaling_a = _RTU_SLAVE_SCALING_A_2,
|
||||
|
||||
.slave_2_scaling_b = _RTU_SLAVE_SCALING_B_2,
|
||||
|
||||
.slave_2_scaling_c = _RTU_SLAVE_SCALING_C_2,
|
||||
|
||||
.slave_2_scaling_d = _RTU_SLAVE_SCALING_D_2,
|
||||
|
||||
.slave_2_unsigned_signed = 0,
|
||||
|
||||
// channel 3
|
||||
.slave_3_bus_address = _RTU_SLAVE_ID_3,
|
||||
|
||||
.slave_3_function = _RTU_SLAVE_FUNC_3,
|
||||
|
||||
.slave_3_register_address = _RTU_SLAVE_ADDR_3,
|
||||
|
||||
.slave_3_lenght = _RTU_SLAVE_LENGHT_3,
|
||||
|
||||
.slave_3_scaling_a = _RTU_SLAVE_SCALING_A_3,
|
||||
|
||||
.slave_3_scaling_b = _RTU_SLAVE_SCALING_B_3,
|
||||
|
||||
.slave_3_scaling_c = _RTU_SLAVE_SCALING_C_3,
|
||||
|
||||
.slave_3_scaling_d = _RTU_SLAVE_SCALING_D_3,
|
||||
|
||||
.slave_3_unsigned_signed = 0,
|
||||
|
||||
// channel 4
|
||||
.slave_4_bus_address = _RTU_SLAVE_ID_4,
|
||||
|
||||
.slave_4_function = _RTU_SLAVE_FUNC_4,
|
||||
|
||||
.slave_4_register_address = _RTU_SLAVE_ADDR_4,
|
||||
|
||||
.slave_4_lenght = _RTU_SLAVE_LENGHT_4,
|
||||
|
||||
.slave_4_scaling_a = _RTU_SLAVE_SCALING_A_4,
|
||||
|
||||
.slave_4_scaling_b = _RTU_SLAVE_SCALING_B_4,
|
||||
|
||||
.slave_4_scaling_c = _RTU_SLAVE_SCALING_C_4,
|
||||
|
||||
.slave_4_scaling_d = _RTU_SLAVE_SCALING_D_4,
|
||||
|
||||
.slave_4_unsigned_signed = 0,
|
||||
|
||||
// channel 5
|
||||
.slave_5_bus_address = _RTU_SLAVE_ID_5,
|
||||
|
||||
.slave_5_function = _RTU_SLAVE_FUNC_5,
|
||||
|
||||
.slave_5_register_address = _RTU_SLAVE_ADDR_5,
|
||||
|
||||
.slave_5_lenght = _RTU_SLAVE_LENGHT_5,
|
||||
|
||||
.slave_5_scaling_a = _RTU_SLAVE_SCALING_A_5,
|
||||
|
||||
.slave_5_scaling_b = _RTU_SLAVE_SCALING_B_5,
|
||||
|
||||
.slave_5_scaling_c = _RTU_SLAVE_SCALING_C_5,
|
||||
|
||||
.slave_5_scaling_d = _RTU_SLAVE_SCALING_D_5,
|
||||
|
||||
.slave_5_unsigned_signed = 0,
|
||||
|
||||
// channel 6
|
||||
.slave_6_bus_address = _RTU_SLAVE_ID_6,
|
||||
|
||||
.slave_6_function = _RTU_SLAVE_FUNC_6,
|
||||
|
||||
.slave_6_register_address = _RTU_SLAVE_ADDR_6,
|
||||
|
||||
.slave_6_lenght = _RTU_SLAVE_LENGHT_6,
|
||||
|
||||
.slave_6_scaling_a = _RTU_SLAVE_SCALING_A_6,
|
||||
|
||||
.slave_6_scaling_b = _RTU_SLAVE_SCALING_B_6,
|
||||
|
||||
.slave_6_scaling_c = _RTU_SLAVE_SCALING_C_6,
|
||||
|
||||
.slave_6_scaling_d = _RTU_SLAVE_SCALING_D_6,
|
||||
|
||||
.slave_6_unsigned_signed = 0
|
||||
};
|
||||
|
|
@ -39,11 +39,14 @@
|
|||
#define _RTU_SLAVE_LENGHT_6 0x1
|
||||
#endif
|
||||
|
||||
const uint32_t __attribute__((section(".config_section_first"))) config_data_pgm_cntr_first = 0x1;
|
||||
|
||||
const uint32_t __attribute__((section(".config_section_first.crc"))) config_data_crc_val_first = 0xDEADBEEF;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_mode_t __attribute__((section(".config_section_first"))) config_data_mode_first = {
|
||||
const config_data_mode_t __attribute__((section(".config_section_first.mode"))) config_data_mode_first = {
|
||||
#ifdef _DIGI
|
||||
.digi = 1,
|
||||
#else
|
||||
|
@ -109,7 +112,7 @@ const config_data_mode_t __attribute__((section(".config_section_first"))) confi
|
|||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_basic_t __attribute__((section(".config_section_first"))) config_data_basic_first = {
|
||||
const config_data_basic_t __attribute__((section(".config_section_first.basic"))) config_data_basic_first = {
|
||||
.callsign = _CALL,
|
||||
.ssid = _SSID,
|
||||
.latitude = _LAT,
|
||||
|
@ -168,7 +171,7 @@ const config_data_basic_t __attribute__((section(".config_section_first"))) conf
|
|||
* Data sources for different parameters
|
||||
*
|
||||
*/
|
||||
const config_data_wx_sources_t __attribute__((section(".config_section_first"))) config_data_wx_sources_first = {
|
||||
const config_data_wx_sources_t __attribute__((section(".config_section_first.sources"))) config_data_wx_sources_first = {
|
||||
#ifdef _TEMPERATURE_INTERNAL
|
||||
.temperature = WX_SOURCE_INTERNAL,
|
||||
#endif
|
||||
|
@ -233,7 +236,7 @@ const config_data_wx_sources_t __attribute__((section(".config_section_first")))
|
|||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_umb_t __attribute__((section(".config_section_first"))) config_data_umb_first = {
|
||||
const config_data_umb_t __attribute__((section(".config_section_first.umb"))) config_data_umb_first = {
|
||||
#ifdef _UMB_SLAVE_ID
|
||||
.slave_id = _UMB_SLAVE_ID,
|
||||
#else
|
||||
|
@ -265,7 +268,7 @@ const config_data_umb_t __attribute__((section(".config_section_first"))) config
|
|||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_rtu_t __attribute__((section(".config_section_first"))) config_data_rtu_first = {
|
||||
const config_data_rtu_t __attribute__((section(".config_section_first.rtu"))) config_data_rtu_first = {
|
||||
.slave_speed = _RTU_SLAVE_SPEED,
|
||||
|
||||
.slave_parity = _RTU_SLAVE_PARITY,
|
||||
|
|
|
@ -33,10 +33,14 @@
|
|||
#define _RTU_SLAVE_LENGHT_6 0x1
|
||||
#endif
|
||||
|
||||
const uint32_t __attribute__((section(".config_section_second"))) config_data_pgm_cntr_second = 0x2;
|
||||
|
||||
const uint32_t __attribute__((section(".config_section_second.crc"))) config_data_crc_val_second = 0xDEADBEEF;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_mode_t __attribute__((section(".config_section_second"))) config_data_mode_second = {
|
||||
const config_data_mode_t __attribute__((section(".config_section_second.mode"))) config_data_mode_second = {
|
||||
#ifdef _DIGI
|
||||
.digi = 1,
|
||||
#else
|
||||
|
@ -102,7 +106,7 @@ const config_data_mode_t __attribute__((section(".config_section_second"))) conf
|
|||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_basic_t __attribute__((section(".config_section_second"))) config_data_basic_second = {
|
||||
const config_data_basic_t __attribute__((section(".config_section_second.basic"))) config_data_basic_second = {
|
||||
.callsign = _CALL,
|
||||
.ssid = _SSID,
|
||||
.latitude = _LAT,
|
||||
|
@ -161,7 +165,7 @@ const config_data_basic_t __attribute__((section(".config_section_second"))) con
|
|||
* Data sources for different parameters
|
||||
*
|
||||
*/
|
||||
const config_data_wx_sources_t __attribute__((section(".config_section_second"))) config_data_wx_sources_second = {
|
||||
const config_data_wx_sources_t __attribute__((section(".config_section_second.sources"))) config_data_wx_sources_second = {
|
||||
#ifdef _TEMPERATURE_INTERNAL
|
||||
.temperature = WX_SOURCE_INTERNAL,
|
||||
#endif
|
||||
|
@ -226,7 +230,7 @@ const config_data_wx_sources_t __attribute__((section(".config_section_second"))
|
|||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_umb_t __attribute__((section(".config_section_second"))) config_data_umb_second = {
|
||||
const config_data_umb_t __attribute__((section(".config_section_second.umb"))) config_data_umb_second = {
|
||||
#ifdef _UMB_SLAVE_ID
|
||||
.slave_id = _UMB_SLAVE_ID,
|
||||
#else
|
||||
|
@ -258,7 +262,7 @@ const config_data_umb_t __attribute__((section(".config_section_second"))) confi
|
|||
/**
|
||||
*
|
||||
*/
|
||||
const config_data_rtu_t __attribute__((section(".config_section_second"))) config_data_rtu_second = {
|
||||
const config_data_rtu_t __attribute__((section(".config_section_second.rtu"))) config_data_rtu_second = {
|
||||
.slave_speed = _RTU_SLAVE_SPEED,
|
||||
|
||||
.slave_parity = _RTU_SLAVE_PARITY,
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* configuration_handler.c
|
||||
*
|
||||
* Created on: Apr 28, 2021
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "configuration_handler.h"
|
||||
#include "config_data.h"
|
||||
|
||||
#include <stm32f10x_crc.h>
|
||||
#include <stm32f10x_flash.h>
|
||||
|
||||
const uint32_t * config_section_first_start = 0x0801E800;
|
||||
const uint32_t * config_section_second_start = 0x0801F000;
|
||||
|
||||
#define CRC_OFFSET 0x7FC
|
||||
#define CRC_32B_WORD_OFFSET CRC_OFFSET / 4
|
||||
|
||||
#define CONFIG_SECTION_LN 0x7FF
|
||||
|
||||
|
||||
volatile extern const config_data_basic_t config_data_basic_default;
|
||||
volatile extern const config_data_mode_t config_data_mode_default;
|
||||
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;
|
||||
|
||||
uint32_t configuration_handler_check_crc(void) {
|
||||
|
||||
uint32_t out = 0;
|
||||
|
||||
// crc stored in the configuration section
|
||||
uint32_t crc_expected = 0;
|
||||
|
||||
// calculated CRC value
|
||||
uint32_t crc_current = 0;
|
||||
|
||||
// reset CRC engine
|
||||
CRC_ResetDR();
|
||||
|
||||
// calculate CRC over everything from config_section_first except the last word which constit crc value itself
|
||||
CRC_CalcBlockCRC(config_section_first_start, CRC_32B_WORD_OFFSET - 1);
|
||||
|
||||
// add 0x0 as a placeholder for CRC value
|
||||
crc_current = CRC_CalcCRC(0x0);
|
||||
|
||||
// expected crc is stored in the last 32b word of the configuration section
|
||||
crc_expected = *(config_section_first_start + CRC_32B_WORD_OFFSET);
|
||||
|
||||
// check if calculated CRC value match value stored in flash memory
|
||||
if (crc_expected == crc_current) {
|
||||
out |= 0x01;
|
||||
}
|
||||
|
||||
// reset the CRC engine
|
||||
CRC_ResetDR();
|
||||
|
||||
// and do the same but for second section
|
||||
CRC_CalcBlockCRC(config_section_second_start, CRC_32B_WORD_OFFSET - 1);
|
||||
|
||||
// add 0x0 as a placeholder for CRC value
|
||||
crc_current = CRC_CalcCRC(0x0);
|
||||
|
||||
//crc_expected = *__config_section_second_end;
|
||||
|
||||
// check if calculated CRC value match value stored in flash memory
|
||||
if (crc_expected == crc_current) {
|
||||
out |= 0x02;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
uint32_t configuration_handler_restore_default(void) {
|
||||
|
||||
uint32_t out = 0;
|
||||
|
||||
// flash operation result
|
||||
FLASH_Status flash_status = 0;
|
||||
|
||||
// unlock flash memory
|
||||
FLASH_Unlock();
|
||||
|
||||
// erase first page
|
||||
//flash_status = FLASH_ErasePage(*__config_section_first_end);
|
||||
|
||||
//if (flash_status)
|
||||
|
||||
// lock the memory back
|
||||
FLASH_Lock();
|
||||
|
||||
}
|
||||
|
||||
uint32_t configuration_handler_load_configuration(void) {
|
||||
|
||||
}
|
||||
|
||||
uint32_t configuration_handler_program(uint8_t* data, uint16_t data_ln, uint8_t config_idx) {
|
||||
|
||||
}
|
|
@ -5,5 +5,5 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
const int __attribute__((section(".config_section_third"))) dummy = 0xDEADBEEF;
|
||||
const int __attribute__((section(".config_section_third"))) dummy = 0xDDDDDDDD;
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "station_config.h"
|
||||
#include "config_data_externs.h"
|
||||
#include "configuration_handler.h"
|
||||
|
||||
#include "diag/Trace.h"
|
||||
#include "antilib_adc.h"
|
||||
|
@ -191,6 +192,7 @@ int main(int argc, char* argv[]){
|
|||
|
||||
RCC->APB1ENR |= (RCC_APB1ENR_TIM2EN | RCC_APB1ENR_TIM3EN | RCC_APB1ENR_TIM7EN | RCC_APB1ENR_TIM4EN);
|
||||
RCC->APB2ENR |= (RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_IOPDEN | RCC_APB2ENR_AFIOEN | RCC_APB2ENR_TIM1EN);
|
||||
RCC->AHBENR |= RCC_AHBENR_CRCEN;
|
||||
|
||||
memset(main_own_aprs_msg, 0x00, OWN_APRS_MSG_LN);
|
||||
|
||||
|
@ -242,6 +244,9 @@ int main(int argc, char* argv[]){
|
|||
rte_wx_init();
|
||||
rte_rtu_init();
|
||||
|
||||
// calculate CRC over configuration blocks
|
||||
configuration_handler_check_crc();
|
||||
|
||||
#if defined _RANDOM_DELAY
|
||||
// configuring a default delay value
|
||||
delay_set(_DELAY_BASE, 1);
|
||||
|
|
Ładowanie…
Reference in New Issue