changeset 81:8a200d65c6a0

buzplayer: play implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 27 Oct 2016 04:39:48 +0000
parents eb5960dc258c
children a3662c156d9a
files target-utils/buzplayer/Makefile target-utils/buzplayer/cmdtab.c target-utils/buzplayer/melplay.c
diffstat 3 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/buzplayer/Makefile	Thu Oct 27 04:31:31 2016 +0000
+++ b/target-utils/buzplayer/Makefile	Thu Oct 27 04:39:48 2016 +0000
@@ -7,7 +7,7 @@
 INSTDIR=/opt/freecalypso/target-bin
 
 PROG=	buzplayer
-OBJS=	crt0.o cmdtab.o main.o melentry.o mygetchar.o timer.o
+OBJS=	crt0.o cmdtab.o main.o melentry.o melplay.o mygetchar.o timer.o
 LIBS=	../libcommon/libcommon.a ../libprintf/libprintf.a ../libbase/libbase.a
 LDS=	../env/iram.lds
 
--- a/target-utils/buzplayer/cmdtab.c	Thu Oct 27 04:31:31 2016 +0000
+++ b/target-utils/buzplayer/cmdtab.c	Thu Oct 27 04:39:48 2016 +0000
@@ -18,10 +18,12 @@
 
 extern void melody_init();
 extern void melody_entry();
+extern void melody_play();
 
 const struct cmdtab cmdtab[] = {
 	{"E", melody_entry},
 	{"I", melody_init},
+	{"P", melody_play},
 	{"abbinit", abb_init},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/buzplayer/melplay.c	Thu Oct 27 04:39:48 2016 +0000
@@ -0,0 +1,26 @@
+#include "types.h"
+#include "melody.h"
+
+extern struct melentry *melody_buf_start, *melody_buf_tailptr;
+
+#define	ARMIO_LOAD_TIM	(*(volatile u16 *) 0xFFFE4808)
+#define	BUZZ_LIGHT_REG	(*(volatile u16 *) 0xFFFE480E)
+
+void
+melody_play()
+{
+	struct melentry *p;
+	int count;
+
+	wait_for_tdma_frame();
+	for (p = melody_buf_start; p < melody_buf_tailptr; p++) {
+		if (p->tone) {
+			ARMIO_LOAD_TIM = p->tone;
+			BUZZ_LIGHT_REG = 1;
+		} else
+			BUZZ_LIGHT_REG = 0;
+		for (count = p->dur; count; count--)
+			wait_for_tdma_frame();
+		BUZZ_LIGHT_REG = 0;
+	}
+}