/* Soil Sensor Firmware * Light Measurement & LED Status Indication * 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 measures ambient light and provides state indication * via the LED on the top of the soil sensor. To measure light, * the photodiode is reverse biased, charging the capacitor in parallel with it. * The pins connected to it are placed in a high impedance state * and the time taken for the photo current to discharge the * capacitor is measured with TIM1. */ /* Set the LED state. This function will only set * LED_OFF, LED_RED, and LED_GREEN. * This function can be safely called while a measurement is * in progress; the state will be set when the measurement is * complete. */ enum led_state_t {LED_OFF, LED_RED, LED_GREEN, LED_MEASURING}; void set_led(enum led_state_t state); /* Setup pins for the LED. */ void init_led(void); /* Perform a light measurement. */ uint32_t measure_light(void);