buzzerled.c

Go to the documentation of this file.
00001 
00053 #include "buzzerled.h"
00054 
00055 #warning FIXME:This drive is obsolete, you must refactor it.
00056 
00057 #if 0
00058 #include "cfg/cfg_buzzerled.h"
00059 #include <drv/timer.h>
00060 
00061 static struct Timer timers[CONFIG_NUM_BLDS];
00062 static bool timer_go[CONFIG_NUM_BLDS];
00063 
00064 INLINE enum BLD_DEVICE hook_parm_to_device(void* parm)
00065 {
00066     struct Timer* t = (struct Timer*)parm;
00067     int num_bld = t - &timers[0];
00068 
00069     ASSERT(num_bld >= 0);
00070     ASSERT(num_bld < NUM_BLDS);
00071 
00072     return (enum BLD_DEVICE)num_bld;
00073 }
00074 
00075 static void hook_turn_off(void* parm)
00076 {
00077     enum BLD_DEVICE num_bld = hook_parm_to_device(parm);
00078     bld_set(num_bld, false);
00079 }
00080 
00081 void bld_init(void)
00082 {
00083     bld_hw_init();
00084 }
00085 
00086 void bld_beep(enum BLD_DEVICE device, uint16_t duration)
00087 {
00088     // \todo This is not reentrant for the same device. FIXME!
00089     struct Timer *t = &timers[device];
00090     timer_set_delay(t, duration);
00091     timer_set_event_softint(t, hook_turn_off, t);
00092     timer_add(t);
00093 
00094     bld_set(device, true);
00095 }
00096 
00097 void bld_beep_and_wait(enum BLD_DEVICE device, uint16_t duration)
00098 {
00099     bld_set(device, true);
00100     timer_delay(duration);
00101     bld_set(device, false);
00102 }
00103 #endif
00104