echoKeyByLed0504() has a bug. I need to modify the mcuBoardStruct to include max led number and max key number, and also enhance echoKeyByLed0504 to 0505.
typedef struct
{
portPinArrayPointerArray *LedPortPinArrayPointerArray;
portPinArrayPointerArray *KeyPortPinArrayPointerArray;
int maxLedPinNumber;
int maxKeyPinNumber;
} mcuBoardStruct;
void echoKeyByLed0505(mcuBoardStruct mcuBoardStruct, int keyNumber, int ledNUmber)
{
setupAllGpioPinsOutputLow050(mcuBoardStruct.LedPortPinArrayPointerArray,
mcuBoardStruct.maxLedPinNumber);
setupAllGpioPinsInput050(mcuBoardStruct.KeyPortPinArrayPointerArray,
mcuBoardStruct.maxKeyPinNumber);
echoKeyByLed050(mcuBoardStruct.KeyPortPinArrayPointerArray, \
mcuBoardStruct.LedPortPinArrayPointerArray, \
keyNumber, ledNUmber);
}
.END
// ***********************************************************************
// Program - Fong EKG v5.0
// Function - Olimex EKG Board Evaluation
// Author - TL Fong
// Build - 2013.10.14.04
// Date - 2013oct14hkt1528
// Hardware - Olimex/CooCox/MagicBlue/WHUT/Somy LPC1114/C14/301
// Olimex EKG board (SHIELD-EKG/EMG Rev B, Bulgaria 2011)
// Software - GCC ARM 4.7, CoIDE 1.7.4, CoLinkEx 1.1, Flash Magic v7.51
// ***********************************************************************
#include "test050.h" // main tests
// ***********************************************************************
// Main Function
// ***********************************************************************
int main()
{
// *** Completed tests ***
// *** Olimex ***
// testOlimexLedKey01(); // Tested OK 2013oct14
// *** Pending tests ***
// test7segmentLed01();
// *** Wuht ***
testWhutLedKey01();
// *** End of tests ***
return 0;
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// test050.h 2013oct13hkt2206
// ***********************************************************************
#include "led050.h"
#include "key050.h"
#include "olimex050.h"
void testOlimexLedKey01() // tested OK 2013oct13
{
// *** For all mcu boards - setup GPIO pin as out and toggle ***
setupGpioPinOutputLow050(PortPinArrayP09); // setup GPIO pin as ooutput
blinkLed0501(PortPinArrayP09); // blink led
// *** Olimex test only - setup I/O pins for testing ***
setupOlimexGpio050(); // setup Olimex GPIO pins as output and input
// *** Olimex test only - blink single LED and run all LEDs***
blinkOlimexLed(LED_7, ON_ONE_FIFTH_SECOND, OFF_ONE_FIFTH_SECOND, REPEAT_6_TIMES); // blink one Led
runOlimexLeds(); // sequentially blink all 8 Leds
// *** Olimex test only - echo key by led ***
echoOlimexKeyByLed(KEY_1, LED_1); // echo Olimex key by led
echoOlimexKeyByLed(KEY_2, LED_2); // echo Olimex key by led
echoOlimexKeyByLed(KEY_1, LED_3); // echo Olimex key by led
// *** For all mcu boards, given mcu board struct, echo key by led ***
echoKeyByLed0504(OlimexLpc1114DevBoardStruct, KEY_1, LED_5); // given mcuboard struct, echo key by led
}
void testWhutLedKey01() // tested OK 2013oct14
{
// *** For all mcu boards - setup GPIO pin as out and toggle ***
setupGpioPinOutputLow050(PortPinArrayP108); // setup LED1 pin
blinkLed0501(PortPinArrayP108); // blink LED1
// *** Whut only - setup I/O pins for testing ***
setupWhutGpio050(); // setup Olimex GPIO pins as output and input
// *** Whut only - blink single LED and run all LEDs***
blinkWhutLed(LED_1, ON_ONE_FIFTH_SECOND, OFF_ONE_FIFTH_SECOND, REPEAT_6_TIMES); // blink one Led
runWhutLeds(); // sequentially blink all 8 Leds
// *** Whut only - echo key by led ***
echoWhutKeyByLed(KEY_1, LED_1); // echo key by led
echoWhutKeyByLed(KEY_2, LED_2); // echo key by led
echoWhutKeyByLed(KEY_1, LED_3); // echo key by led
// *** For all mcu boards, given mcu board struct, echo key by led ***
echoKeyByLed0505(WhutLpc11c14DevBoardStruct, KEY_1, LED_2); // given mcuboard struct, echo key by led
}
void test7segmentLed01() //
{
// *** system self diagnostic test - blink LED P09 ***
setupGpioPinOutputLow050(PortPinArrayP09); // setup GPIO pin as output
blinkLed0501(PortPinArrayP09); // blink led
// *** setup Hc595 output pins ***
setupAllGpioPinsOutputLow050(Hc595PortPinArrayPointerArray, MAX_HC595_PIN_NUMBER);
// *** Toggle HC595 control pins ***
blinkLed0501(Hc595SerialInClockPulsePortPinArray); // Pin 11
blinkLed0501(Hc595SerialInDataPortPinArray); // Pin 14
blinkLed0501(Hc595ParallOutDataLatchPortPinArray); // Pin 12
blinkLed0501(Hc595OutputEnablePortPinArray); // Pin 13
// displayOlimex7segmentDigit(DIGIT_4);
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// config050.h - 2013oct14hk0922
// ***********************************************************************
#include "lpc11xx_syscon.h"
#include "lpc11xx_gpio.h"
#include "lpc11xx_iocon.h"
#ifndef CONFIG_HEADER_SEEN
#define CONFIG_HEADER_SEEN
// *** Logic level ***
#define LOW 0
#define HIGH 1
#define LOW_LEVEL 0
#define HIGH_LEVEL 1
#define LOGIC_LOW_LEVEL 0
#define LOGIC_HIGH_LEVEL 1
typedef int logicLevelValue;
logicLevelValue LogicLevelLow = 0;
logicLevelValue LogicLevelHigh = 1;
// *** GPIO direction ***
#define INPUT_DIRECTION 0
#define OUTPUT_DIRECTION 1
typedef int directionValue;
directionValue InputDirection = 0;
directionValue OutputDirection = 1;
// *** GPIO port number, pin number, port/pin number ***
#define PORT0 0
#define PORT1 1
#define PORT2 2
#define PORT3 3
#define PIN0 0
#define PIN1 1
#define PIN2 2
#define PIN3 3
#define PIN4 4
#define PIN5 5
#define PIN6 6
#define PIN7 7
#define PIN8 8
#define PIN9 9
#define PIN10 10
#define PIN11 11
typedef int portNumber;
portNumber Port0 = 0;
portNumber Port1 = 1;
portNumber Port2 = 2;
portNumber Port3 = 3;
typedef int pinNumber;
pinNumber Pin0 = 0;
pinNumber Pin1 = 1;
pinNumber Pin2 = 2;
pinNumber Pin3 = 3;
pinNumber Pin4 = 4;
pinNumber Pin5 = 5;
pinNumber Pin6 = 6;
pinNumber Pin7 = 7;
pinNumber Pin8 = 8;
pinNumber Pin9 = 9;
pinNumber Pin10 = 10;
pinNumber Pin11 = 11;
typedef const int portPinNumber;
portPinNumber Pio05 = 5;
portPinNumber Pio08 = 8;
portPinNumber Pio09 = 9;
portPinNumber Rpio11 = 11;
portPinNumber Rpio12 = 12;
portPinNumber Pio19 = 19;
portPinNumber Rpio18 = 18;
portPinNumber Pio110 = 110;
// *** LED, key, 7-segment LED digit number ***
typedef const int deviceNumber;
#define LED1 1
#define LED2 2
#define LED3 3
#define LED4 4
#define LED5 5
#define LED6 6
#define LED7 7
#define LED8 8
#define LED_1 1
#define LED_2 2
#define LED_3 3
#define LED_4 4
#define LED_5 5
#define LED_6 6
#define LED_7 7
#define LED_8 8
#define KEY_1 1
#define KEY_2 2
#define KEY_3 3
#define KEY_4 4
#define KEY_5 5
#define MAX_DEVICE_NUMBER 5
#define MAX_LED_NUMBER 5
#define MAX_KEY_NUMBER 5
#define MAX_PWM_NUMBER 5
#define DIGIT_0 0
#define DIGIT_1 1
#define DIGIT_2 2
#define DIGIT_3 3
#define DIGIT_4 4
#define DIGIT_5 5
#define DIGIT_6 6
#define DIGIT_7 7
#define DIGIT_8 8
#define DIGIT_9 9
// *** Port pin array and port pin array pinters ***
#define PORT_INDEX 0
#define PIN_INDEX 1
typedef int portPinArray[2];
typedef portPinArray *portPinArrayPointerArray[MAX_DEVICE_NUMBER];
// *** Mcu board struct ***
/*
typedef struct
{
portPinArrayPointerArray *LedPortPinArrayPointerArray;
portPinArrayPointerArray *KeyPortPinArrayPointerArray;
} mcuBoardStruct;
*/
typedef struct
{
portPinArrayPointerArray *LedPortPinArrayPointerArray;
portPinArrayPointerArray *KeyPortPinArrayPointerArray;
int maxLedPinNumber;
int maxKeyPinNumber;
} mcuBoardStruct;
// *** Generic port pin array ***
portPinArray PortPinArrayP04 = {PORT0, PIN4};
portPinArray PortPinArrayP05 = {PORT0, PIN5};
portPinArray PortPinArrayP09 = {PORT0, PIN9};
portPinArray PortPinArrayP14 = {PORT1, PIN4}; // KEY2
portPinArray PortPinArrayP24 = {PORT2, PIN4};
portPinArray PortPinArrayP25 = {PORT2, PIN5}; // USB D- do NOT use
portPinArray PortPinArrayP26 = {PORT2, PIN6}; // USB D+ do NOT use
portPinArray PortPinArrayP27 = {PORT2, PIN7};
portPinArray PortPinArrayP29 = {PORT2, PIN9}; // KEY1
portPinArray PortPinArrayP30 = {PORT3, PIN0}; // LED1
portPinArray PortPinArrayP34 = {PORT3, PIN4}; // replacing P24
portPinArray PortPinArrayP35 = {PORT3, PIN5}; // replacing P25
portPinArray PortPinArrayP108 = {PORT1, PIN8}; // Wuht LED1
portPinArray PortPinArrayP109 = {PORT1, PIN9}; // Wuht LED2
portPinArray PortPinArrayP110 = {PORT1, PIN10}; // Wuht LED3
portPinArray PortPinArrayP111 = {PORT1, PIN11}; // Wuht LED4
// *** Olimex LED port pin array ***
#define MAX_OLIMEX_LED_PIN_NUMBER 8 // 2013oct11
#define SERIAL_CLOCK_INDEX 0
#define SERIAL_DATA_IN_INDEX 1
#define PARALLEL_DATA_OUTPUT_LATCH_INDEX 2
#define OUTPUT_ENABLE_INDEX 3
int SizeOfPortPinArrayPointer = sizeof(PortPinArrayP04);
portPinArray OlimexBoardLedPortPinArray1 = {PORT3, PIN0}; // LED 0 2013oct11
portPinArray OlimexBoardLedPortPinArray2 = {PORT3, PIN1}; // LED 1 2013oct11
portPinArray OlimexBoardLedPortPinArray3 = {PORT3, PIN2}; // LED 2 2013oct11
portPinArray OlimexBoardLedPortPinArray4 = {PORT3, PIN3}; // LED 3 2013oct11
portPinArray OlimexBoardLedPortPinArray5 = {PORT3, PIN4}; // LED 4 2013oct11
portPinArray OlimexBoardLedPortPinArray6 = {PORT3, PIN5}; // LED 5 2013oct11
portPinArray OlimexBoardLedPortPinArray7 = {PORT2, PIN6}; // LED 6 2013oct11
portPinArray OlimexBoardLedPortPinArray8 = {PORT2, PIN7}; // LED 7 2013oct11
portPinArrayPointerArray OlimexBoardLedPortPinArrayPointerArray[MAX_OLIMEX_LED_PIN_NUMBER] = \
{&OlimexBoardLedPortPinArray1, &OlimexBoardLedPortPinArray2, \
&OlimexBoardLedPortPinArray3, &OlimexBoardLedPortPinArray4, \
&OlimexBoardLedPortPinArray5, &OlimexBoardLedPortPinArray6, \
&OlimexBoardLedPortPinArray7, &OlimexBoardLedPortPinArray8};
// *** Olimex Key port pin array ***
#define MAX_OLIMEX_KEY_PIN_NUMBER 2
portPinArray OlimexBoardKeyPortPinArray1 = {PORT2, PIN9};
portPinArray OlimexBoardKeyPortPinArray2 = {PORT1, PIN4};
portPinArrayPointerArray OlimexBoardKeyPortPinArrayPointerArray[MAX_OLIMEX_KEY_PIN_NUMBER] = \
{&OlimexBoardKeyPortPinArray1, &OlimexBoardKeyPortPinArray2};
// *** Olimex LPC1114 Board Struct ***
mcuBoardStruct OlimexLpc1114DevBoardStruct = {OlimexBoardLedPortPinArrayPointerArray, \
OlimexBoardKeyPortPinArrayPointerArray};
// *** Whut LPC11c14 Dev Board ***
#define MAX_WHUT_LED_PIN_NUMBER 5
portPinArray WhutBoardLedPortPinArray1 = {PORT1, PIN8}; // LED D1
portPinArray WhutBoardLedPortPinArray2 = {PORT1, PIN9}; // LED D2
portPinArray WhutBoardLedPortPinArray3 = {PORT1, PIN10}; // LED D3
portPinArray WhutBoardLedPortPinArray4 = {PORT1, PIN11}; // LED D4
portPinArray WhutBoardLedPortPinArray5 = {PORT0, PIN9}; // JTAG pin13
portPinArrayPointerArray WhutBoardLedPortPinArrayPointerArray[MAX_WHUT_LED_PIN_NUMBER] = \
{&WhutBoardLedPortPinArray1, &WhutBoardLedPortPinArray2, \
&WhutBoardLedPortPinArray3, &WhutBoardLedPortPinArray4, \
&WhutBoardLedPortPinArray5};
#define MAX_WHUT_KEY_PIN_NUMBER 2
portPinArray WhutBoardKeyPortPinArray1 = {PORT0, PIN1}; // ISP Boot key
portPinArray WhutBoardKeyPortPinArray2 = {PORT1, PIN4}; // Wakeup key
portPinArrayPointerArray WhutBoardKeyPortPinArrayPointerArray[MAX_WHUT_KEY_PIN_NUMBER] = \
{&WhutBoardKeyPortPinArray1, &WhutBoardKeyPortPinArray2};
mcuBoardStruct WhutLpc11c14DevBoardStruct = {WhutBoardLedPortPinArrayPointerArray, \
WhutBoardKeyPortPinArrayPointerArray, MAX_WHUT_LED_PIN_NUMBER, MAX_WHUT_KEY_PIN_NUMBER};
// *** 7 Segment LED - HC595 Serial in parallel out shift register with output latch ***
#define MAX_HC595_PIN_NUMBER 4 // 2013oct14
portPinArray Hc595SerialInClockPulsePortPinArray = {PORT2, PIN8}; // Pin 11 SHCP
portPinArray Hc595SerialInDataPortPinArray = {PORT2, PIN9}; // Pin 14 DS
portPinArray Hc595ParallOutDataLatchPortPinArray = {PORT2, PIN10}; // Pin 12 Latch
portPinArray Hc595OutputEnablePortPinArray = {PORT2, PIN11}; // Pin 13 Output Enable
portPinArrayPointerArray Hc595PortPinArrayPointerArray[MAX_HC595_PIN_NUMBER] = \
{&Hc595SerialInClockPulsePortPinArray, &Hc595SerialInDataPortPinArray, \
&Hc595ParallOutDataLatchPortPinArray, &Hc595OutputEnablePortPinArray};
#endif /* CONFIG_HEADER_SEEN */
// ***********************************************************************
// * End *
// ***********************************************************************
// ***********************************************************************
// key050.h 2013oct14hkt0923
// ***********************************************************************
#include "config050.h"
#include "gpio050.h"
#include "timer050.h"
// *** Get key status ***
logicLevelValue getKeyStatus01(portPinArray keyPortPinArray)
{
logicLevelValue keyStatus;
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber(keyPortPinArray);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber(keyPortPinArray);
keyStatus = getGpioDataPinValue01(gpioStructPointer, pinNumber);
return keyStatus;
}
logicLevelValue getKeyStatus(portPinArrayPointerArray keyPortPinArrayPointerArray, \
deviceNumber keyNumber)
{
logicLevelValue keyStatus;
int portNumber;
int pinNumber;
GPIO_TypeDef *gpio_struct_ptr;
keyStatus = getGpioDataPinValue(keyPortPinArrayPointerArray, keyNumber);
return keyStatus;
}
// *** Echo key by led ***
void echoKeyByLed02(portPinArray keyPortPinArray, portPinArray ledPortPinArray)
{
int count;
logicLevelValue keyStatus;
keyStatus = HIGH;
while (keyStatus == HIGH)
{
keyStatus = getKeyStatus01(keyPortPinArray);
if (keyStatus == LOW)
{
// blinkLedP09TwoTimes();
blink1Led02(ledPortPinArray, ONE_FIFTH_SECOND, ONE_HALF_SECOND, REPEAT_2_TIMES);
delayTime(TWO_SECONDS);
keyStatus = HIGH;
break;
}
}
}
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 echoOlimex1KeyBySingleLed01(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)
{
blinkOlimex1Led(ledNumber);
delayTime(TWO_SECONDS);
keyStatus = HIGH;
break;
}
}
}
}
void echoOlimex1KeyBySingleLed4201(portPinArrayPointerArray keyPortPinArrayPointerArray, \
deviceNumber keyNumber, \
portPinArrayPointerArray ledPortPinArrayPointerArray, deviceNumber ledNumber)
{
int count;
logicLevelValue keyStatus;
delayTime(ONE_SECOND);
keyStatus = HIGH;
while (keyStatus == HIGH)
{
keyStatus = getKeyStatus(keyPortPinArrayPointerArray, keyNumber);
if (keyStatus == LOW)
{
blinkOneLed050(PortPinArrayP30, ON_ONE_HALF_SECOND, OFF_ONE_HALF_SECOND, \
REPEAT_4_TIMES);
delayTime(TWO_SECONDS);
keyStatus = HIGH;
break;
}
}
}
/*
void echo1KeyBySingleLed(deviceNumber keyNumber, int ledNumber, int repeatCount)
{
echo1KeyBySingleLed01(*WhutBoardKeyPortPinArrayPointerArray, keyNumber, \
*WhutBoardLedPortPinArrayPointerArray, ledNumber, \
repeatCount);
}
*/
void echoOlimex1KeyBySingleLed(deviceNumber keyNumber, int ledNumber, int repeatCount)
{
echoOlimex1KeyBySingleLed01(*OlimexBoardKeyPortPinArrayPointerArray, keyNumber, \
*OlimexBoardLedPortPinArrayPointerArray, ledNumber, \
repeatCount);
}
void echoOlimex1KeyBySingleLed42(deviceNumber keyNumber, int ledNumber)
{
echoOlimex1KeyBySingleLed4201(*OlimexBoardKeyPortPinArrayPointerArray, keyNumber, \
*OlimexBoardLedPortPinArrayPointerArray, ledNumber);
}
void echoOlimex1KeyBySingleLed43(portPinArrayPointerArray keyPortPinArrayPointerArray, \
portPinArrayPointerArray ledPortPinArrayPointerArray, \
deviceNumber keyNumber, int ledNumber)
{
echoOlimex1KeyBySingleLed4201(keyPortPinArrayPointerArray, keyNumber, \
ledPortPinArrayPointerArray, ledNumber);
}
// *** Echo key by 7 segment LED ***
void echoKeyBy7SegmentLed01(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)
{
blinkDigit(digitNumber, ONE_HALF_SECOND, ONE_HALF_SECOND, REPEAT_2_TIMES);
displayDigitBlank();
delayTime(TWO_SECONDS);
keyStatus = HIGH;
break;
}
}
}
}
/*
void echoKeyBy7SegmentLed(deviceNumber keyNumber, int digitNumber, int repeatCount)
{
echoKeyBy7SegmentLed01(*WhutBoardKeyPortPinArrayPointerArray, keyNumber, \
*WhutBoardSevenSegmentLedPortPinArrayPointerArray, digitNumber, \
repeatCount);
}
*/
// ***********************************************************************
// Echo Key Tests
// ***********************************************************************
/*
void echoWakeUpKeyByLed() // Echo Wake Up Key 4 times
{
initializeAllInputPins(WhutBoardKeyPortPinArrayPointerArray, MAX_KEY_NUMBER);
echo1KeyBySingleLed(KEY_5, LED_5, REPEAT_4_TIMES);
}
*/
void echoOlimexWakeUpKeyByLed() // 2013oct11
{
initializeAllInputPins(OlimexBoardKeyPortPinArrayPointerArray, MAX_OLIMEX_KEY_PIN_NUMBER);
echoOlimex1KeyBySingleLed(KEY_2, LED_2, REPEAT_4_TIMES);
}
void echoWakeUpKey40() // ***** 2013oct12 *****
{
initializeAllInputPins40(OlimexBoardKeyPortPinArrayPointerArray);
echoOlimex1KeyBySingleLed(KEY_2, LED_2, REPEAT_4_TIMES);
}
void echoWakeUpKey41(portPinArrayPointerArray keyPortPinArrayPointerArray) // ***** 2013oct12 *****
{
initializeAllInputPins40(keyPortPinArrayPointerArray);
echoOlimex1KeyBySingleLed(KEY_2, LED_2, REPEAT_4_TIMES);
}
void echoKeyByLed42(portPinArrayPointerArray keyPortPinArrayPointerArray, int keyNumber, int ledNumber) // ***** 2013oct12 *****
{
initializeAllInputPins40(keyPortPinArrayPointerArray);
echoOlimex1KeyBySingleLed42(keyNumber, ledNumber);
}
void echoKeyByLed43(portPinArrayPointerArray keyPortPinArrayPointerArray, \
portPinArrayPointerArray ledPortPinArrayPointerArray, \
int keyNumber, int ledNumber) // ***** 2013oct12 *****
{
initializeAllInputPins40(keyPortPinArrayPointerArray);
echoOlimex1KeyBySingleLed43(keyPortPinArrayPointerArray, ledPortPinArrayPointerArray, keyNumber, ledNumber);
}
void echoKeyByLed45(mcuBoardStruct mcuBoardStruct, int keyNumber, int ledNumber)
{
initializeAllInputPins40(mcuBoardStruct.KeyPortPinArrayPointerArray);
echoOlimex1KeyBySingleLed43(mcuBoardStruct.KeyPortPinArrayPointerArray, \
mcuBoardStruct.LedPortPinArrayPointerArray, \
keyNumber, ledNumber);
}
void echoBootKeyThreeTimes() // Echo key by LED P0.9 MOSI
{
portPinArray ledPortPinArray = {0, 9};
portPinArray bootPortPinArray = {0, 1};
initializeOutputPin01(ledPortPinArray);
initializeInputPin01(bootPortPinArray);
int count;
for (count = 0; count < 3; count++)
{
echoKeyByLed02(bootPortPinArray, ledPortPinArray);
}
}
void echoMisoKeyByMosiLedTwoTimes()
{
portPinArray mosiPortPinArray = {0, 9};
portPinArray misoPortPinArray = {0, 8};
initializeOutputPin01(mosiPortPinArray);
initializeInputPin01(misoPortPinArray);
int count;
for (count = 0; count < 2; count++)
{
echoKeyByLed02(misoPortPinArray, mosiPortPinArray);
}
}
/*
void echoAllKeysByLed() // Echo All keys twice
{
initializeAllInputPins(WhutBoardKeyPortPinArrayPointerArray, MAX_KEY_NUMBER);
echo1KeyBySingleLed(KEY_1, LED_1, REPEAT_2_TIMES);
echo1KeyBySingleLed(KEY_2, LED_2, REPEAT_2_TIMES);
echo1KeyBySingleLed(KEY_3, LED_3, REPEAT_2_TIMES);
echo1KeyBySingleLed(KEY_4, LED_4, REPEAT_2_TIMES);
echo1KeyBySingleLed(KEY_5, LED_5, REPEAT_2_TIMES);
}
*/
/*
void echoWakeUpKeyByDigit() // Echo Wake Up Key by digit
{
initializeAllOutputPins(WhutBoardSevenSegmentLedPortPinArrayPointerArray, \
MAX_7_SEG_LED_PIN_NUMBER);
echoKeyBy7SegmentLed(KEY_5, LED_5, REPEAT_2_TIMES);
}
void echoAllKeysByDigit() // Echo Wake Up Key by digit
{
initializeAllOutputPins(WhutBoardSevenSegmentLedPortPinArrayPointerArray, \
MAX_7_SEG_LED_PIN_NUMBER);
echoKeyBy7SegmentLed(KEY_1, LED_1, REPEAT_2_TIMES);
echoKeyBy7SegmentLed(KEY_2, LED_2, REPEAT_2_TIMES);
echoKeyBy7SegmentLed(KEY_3, LED_3, REPEAT_2_TIMES);
echoKeyBy7SegmentLed(KEY_4, LED_4, REPEAT_2_TIMES);
echoKeyBy7SegmentLed(KEY_5, LED_5, REPEAT_2_TIMES);
}
*/
// Version 050
void echoKeyByLed0504(mcuBoardStruct mcuBoardStruct, int keyNumber, int ledNUmber)
{
setupAllGpioPinsOutputLow050(mcuBoardStruct.LedPortPinArrayPointerArray, MAX_OLIMEX_LED_PIN_NUMBER);
setupAllGpioPinsInput050(mcuBoardStruct.KeyPortPinArrayPointerArray, MAX_OLIMEX_KEY_PIN_NUMBER);
echoKeyByLed050(mcuBoardStruct.KeyPortPinArrayPointerArray, \
mcuBoardStruct.LedPortPinArrayPointerArray, \
keyNumber, ledNUmber);
}
void echoKeyByLed0505(mcuBoardStruct mcuBoardStruct, int keyNumber, int ledNUmber)
{
setupAllGpioPinsOutputLow050(mcuBoardStruct.LedPortPinArrayPointerArray, mcuBoardStruct.maxLedPinNumber);
setupAllGpioPinsInput050(mcuBoardStruct.KeyPortPinArrayPointerArray, mcuBoardStruct.maxKeyPinNumber);
echoKeyByLed050(mcuBoardStruct.KeyPortPinArrayPointerArray, \
mcuBoardStruct.LedPortPinArrayPointerArray, \
keyNumber, ledNUmber);
}
void echoKeyByLed050(portPinArrayPointerArray keyPortPinArrayPointerArray, \
portPinArrayPointerArray ledPortPinArrayPointerArray, \
int keyNumber, int ledNumber)
{
int count;
logicLevelValue keyStatus;
delayTime(ONE_HALF_SECOND);
keyStatus = HIGH;
while (keyStatus == HIGH)
{
keyStatus = getKeyStatus(keyPortPinArrayPointerArray, keyNumber);
if (keyStatus == LOW)
{
blinkOneLed0501(ledPortPinArrayPointerArray, ledNumber, \
ON_ONE_FIFTH_SECOND, OFF_ONE_HALF_SECOND, REPEAT_2_TIMES);
delayTime(TWO_SECONDS);
keyStatus = HIGH;
break;
}
}
}
void echoWhutKeyByLed(int keyNumber, int ledNUmber)
{
setupAllGpioPinsOutputLow050(WhutBoardLedPortPinArrayPointerArray, MAX_WHUT_LED_PIN_NUMBER);
setupAllGpioPinsInput050(WhutBoardKeyPortPinArrayPointerArray, MAX_WHUT_KEY_PIN_NUMBER);
echoKeyByLed050(WhutBoardKeyPortPinArrayPointerArray, WhutBoardLedPortPinArrayPointerArray, \
keyNumber, ledNUmber);
}
// ***********************************************************************
// End
// ***********************************************************************
No comments:
Post a Comment