30 #define TRACE_LEVEL ACCELEROMETER_TASK_TRACE_LEVEL
31 #define LOCAL_TASK_ID ACCELEROMETER_TASK_ID
35 #if (ENABLE_ACCELEROMETER)
57 #if (ENABLE_STACK_USAGE)
59 void AccelerometerTask::TaskMonitorStack()
61 uint16_t stackUsage = (uint16_t)uxTaskGetStackHighWaterMark( NULL );
115 bool is_module_ready;
116 uint8_t hardware_check_attempt;
117 bool start_calibration =
false;
123 #if (ENABLE_STACK_USAGE)
144 start_calibration =
true;
171 TRACE_VERBOSE_F(F(
"ACCELEROMETER_STATE_INIT -> ACCELEROMETER_STATE_CHECK_HARDWARE\r\n"));
180 hardware_check_attempt = 0;
181 is_module_ready =
false;
185 if (!is_module_ready)
188 TRACE_VERBOSE_F(F(
"ACCELEROMETER_STATE_CHECK_HARDWARE -> ACCELEROMETER_STATE_SETUP_MODULE\r\n"));
193 hardware_check_attempt++;
204 is_module_ready =
true;
209 TRACE_VERBOSE_F(F(
"ACCELEROMETER_STATE_SETUP_MODULE -> ACCELEROMETER_STATE_CHECK_OPERATION\r\n"));
242 if(start_calibration) {
246 start_calibration =
false;
272 #if (ENABLE_STACK_USAGE)
288 bool register_config_valid =
true;
290 static uavcan_register_Value_1_0 val = {0};
292 TRACE_INFO_F(F(
"ACCELEROMETER: Load configuration...\r\n"));
298 if(register_config_valid) {
300 uavcan_register_Value_1_0_select_natural8_(&val);
301 val.natural8.value.count = 2;
308 if(uavcan_register_Value_1_0_is_natural8_(&val) && (val.natural8.value.count != 2)) {
309 register_config_valid =
false;
320 if(register_config_valid) {
322 uavcan_register_Value_1_0_select_real32_(&val);
323 val.real32.value.count = 3;
325 val.real32.value.elements[0] = 0.0;
326 val.real32.value.elements[1] = 0.0;
327 val.real32.value.elements[2] = 0.0;
331 if(uavcan_register_Value_1_0_is_real32_(&val) && (val.real32.value.count != 3)) {
332 register_config_valid =
false;
365 static uavcan_register_Value_1_0 val = {0};
383 uavcan_register_Value_1_0_select_natural8_(&val);
384 val.natural8.value.count = 2;
396 uavcan_register_Value_1_0_select_real32_(&val);
397 val.real32.value.count = 3;
428 static uavcan_register_Value_1_0 val = {0};
434 uavcan_register_Value_1_0_select_real32_(&val);
435 val.real32.value.count = 3;
450 bool hw_check =
false;
489 int16_t data_raw_acceleration[3];
490 memset(data_raw_acceleration, 0x00, 3 *
sizeof(int16_t));
#define ACCELEROMETER_MAX_CHECK_ATTEMPT
#define ACCELEROMETER_WAIT_CHECK_HARDWARE
accelerometer cpp_Freertos header file
#define BUBBLE_TIMINGS_VERIFY
#define ACCELEROMETER_TASK_WAIT_DELAY_MS
#define BUBBLE_ANGLE_MIRROR
#define BUBBLE_ANGLE_ERROR
#define ACCELEROMETER_TASK_SLEEP_DELAY_MS
accelerometer_t accelerometer_configuration
void printConfiguration(void)
Print configuration Accelerometer.
void TaskState(uint8_t state_position, uint8_t state_subposition, task_flag state_operation)
local suspend flag and positor running state Task (optional)
void loadConfiguration(void)
Load configuration accelleration module.
void setupModule(void)
Setup hardware configuration.
AccelerometerState_t state
void calibrate(bool is_default, bool save_register)
Calibrate accelereometer position X-Y-Z to actual value (set offset from 0)
@ ACCELEROMETER_STATE_HARDWARE_FAIL
@ ACCELEROMETER_STATE_CHECK_HARDWARE
@ ACCELEROMETER_STATE_INIT
@ ACCELEROMETER_STATE_SETUP_MODULE
@ ACCELEROMETER_STATE_CREATE
@ ACCELEROMETER_STATE_CHECK_OPERATION
@ ACCELEROMETER_STATE_WAIT_RESUME
void saveConfiguration(bool is_default)
Init/Save configuration param Accelerometer.
void TaskWatchDog(uint32_t millis_standby)
local watchDog and Sleep flag Task (optional)
virtual void Run()
RUN Task.
AccelerometerParam_t param
bool readModule(void)
Read data from module accelerometer.
Accelerometer accelerometer
AccelerometerTask(const char *taskName, uint16_t stackSize, uint8_t priority, AccelerometerParam_t AccelerometerParam)
Construct the Accelerometer Task::AccelerometerTask object.
void powerDownModule(void)
Activate power saving hardware module.
bool checkModule(void)
Check hardware module.
void read(const char *const register_name, uavcan_register_Value_1_0 *const inout_value)
Legge un registro Cypal/Uavcan wrapper UAVCAN (Imposta Default su Set inout_value su value se non esi...
void write(const char *const register_name, const uavcan_register_Value_1_0 *const value)
Store the given register value into the persistent storage.
#define WDT_CONTROLLER_MS
Task milliseconds minimal check.
#define ALL_TASK_ID
All task ID. Send message to ALL Task.
#define WDT_STARTING_TASK_MS
Init WatchDog Task local milliseconds.
#define ACCELEROMETER_TASK_ID
Accelerometer task ID.
#define UNUSED_SUB_POSITION
Monitor Sub Position not used flag.
#define TRACE_INFO_F(...)
#define TRACE_VERBOSE_F(...)
int32_t iis328dq_device_id_get(uint8_t *buff)
Device Who am I.[get].
int32_t iis328dq_block_data_update_set(uint8_t val)
Block data update.[set].
int32_t iis328dq_full_scale_set(iis328dq_fs_t val)
Accelerometer full-scale selection.[set].
int32_t iis328dq_status_reg_get(iis328dq_status_reg_t *val)
The STATUS_REG register is read by the interface.[get].
int32_t iis328dq_data_rate_set(iis328dq_dr_t val)
Accelerometer data rate selection.[set].
int32_t iis328dq_acceleration_raw_get(int16_t *val)
Linear acceleration output register. The value is expressed as a 16-bit word in two’s complement....
int32_t iis328dq_hp_path_set(iis328dq_hpen_t val)
Select High Pass filter path.[set].
void push_raw_data(int16_t *data_raw)
Push data row for scroll mean sensibility data.
float_t iis328dq_from_fsx_to_inc(int16_t lsb)
Read istant value accelerometer scaled 0-100% to inclinometer value.
@ set
Set WDT (From Application TASK... All OK)
@ timer
Set Timered WDT (From Application long function WDT...)
task_flag
Task state Flag type.
@ suspended
Task is excluded from WDT Controller or Suspended complete.
@ sleepy
Task is in sleep mode or longer wait (Inform WDT controller)
@ normal
Normal operation Task controller.
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.
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.
Accelerometer::iis328dq_dr_t module_power
module updating frequency (enabled)
uint8_t config_valid
Inizialization Byte Config.
float offset_y
offset_y to 0
float offset_x
offset_x to 0
float offset_z
offset_z to 0
System message for queue.
uint8_t task_dest
Command struct.
uint8_t do_sleep
Optional param for difference level Sleep.
uint8_t do_calib
Calibrate accelerometr.
struct system_message_t::@7 command
bool bubble_level_error
Bubble software accelerometer error.
struct system_status_t::@6 running
struct system_status_t::@5 events
Module error or alert timings continuos verify.
task_t tasks[TOTAL_INFO_TASK]
Info Task && WDT.
bool is_bubble_level_error
Bubble software accelerometer error.
bool is_accelerometer_error
Accelerometer error.
uint32_t epoch_bubble_level_error
Bubble software accelerometer error epoch event start.
int32_t watch_dog_ms
WatchDog of Task Timer.
uint8_t running_pos
!=0 (CREATE) Task Started (Generic state of Task)
task_flag state
Long sleep Task.
wdt_flag watch_dog
WatchDog of Task.
uint16_t stack
Stack Max Usage Monitor.
uint8_t running_sub
Optional SubState of Task.
iis328dq_status_reg_t status_reg