STIMA
3
|
#include "i2c-rain-config.h"
#include <debug.h>
#include <i2c_config.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include <i2c_utility.h>
#include <rmap_utility.h>
#include <sdcard_utility.h>
#include <eeprom_utility.h>
#include <Wire.h>
#include <typedef.h>
#include <registers-rain.h>
#include <debug_config.h>
#include <SdFat.h>
#include <StreamUtils.h>
#include <ArduinoLog.h>
Go to the source code of this file.
Classes | |
struct | configuration_t |
EEPROM saved configuration. More... | |
struct | readable_data_t |
Readable data through i2c bus. More... | |
struct | writable_data_t |
Writable data through i2c bus. More... | |
Enumerations | |
enum | state_t { INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END , REBOOT , INIT , TASKS_EXECUTION , END , INIT , TASKS_EXECUTION , END } |
Main loop finite state machine. More... | |
enum | tipping_bucket_state_t { TIPPING_BUCKET_INIT , TIPPING_BUCKET_READ , TIPPING_BUCKET_COUNT , TIPPING_BUCKET_END , TIPPING_BUCKET_WAIT_STATE } |
Tipping bucket task finite state machine. More... | |
Functions | |
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_system (void) |
Init system. More... | |
void | init_buffers (void) |
Init buffers. More... | |
void | init_tasks (void) |
Init tasks variable and state. More... | |
void | init_pins (void) |
Init hardware pins. More... | |
void | init_wire (void) |
Init wire (i2c) library and performs checks on the bus. More... | |
void | init_spi (void) |
Init SPI library. More... | |
void | init_rtc (void) |
Init RTC module. More... | |
void | init_sensors (void) |
Create and setup sensors. More... | |
void | print_configuration (void) |
Print current configuration. More... | |
void | load_configuration (void) |
Load configuration from EEPROM. More... | |
void | save_configuration (bool) |
Save configuration to EEPROM. More... | |
void | commands (void) |
Performs specific operations based on the received command. More... | |
void | tests (void) |
Performs specific operations based on the received command. More... | |
void | reset_buffers (void) |
Reset buffers to default value. More... | |
void | exchange_buffers (void) |
Exchange reader and writer pointer to buffer. More... | |
void | init_logging () |
Init logging system. More... | |
void | tipping_bucket_task (void) |
Tipping bucket task. More... | |
void | command_task (void) |
Command Task. Execute the command received on i2c bus by reading i2c received data buffer. More... | |
void | i2c_request_interrupt_handler (void) |
I2C request interrupt handler. More... | |
void | i2c_receive_interrupt_handler (int rx_data_length) |
I2C receive interrupt handler. More... | |
void | tipping_bucket_interrupt_handler (void) |
Tipping bucket interrupt handler. More... | |
Variables | |
configuration_t | configuration |
volatile readable_data_t | readable_data_1 |
volatile readable_data_t | readable_data_2 |
volatile readable_data_t * | readable_data_read_ptr |
volatile readable_data_t * | readable_data_write_ptr |
volatile readable_data_t * | readable_data_temp_ptr |
writable_data_t | writable_data |
writable_data_t * | writable_data_ptr |
volatile uint8_t | readable_data_address |
volatile uint8_t | readable_data_length |
volatile uint8_t | i2c_rx_data [I2C_MAX_DATA_LENGTH] |
volatile uint8_t | lastcommand |
volatile uint8_t | i2c_error |
volatile uint8_t | i2c_time |
volatile uint8_t | ready_tasks_count |
uint32_t | awakened_event_occurred_time_ms |
volatile bool | inside_transaction |
volatile uint16_t | transaction_time |
bool | is_start |
bool | is_stop |
bool | is_test |
bool | is_started |
Start command is active and measure is active. | |
rain_t | rain |
Rain data. | |
state_t | state |
tipping_bucket_state_t | tipping_bucket_state |
Current tipping bucket task state. | |
volatile bool | is_event_tipping_bucket |
Enable or disable the Tipping Bucket task. | |
volatile bool | is_event_command_task |
enum state_t |
Main loop finite state machine.
Tipping bucket task finite state machine.
void command_task | ( | ) |
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.
void commands | ( | ) |
Performs specific operations based on the received command.
CONTINUOUS TEST
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS TEST
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS TEST
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS TEST
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS TEST
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS TEST
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS TEST
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
CONTINUOUS START
CONTINUOUS STOP
CONTINUOUS START-STOP
ONESHOT START
ONESHOT STOP
ONESHOT START-STOP
void exchange_buffers | ( | ) |
Exchange reader and writer pointer to buffer.
void i2c_receive_interrupt_handler | ( | int | rx_data_length | ) |
I2C receive interrupt handler.
[in] | rx_data_length | received data length in bytes. |
check crc: ok
check crc: ok
check crc: ok
check crc: ok
check crc: ok
check crc: ok
check crc: ok
check crc: ok
check crc: ok
void i2c_request_interrupt_handler | ( | ) |
I2C request interrupt handler.
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
write crc8
write readable_data_length bytes of data stored in readable_data_read_ptr (base) + readable_data_address (offset) on i2c bus
void init_buffers | ( | ) |
Init buffers.
copy readable_data_2 in readable_data_1
copy readable_data_2 in readable_data_1
copy readable_data_write in readable_data_read
copy readable_data_write in readable_data_read
copy readable_data_2 in readable_data_1
copy readable_data_2 in readable_data_1
copy readable_data_write in readable_data_read
copy readable_data_write in readable_data_read
copy readable_data_write in readable_data_read
copy readable_data_2 in readable_data_1
copy readable_data_write in readable_data_read
copy readable_data_2 in readable_data_1
copy readable_data_2 in readable_data_1
copy readable_data_write in readable_data_read
copy readable_data_write in readable_data_read
copy readable_data_write in readable_data_read
copy readable_data_2 in readable_data_1
copy readable_data_write in readable_data_read
void init_logging | ( | ) |
Init logging system.
void init_pins | ( | ) |
Init hardware pins.
void init_power_down | ( | uint32_t * | time_ms, |
uint32_t | debouncing_ms | ||
) |
Enter power down mode.
time_ms | pointer to a variable to save the last instant you entered power down. |
debouncing_ms | delay to power down. |
void init_rtc | ( | ) |
Init RTC module.
void init_sensors | ( | ) |
Create and setup sensors.
void init_spi | ( | ) |
Init SPI library.
void init_system | ( | ) |
Init system.
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
main loop state
void init_tasks | ( | ) |
Init tasks variable and state.
no tasks ready
no tasks ready
reset samples_count value
no tasks ready
no tasks ready
reset samples_count value
no tasks ready
no tasks ready
reset samples_count value
no tasks ready
no tasks ready
reset samples_count value
no tasks ready
no tasks ready
no tasks ready
no tasks ready
no tasks ready
reset samples_count value
no tasks ready
no tasks ready
no tasks ready
no tasks ready
void init_wdt | ( | uint8_t | wdt_timer | ) |
Init watchdog.
wdt_timer | a time value for init watchdog (WDTO_xxxx). |
void init_wire | ( | ) |
Init wire (i2c) library and performs checks on the bus.
clear the I2C bus first before calling Wire.begin()
clear the I2C bus first before calling Wire.begin()
void load_configuration | ( | ) |
Load configuration from EEPROM.
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
read configuration from eeprom
void print_configuration | ( | ) |
Print current configuration.
void reset_buffers | ( | void | ) |
Reset buffers to default value.
void save_configuration | ( | bool | is_default | ) |
Save configuration to EEPROM.
is_default | if true save default configuration; if false save current configuration. |
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
write configuration to eeprom
void tests | ( | ) |
Performs specific operations based on the received command.
Performs tests operations based on the received command.
void tipping_bucket_interrupt_handler | ( | void | ) |
Tipping bucket interrupt handler.
void tipping_bucket_task | ( | void | ) |
Tipping bucket task.