view target-utils/buzplayer/melplay.c @ 1011:6d9b10633f10 default tip

etmsync Pirelli IMEI retrieval: fix poor use of printf() Bug reported by Vadim Yanitskiy <fixeria@osmocom.org>: the construct where a static-allocated string was passed to printf() without any format arguments causes newer compilers to report a security problem. Given that formatted output is not needed here, just fixed string output, change printf() to fputs(), and direct the error message to stderr while at it.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 23 May 2024 17:29:57 +0000
parents 158dd05fb9f9
children
line wrap: on
line source

#include "types.h"
#include "melody.h"

extern struct melentry *melody_buf_start, *melody_buf_tailptr;
extern int melody_mode;

#define	ARMIO_LOAD_TIM	(*(volatile u16 *) 0xFFFE4808)
#define	BUZZ_LIGHT_REG	(*(volatile u16 *) 0xFFFE480E)

#define	PWT_FRC_REG	(*(volatile u8 *) 0xFFFE8800)
#define	PWT_VCR_REG	(*(volatile u8 *) 0xFFFE8801)

void
melody_play_bu()
{
	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;
	}
}

void
melody_play_pwt()
{
	struct melentry *p;
	int count;

	wait_for_tdma_frame();
	for (p = melody_buf_start; p < melody_buf_tailptr; p++) {
		PWT_FRC_REG = p->tone;
		PWT_VCR_REG = p->vol;
		for (count = p->dur; count; count--)
			wait_for_tdma_frame();
		PWT_VCR_REG = 0;
	}
}

void
melody_play()
{
	switch (melody_mode) {
	case 1:
		melody_play_bu();
		return;
	case 2:
		melody_play_pwt();
		return;
	default:
		printf("ERROR: no melody entered\n");
	}
}