#ifndef WIFI_MAIN_H_ #define WIFI_MAIN_H_ #include "util.h" /* User buttons */ #define KEYS_PORT PORTB #define KEYS_PIN PINB #define KEYS_DDR DDRB #define KEY_NEXT (1 << 0) #define KEY_PREV (1 << 1) #define KEY_SCAN (1 << 2) #define KEYS_MASK (KEY_NEXT | KEY_PREV | KEY_SCAN) static inline bool key_is_pressed(uint8_t key_mask) { return !(KEYS_PIN & key_mask); } void key_debounce(uint8_t key_mask, uint8_t delay); void emergency_shutdown(void); /* Jiffies timing helpers derived from the Linux Kernel sources. * These inlines deal with timer wrapping correctly. * * time_after(a, b) returns true if the time a is after time b. * * Do this with "<0" and ">=0" to only test the sign of the result. A * good compiler would generate better code (and a really good compiler * wouldn't care). Gcc is currently neither. */ #define time_after(a, b) ((int8_t)(b) - (int8_t)(a) < 0) #define time_before(a, b) time_after(b, a) #endif /* WIFI_MAIN_H_ */