I am looking for some help with migrating from mikroC to BoostC. If some experts out there can help me translate the following code portion below into BoostC I would really appreciate it.
Cont ...
Rich (BB code):
/*
* PROJECT:
DIY Keypad-based car engine security system ...
Copyright ©2010 Trent Jackson all rights reserved
* MCU:
PIC16F628a @4MHz
*/
// :: Global scope variables :: //
unsigned short scan = 0;
unsigned short userCode[6];
unsigned short user[6];
unsigned short keyDown = 0;
unsigned short active = 1;
unsigned short tmrLED = 0;
unsigned short progMode = 0;
unsigned short codeCorrect = 0;
unsigned short hashPressed = 0;
unsigned short ukeyPointer = 0;
unsigned short Pinattempts = 0;
unsigned short i = 0;
unsigned short j = 0;
unsigned int timeout = 0;
unsigned int tmrIgnit = 0;
// :: Defines :: //
// Keypad rows ...
#define rowA PORTB.F0
#define rowB PORTB.F1
#define rowC PORTB.F2
#define rowD PORTB.F3
// Keypad columns
#define colA PORTB.F4
#define colB PORTB.F5
#define colC PORTB.F6
// LEDs ...
#define LEDa PORTA.F3
#define LEDb PORTB.F7
// Relays
#define relayA PORTA.F0
#define relayB PORTA.F1
// Ignition
#define ignit PORTA.F4
void interrupt()
{
tmrLED++;
tmrIgnit++;
TMR0 = 96;
INTCON = 0x20;
}
void flashLEDa()
{
LEDa = ~LEDa;
}
void flashLEDb()
{
LEDb = ~LEDb;
}
void playValidSND()
{
for (i = 0; i < 5; i++)
{
Sound_Play(2000, 25);
Delay_ms(100);
}
}
void playErrorSND()
{
for (i = 0; i < 5; i++)
{
Sound_Play(250, 50);
Delay_ms(100);
}
}
void rstUser()
{
ukeyPointer = 0;
codeCorrect = 0;
hashPressed = 0;
for (i = 0; i < 5; i++)
{
user = 255;
}
}
unsigned short getKey()
{
/*
:: Multiplex 4x3 keypad function ::
1. Cycle through rows and check for corresponding column being set ...
2. Return the key if col is set (active high)
3. Protocol implementation(s) / limitation(s):
a. No simultaneous key sequences
b. Key detect on release ...
c. Very responsive with zero bounce
*/
switch (scan)
{
case 0: // :: First col (1, 4, 7, *) :: //
// Set cols
colA = 1;
colB = 0;
colC = 0;
// 5mS delay allow port to settle
Delay_ms(5);
// Check for button press ...
if (rowA == 1)
{
return 1;
}
else if (rowB == 1)
{
return 4;
}
else if (rowC == 1)
{
return 7;
}
else if (rowD == 1)
{
return 54;
}
break;
case 1:
// Set cols
colA = 0;
colB = 1;
colC = 0;
// 5mS delay allow port to settle
Delay_ms(5);
// Check for button press ...
if (rowA == 1)
{
return 2;
}
else if (rowB == 1)
{
return 5;
}
else if (rowC == 1)
{
return 8;
}
else if (rowD == 1)
{
return 0;
}
break;
case 2:
// Set cols
colA = 0;
colB = 0;
colC = 1;
// 5mS delay allow port to settle
Delay_ms(5);
// Check for button press ...
if (rowA == 1)
{
return 3;
}
else if (rowB == 1)
{
return 6;
}
else if (rowC == 1)
{
return 9;
}
else if (rowD == 1)
{
return 55;
}
break;
}
// Inc to next col ...
scan ++;
// Reset after last row
if (scan == 3)
{
scan = 0;
}
// Nothing pressed, 255 denotes this
return 255;
}
Cont ...