libs
This commit is contained in:
parent
d27b18f8d3
commit
08438dd6b6
|
@ -18,7 +18,8 @@
|
|||
#define SH7337_PGDR 0xA400012C
|
||||
#define SH7337_SCPDR 0xA4000136
|
||||
|
||||
void SwitchPinState();
|
||||
void SwitchPinState(char level);
|
||||
void PlayNote();
|
||||
void InitPorts();
|
||||
|
||||
#endif
|
||||
|
|
26
src/main.c
26
src/main.c
|
@ -9,31 +9,13 @@
|
|||
|
||||
unsigned char bincod[25] = {0};
|
||||
unsigned char place = 0;
|
||||
|
||||
static struct {
|
||||
int freq;
|
||||
int length_ms;
|
||||
} seq[] = {
|
||||
{ 352, 500 },
|
||||
{ 412, 375 },
|
||||
{ 352, 250 },
|
||||
{ 352, 125 },
|
||||
{ 475, 250 },
|
||||
{ 352, 250 },
|
||||
{ 316, 250 },
|
||||
{ -1, -1 },
|
||||
};
|
||||
|
||||
unsigned char range = 0;
|
||||
|
||||
void lect()
|
||||
{
|
||||
static unsigned char range = 0;
|
||||
|
||||
if(bincod[range%place] != bincod[(range+1)%place])
|
||||
{
|
||||
SwitchPinState();
|
||||
}
|
||||
range++;
|
||||
SwitchPinState(bincod[range]=='-');
|
||||
range++;
|
||||
if(!(bincod[range])) range=0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
|
|
@ -1,18 +1,43 @@
|
|||
#include "sound4calc.h"
|
||||
#include <mpu.h> // from Gint
|
||||
#include <timer.h> //from Gint
|
||||
|
||||
void SwitchPinState()
|
||||
unsigned char* signal = {"----_____"};
|
||||
|
||||
/*
|
||||
SwitchPinState()
|
||||
put the pin at the level
|
||||
*/
|
||||
void SwitchPinState(char level)
|
||||
{
|
||||
level = !!level;
|
||||
|
||||
if(isSH3())
|
||||
{
|
||||
*(volatile unsigned char*)SH7337_SCPDR ^= 0x01;
|
||||
*(volatile unsigned char*)SH7337_SCPDR = (*(volatile unsigned char*)SH7337_SCPDR & 0xFE) | level ;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(volatile unsigned char*)SH7305_PJDR ^= 0x04;
|
||||
*(volatile unsigned char*)SH7305_PJDR = (*(volatile unsigned char*)SH7305_PJDR & 0xF3) | (0x1<<(2+level));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
PlayNote()
|
||||
allow to make different waveforms with '-' and '_'
|
||||
*/
|
||||
void PlayNote()
|
||||
{
|
||||
static x = 0;
|
||||
SwitchPinState(signal[x]=='-');
|
||||
x = x + 1;
|
||||
if(!(signal[x])) x = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
InitPorts();
|
||||
Init ports to output
|
||||
*/
|
||||
void InitPorts()
|
||||
{
|
||||
if(isSH3())
|
||||
|
|
Loading…
Reference in New Issue