buzzerled.c
Go to the documentation of this file.00001
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #include "buzzerled.h"
00079 #include "timer.h"
00080
00081 static struct Timer timers[NUM_BLDS];
00082 static bool timer_go[NUM_BLDS];
00083
00084 INLINE enum BLD_DEVICE hook_parm_to_device(void* parm)
00085 {
00086 struct Timer* t = (struct Timer*)parm;
00087 int num_bld = t - &timers[0];
00088
00089 ASSERT(num_bld >= 0);
00090 ASSERT(num_bld < NUM_BLDS);
00091
00092 return (enum BLD_DEVICE)num_bld;
00093 }
00094
00095 static void hook_turn_off(void* parm)
00096 {
00097 enum BLD_DEVICE num_bld = hook_parm_to_device(parm);
00098 bld_set(num_bld, false);
00099 }
00100
00101 void bld_init(void)
00102 {
00103 bld_hw_init();
00104 }
00105
00106 void bld_beep(enum BLD_DEVICE device, uint16_t duration)
00107 {
00108
00109 struct Timer *t = &timers[device];
00110 timer_set_delay(t, duration);
00111 timer_set_event_softint(t, hook_turn_off, t);
00112 timer_add(t);
00113
00114 bld_set(device, true);
00115 }
00116
00117 void bld_beep_and_wait(enum BLD_DEVICE device, uint16_t duration)
00118 {
00119 bld_set(device, true);
00120 timer_delay(duration);
00121 bld_set(device, false);
00122 }
00123