view target-utils/buzplayer/melplay.c @ 661:fd7b447b99e3

libserial rename The version that was previously named libserial-newlnx is now libserial-linux, and the version that was previosly named libserial-orig is now libserial-posix. This new naming is more in line with the objective reality of the difference, moving away from naming based on our project history.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Mar 2020 19:54:31 +0000
parents 8a200d65c6a0
children 158dd05fb9f9
line wrap: on
line source

#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;
	}
}