FreeCalypso > hg > freecalypso-tools
view target-utils/buzplayer/melplay.c @ 964:a96cb97b66a2
ringtools/imy: fix duplicate definition of tdma_durations[]
The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>,
although the present fix is slightly different from the contributed
patch: because main.c doesn't need this tdma_durations[] array
at all, let's simply remove the reference to this array from main.c
rather than turn it into an extern.
I no longer remember my original thought flow that resulted (by mistake)
in tdma_durations[] being multiply defined in main.c and durations.c.
My intent might have been to define all globals in main.c and have
the reference in durations.c be an extern - and I missed that extern -
but without clear memory, I have no certainty. In any case, having
this data array defined in the same module that fills it (durations.c)
is sensible, so let's make it the new way.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 31 Aug 2023 19:38:18 +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"); } }