From 141cde93ddcaa1a249c29d663ea4dd6834c301d2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 31 Mar 2018 10:44:44 +0200 Subject: [PATCH] add: buzzer code from elechouse repo --- armsrc/buzzer.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ armsrc/buzzer.h | 50 ++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 armsrc/buzzer.c create mode 100644 armsrc/buzzer.h diff --git a/armsrc/buzzer.c b/armsrc/buzzer.c new file mode 100644 index 000000000..23e7e05d6 --- /dev/null +++ b/armsrc/buzzer.c @@ -0,0 +1,86 @@ +#include "buzzer.h" + +void Ring_BEE_ONCE(uint16_t music_note) { + BEE_ON(); + SpinDelayUs(music_note); + BEE_OFF(); + SpinDelayUs(music_note); +} + +void ring_2_7khz(uint16_t count) { + Ring_BEE_TIME(n_2_7khz,count); +} + +void Ring_BEE_TIME(uint16_t music_note,uint16_t count) { + for(uint16_t i=0 ; i < count; i++) + Ring_BEE_ONCE(music_note); + SpinDelay(9); +} + +void Ring_ALL(uint16_t count) { + Ring_BEE_TIME(note_1, count); + Ring_BEE_TIME(note_2, count); + Ring_BEE_TIME(note_3, count); + Ring_BEE_TIME(note_4, count); + Ring_BEE_TIME(note_5, count); + Ring_BEE_TIME(note_6, count); + Ring_BEE_TIME(note_7, count); + SpinDelay(10); +} + +void Ring_Little_Star(uint16_t count) { + Ring_BEE_TIME(note_1,count); + Ring_BEE_TIME(note_1,count); + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_6,count); + Ring_BEE_TIME(note_6,count); + Ring_BEE_TIME(note_5,2*count); + LED_A_ON(); + /* + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_2,count); + Ring_BEE_TIME(note_2,count); + Ring_BEE_TIME(note_1,2*count); + LED_A_OFF(); + + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_2,2*count); + LED_A_ON(); + + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_2,2*count); + LED_A_OFF(); + + Ring_BEE_TIME(note_1,count); + Ring_BEE_TIME(note_1,count); + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_5,count); + Ring_BEE_TIME(note_6,count); + Ring_BEE_TIME(note_6,count); + Ring_BEE_TIME(note_5,2*count); + LED_A_ON(); + + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_4,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_3,count); + Ring_BEE_TIME(note_2,count); + Ring_BEE_TIME(note_2,count); + Ring_BEE_TIME(note_1,2*count); + LED_B_ON(); + */ +} \ No newline at end of file diff --git a/armsrc/buzzer.h b/armsrc/buzzer.h new file mode 100644 index 000000000..e253977cf --- /dev/null +++ b/armsrc/buzzer.h @@ -0,0 +1,50 @@ +/******* +--by sww.2017.4.6 +*******/ + +#ifndef __BUZZER_H +#define __BUZZER_H + +#include +#include "proxmark3.h" +#include "apps.h" +#include "util.h" + +#define n_2_7khz 185 +#define note_1 956 +#define note_2 851 +#define note_3 758 +#define note_4 715 +#define note_5 638 +#define note_6 568 +#define note_7 506 +#define note_8 0 + +extern void Ring_BEE_ONCE(uint16_t music_note); +extern void Ring_BEE_TIME(uint16_t music_note,uint16_t count); +extern void ring_2_7khz(uint16_t count); +extern void Ring_ALL(uint16_t count); +extern void Ring_Little_Star(uint16_t count); + +#endif + + + + + + + + + + + + + + + + + + + + +