Diese Sektion erlaubt es ihnen alle Beiträge dieses Mitglieds zu sehen. Beachten sie, dass sie nur solche Beiträge sehen können, zu denen sie auch Zugriffsrechte haben.
#include "keyboard.h"
#include "lpc2220.h"
unsigned char Rows[6]; // the pressed Keys ar stored here multiple Keys ar possibe
unsigned int keytest;
unsigned char help;
void initKeys(void)
{
IODIR1=((1<<16)|(1<<17)|(1<<18)|(1<<19)|(1<<21)|(1<<22)); // 1=output
IOSET1=((1<<16)|(1<<17)|(1<<18)|(1<<19)|(1<<21)|(1<<22)); // set to 1
keys[0] = 0;
keys[1] = 0;
}
void scanKeys(void)
{
for (help=0;help<4;help++) //scan coluns P1.16 to P1.19
{
IOSET1=((1<<16)|(1<<17)|(1<<18)|(1<<19)|(1<<21)|(1<<22)); // 1
keytest=IOPIN2&0x01fe0000; // read rows
IOCLR1=(1<<(16+help)); // set low to scan
keytest^=IOPIN2&0x01fe0000;// read rows and compare with previously read
// Key scan algorithm: pressed Key will read as 1 after xor
keys[help]=(unsigned char)(keytest>>18);
}
for (help=4;help<6;help++) //No. 20 will skipped
{
IOSET1=((1<<16)|(1<<17)|(1<<18)|(1<<19)|(1<<21)|(1<<22)); // 1
keytest=IOPIN2&0x01fe0000;
IOCLR1=(1<<(17+help));
keytest^=IOPIN2&0x01fe0000;
keys[help]=(unsigned char)(keytest>>18);
}
}