Skip to content

Commit

Permalink
Cumulative update
Browse files Browse the repository at this point in the history
Updated to [email protected] (lastest) for all module and boot_loader.
Removed VECT_TAB_OFFSET (for new library)
Updated cyclone bsd timing bsd socket for adjust new compiler (define error).
Add button reset (config hw and software) and reset defaults param for slave.

Rechecking all modules with bootloader loading and local operation
  • Loading branch information
digitecomg committed Mar 14, 2024
1 parent 5f3cad0 commit c023e47
Show file tree
Hide file tree
Showing 28 changed files with 253 additions and 141 deletions.
18 changes: 9 additions & 9 deletions platformio/stima_v4/libraries/CycloneTCP/src/core/bsd_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ int_t setsockopt(int_t s, int_t level, int_t optname, const void *optval,
{
int_t ret;
int_t *val;
TIMEVAL *t;
TIMEVAL32 *t;
Socket *sock;

//Make sure the socket descriptor is valid
Expand Down Expand Up @@ -1007,10 +1007,10 @@ int_t setsockopt(int_t s, int_t level, int_t optname, const void *optval,
else if(optname == SO_SNDTIMEO || optname == SO_RCVTIMEO)
{
//Check the length of the option
if(optlen >= (socklen_t) sizeof(TIMEVAL))
if(optlen >= (socklen_t) sizeof(TIMEVAL32))
{
//Cast the option value to the relevant type
t = (TIMEVAL *) optval;
t = (TIMEVAL32 *) optval;

//If the specified value is of zero, I/O operations shall not
//time out
Expand Down Expand Up @@ -1280,7 +1280,7 @@ int_t getsockopt(int_t s, int_t level, int_t optname, void *optval,
{
int_t ret;
int_t *val;
TIMEVAL *t;
TIMEVAL32 *t;
Socket *sock;

//Make sure the socket descriptor is valid
Expand All @@ -1305,10 +1305,10 @@ int_t getsockopt(int_t s, int_t level, int_t optname, void *optval,
if(optname == SO_SNDTIMEO || optname == SO_RCVTIMEO)
{
//Check the length of the option
if(*optlen >= (socklen_t) sizeof(TIMEVAL))
if(*optlen >= (socklen_t) sizeof(TIMEVAL32))
{
//Cast the option value to the relevant type
t = (TIMEVAL *) optval;
t = (TIMEVAL32 *) optval;

//Return the timeout value
if(sock->timeout == INFINITE_DELAY)
Expand All @@ -1323,7 +1323,7 @@ int_t getsockopt(int_t s, int_t level, int_t optname, void *optval,
}

//Return the actual length of the option
*optlen = sizeof(TIMEVAL);
*optlen = sizeof(TIMEVAL32);
//Successful processing
ret = SOCKET_SUCCESS;
}
Expand Down Expand Up @@ -1382,7 +1382,7 @@ int_t getsockopt(int_t s, int_t level, int_t optname, void *optval,
else if(optname == SO_KEEPALIVE)
{
//Check the length of the option
if(*optlen >= (socklen_t) sizeof(TIMEVAL))
if(*optlen >= (socklen_t) sizeof(TIMEVAL32))
{
//Cast the option value to the relevant type
val = (int_t *) optval;
Expand Down Expand Up @@ -1863,7 +1863,7 @@ int_t closesocket(int_t s)
**/

int_t select(int_t nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, const struct timeval *timeout)
fd_set *exceptfds, const struct timeval32 *timeout)
{
int_t i;
int_t j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,18 @@ typedef struct addrinfo
} ADDRINFO, *PADDRINFO;


#ifndef _TIMEVAL_DEFINED
#ifndef _TIMEVAL32_DEFINED
#define _TIMEVAL32_DEFINED

/**
* @brief Timeout structure
**/

typedef struct timeval
typedef struct timeval32
{
int32_t tv_sec;
int32_t tv_usec;
} TIMEVAL, *PTIMEVAL;
} TIMEVAL32, *PTIMEVAL32;

#endif

Expand Down Expand Up @@ -413,7 +414,7 @@ int_t shutdown(int_t s, int_t how);
int_t closesocket(int_t s);

int_t select(int_t nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, const struct timeval *timeout);
fd_set *exceptfds, const struct timeval32 *timeout);

int_t gethostname(char_t *name, size_t len);
struct hostent *gethostbyname(const char_t *name);
Expand Down
7 changes: 3 additions & 4 deletions platformio/stima_v4/master/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
boards_dir= ../../custom_boards

[env]
platform = ststm32
platform = ststm32@17.3.0
framework = arduino
lib_extra_dirs =
../libraries
Expand All @@ -22,16 +22,15 @@ monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
extra_scripts =
pre:../cyphal/nnvg_piovenv_compile.py
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable
;platform_packages =
; framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_master]
board = stimav4_master
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
; debug_build_flags = -O0 -ggdb3 -g3
build_flags =
;-DSTIMAV4_MASTER_HW_VER_01_01
-DVECT_TAB_OFFSET=0xB000
-DPIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-DUSB_PRODUCT_STRING="\"Stima V4 Master\""
-DINIT_PARAMETER=false
Expand Down
19 changes: 4 additions & 15 deletions platformio/stima_v4/master/src/tasks/supervisor_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,19 +830,11 @@ void SupervisorTask::printConfiguration()

for (uint8_t i = 0; i < param.configuration->constantdata_count; i++)
{
TRACE_INFO_F(F("--> cd %d:/t%s : %s"), i, param.configuration->constantdata[i].btable, param.configuration->constantdata[i].value);
TRACE_INFO_F(F("--> cd %d:%s : %s"), i, param.configuration->constantdata[i].btable, param.configuration->constantdata[i].value);
}

// TRACE_INFO_F(F("-> %u configured sensors:\r\n"), configuration->sensors_count);

// for (uint8_t i = 0; i < configuration->sensors_count; i++)
// {
// TRACE_INFO_F(F("--> %u: %s-%s\r\n"), i + 1, configuration->sensors[i].driver, configuration->sensors[i].type);
// }

TRACE_INFO_F(F("-> data report every %d seconds\r\n"), param.configuration->report_s);
TRACE_INFO_F(F("-> data observation every %d seconds\r\n"), param.configuration->observation_s);
// TRACE_INFO_F(F("-> data level: %s\r\n"), param.configuration->data_level);
TRACE_INFO_F(F("-> ident: %s\r\n"), param.configuration->ident);
TRACE_INFO_F(F("-> longitude %07d and latitude %07d\r\n"), param.configuration->longitude, param.configuration->latitude);
TRACE_INFO_F(F("-> network: %s\r\n"), param.configuration->network);
Expand Down Expand Up @@ -881,7 +873,7 @@ void SupervisorTask::printConfiguration()
TRACE_INFO_F(F("-> mqtt rpc topic: %s/%s/%s/%07d,%07d/%s/\r\n"),
param.configuration->mqtt_rpc_topic, param.configuration->mqtt_username, param.configuration->ident,
param.configuration->longitude, param.configuration->latitude, param.configuration->network);
#endif
#endif

param.configurationLock->Give();
}
Expand Down Expand Up @@ -985,12 +977,9 @@ bool SupervisorTask::saveConfiguration(bool is_default)
//! write configuration to eeprom
status = param.eeprom->Write(CONFIGURATION_EEPROM_ADDRESS, (uint8_t *)(param.configuration), sizeof(configuration_t));

if (is_default)
{
if (is_default) {
TRACE_INFO_F(F("Save default configuration... [ %s ]\r\n"), status ? OK_STRING : ERROR_STRING);
}
else
{
} else {
TRACE_INFO_F(F("Save configuration... [ %s ]\r\n"), status ? OK_STRING : ERROR_STRING);
}

Expand Down
9 changes: 4 additions & 5 deletions platformio/stima_v4/slave-mppt/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
boards_dir= ../../custom_boards

[env]
platform = ststm32
platform = ststm32@17.3.0
framework = arduino
lib_extra_dirs =
../libraries
lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable
;platform_packages =
; framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DSTIMAV4_SLAVE_HW_VER_01_01
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=true
Expand All @@ -45,7 +45,6 @@ build_flags =
-Wl,--gc-sections
-D__error_t_defined
-DHAL_CAN_MODULE_ENABLED
-DHAL_DAC_MODULE_DISABLED
-DUSE_HAL_DRIVER=1
-DBXCAN_MAX_IFACE_INDEX=0
-w
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ extern CAN_HandleTypeDef hcan1;
#define PIN_IN1 PA8
#define PIN_IN2 PB8

// INPUT BUTTON
#ifdef STIMAV4_SLAVE_HW_VER_01_01
#define PIN_BTN PH0 // INPUT BUTTON (RESET PARAMETERS)
#endif

// I2C
#define PIN_I2C2_EN PC11
#define PIN_I2C2_SDA PB14
Expand Down Expand Up @@ -168,6 +173,10 @@ extern CAN_HandleTypeDef hcan1;
#define IN2_GPIO_Port GPIOB
#define EN_5VA_Pin GPIO_PIN_9
#define EN_5VA_GPIO_Port GPIOB
#ifdef STIMAV4_SLAVE_HW_VER_01_01
#define IN_BTN_Pin GPIO_PIN_0
#define IN_BTN_GPIO_Port GPIOH
#endif

// ******************************************************************************

Expand Down
11 changes: 5 additions & 6 deletions platformio/stima_v4/slave-radiation/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
boards_dir= ../../custom_boards

[env]
platform = ststm32
platform = ststm32@17.3.0
framework = arduino
lib_extra_dirs =
../libraries
lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable
;platform_packages =
; framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DSTIMAV4_SLAVE_HW_VER_01_01
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=false
-DUSE_DEBUG=true
-fexceptions
-fno-common
-Wall
Expand All @@ -45,7 +45,6 @@ build_flags =
-Wl,--gc-sections
-D__error_t_defined
-DHAL_CAN_MODULE_ENABLED
-DHAL_DAC_MODULE_DISABLED
-DUSE_HAL_DRIVER=1
-DBXCAN_MAX_IFACE_INDEX=0
-w
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ extern "C" void MX_GPIO_Init(void)
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();

/*Configure GPIO pins : DEN_Pin DSEL0_Pin DSEL1_Pin PW0_Pin
PW1_Pin PW2_Pin PW3_Pin I2C2_EN_Pin
Expand Down Expand Up @@ -465,6 +466,14 @@ extern "C" void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(EN_SPLY_GPIO_Port, &GPIO_InitStruct);

#ifdef STIMAV4_SLAVE_HW_VER_01_01
/*Configure GPIO pin : IN_BTN_Pin */
GPIO_InitStruct.Pin = IN_BTN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(IN_BTN_GPIO_Port, &GPIO_InitStruct);
#endif

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, DEN_Pin|DSEL0_Pin|DSEL1_Pin|PW0_Pin
|PW1_Pin|PW2_Pin|PW3_Pin|I2C2_EN_Pin
Expand Down
34 changes: 20 additions & 14 deletions platformio/stima_v4/slave-radiation/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

void setup() {

// Reset param (Flag Fixed or on Button reset operation)
bool init_parameter = INIT_PARAMETER;

// Semaphore, Queue && Param Config for TASK
#if (ENABLE_I2C1)
static BinarySemaphore *wireLock; // Access I2C internal EEprom, Accelerometer
Expand Down Expand Up @@ -43,8 +46,11 @@ void setup() {
SetupSystemPeripheral();
init_debug(SERIAL_DEBUG_BAUD_RATE);
init_wire();
init_pins();
init_rtc(INIT_PARAMETER);
init_pins();
// Check Reset default PIN pression button if enabled
#ifdef STIMAV4_SLAVE_HW_VER_01_01
if(!digitalRead(PIN_BTN)) init_parameter = true;
#endif

// Init SystemStatus Parameter !=0 ... For Check control Value
// Task check init data (Wdt = True, TaskStack Max, TaskReady = False)
Expand Down Expand Up @@ -103,7 +109,7 @@ void setup() {
// Get Serial Number
configuration.serial_number = StimaV4GetSerialNumber();

// Serial Print Fixed for Serial Number
// Serial Print Fixed for Serial Number
Serial.println();
Serial.println(F("*****************************"));
Serial.println(F("* Stima V4 SLAVE - SER.NUM. *"));
Expand All @@ -124,19 +130,19 @@ void setup() {
// Load Info from E2 boot_check flag and send to Config
static EEprom memEprom(&Wire, wireLock);
static bootloader_t boot_check = {0};
#if INIT_PARAMETER
boot_check.app_executed_ok = true;
memEprom.Write(BOOT_LOADER_STRUCT_ADDR, (uint8_t*) &boot_check, sizeof(boot_check));
#else
memEprom.Read(BOOT_LOADER_STRUCT_ADDR, (uint8_t*) &boot_check, sizeof(boot_check));
#endif
// Reset to defaults?
if(init_parameter) {
boot_check.app_executed_ok = true;
memEprom.Write(BOOT_LOADER_STRUCT_ADDR, (uint8_t*) &boot_check, sizeof(boot_check));
} else {
memEprom.Read(BOOT_LOADER_STRUCT_ADDR, (uint8_t*) &boot_check, sizeof(boot_check));
}
// Optional send other InfoParm Boot (Uploaded, rollback, error fail ecc.. to config)
#endif
// Reset Factory register value
static EERegister clRegister(&Wire, wireLock);
#if INIT_PARAMETER
clRegister.doFactoryReset();
#endif
// Reset to defaults?
if(init_parameter) clRegister.doFactoryReset();
// Init access Flash istance object
static Flash memFlash(&hqspi);

Expand Down Expand Up @@ -251,10 +257,10 @@ void loop() {

/// @brief Init Pin (Diag and configuration)
void init_pins() {
#if (ENABLE_DIAG_PIN)
// *****************************************************
// STARTUP LED E PIN DIAGNOSTICI (SE UTILIZZATI)
// *****************************************************
#if (ENABLE_DIAG_PIN)
// Output mode for LED(1/2) BLINK SW LOOP (High per Setup)
// Input mode for test button
#ifdef LED1_PIN
Expand Down Expand Up @@ -297,7 +303,7 @@ void init_rtc(bool init)
if(init) {
// Set the date && Time Init Value
rtc.setHours(0);rtc.setMinutes(0);rtc.setSeconds(0);
rtc.setWeekDay(0);rtc.setDay(1);rtc.setMonth(1);rtc.setYear(23);
rtc.setWeekDay(0);rtc.setDay(1);rtc.setMonth(1);rtc.setYear(24);
}
// Start LowPower configuration
LowPower.begin();
Expand Down
Loading

0 comments on commit c023e47

Please sign in to comment.