📄 eint.c
字号:
/******************************************************************************
* Eint.c: Philips LPC23xx Family Microprocessors
* file is for Button Interrupt handler for DSS demo
*
*
* Copyright(C) 2007, Philips Semiconductor
* All rights reserved.
*
* History
* 2007.05.01 ver 1.00 Prelimnary version, first Release
*
******************************************************************************/
#include <stdio.h>
#include "lpc23xx.h"
#include "type.h"
#include "irq.h"
#define SONG song_joy
int I2S_muteFlag; /* only count L3_ticks when audio on -> muteFlag=1*/
extern unsigned int freq;
extern unsigned int accum;
unsigned int songindex;
unsigned long piano_Keys[] =
{
27, 29, 31, 33, 34, 37, 39, 41, 44, 46, 48, 52, 0,0,0,0,
55, 58, 62, 65, 69, 73, 78, 82, 87, 92, 97, 104, 0,0,0,0,
110, 117, 123, 131, 139, 146, 156, 165, 174, 185, 195, 208, 0,0,0,0,
220, 233, 247, 262, 277, 293, 311, 330, 349, 370, 392, 415, 0,0,0,0,
440, 466, 494, 523, 554, 587, 622, 659, 698, 740, 784, 831, 0,0,0,0,
880, 932, 988, 1046, 1109, 1175, 1244, 1318, 1397, 1480, 1568, 1661, 0,0,0,0,
1760, 1865, 1976, 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 0,0,0,0,
3520, 3729, 3951, 4186
};
unsigned char song_lamb[] =
{
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x40,0x40,0x40,0x42,0x45,0x45,
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x42,0x40,0x40,0x42,0x40,0x3a,
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x40,0x40,0x40,0x42,0x45,0x45,
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x42,0x40,0x40,0x42,0x40,0x3a,0x45,
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x40,0x40,0x40,0x42,0x45,0x45,0x45,
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x42,0x40,0x40,0x42,0x40,0x3a,0x45,
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x40,0x40,0x40,0x42,0x45,0x45,0x45,
0x42,0x40,0x3a,0x40,0x42,0x42,0x42,0x42,0x40,0x40,0x42,0x40,0x3a,0x4f
};
unsigned char song_joy[] =
{
0x37,0x37,0x38,0x3a,0x3a,0x38,0x37,0x35,0x33,0x33,0x35,0x37,0x37,0x35,0x35,
0x37,0x37,0x38,0x3a,0x3a,0x38,0x37,0x35,0x33,0x33,0x35,0x37,0x35,0x33,0x33,
0x35,0x35,0x37,0x33,0x35,0x37,0x38,0x37,0x33,0x35,0x37,0x38,0x37,0x35,0x33,0x35,0x2a,0x37,
0x37,0x38,0x3a,0x3a,0x38,0x37,0x35,0x33,0x33,0x35,0x37,0x35,0x33,0x33,0x3f
};
unsigned char song_40[] =
{
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40
};
/*******************************************************************************
* Function: key_Handler
This function will play the next note in current SONG array
called from the keyboard scan routine
*******************************************************************************/
void key_HandlerDSS(void)
{
freq = piano_Keys[SONG[songindex]];
songindex++;
if (songindex > sizeof(SONG)-1 ) songindex = 0; /* restart song at end */
I2S_muteFlag = 0;
FIO2SET = 0x1; /* turn on led 0 */
}
/*******************************************************************************
* Function: IRQ_EINT0_Handler
This handler will start he next note in current SONG array
*******************************************************************************/
void IRQ_EINT0_HandlerDSS(void) __irq
{
freq = piano_Keys[SONG[songindex]];
songindex++;
if (songindex >= sizeof(SONG)-1 ) songindex = 0; /* restart song at end */
accum=0;
I2S_muteFlag = 0; /* begin note sequence */
FIO2SET = 0x1; /* turn on led 0 */
EXTINT = 0x01 << 0 ; /* clear interrupt */
VICVectAddr = 0; /* Acknowledge VIC Interrupt */
}
/*******************************************************************************
* Function: init_EINT init External interrupt
inputs: number is interrupt 0-3
mode is level and edge sensitivity
polarity is trigger condition
*******************************************************************************/
void init_EINT(unsigned long number, unsigned long mode, unsigned long polarity)
{
disable_VIC_irq(14 + number);
number &= 0x03; /* limit to four Eints */
/* Pin Select */
PINSEL4 = 0x01 << (20 + (number << 1) );
EXTMODE = mode << number; /* 0 = Level; 1 = edge sensitive */
EXTPOLAR = polarity << number; /*trigger: 0 = falling edge/low; 1 = rising edge/ high */
EXTINT = 0x01 << number; /* clear interrupt */
}
/*******************************************************************************/
void check_freq(float samplingfreq) /* test for periodicy in piano freq */
{
int i;
float test;
for (i=0; i< 117; i++)
{
test = piano_Keys[i];
printf("%11.6f ,", samplingfreq/test);
if (i%16 == 15) printf("\r\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -