]> www.fi.muni.cz Git - bike-lights.git/blob - firmware/lights.h
pwm.c: publish only PWM_MAX as non-internal value
[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 init_log();
13 void log_set_state(unsigned char val);
14 void log_flush();
15 void log_byte(unsigned char byte);
16 void log_word(uint16_t word);
17 #else
18 void inline init_log() { }
19 void inline log_set_state(unsigned char val) { }
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
29 /* pwm.c */
30 /*
31  * The real Timer/Counter 1 frequency should not be too close to the
32  * A/D converter frequency (125 kHz). Note that this is not the Top
33  * value of T/C 1, it is shifted by PWM_STEP_SHIFT as described in pwm.c
34  */
35 #define PWM_MAX 0x780
36 void init_pwm();
37 void susp_pwm();
38 void pwm_off(unsigned char n);
39 void pwm_set(unsigned char n, uint16_t stride);
40 void pwm_timer();
41
42 /* tmr.c */
43 extern volatile uint16_t jiffies;
44 void init_tmr();
45 void susp_tmr();
46
47 /* pwmled.c */
48 void init_pwmled();
49 void pwmled_adc(unsigned char n, uint16_t adcval);
50 void pwmled_set_mode(unsigned char n, unsigned char mode);
51
52 /* gpio.c */
53 void init_gpio();
54 void susp_gpio();
55 void gpio_set(unsigned char n, unsigned char on);
56
57 /* ambient.c */
58 void init_ambient();
59 extern volatile unsigned char ambient_zone;
60 void ambient_adc(uint16_t adc_val);
61
62 /* pattern.c */
63 typedef struct {
64         unsigned char mode: 3;
65         unsigned char duration: 5;
66 } pattern_t;
67
68 #define PATTERN_FOREVER 0x1F
69 #define PATTERN_END { 0, 0 }
70 void init_pattern();
71 void patterns_next_tick();
72 void led_set_pattern(unsigned char led, pattern_t *pattern);
73 pattern_t *number_pattern(unsigned char num, unsigned char inv);
74 void pattern_reload();
75
76 /* buttons.c */
77 #define MAX_USER_PARAMS 3
78 void init_buttons();
79 void susp_buttons();
80 void timer_check_buttons();
81 unsigned char get_user_param(unsigned char param);
82 unsigned char buttons_wait_for_release();
83 unsigned char buttons_setup_in_progress();
84 pattern_t *buttons_setup_status0_pattern_select();
85 pattern_t *buttons_setup_status1_pattern_select();
86
87 /* battery.c */
88 extern volatile unsigned char battery_100mv;
89 void battery_adc();
90 void init_battery();
91
92 /* control.c */
93 extern pattern_t on1_pattern[];
94
95 void init_control();
96 void toggle_dim_mode();
97 void set_panic_mode();
98 pattern_t *pwmled0_pattern_select();
99 pattern_t *pwmled1_pattern_select();
100 pattern_t *pwmled2_pattern_select();
101 pattern_t *status_led_pattern_select();
102 pattern_t *illumination_led_pattern_select();
103
104 /* main.c */
105 void power_down();
106
107 #endif /* !LIGHTS_H__ */
108