]> www.fi.muni.cz Git - bike-lights.git/blob - firmware/lights.h
firmware: buttons-press and pwrdown rework
[bike-lights.git] / firmware / lights.h
1 #ifndef LIGHTS_H__
2 #define LIGHTS_H__ 1
3
4 #define N_LEDS 7
5 #define N_PWMLEDS 3
6 #define N_PWMLED_MODES 4
7
8 #define N_BUTTONS 2
9
10 /* logging.c */
11 #ifdef USE_LOGGING
12 void log_set_state(unsigned char val);
13 void log_init();
14 void log_flush();
15 void log_byte(unsigned char byte);
16 void log_word(uint16_t word);
17 #else
18 void inline log_set_state(unsigned char val) { }
19 void inline log_init() { }
20 void inline log_flush() { }
21 void inline log_byte(unsigned char byte) { }
22 void inline log_word(uint16_t word) { }
23 #endif
24
25 /* adc.c */
26 void init_adc();
27 void susp_adc();
28 void timer_start_adcs();
29
30 /* pwm.c */
31 #define PWM_MAX 0x1FF
32
33 void init_pwm();
34 void susp_pwm();
35 void pwm_off(unsigned char n);
36 void pwm_set(unsigned char n, uint16_t stride);
37
38 /* tmr.c */
39 extern volatile uint16_t jiffies;
40 void init_tmr();
41 void susp_tmr();
42
43 /* pwmled.c */
44 void pwmled_init();
45 void pwmled_adc(unsigned char n, uint16_t adcval);
46 void pwmled_set_mode(unsigned char n, unsigned char mode);
47 unsigned char pwmled_needs_adc(unsigned char n);
48 unsigned char pwmled_enabled(unsigned char n);
49
50 /* gpio.c */
51 void gpio_init();
52 void susp_gpio();
53 void gpio_set(unsigned char n, unsigned char on);
54 void gpio_before_poweroff();
55
56 /* ambient.c */
57 void ambient_init();
58 extern volatile unsigned char ambient_zone;
59 void ambient_adc(uint16_t adc_val);
60
61 /* pattern.c */
62 typedef struct {
63         unsigned char mode: 3;
64         unsigned char duration: 5;
65 } pattern_t;
66
67 #define PATTERN_END { 0, 0 }
68 extern pattern_t off_pattern[];
69 extern pattern_t on_pattern[];
70
71 void pattern_init();
72 void patterns_next_tick();
73 void led_set_status(unsigned char status);
74 void led_set_pattern(unsigned char led, pattern_t *pattern);
75
76 /* buttons.c */
77 #define MAX_USER_PARAMS 3
78 void init_buttons();
79 void timer_check_buttons();
80 unsigned char get_user_param(unsigned char param);
81
82 /* battery.c */
83 extern volatile unsigned char battery_100mv;
84 void battery_adc();
85 void init_battery();
86
87 /* main.c */
88 void power_down();
89
90 #endif /* !LIGHTS_H__ */
91