FreeCalypso > hg > freecalypso-tools
diff target-utils/buzplayer/pwt.c @ 820:03457a66d860
buzplayer: add basic support for PWT
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 30 May 2021 03:39:58 +0000 |
parents | |
children | 16bee7b6bd6b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target-utils/buzplayer/pwt.c Sun May 30 03:39:58 2021 +0000 @@ -0,0 +1,67 @@ +/* + * Commands for exercising the Calypso buzzer in PWT mode. + */ + +#include <sys/types.h> +#include <strings.h> +#include "types.h" + +extern u_long strtoul(); + +#define ASIC_CONF_REG (*(volatile u16 *) 0xFFFEF008) +#define PWT_MODE_MASK 0x0020 + +#define PWT_FRC_REG (*(volatile u8 *) 0xFFFE8800) +#define PWT_VCR_REG (*(volatile u8 *) 0xFFFE8801) +#define PWT_GCR_REG (*(volatile u8 *) 0xFFFE8802) + +void +cmd_pwt(argbulk) + char *argbulk; +{ + char *argv[2]; + + if (parse_args(argbulk, 1, 1, argv, 0) < 0) + return; + if (!strcmp(argv[0], "on")) { + ASIC_CONF_REG |= PWT_MODE_MASK; + PWT_GCR_REG = 0x01; + } else if (!strcmp(argv[0], "off")) { + ASIC_CONF_REG &= ~PWT_MODE_MASK; + PWT_GCR_REG = 0; + } else + printf("ERROR: \"on\" or \"off\" argument expected\n"); +} + +void +cmd_buzpwt(argbulk) + char *argbulk; +{ + char *argv[3]; + u32 note, vol; + int c; + + if (parse_args(argbulk, 1, 2, argv, 0) < 0) + return; + note = strtoul(argv[0], 0, 0); + if (note > 47) { + printf("ERROR: note argument out of range\n"); + return; + } + if (argv[1]) { + vol = strtoul(argv[1], 0, 0); + if (vol > 63) { + printf("ERROR: volume argument out of range\n"); + return; + } + } else + vol = 63; + PWT_FRC_REG = note; + PWT_VCR_REG = (vol << 1) | 1; + for (;;) { + c = serial_in_poll(); + if (c >= 0) + break; + } + PWT_VCR_REG = 0; +}