STIMA  3
Functions
i2c-leaf.ino File Reference
#include "i2c-leaf.h"
Include dependency graph for i2c-leaf.ino:

Functions

void setup ()
 Arduino setup function. Init watchdog, hardware, debug, buffer and load configuration stored in EEPROM. More...
 
void loop ()
 Arduino loop function. First, initialize tasks and sensors, then execute the tasks and activates the power down if no task is running. More...
 
void logPrefix (Print *_logOutput)
 
void logSuffix (Print *_logOutput)
 
void init_logging ()
 Init logging system. More...
 
void init_power_down (uint32_t *time_ms, uint32_t debouncing_ms)
 Enter power down mode. More...
 
void init_wdt (uint8_t wdt_timer)
 Init watchdog. More...
 
void init_buffers ()
 Init buffers. More...
 
void init_tasks ()
 Init tasks variable and state. More...
 
void init_pins ()
 Init hardware pins. More...
 
void init_wire ()
 Init wire (i2c) library and performs checks on the bus. More...
 
void init_spi ()
 Init SPI library. More...
 
void init_rtc ()
 Init RTC module. More...
 
void init_system ()
 Init system. More...
 
void print_configuration ()
 Print current configuration. More...
 
void save_configuration (bool is_default)
 Save configuration to EEPROM. More...
 
void load_configuration ()
 Load configuration from EEPROM. More...
 
void init_sensors ()
 Create and setup sensors. More...
 
 ISR (TIMER1_OVF_vect)
 Timer1 overflow interrupts routine. More...
 
void i2c_request_interrupt_handler ()
 I2C request interrupt handler. More...
 
void i2c_receive_interrupt_handler (int rx_data_length)
 I2C receive interrupt handler. More...
 
void leaf_reading_task ()
 Sensors reading Task. Read data from sensors. More...
 
void exchange_buffers ()
 Exchange reader and writer pointer to buffer. More...
 
void reset_samples_buffer ()
 Reset samples buffers to default value. More...
 
void reset_report_buffer ()
 
void command_task ()
 Command Task. Execute the command received on i2c bus by reading i2c received data buffer. More...
 
void copy_buffers ()
 
void commands ()
 Performs specific operations based on the received command. More...
 

Function Documentation

◆ command_task()

void command_task ( void  )

Command Task. Execute the command received on i2c bus by reading i2c received data buffer.

Execute the command received on i2c bus by reading i2c received data buffer.

Returns
void.

◆ commands()

void commands ( void  )

Performs specific operations based on the received command.

Returns
void.

CONTINUOUS TEST

CONTINUOUS START

CONTINUOUS STOP

CONTINUOUS START-STOP

ONESHOT START

ONESHOT STOP

ONESHOT START-STOP

◆ copy_buffers()

void copy_buffers ( )

copy readable_data_2 in readable_data_1

◆ exchange_buffers()

void exchange_buffers ( void  )

Exchange reader and writer pointer to buffer.

Returns
void.

◆ i2c_receive_interrupt_handler()

void i2c_receive_interrupt_handler ( int  rx_data_length)

I2C receive interrupt handler.

Parameters
[in]rx_data_lengthreceived data length in bytes.
Returns
void.

check crc: ok

◆ i2c_request_interrupt_handler()

void i2c_request_interrupt_handler ( void  )

I2C request interrupt handler.

Returns
void.

write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus

write crc8

◆ init_buffers()

void init_buffers ( void  )

Init buffers.

Returns
void.

copy readable_data_2 in readable_data_1

◆ init_logging()

void init_logging ( void  )

Init logging system.

Returns
void.

◆ init_pins()

void init_pins ( void  )

Init hardware pins.

Returns
void.

◆ init_power_down()

void init_power_down ( uint32_t *  time_ms,
uint32_t  debouncing_ms 
)

Enter power down mode.

Parameters
time_mspointer to a variable to save the last instant you entered power down.
debouncing_msdelay to power down.
Returns
void.

◆ init_rtc()

void init_rtc ( void  )

Init RTC module.

Returns
void.

◆ init_sensors()

void init_sensors ( void  )

Create and setup sensors.

Returns
void.

◆ init_spi()

void init_spi ( void  )

Init SPI library.

Returns
void.

◆ init_system()

void init_system ( void  )

Init system.

Returns
void.

main loop state

◆ init_tasks()

void init_tasks ( void  )

Init tasks variable and state.

Returns
void.

no tasks ready

◆ init_wdt()

void init_wdt ( uint8_t  wdt_timer)

Init watchdog.

Parameters
wdt_timera time value for init watchdog (WDTO_xxxx).
Returns
void.

◆ init_wire()

void init_wire ( void  )

Init wire (i2c) library and performs checks on the bus.

Returns
void.

◆ ISR()

ISR ( TIMER1_OVF_vect  )

Timer1 overflow interrupts routine.

Returns
void.

Pre-load timer counter register

increment timer_counter_ms by TIMER1_INTERRUPT_TIME_MS

check if SENSORS_SAMPLE_TIME_MS ms have passed since last time. if true and if is in continuous mode and continuous start command It has been received, activate Sensor reading task

reset timer_counter_ms if it has become larger than TIMER_COUNTER_VALUE_MAX_MS

increment transaction_time by TIMER1_INTERRUPT_TIME_MS

◆ leaf_reading_task()

void leaf_reading_task ( void  )

Sensors reading Task. Read data from sensors.

Returns
void.

◆ load_configuration()

void load_configuration ( void  )

Load configuration from EEPROM.

Returns
void.

read configuration from eeprom

◆ loop()

void loop ( void  )

Arduino loop function. First, initialize tasks and sensors, then execute the tasks and activates the power down if no task is running.

Returns
void.

◆ print_configuration()

void print_configuration ( void  )

Print current configuration.

Returns
void.

◆ reset_samples_buffer()

void reset_samples_buffer ( void  )

Reset samples buffers to default value.

Returns
void.

◆ save_configuration()

void save_configuration ( bool  is_default)

Save configuration to EEPROM.

Parameters
is_defaultif true save default configuration; if false save current configuration.
Returns
void.

write configuration to eeprom

◆ setup()

void setup ( )

Arduino setup function. Init watchdog, hardware, debug, buffer and load configuration stored in EEPROM.

Arduino setup function. Init watchdog, hardware, debug and load configuration stored in EEPROM.

Returns
void.