#ifndef LIGHTS_H__ #define LIGHTS_H__ 1 #define N_LEDS 7 #define N_PWMLEDS 3 #define N_PWMLED_MODES 4 #define N_BUTTONS 2 /* logging.c */ #ifdef USE_LOGGING void log_set_state(unsigned char val); void log_init(); void log_flush(); void log_byte(unsigned char byte); void log_word(uint16_t word); #else void inline log_set_state(unsigned char val) { } void inline log_init() { } void inline log_flush() { } void inline log_byte(unsigned char byte) { } void inline log_word(uint16_t word) { } #endif /* adc.c */ void init_adc(); void susp_adc(); void timer_start_adcs(); /* pwm.c */ #define PWM_MAX 0x1E4 /* This should be different than ADC frequency 125 kHz */ #define PWM_STEP_SHIFT 2 /* second parameter of pwm_set is shifted by * PWM_STEP_SHIFT bits to the right before setting * into HW */ void init_pwm(); void susp_pwm(); void pwm_off(unsigned char n); void pwm_set(unsigned char n, uint16_t stride); void pwm_timer(); /* tmr.c */ extern volatile uint16_t jiffies; void init_tmr(); void susp_tmr(); /* pwmled.c */ void init_pwmled(); void pwmled_adc(unsigned char n, uint16_t adcval); void pwmled_set_mode(unsigned char n, unsigned char mode); /* gpio.c */ void init_gpio(); void susp_gpio(); void gpio_set(unsigned char n, unsigned char on); /* ambient.c */ void init_ambient(); extern volatile unsigned char ambient_zone; void ambient_adc(uint16_t adc_val); /* pattern.c */ typedef struct { unsigned char mode: 3; unsigned char duration: 5; } pattern_t; #define PATTERN_FOREVER 0x1F #define PATTERN_END { 0, 0 } extern pattern_t off_pattern[]; extern pattern_t zero_pattern[]; extern pattern_t on_pattern[]; extern pattern_t mode1_pattern[]; void pattern_init(); void patterns_next_tick(); void led_set_pattern(unsigned char led, pattern_t *pattern); pattern_t *number_pattern(unsigned char num); /* buttons.c */ #define MAX_USER_PARAMS 3 void init_buttons(); void susp_buttons(); void timer_check_buttons(); unsigned char get_user_param(unsigned char param); pattern_t *status_pattern_select(unsigned char n); unsigned char buttons_wait_for_release(); /* battery.c */ extern volatile unsigned char battery_100mv; void battery_adc(); void init_battery(); /* main.c */ void power_down(); #endif /* !LIGHTS_H__ */