// Program - Test LPC1114
// Function - Test LPC1114
// Author - TL Fong
// Build - 2013.08.27.01
// Date - 2013aug27hkt1009
// Hardware - LPC1114/102, LPC1114/301
// Software - GCC ARM 4.7, CoIDE 1.7.4, CoLinkEx 1.1, Flash Magic v7.51
// ***********************************************************************
#include "test031.h"
// ***********************************************************************
// Functions
// ***********************************************************************
// ***********************************************************************
// Main Function
// ***********************************************************************
int main()
{
initSystem();
blinkLedAllDisplayDigitAll(); // blink all LEDs, display all digits
display1Digit(DIGIT_0); // display decimal digit 0
echo2Keys(); // echo key by LED
display1Digit(DIGIT_9); // display decimal digit 9
return 0;
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// test031.h
// ***********************************************************************
#include "blink031.h"
#include "blink032.h"
#include "display7SegLed031.h"
#include "key031.h"
void initSystem()
{
initializeAllOutputPins(WhutBoardLedPortPinArrayPointerArray, MAX_LED_NUMBER);
initializeAllOutputPins(WhutBoardSevenSegmentLedPortPinArrayPointerArray, \
MAX_7_SEG_LED_PIN_NUMBER);
initializeAllInputPins(WhutBoardKeyPortPinArrayPointerArray, MAX_KEY_NUMBER);
}
void blinkLedAllDisplayDigitAll()
{
blinkLedP18(ON_ONE_FIFTH_SECOND, OFF_ONE_FIFTH_SECOND, REPEAT_2_TIMES);
blinkLedP09(ON_ONE_FIFTH_SECOND, OFF_ONE_FIFTH_SECOND, REPEAT_2_TIMES);
blinkAllLeds(ON_ONE_FIFTH_SECOND, OFF_ONE_FIFTH_SECOND, REPEAT_2_TIMES);
displayAllDigits();
}
void echo2Keys()
{
// echo1KeyBySingleLed(KEY_1, LED_1, REPEAT_1_TIME);
// echo1KeyBySingleLed(KEY_1, LED_2, REPEAT_1_TIME);
// echo1KeyBySingleLed(KEY_2, LED_1, REPEAT_1_TIME);
// echo1KeyBySingleLed(KEY_2, LED_2, REPEAT_1_TIME);
echo1KeyBy7SegmentLed(KEY_1, DIGIT_1, REPEAT_1_TIME);
echo1KeyBy7SegmentLed(KEY_1, DIGIT_2, REPEAT_1_TIME);
echo1KeyBy7SegmentLed(KEY_2, DIGIT_1, REPEAT_1_TIME);
echo1KeyBy7SegmentLed(KEY_2, DIGIT_2, REPEAT_1_TIME);
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// key031.h
// ***********************************************************************
#include "config031.h"
#include "delay031.h"
#include "gpio032.h"
// ***********************************************************************
// Key functions
// ***********************************************************************
logicLevelValue getKeyStatus();
void echo1Key01();
void echo1Key();
void testEchoThreeKeys();
// ***********************************************************************
// Function - getKeyStatus
// Input - keyPortPinArrayPointerArray, keyNumber
// Output - port pin data bit
// ***********************************************************************
logicLevelValue getKeyStatus(portPinArrayPointerArray keyPortPinArrayPointerArray, \
deviceNumber keyNumber)
{
logicLevelValue keyStatus;
int portNumber;
int pinNumber;
GPIO_TypeDef *gpio_struct_ptr;
keyStatus = getGpioDataPinValue(keyPortPinArrayPointerArray, keyNumber);
return keyStatus;
}
// ***********************************************************************
// Function - echo key by LED
// Input - keyPinPortArrayPointerArray, keyNumber, ledPinPortArrayPointerArray, ledNumber
// Output - none
// ***********************************************************************
// *** Echo key by single LED ***
void echo1KeyBySingleLed01(portPinArrayPointerArray keyPortPinArrayPointerArray, \
deviceNumber keyNumber, \
portPinArrayPointerArray ledPortPinArrayPointerArray, \
deviceNumber ledNumber, int echoCount)
{
int count;
logicLevelValue keyStatus;
for (count = 0; count < echoCount; count++)
{
delayTime(ONE_SECOND);
keyStatus = HIGH;
while (keyStatus == HIGH)
{
keyStatus = getKeyStatus(keyPortPinArrayPointerArray, keyNumber);
if (keyStatus == LOW)
{
blink1Led(ledNumber);
delayTime(TWO_SECONDS);
keyStatus = HIGH;
break;
}
}
}
}
void echo1KeyBySingleLed(deviceNumber keyNumber, int ledNumber, int repeatCount)
{
echo1KeyBySingleLed01(*WhutBoardKeyPortPinArrayPointerArray, keyNumber, \
*WhutBoardLedPortPinArrayPointerArray, ledNumber, \
repeatCount);
}
// *** Echo key by 7 segment LED ***
void echo1KeyBy7SegmentLed01(portPinArrayPointerArray keyPortPinArrayPointerArray, \
deviceNumber keyNumber, \
portPinArrayPointerArray sevenSegmentledPortPinArrayPointerArray, \
int digitNumber, int echoCount)
{
int count;
logicLevelValue keyStatus;
for (count = 0; count < echoCount; count++)
{
delayTime(ONE_SECOND);
keyStatus = HIGH;
while (keyStatus == HIGH)
{
keyStatus = getKeyStatus(keyPortPinArrayPointerArray, keyNumber);
if (keyStatus == LOW)
{
// blink1Led(ledNumber);
display1Digit(digitNumber);
delayTime(TWO_SECONDS);
keyStatus = HIGH;
break;
}
}
}
}
void echo1KeyBy7SegmentLed(deviceNumber keyNumber, int digitNumber, int repeatCount)
{
echo1KeyBy7SegmentLed01(*WhutBoardKeyPortPinArrayPointerArray, keyNumber, \
*WhutBoardSevenSegmentLedPortPinArrayPointerArray, digitNumber, \
repeatCount);
}
// ***********************************************************************
// End
// ***********************************************************************
No comments:
Post a Comment