ajout d'une fonction + volatile
This commit is contained in:
parent
df5aa4aeea
commit
00cae6299e
|
@ -12,4 +12,6 @@ void SetPin(void);
|
|||
void ResetPin(void);
|
||||
char getMPU(void); //get_MPU to compatibility
|
||||
|
||||
unsigned char *itoa(int n, unsigned char* str, int base);
|
||||
|
||||
#endif
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#define PI 3.14159265358
|
||||
|
||||
char *itoa(int n, unsigned char* str, int base)
|
||||
unsigned char *itoa(int n, unsigned char* str, int base)
|
||||
{
|
||||
int i=1, j=0, x;
|
||||
if(n<0) str[j++] = '-', n = -n;
|
||||
|
@ -29,8 +29,10 @@ int main(void)
|
|||
|
||||
int sleep = 2000;
|
||||
int i;
|
||||
#ifdef DEBUG
|
||||
char before = 0, during = 0, after = 0;
|
||||
|
||||
#endif
|
||||
|
||||
setup();
|
||||
//ResetPin();
|
||||
while(1)
|
||||
|
@ -58,12 +60,12 @@ int main(void)
|
|||
{
|
||||
#ifdef DEBUG
|
||||
|
||||
before=*SH7305_PJDR;
|
||||
before=*(volatile unsigned char*)SH7305_PJDR;
|
||||
ResetPin();
|
||||
during=*SH7305_PJDR;
|
||||
during=*(volatile unsigned char*)SH7305_PJDR;
|
||||
for(i=0;i<sleep;i++);
|
||||
SetPin();
|
||||
after=*SH7305_PJDR;
|
||||
after=*(volatile unsigned char*)SH7305_PJDR;
|
||||
|
||||
#else
|
||||
|
||||
|
@ -88,36 +90,36 @@ void setup()
|
|||
if(is_SH4)
|
||||
{
|
||||
// SCIF2 clock on (MSTPCR0.MSTP007)
|
||||
*(unsigned int*)SH7305_MSTPCR0 &= ~0x00000080;
|
||||
*(volatile unsigned int*)SH7305_MSTPCR0 &= ~0x00000080;
|
||||
// switch off SCSMR_2.TE and SCSMR_2.RE
|
||||
*(unsigned short*)SH7305_SCSCR &= ~0x0030;
|
||||
*(volatile unsigned short*)SH7305_SCSCR &= ~0x0030;
|
||||
// SCIF2 clock off (MSTPCR0.MSTP007)
|
||||
*(unsigned int*)SH7305_MSTPCR0 |= 0x00000080;
|
||||
*(volatile unsigned int*)SH7305_MSTPCR0 |= 0x00000080;
|
||||
|
||||
// set bit 3 of port U to output mode
|
||||
*(unsigned short*)SH7305_PUCR = ( *(unsigned short*)SH7305_PUCR & ~0x00C0 ) | 0x0040;
|
||||
*(volatile unsigned short*)SH7305_PUCR = ( *(volatile unsigned short*)SH7305_PUCR & ~0x00C0 ) | 0x0040;
|
||||
// set bit 4 and 5 of port U
|
||||
*(unsigned char*)SH7305_PUDR |= 0x0C;
|
||||
*(volatile unsigned char*)SH7305_PUDR |= 0x0C;
|
||||
|
||||
// set port J bit 2 to output mode
|
||||
*(unsigned short*)SH7305_PJCR = ( *(unsigned short*)SH7305_PJCR & ~0x0030 ) | 0x0010;
|
||||
*(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x0030 ) | 0x0010;
|
||||
// set port J bit 3 to output mode
|
||||
*(unsigned short*)SH7305_PJCR = ( *(unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0040;
|
||||
*(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0040;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SCIF2 clock on (STBCR3.MSTP31)
|
||||
*(unsigned char*)SH7337_STBCR3 &= ~0x02;
|
||||
*(volatile unsigned char*)SH7337_STBCR3 &= ~0x02;
|
||||
// switch off SCSMR_2.TE and SCSMR_2.RE
|
||||
*(unsigned short*)SH7337_SCSCR2 &= ~0x0030;
|
||||
*(volatile unsigned short*)SH7337_SCSCR2 &= ~0x0030;
|
||||
// SCIF2 clock off (STBCR3.MSTP31)
|
||||
*(unsigned char*)SH7337_STBCR3 |= 0x02;
|
||||
*(volatile unsigned char*)SH7337_STBCR3 |= 0x02;
|
||||
// set bit 6 of port G to output mode
|
||||
*(unsigned short*)SH7337_PGCR = ( *(unsigned short*)SH7337_PGCR & ~0x3000 ) | 0x1000;
|
||||
*(volatile unsigned short*)SH7337_PGCR = ( *(volatile unsigned short*)SH7337_PGCR & ~0x3000 ) | 0x1000;
|
||||
// set bit 5 and 6 of port G
|
||||
*(unsigned char*)SH7337_PGDR |= 0x60;
|
||||
*(volatile unsigned char*)SH7337_PGDR |= 0x60;
|
||||
// set port SC bit 0 to output
|
||||
*(unsigned short*)SH7337_SCPCR = ( *(unsigned short*)SH7337_SCPCR & ~0x0003 ) | 0x0001;
|
||||
*(volatile unsigned short*)SH7337_SCPCR = ( *(volatile unsigned short*)SH7337_SCPCR & ~0x0003 ) | 0x0001;
|
||||
}
|
||||
/*
|
||||
// set port J bit 2 to output
|
||||
|
@ -130,13 +132,13 @@ void SetPin()
|
|||
{
|
||||
if(is_SH4)
|
||||
{
|
||||
*(unsigned char*)SH7305_PJDR |= 0x04;
|
||||
*(unsigned char*)SH7305_PJDR &= ~0x08;
|
||||
*(volatile unsigned char*)SH7305_PJDR |= 0x04;
|
||||
*(volatile unsigned char*)SH7305_PJDR &= ~0x08;
|
||||
//set pin to 0x4B
|
||||
}
|
||||
else
|
||||
{
|
||||
*(unsigned char*)SH7337_SCPDR |= 0x01;
|
||||
*(volatile unsigned char*)SH7337_SCPDR |= 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,14 +146,14 @@ void ResetPin()
|
|||
{
|
||||
if(is_SH4)
|
||||
{
|
||||
*(unsigned char*)SH7305_PJDR &= ~0x04;
|
||||
*(unsigned char*)SH7305_PJDR |= 0x08;
|
||||
*(volatile unsigned char*)SH7305_PJDR &= ~0x04;
|
||||
*(volatile unsigned char*)SH7305_PJDR |= 0x08;
|
||||
// set the pin to 0x47
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
*(unsigned char*)SH7337_SCPDR &= ~0x01;
|
||||
*(volatile unsigned char*)SH7337_SCPDR &= ~0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue