40 #include "contiki-conf.h"
43 #include "lib/sensors.h"
46 const struct sensors_sensor reset_sensor;
49 static int reset_counter_get(
int type)
51 unsigned char buf[12];
52 xmem_pread(buf, 12, RESET_COUNTER_XMEM_OFFSET);
55 return (buf[2] << 8) | buf[3];
61 static int reset_counter_update(
int type,
int c)
63 unsigned char buf[12];
64 int reset_counter = reset_counter_get(0);
68 buf[2] = reset_counter >> 8;
69 buf[3] = reset_counter & 0xff;
70 xmem_erase(XMEM_ERASE_UNIT_SIZE, RESET_COUNTER_XMEM_OFFSET);
71 xmem_pwrite(buf, 12, RESET_COUNTER_XMEM_OFFSET);
75 void reset_counter_reset()
77 unsigned char buf[12];
78 unsigned int reset_counter = 0;
81 buf[2] = reset_counter >> 8;
82 buf[3] = reset_counter & 0xff;
83 xmem_erase(XMEM_ERASE_UNIT_SIZE, RESET_COUNTER_XMEM_OFFSET);
84 xmem_pwrite(buf, 12, RESET_COUNTER_XMEM_OFFSET);
87 static int reset_counter_status(
int type)
92 SENSORS_SENSOR(reset_sensor,
"Resets",
93 reset_counter_get , reset_counter_update , reset_counter_status);