FreeCalypso > hg > freecalypso-tools
view target-utils/buzplayer/pwt.c @ 828:502aec4c1e8e
fc-buzplay: implement playt command for PWT melodies
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 30 May 2021 20:54:02 +0000 |
parents | 7c02cc7f28df |
children |
line wrap: on
line source
/* * 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 pwt_on() { ASIC_CONF_REG |= PWT_MODE_MASK; PWT_GCR_REG = 0x01; } void pwt_off() { ASIC_CONF_REG &= ~PWT_MODE_MASK; PWT_GCR_REG = 0; } void cmd_pwt(argbulk) char *argbulk; { char *argv[2]; if (parse_args(argbulk, 1, 1, argv, 0) < 0) return; if (!strcmp(argv[0], "on")) pwt_on(); else if (!strcmp(argv[0], "off")) pwt_off(); else printf("ERROR: \"on\" or \"off\" argument expected\n"); } void cmd_bzt(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_on(); PWT_FRC_REG = note; PWT_VCR_REG = (vol << 1) | 1; for (;;) { c = serial_in_poll(); if (c >= 0) break; } PWT_VCR_REG = 0; }