1 #define TRACE_LEVEL STIMA_TRACE_LEVEL 
    8   bool init_parameter = INIT_PARAMETER;
 
   12   static BinarySemaphore *wireLock;       
 
   16   static BinarySemaphore *wire2Lock;      
 
   20   static BinarySemaphore *canLock;        
 
   24   static BinarySemaphore *qspiLock;       
 
   27   static BinarySemaphore *rtcLock;        
 
   30   static Queue *systemMessageQueue;
 
   32   static Queue *elaborateDataQueue;
 
   33   static Queue *requestDataQueue;
 
   34   static Queue *reportDataQueue;
 
   36   static Queue *rainQueue; 
 
   39   static BinarySemaphore *configurationLock;  
 
   40   static BinarySemaphore *systemStatusLock;   
 
   41   static BinarySemaphore *registerAccessLock; 
 
   53 #ifdef STIMAV4_SLAVE_HW_VER_01_01 
   54   if(!digitalRead(PIN_BTN)) init_parameter = 
true;
 
   63 #if (ENABLE_STACK_USAGE) 
   78   if(IWatchdog.isReset()) {
 
   80     TRACE_INFO_F(F(
"\r\n\r\nALERT: Verified an WDT Reset !!!\r\n\r\n"));
 
   81     IWatchdog.clearReset();
 
   88   wireLock = 
new BinarySemaphore(
true);
 
   91   wire2Lock = 
new BinarySemaphore(
true);
 
   94   canLock = 
new BinarySemaphore(
true);
 
   97   qspiLock = 
new BinarySemaphore(
true);
 
   99   rtcLock = 
new BinarySemaphore(
true);
 
  102   configurationLock = 
new BinarySemaphore(
true);
 
  103   systemStatusLock = 
new BinarySemaphore(
true);
 
  104   registerAccessLock = 
new BinarySemaphore(
true);
 
  121   Serial.println(F(
"*****************************"));
 
  122   Serial.println(F(
"* Stima V4 SLAVE - SER.NUM. *"));
 
  123   Serial.println(F(
"*****************************"));
 
  124   Serial.print(F(
"COD: "));
 
  125   for(int8_t 
id=7; 
id>=0; 
id--) {
 
  126     if((uint8_t)((configuration.
serial_number >> (8*
id)) & 0xFF) < 16) Serial.print(F(
"0"));
 
  127     Serial.print((uint8_t)((configuration.
serial_number >> (8*
id)) & 0xFF), 16);
 
  128     if(
id) Serial.print(F(
"-"));
 
  130   Serial.println(
"\r\n");
 
  138   static EEprom  memEprom(&Wire, wireLock);
 
  150   static EERegister clRegister(&Wire, wireLock);
 
  154   static Flash memFlash(&hqspi);
 
  164   wdtParam.
eeprom = &memEprom;
 
  178   canParam.
eeprom = &memEprom;
 
  180   canParam.
flash = &memFlash;
 
  186 #if (ENABLE_ACCELEROMETER) 
  193   accelerometerParam.
wire = &Wire;
 
  194   accelerometerParam.
wireLock = wireLock;
 
  201 #if (MODULE_TYPE == STIMA_MODULE_TYPE_RAIN) 
  220   elaborateDataParam.
rainQueue = rainQueue;
 
  238   static SupervisorTask supervisor_task(
"SupervisorTask", 300, OS_TASK_PRIORITY_04, supervisorParam);
 
  240 #if (MODULE_TYPE == STIMA_MODULE_TYPE_RAIN) 
  241   static RainSensorTask rain_sensor_task(
"RainTask", 350, OS_TASK_PRIORITY_03, rainSensorParam);
 
  243   static ElaborateDataTask elaborate_data_task(
"ElaborateDataTask", 350, OS_TASK_PRIORITY_02, elaborateDataParam);
 
  245 #if (ENABLE_ACCELEROMETER) 
  246   static AccelerometerTask accelerometer_task(
"AccelerometerTask", 350, OS_TASK_PRIORITY_01, accelerometerParam);
 
  250   static CanTask can_task(
"CanTask", 7300, OS_TASK_PRIORITY_02, canParam);
 
  254   static WdtTask wdt_task(
"WdtTask", 350, OS_TASK_PRIORITY_01, wdtParam);
 
  258   Thread::StartScheduler();
 
  265   #ifndef _EXIT_SLEEP_FOR_DEBUGGING 
  275   #if (ENABLE_DIAG_PIN) 
  279   pinMode(LED1_PIN, OUTPUT);
 
  280   digitalWrite(LED1_PIN, HIGH);
 
  283   pinMode(LED2_PIN, OUTPUT);
 
  284   digitalWrite(LED1_PIN, LOW);
 
  287   pinMode(USER_INP, INPUT);
 
  297   Wire.setClock(I2C1_BUS_CLOCK_HZ);
 
  302   Wire2.setClock(I2C2_BUS_CLOCK_HZ);
 
  310   STM32RTC& rtc = STM32RTC::getInstance();
 
  312   rtc.setClockSource(STM32RTC::LSE_CLOCK);
 
  317     rtc.setHours(0);rtc.setMinutes(0);rtc.setSeconds(0);
 
  318     rtc.setWeekDay(0);rtc.setDay(1);rtc.setMonth(1);rtc.setYear(24);
 
  323   LowPower.idleHookEnable();
 
ACCELEROMETER TASK cpp_freertos class.
 
CAN TASK cpp_freertos class.
 
void doFactoryReset(void)
Erase all registers such that the defaults are used at the next launch.
 
bool Read(uint16_t address, uint8_t *buffer, uint16_t length)
Read a number of data byte from EEPROM.
 
bool Write(uint16_t address, uint8_t *buffer, uint16_t length)
Write a number of data byte into EEPROM.
 
ELABORATE DATA TASK cpp_freertos class.
 
SENSOR TASK cpp_freertos class.
 
SUPERVISOR TASK cpp_freertos class.
 
WATCH DOG TASK cpp_freertos class.
 
#define TOTAL_INFO_TASK
Total Max Task for WDT Task Control.
 
#define SYSTEM_MESSAGE_QUEUE_LENGTH
Request system message queue length.
 
#define ELABORATE_DATA_QUEUE_LENGTH
Elaborate data message queue length.
 
#define RAIN_QUEUE_LENGTH
Request sensor queue length.
 
#define REPORT_DATA_QUEUE_LENGTH
Report data message queue length.
 
#define WDT_TIMEOUT_BASE_US
WatchDog Hardware microseconds timeout.
 
#define SERIAL_DEBUG_BAUD_RATE
Monitor Debug Serial speed.
 
#define BOOT_LOADER_STRUCT_ADDR
Bootloader start address
 
#define REQUEST_DATA_QUEUE_LENGTH
Request data message queue length.
 
void init_debug(uint32_t baudrate)
init serial monitor
 
#define TRACE_INFO_F(...)
 
@ suspended
Task is excluded from WDT Controller or Suspended complete.
 
void init_pins()
Init Pin (Diag and configuration)
 
void SetupSystemPeripheral(void)
Startup PeripheralConfig Local Board.
 
uint64_t StimaV4GetSerialNumber(void)
Get StimaV4 Serial Number from UID Cpu and Module TYPE.
 
struct local elaborate data parameter
 
system_status_t * system_status
system status pointer struct
 
TwoWire * wire
Local Wire access for sensor accelerometer.
 
cpp_freertos::Queue * systemMessageQueue
Queue for system message.
 
cpp_freertos::BinarySemaphore * systemStatusLock
Semaphore to system status access.
 
configuration_t * configuration
system configuration pointer struct
 
cpp_freertos::BinarySemaphore * wireLock
Semaphore to Wire access for sensor accelerometer.
 
EERegister * clRegister
Object Register C++ access.
 
cpp_freertos::BinarySemaphore * registerAccessLock
Semaphore to register Cyphal access.
 
struct local elaborate data parameter
 
cpp_freertos::BinarySemaphore * rtcLock
Semaphore to RTC Access.
 
Flash * flash
Object Flash C++ access.
 
cpp_freertos::BinarySemaphore * registerAccessLock
Semaphore to register Cyphal access.
 
cpp_freertos::Queue * reportDataQueue
Queue to report data.
 
cpp_freertos::Queue * systemMessageQueue
Queue for system message.
 
cpp_freertos::Queue * requestDataQueue
Queue to request data.
 
cpp_freertos::BinarySemaphore * configurationLock
Semaphore to configuration access.
 
configuration_t * configuration
system configuration pointer struct
 
EERegister * clRegister
Object Register C++ access.
 
system_status_t * system_status
system status pointer struct
 
cpp_freertos::BinarySemaphore * canLock
Semaphore to CAN Bus access.
 
bootloader_t * boot_request
Boot struct pointer.
 
cpp_freertos::BinarySemaphore * qspiLock
Semaphore to QSPI Memory flash access.
 
EEprom * eeprom
Object EEprom C++ access.
 
cpp_freertos::BinarySemaphore * systemStatusLock
Semaphore to system status access.
 
struct local elaborate data parameter
 
cpp_freertos::Queue * systemMessageQueue
Queue for system message.
 
cpp_freertos::Queue * elaborateDataQueue
Queue for elaborate data.
 
configuration_t * configuration
system configuration pointer struct
 
system_status_t * system_status
system status pointer struct
 
cpp_freertos::Queue * rainQueue
Queue to RAIN Event.
 
cpp_freertos::BinarySemaphore * systemStatusLock
semaphore access to system status
 
cpp_freertos::Queue * requestDataQueue
Queue for request data.
 
cpp_freertos::BinarySemaphore * configurationLock
semaphore access to configuration
 
cpp_freertos::Queue * reportDataQueue
Queue for report data.
 
struct local elaborate data parameter
 
cpp_freertos::BinarySemaphore * systemStatusLock
Semaphore to system status access.
 
system_status_t * system_status
system status pointer struct
 
cpp_freertos::Queue * systemMessageQueue
Queue for system message.
 
cpp_freertos::Queue * rainQueue
Queue for rain events.
 
cpp_freertos::BinarySemaphore * configurationLock
Semaphore to configuration access.
 
cpp_freertos::Queue * elaborateDataQueue
Queue for elaborate data.
 
configuration_t * configuration
system configuration pointer struct
 
struct local elaborate data parameter
 
system_status_t * system_status
system status pointer struct
 
EERegister * clRegister
Object Register C++ access.
 
cpp_freertos::BinarySemaphore * systemStatusLock
Semaphore to system status access.
 
cpp_freertos::BinarySemaphore * registerAccessLock
Semaphore to register Cyphal access.
 
configuration_t * configuration
system configuration pointer struct
 
cpp_freertos::BinarySemaphore * configurationLock
Semaphore to configuration access.
 
bool is_initialization_request
External require initilizaztion register E2.
 
cpp_freertos::Queue * systemMessageQueue
Queue for system message.
 
struct for local param access
 
cpp_freertos::BinarySemaphore * rtcLock
semaphore access to RTC
 
cpp_freertos::BinarySemaphore * systemStatusLock
semaphore access to system status
 
EEprom * eeprom
Pointer to EEprom C++ object.
 
system_status_t * system_status
system configuration pointer struct
 
bootloader_t * boot_request
bootloader struct access pointer
 
Backup && Upload Firmware TypeDef (BootLoader)
 
bool app_executed_ok
Flag running APP (setted after new firmware, prevert a rollback operation)
 
System module configuration.
 
uint64_t serial_number
module serial number
 
System message for queue.
 
task_t tasks[TOTAL_INFO_TASK]
Info Task && WDT.
 
task_flag state
Long sleep Task.
 
uint16_t stack
Stack Max Usage Monitor.