Fix audio
This commit is contained in:
parent
d1ddb909ff
commit
8a8e50dfb9
11 changed files with 81 additions and 27 deletions
|
@ -157,7 +157,7 @@ void beep(unsigned char n) {
|
|||
SIDsetfrq(0,5001);
|
||||
break;
|
||||
}
|
||||
PWMPR = 0;
|
||||
//PWMPR = 0;
|
||||
switchSound(SOUND_ON);
|
||||
SID.flags |= SIDenable;
|
||||
SID.reg[REG_Control] |= GATE;
|
||||
|
|
|
@ -101,12 +101,12 @@ struct SID_ {
|
|||
|
||||
struct SID_ SID;
|
||||
|
||||
unsigned int playtone_cb;
|
||||
unsigned char *playtone[3];
|
||||
unsigned char playstate;
|
||||
unsigned char tonelen[3];
|
||||
unsigned short playcounter;
|
||||
unsigned short playcountermax;
|
||||
extern unsigned int playtone_cb;
|
||||
extern unsigned char *playtone[3];
|
||||
extern unsigned char playstate;
|
||||
extern unsigned char tonelen[3];
|
||||
extern unsigned short playcounter;
|
||||
extern unsigned short playcountermax;
|
||||
|
||||
void SIDsetfrq(unsigned char voice, unsigned short frq);
|
||||
void SIDsetadsr(unsigned char voice,unsigned char attack, unsigned char decay, unsigned char sustain, unsigned char release);
|
||||
|
|
|
@ -769,6 +769,7 @@ const unsigned char song1[] = {
|
|||
0xa2,0x25,0x00,0x00,0x21,0x11,0x70,0xd2,0x0f,0x00,0x00,0x21,0x00,0x70,
|
||||
0xa2,0x25,0x00,0x00,0x21,0x11,0x70,0xd2,0x0f,0x00,0x00,0x21,0x00,0x70,
|
||||
0xa2,0x25,0x00,0x00,0x21,0x11,0x70,0xd2,0x0f,0x00,0x00,0x21,0x00,0x70,
|
||||
/*
|
||||
0x1f,0x15,0x00,0x00,0x21,0x11,0x70,0xc3,0x10,0x00,0x00,0x21,0x00,0x70,
|
||||
0x1f,0x15,0x00,0x00,0x21,0x11,0x70,0xc3,0x10,0x00,0x00,0x21,0x00,0x70,
|
||||
0x1f,0x15,0x00,0x00,0x21,0x11,0x70,0xc3,0x10,0x00,0x00,0x21,0x00,0x70,
|
||||
|
@ -1001,4 +1002,5 @@ const unsigned char song1[] = {
|
|||
0xc1,0x2c,0x00,0x00,0x21,0x11,0x70,0x31,0x1c,0x00,0x00,0x21,0x00,0x70,
|
||||
0xc1,0x2c,0x00,0x00,0x21,0x11,0x70,0x31,0x1c,0x00,0x00,0x21,0x00,0x70,
|
||||
0xc1,0x2c,0x00,0x00,0x21,0x11,0x70,0x31,0x1c,0x00,0x00,0x21,0x00,0x70
|
||||
*/
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "sound.h"
|
||||
#include "soundirq.h"
|
||||
#include "lpc2220.h"
|
||||
#include "pwm.h"
|
||||
|
||||
#define AUTO_OFF_TIME 0x4000
|
||||
|
||||
|
@ -37,7 +38,7 @@ unsigned char timeout;
|
|||
unsigned int auto_timeout;
|
||||
|
||||
void startSoundIRQ(void)
|
||||
{
|
||||
{/*
|
||||
timeout = 0;
|
||||
auto_timeout = 0;
|
||||
out1 = 0;
|
||||
|
@ -57,6 +58,7 @@ void startSoundIRQ(void)
|
|||
//VICVectCntl0 = VIC_SLOT_EN | INT_SRC_PWM;
|
||||
VICIntSelect |= INT_PWM;
|
||||
VICIntEnable = INT_PWM;
|
||||
*/
|
||||
}
|
||||
|
||||
void initSound(void)
|
||||
|
@ -67,12 +69,18 @@ void initSound(void)
|
|||
tval = 0;
|
||||
last_sample = 0;
|
||||
bl_val = 0x3F;
|
||||
timeout = 0;
|
||||
auto_timeout = 0;
|
||||
out1 = 0;
|
||||
}
|
||||
|
||||
void switchSound(unsigned char onoff)
|
||||
{
|
||||
if(onoff)
|
||||
{
|
||||
|
||||
PWM_set_frequency(30864);
|
||||
|
||||
sound_shutdown = 0;
|
||||
PINSEL0 &= ~(3 << (2 * SND_PWM)); // IO
|
||||
PINSEL0 |= (2 << (2 * SND_PWM)); // PWM
|
||||
|
@ -81,6 +89,7 @@ void switchSound(unsigned char onoff)
|
|||
FIODIR0 |= (1<<SND_ON) | (1<<SND_EN);
|
||||
FIOSET0 = (1<<SND_EN);
|
||||
FIOCLR0 = (1<<SND_ON);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "sound.h"
|
||||
#include "sid.h"
|
||||
#include "lpc2220.h"
|
||||
#include "pwm.h"
|
||||
|
||||
#define AUTO_OFF_TIME 0x4000
|
||||
|
||||
|
@ -41,13 +42,15 @@ unsigned char sact;
|
|||
unsigned char out1;
|
||||
unsigned char last_sample;
|
||||
unsigned char sound_shutdown;
|
||||
unsigned char tcount;
|
||||
|
||||
const unsigned char prevvoice[3] = {2,0,1};
|
||||
|
||||
void __attribute__ ((section(".text.fastcode"))) soundIRQ (void)
|
||||
{
|
||||
PWMIR = 0x01;
|
||||
|
||||
|
||||
/*
|
||||
// play sample
|
||||
if(sact != 0)
|
||||
{
|
||||
|
@ -75,8 +78,9 @@ void __attribute__ ((section(".text.fastcode"))) soundIRQ (void)
|
|||
PWMLER = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
// synthesize
|
||||
else if(SID.flags & SIDenable)
|
||||
else */if(SID.flags & SIDenable)
|
||||
{
|
||||
unsigned short tempphase;
|
||||
unsigned char x;
|
||||
|
|
Binary file not shown.
|
@ -29,6 +29,7 @@
|
|||
#include "ir_selector.h"
|
||||
#include "infrared.h"
|
||||
#include "sid.h"
|
||||
#include "sidfiles.h"
|
||||
#include "timerfuncs.h"
|
||||
#include "sound.h"
|
||||
#include "lpc2220.h"
|
||||
|
@ -934,6 +935,9 @@ void test_sid(void) {
|
|||
draw_string (0, 95, "color keys", LCD_COLOR_B, DRAW_PUT);
|
||||
draw_string (0, 104, "set waveform", LCD_COLOR_B, DRAW_PUT);
|
||||
|
||||
draw_string (0, 120, "Mute", LCD_COLOR_B, DRAW_PUT);
|
||||
draw_string (0, 129, "Raiders March", LCD_COLOR_B, DRAW_PUT);
|
||||
|
||||
sysInfo |= SYS_IR;
|
||||
SID.noise = 0xaa;
|
||||
playstate = 0x00;
|
||||
|
@ -1052,6 +1056,20 @@ void test_sid(void) {
|
|||
playtone_cb = addTimerCB(SIDplaytone, 4);
|
||||
startCB(playtone_cb);
|
||||
}
|
||||
} else if (KEY_Mute)
|
||||
{
|
||||
if (playstate == 0)
|
||||
{
|
||||
playstate = 1;
|
||||
|
||||
playtone[0] = (unsigned char*)&song1[0];
|
||||
|
||||
playcounter = 0;
|
||||
playcountermax = sizeof(song1)/14;
|
||||
|
||||
playtone_cb = addTimerCB(SIDplaydump, 4);
|
||||
startCB(playtone_cb);
|
||||
}
|
||||
}
|
||||
} while (!KEY_Exit);
|
||||
sysInfo &= ~SYS_IR;
|
||||
|
|
|
@ -62,9 +62,9 @@ void startIrIRQ(void)
|
|||
// T1PR = 0x01;
|
||||
T1MCR = 0x03;
|
||||
|
||||
//VICVectAddr1 = (unsigned long)&(irIRQ);
|
||||
//VICVectCntl1 = VIC_SLOT_EN | INT_SRC_TIMER1;
|
||||
VICIntSelect |= INT_TIMER1;
|
||||
VICVectAddr1 = (unsigned long)&(irIRQ);
|
||||
VICVectCntl1 = VIC_SLOT_EN | INT_SRC_TIMER1;
|
||||
//VICIntSelect |= INT_TIMER1;
|
||||
VICIntEnable = INT_TIMER1;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "global.h"
|
||||
#include "lpc2220.h"
|
||||
#include "irq.h"
|
||||
|
||||
void PWM_init(void)
|
||||
{
|
||||
|
@ -25,24 +26,44 @@ void PWM_init(void)
|
|||
PINSEL1 &= ~(3 << (10)); // IO
|
||||
PINSEL1 |= (1 << (10)); // PWM5
|
||||
|
||||
PWMTC = 0; //Timer Counter
|
||||
PWMPR = 0; //Prescale Register
|
||||
PWMPC = 0; //Prescale Counter
|
||||
PWMTC = 0; //Timer Counter
|
||||
PWMPR = 0; //Prescale Register
|
||||
PWMPC = 0; //Prescale Counter
|
||||
|
||||
PWMMR0 = 416; // pwm rate
|
||||
PWMMR5 = 0; // pwm value
|
||||
PWMMR0 = 416; // pwm rate
|
||||
PWMMR2 = 0x00; // pwm value sound
|
||||
PWMMR5 = 0x00; // pwm value IR
|
||||
|
||||
PWMLER = 0x21; //Latch Enable
|
||||
PWMMCR = 0x02; //Match Control
|
||||
PWMPCR |= (1<<13);
|
||||
PWMLER = 0x26; //Latch Enable
|
||||
PWMMCR = 0x03; //Match Control
|
||||
PWMPCR |= (1<<13) | (1<<10);
|
||||
PWMTCR = 0x03;
|
||||
PWMTCR = 0x09;
|
||||
|
||||
/* PWMTC = 0;
|
||||
PWMPR = 7;
|
||||
PWMMR0 = 0x1E6; // pwm rate
|
||||
PWMMR2 = 0x00; // pwm value
|
||||
PWMLER = 0x05;
|
||||
PWMPCR = (1<<10);
|
||||
*/
|
||||
|
||||
//VICVectAddr0 = (unsigned long)&(soundIRQ);
|
||||
//VICVectCntl0 = VIC_SLOT_EN | INT_SRC_PWM;
|
||||
VICIntSelect |= INT_PWM;
|
||||
VICIntEnable = INT_PWM;
|
||||
|
||||
}
|
||||
|
||||
void PWM_set_frequency(unsigned long f)
|
||||
{
|
||||
PWMMR0 = 15000000 / f;
|
||||
if(f<5000) {
|
||||
PWMPR = 7;
|
||||
PWMMR0 = 1875000 / f;
|
||||
} else {
|
||||
PWMPR = 0;
|
||||
PWMMR0 = 15000000 / f;
|
||||
}
|
||||
PWMLER |= 0x01; //Latch Enable
|
||||
|
||||
}
|
||||
|
|
|
@ -71,12 +71,12 @@ unsigned restoreIRQ(unsigned oldCPSR)
|
|||
// (where's the vector? in lpc2220_rom.ld ?)
|
||||
void __attribute__ ((section(".text.fastcode"))) FIQ_Routine (void)
|
||||
{
|
||||
while ((PWMIR == 0x01) || (T1IR == 1))
|
||||
//while ((PWMIR == 0x01))
|
||||
{
|
||||
if (PWMIR == 0x01)
|
||||
soundIRQ(); // sound, backlight
|
||||
if (T1IR == 1)
|
||||
irIRQ(); // IR
|
||||
//if (T1IR == 1)
|
||||
// irIRQ(); // IR
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ int main(void)
|
|||
FIOSET0 |= (1<<12);
|
||||
FIOCLR0 |= (1<<4);
|
||||
|
||||
setSpeed(SPEED_30);
|
||||
setSpeed(SPEED_60);
|
||||
|
||||
lcd_init(0);
|
||||
serial_init();
|
||||
|
@ -254,7 +254,7 @@ int main(void)
|
|||
initKeys();
|
||||
|
||||
initSound();
|
||||
startSoundIRQ();
|
||||
//startSoundIRQ();
|
||||
|
||||
initIR();
|
||||
startIrIRQ();
|
||||
|
|
Loading…
Reference in a new issue