/* Soil Sensor Firmware * Timekeeping * Sensiplicity Systems * * Copyright 2015 * * Department of Botany and Plant Pathology * Center for Genome Research and Biocomputing * Oregon State University * Corvallis, OR 97331 * * This program is not free software; you can not redistribute it and/or * modify it at all. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include /* This module implements a timer that tracks the time * elapsed since the system was powered on. * Timer 0 is used by this module. */ /* Initialize and start the uptime counter. */ void init_timer(void); /* Get the number of seconds since the system was powered on. */ uint32_t get_uptime(void); /* Wait for a condition to become true, timing out after a given * time. The condition is defined by a value, mask, and polarity. * The mask is a bitmask that selects bit(s) in a value. If polarity * is not 0, the condition is true when any of the bits are 1. If * polarity is 0, the condition is true when all are 0. * * The timeout value is in milliseconds. The maximum timeout is 127 milliseconds. * * Returns 0 if the condition became true, -1 if a timeout occurred. */ int8_t wait_condition(volatile uint8_t *value, uint8_t mask, uint8_t polarity, uint8_t timeout_ms);