changeset 36:29d0965ebf86

target-utils: buzzer exercising code written, added to c139explore
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 25 Oct 2016 23:57:15 +0000
parents 2942c5ef76ed
children f24b31082605
files target-utils/c139explore/cmdtab.c target-utils/libcommon/Makefile target-utils/libcommon/buzzer.c
diffstat 3 files changed, 62 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/c139explore/cmdtab.c	Tue Oct 25 22:45:03 2016 +0000
+++ b/target-utils/c139explore/cmdtab.c	Tue Oct 25 23:57:15 2016 +0000
@@ -2,6 +2,8 @@
 
 extern void cmd_abbr();
 extern void cmd_abbw();
+extern void cmd_buz();
+extern void cmd_buzlev();
 extern void cmd_dbl();
 extern void cmd_hbars();
 extern void cmd_jump();
@@ -26,6 +28,8 @@
 	{"abbinit", abb_init},
 	{"abbr", cmd_abbr},
 	{"abbw", cmd_abbw},
+	{"buz", cmd_buz},
+	{"buzlev", cmd_buzlev},
 	{"dbl", cmd_dbl},
 	{"dump", cmd_memdump_human},
 	{"hbars", cmd_hbars},
--- a/target-utils/libcommon/Makefile	Tue Oct 25 22:45:03 2016 +0000
+++ b/target-utils/libcommon/Makefile	Tue Oct 25 23:57:15 2016 +0000
@@ -4,7 +4,7 @@
 AR=	arm-elf-ar
 RANLIB=	arm-elf-ranlib
 
-OBJS=	abbcmd.o cmdentry.o dispatch.o hexarg.o parseargs.o uartsel.o \
+OBJS=	abbcmd.o buzzer.o cmdentry.o dispatch.o hexarg.o parseargs.o uartsel.o \
 	cmd_baud_switch.o cmd_dieid.o cmd_jump.o cmd_r8.o cmd_r16.o cmd_r32.o \
 	cmd_w8.o cmd_w16.o cmd_w32.o cmd_memdump_human.o cmd_memdump_machine.o
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/libcommon/buzzer.c	Tue Oct 25 23:57:15 2016 +0000
@@ -0,0 +1,57 @@
+/*
+ * Commands for exercising the Calypso's buzzer output, whatever
+ * actual hardware (piezo buzzer or vibrator) it may be driving
+ * on a given Calypso device.
+ */
+
+#include <sys/types.h>
+#include "types.h"
+
+#define	ARMIO_LOAD_TIM	(*(volatile u16 *) 0xFFFE4808)
+#define	BUZZ_LIGHT_REG	(*(volatile u16 *) 0xFFFE480E)
+#define	BUZZ_LEVEL_REG	(*(volatile u16 *) 0xFFFE4812)
+
+void
+cmd_buzlev(argbulk)
+	char *argbulk;
+{
+	char *argv[2];
+	u32 arg;
+
+	if (parse_args(argbulk, 0, 1, argv, 0) < 0)
+		return;
+	if (argv[0]) {
+		arg = strtoul(argv[0], 0, 0);
+		if (arg > 0xFFFF) {
+			printf("ERROR: argument out of range\n");
+			return;
+		}
+		BUZZ_LEVEL_REG = arg;
+	} else
+		printf("%04X\n", BUZZ_LEVEL_REG);
+}
+
+void
+cmd_buz(argbulk)
+	char *argbulk;
+{
+	char *argv[2];
+	u32 arg;
+	int c;
+
+	if (parse_args(argbulk, 1, 1, argv, 0) < 0)
+		return;
+	arg = strtoul(argv[0], 0, 0);
+	if (arg > 0xFFFF) {
+		printf("ERROR: argument out of range\n");
+		return;
+	}
+	ARMIO_LOAD_TIM = arg;
+	BUZZ_LIGHT_REG = 1;
+	for (;;) {
+		c = serial_in_poll();
+		if (c >= 0)
+			break;
+	}
+	BUZZ_LIGHT_REG = 0;
+}