6 #include "mountainsensing/common/ms-io.h"
10 #include "dev/avr-handler.h"
13 #include "event-sensor.h"
14 #include "reset-sensor.h"
22 static bool is_sense_on =
false;
35 static void avr_write_bytes(uint8_t *buf,
int length) {
40 for (i = 0; i < length; i++) {
52 adc_zoul.configure(SENSORS_HW_INIT, ZOUL_SENSORS_ADC1 + ZOUL_SENSORS_ADC2 + ZOUL_SENSORS_ADC3);
61 SENSORS_ACTIVATE(event_sensor);
65 avr_set_output(&avr_write_bytes);
73 void ms_sense_on(
void) {
80 void ms_sense_off(
void) {
87 bool ms_get_time(uint32_t *seconds) {
91 *seconds = ERROR_EPOCH;
95 *seconds = (uint32_t) mktime(&t);
103 bool ms_set_time(uint32_t seconds) {
109 gmtime_r((time_t *) &seconds, &t);
117 bool ms_get_batt(
float *batt) {
120 *batt = ((float) (adc_zoul.value(ZOUL_SENSORS_ADC3)/1698));
124 bool ms_get_temp(
float *temp) {
131 *temp = ((float) centi_temp) / 100;
135 bool ms_get_humid(
float *humid) {
140 bool ms_get_adc1(uint32_t *adc1) {
141 *adc1 = adc_zoul.value(ZOUL_SENSORS_ADC1);
145 bool ms_get_adc2(uint32_t *adc2) {
146 *adc2 = adc_zoul.value(ZOUL_SENSORS_ADC2);
150 bool ms_get_rain(uint32_t *rain) {
152 *rain = event_sensor.value(
true);
156 bool ms_get_acc(int32_t *x, int32_t *y, int32_t *z) {
161 bool ms_get_reboot(uint16_t *reboot) {
163 *reboot = reset_sensor.value(0);
167 bool ms_reset_reboot(
void) {
168 reset_counter_reset();
void uart_set_input(uint8_t uart, int(*input)(unsigned char c))
Assigns a callback to be called when the UART receives a byte.
#define EARLIEST_EPOCH
Earliest time supported by the rtc - 2000/01/01 00:00:00.
Sensors for DS3231 (RTC with Temperature Sensor).
#define GPIO_PIN_MASK(PIN)
Converts a pin number to a pin mask.
Header file with definitions related to the I/O connections on the Muntjac platform, cc2538-based.
#define UART_LCRH
UART line control.
Header file for the Zoul ADC interface.
#define GPIO_CLR_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE low.
#define UART_LCRH_FEN
UART enable FIFOs.
#define GPIO_SET_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE high.
void uart_write_byte(uint8_t uart, uint8_t b)
Sends a single character down the UART.
#define NULL
The null pointer.
#define UART_FR_BUSY
UART busy.
int ds3231_get_time(struct tm *t)
ds3231_get_time
#define GPIO_PORT_TO_BASE(PORT)
Converts a port number to the port base address.
void lpm_register_peripheral(lpm_periph_permit_pm1_func_t permit_pm1_func)
Register a peripheral function which will get called by the LPM module to get 'permission' to drop to...
void process_start(struct process *p, process_data_t data)
Start a process.
static bool lpm_permit_pm1(void)
Callback to allow Low Power Modes 1 and 2.
int ds3231_set_time(struct tm *t)
ds3231_set_time
#define UART_FR
UART flag.
int ds3231_get_temperature(int *temperature)
ds3231_temperature