All the following four tested OK
// testOlimexLedKey01();
// testWhutLedKey01();
// testWhut7segmentLed01();
// testOlimex7segmentLed01();
.END
// ***********************************************************************
// Program - Fong EKG v5.0
// Function - Olimex EKG Board Evaluation
// Author - TL Fong
// Build - 2013.10.15.01
// Date - 2013oct15hkt1106
// 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 ***
// testOlimexLedKey01();
// testWhutLedKey01();
// testWhut7segmentLed01();
testOlimex7segmentLed01();
// *** End of tests ***
return 0;
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// test050.h 2013oct15hkt1109
// ***********************************************************************
#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 testWhut7segmentLed01()
{
// *** system self diagnostic test - blink LED P108 ***
setupGpioPinOutputLow050(PortPinArrayP108); // setup LED1 pin
blinkLed0501(PortPinArrayP108); // blink LED1
// *** Testing 7 segment LED ***
displayAllDigits050(WhutBoardSevenSegmentLedPortPinArrayPointerArray, MAX_WHUT_7_SEG_LED_PIN_NUMBER);
}
void testOlimex7segmentLed01() //
{
// *** system self diagnostic test - blink LED P09 ***
setupGpioPinOutputLow050(PortPinArrayP09); // setup GPIO pin as output
blinkLed0501(PortPinArrayP09); // blink led
// *** Testing 7 segment LED ***
displayAllDigits050(OlimexBoardSevenSegmentLedPortPinArrayPointerArray, MAX_OLIMEX_7_SEG_LED_PIN_NUMBER);
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// led050.h 2013oct15hkt1110
// ***********************************************************************
#include "config050.h"
#include "gpio050.h"
#include "timer050.h"
void blinkOneLed050(portPinArray ledPortPinArrayPointer, \
int onTime, int offTime, int blinkCount)
{
int count;
for (count = 0; count < blinkCount; count++)
{
setGpioDataPinLow01(ledPortPinArrayPointer);
delayTenthSecond(onTime);
setGpioDataPinHigh01(ledPortPinArrayPointer);
delayTenthSecond(offTime);
}
}
void blinkOneLed0501(portPinArrayPointerArray portPinArrayPointerArray, \
deviceNumber ledNumber, int onTime, int offTime, int blinkCount)
{
int count = 0;
portPinArray *ledPortPinArrayPointer;
ledPortPinArrayPointer = portPinArrayPointerArray[ledNumber - 1];
blinkOneLed050(ledPortPinArrayPointer, onTime, offTime, blinkCount);
}
void blinkAllLeds050(portPinArrayPointerArray ledPortPinArrayPointerArray, \
int maxLedPinNumber, int onTime, int offTime, int repeatCount)
{
int ledNumber;
for (ledNumber = 1; ledNumber < (maxLedPinNumber + 1); ledNumber++ )
{
blinkOneLed0501(ledPortPinArrayPointerArray, ledNumber, \
onTime, offTime, repeatCount);
}
}
void runOlimexLeds050(portPinArrayPointerArray ledPortPinArrayPointerArray, \
int maxLedPinNumber, int onTime, int offTime, \
int blinkCount, int sequenceCount)
{
setupAllGpioPinsOutputLow050(ledPortPinArrayPointerArray, maxLedPinNumber);
delayTime(ONE_HALF_SECOND);
int count;
for (count = 0; count < sequenceCount; count++)
{
blinkAllLeds050(ledPortPinArrayPointerArray, maxLedPinNumber, onTime, offTime, blinkCount);
}
}
void blinkLed0501(portPinArray ledPortPinArray)
{
// setupGpioPinOutputLow050(ledPortPinArray);
blinkOneLed050(ledPortPinArray, ON_ONE_HALF_SECOND, OFF_ONE_HALF_SECOND, \
REPEAT_2_TIMES);
}
// *** Olimex only ***
void blinkOlimexLed(int ledNumber, int onTime, int offTime, int blinkCount)
{
blinkOneLed0501(OlimexBoardLedPortPinArrayPointerArray, \
ledNumber, onTime, offTime, blinkCount);
}
void runOlimexLeds()
{
runOlimexLeds050(OlimexBoardLedPortPinArrayPointerArray, MAX_OLIMEX_LED_PIN_NUMBER, \
ON_ONE_FIFTH_SECOND, OFF_ONE_FIFTH_SECOND, BLINK_1_TIME, \
SEQUENCE_2_TIMES);
}
void echoOlimexKeyByLed(int keyNumber, int ledNUmber)
{
setupAllGpioPinsOutputLow050(OlimexBoardLedPortPinArrayPointerArray, MAX_OLIMEX_LED_PIN_NUMBER);
setupAllGpioPinsInput050(OlimexBoardKeyPortPinArrayPointerArray, MAX_OLIMEX_KEY_PIN_NUMBER);
echoKeyByLed050(OlimexBoardKeyPortPinArrayPointerArray, OlimexBoardLedPortPinArrayPointerArray, \
keyNumber, ledNUmber);
}
// *** Whut only ***
void blinkWhutLed(int ledNumber, int onTime, int offTime, int blinkCount)
{
blinkOneLed0501(WhutBoardLedPortPinArrayPointerArray, \
ledNumber, onTime, offTime, blinkCount);
}
void runWhutLeds()
{
runOlimexLeds050(WhutBoardLedPortPinArrayPointerArray, MAX_WHUT_LED_PIN_NUMBER, \
ON_ONE_FIFTH_SECOND, OFF_ONE_FIFTH_SECOND, BLINK_1_TIME, \
SEQUENCE_2_TIMES);
}
// *** 7 Segment LED ***
void displayAllDigits050(portPinArrayPointerArray sevenSegmentLedPortPinArrayPointerArray, int maxSevenSegmentPinNumber)
{
initializeAllOutputPins(sevenSegmentLedPortPinArrayPointerArray, maxSevenSegmentPinNumber );
delayTime(ONE_SECOND);
displayAllDigits0501(sevenSegmentLedPortPinArrayPointerArray);
displayDigitBlank(sevenSegmentLedPortPinArrayPointerArray);
}
void displayAllDigits0501(portPinArrayPointerArray sevenSegmentLedPortPinArrayPointerArray)
{
int digitNumber;
for (digitNumber = 0; digitNumber < 10; digitNumber++)
{
displayDigit0502(sevenSegmentLedPortPinArrayPointerArray, digitNumber);
delayTime(ONE_HALF_SECOND);
}
}
void displayDigit0502(portPinArrayPointerArray sevenSegmentPortPinArrayPointerArray, \
int digitNumber) // display 1 digit
{
portPinArray *portPinArrayPointerClock; // GPIO pin for clock
portPinArray *portPinArrayPointerData; // GPIO pin for data
portPinArray *portPinArrayPointerLatch; // GPIO pin for latch
portPinArrayPointerClock = sevenSegmentPortPinArrayPointerArray[SCLK_INDEX];
portPinArrayPointerData = sevenSegmentPortPinArrayPointerArray[DIN_INDEX];
portPinArrayPointerLatch = sevenSegmentPortPinArrayPointerArray[LATCH_INDEX];
setGpioDataPinLow01(portPinArrayPointerLatch); // set latch low
setGpioDataPinLow01(portPinArrayPointerClock); // set clock pin low
loadSevenSegmentDataBits(portPinArrayPointerData, portPinArrayPointerClock, digitNumber); // load segment bits
setGpioDataPinHigh01(portPinArrayPointerLatch); // set latch pin high
}
void sendPositiveGoingPulse(portPinArray *portPinArrayPointer)
{
setGpioDataPinHigh01(portPinArrayPointer);
setGpioDataPinLow01(portPinArrayPointer);
}
void loadSevenSegmentDataBits(portPinArray *portPinArrayPointerData, \
portPinArray *portPinArrayPointerClock, int alphaNumbericCharacter)
{
int segmentNumber;
int segmentBit;
int segmentByte, segmentByte1;
int Segment0 = 0b11111100; // 7 sements bits & decimal point pattern of digit 0
int Segment1 = 0b01100000;
int Segment2 = 0b11011010;
int Segment3 = 0b11110010;
int Segment4 = 0b01100110;
int Segment5 = 0b10110110;
int Segment6 = 0b10111110;
int Segment7 = 0b11100000;
int Segment8 = 0b11111110;
int Segment9 = 0b11110110; // digit 9
int AllBlank = 0b00000000; // all 7 segments and decimal pont blank
int SegmentArray[] = {Segment0, Segment1, Segment2, Segment3, Segment4, \
Segment5, Segment6, Segment7, Segment8, Segment9, AllBlank};
segmentByte = SegmentArray[alphaNumbericCharacter];
for (segmentNumber = 0; segmentNumber < 8; segmentNumber++) // load 8 segment bits
{
segmentByte1 = segmentByte | (1 << segmentNumber);
if (segmentByte1 == segmentByte)
setGpioDataPinHigh01(portPinArrayPointerData);
else
setGpioDataPinLow01(portPinArrayPointerData);
sendPositiveGoingPulse(portPinArrayPointerClock); // then write positive going pulse to latch data
}
}
void displayDigitBlank(portPinArrayPointerArray sevenSegmentPortPinArrayPointerArray)
{
int DigitBlank = 10;
displayDigit0502(sevenSegmentPortPinArrayPointerArray, DigitBlank);
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// key050.h 2013oct15hkt1111
// ***********************************************************************
#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
// ***********************************************************************
// ***********************************************************************
// config050.h - 2013oct15hk1107
// ***********************************************************************
#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
#define DIGIT_10 10
#define DIGIT_BLANK 10
// *** 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
portPinArray PortPinArrayP208 = {PORT2, PIN8};
portPinArray PortPinArrayP209 = {PORT2, PIN9};
portPinArray PortPinArrayP210 = {PORT2, PIN10};
portPinArray PortPinArrayP211 = {PORT2, PIN11};
// *** 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};
// *** Whut 7 Segment LED configuration ***
#define SCLK_INDEX 0
#define DIN_INDEX 1
#define LATCH_INDEX 2
#define MAX_WHUT_7_SEG_LED_PIN_NUMBER 3
#define MAX_7_SEG_LED_PIN_NUMBER 3
portPinArray WhutBoardSevenSegmentLedPortPinArraySclk = {PORT2, PIN1}; // Serial Clock
portPinArray WhutBoardSevenSegmentLedPortPinArrayDin = {PORT2, PIN3}; // Data in
portPinArray WhutBoardSevenSegmentLedPortPinArrayLatch = {PORT2, PIN0}; // Latch
portPinArrayPointerArray WhutBoardSevenSegmentLedPortPinArrayPointerArray[MAX_WHUT_7_SEG_LED_PIN_NUMBER] = \
{&WhutBoardSevenSegmentLedPortPinArraySclk, &WhutBoardSevenSegmentLedPortPinArrayDin, \
&WhutBoardSevenSegmentLedPortPinArrayLatch};
// *** Olimex 7 Segment LED configuration ***
#define MAX_OLIMEX_7_SEG_LED_PIN_NUMBER 3
portPinArray OlimexBoardSevenSegmentLedPortPinArraySclk = {PORT2, PIN8}; // Serial Clock
portPinArray OlimexBoardSevenSegmentLedPortPinArrayDin = {PORT2, PIN9}; // Data in
portPinArray OlimexBoardSevenSegmentLedPortPinArrayLatch = {PORT2, PIN10}; // Latch
portPinArrayPointerArray OlimexBoardSevenSegmentLedPortPinArrayPointerArray[MAX_OLIMEX_7_SEG_LED_PIN_NUMBER] = \
{&OlimexBoardSevenSegmentLedPortPinArraySclk, &OlimexBoardSevenSegmentLedPortPinArrayDin, \
&OlimexBoardSevenSegmentLedPortPinArrayLatch};
#endif /* CONFIG_HEADER_SEEN */
// ***********************************************************************
// * End *
// ***********************************************************************
// ***********************************************************************
// gpio050.h 2013oct15hkt1108
// ***********************************************************************
#ifndef GPIO050_HEADER_SEEN
#define GPIO050_HEADER_SEEN
#include "lpc11xx_syscon.h"
#include "lpc11xx_gpio.h"
#include "lpc11xx_iocon.h"
#include "config050.h"
#include "timer050.h"
// *** GPIO struct pointer ***
typedef GPIO_TypeDef *gpioStructPointerArray[4];
gpioStructPointerArray CmsisGpioStructPointerArray = {LPC_GPIO0, LPC_GPIO1, LPC_GPIO2, LPC_GPIO3};
GPIO_TypeDef *getGpioStructPointer(int portNumber)
{
GPIO_TypeDef *gpioStructPointer;
gpioStructPointer = CmsisGpioStructPointerArray[portNumber];
return gpioStructPointer;
}
typedef struct
{
GPIO_TypeDef *GpioStructPointer;
int PinNumber;
} gpioPortStructPinStruct;
gpioPortStructPinStruct *getGpioPortStructPinStructPointer(portNumber portNumber, \
pinNumber pinNumber) // *** To be tested ***
{
gpioPortStructPinStruct *gpioPortStructPinStruct;
gpioPortStructPinStruct->GpioStructPointer = getGpioStructPointer(portNumber);
gpioPortStructPinStruct->PinNumber = pinNumber;
return gpioPortStructPinStruct;
}
// *** GPIO functions ***
void setGpioDataPinInput(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
gpio_struct_ptr->DIR &= ~(1 << pinNumber);
}
void setGpioDataPinOutput(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
gpio_struct_ptr->DIR |= (1 << pinNumber);
}
void setGpioDataPinLow(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
gpio_struct_ptr->DATA &= ~(1 << pinNumber);
}
void setGpioDataPinHigh(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
gpio_struct_ptr->DATA |= (1 << pinNumber);
}
void setGpioPinDirection(GPIO_TypeDef *gpio_struct_ptr, int pinNumber, directionValue directionValue)
{
if (directionValue == INPUT_DIRECTION)
setGpioDataPinInput(gpio_struct_ptr, pinNumber);
else
setGpioDataPinOutput(gpio_struct_ptr, pinNumber);
}
void setGpioDataPin(GPIO_TypeDef *gpio_struct_ptr, int pinNumber, logicLevelValue logicLevelValue)
{
if (logicLevelValue == LOGIC_LOW_LEVEL)
setGpioDataPinLow(gpio_struct_ptr, pinNumber);
else
setGpioDataPinHigh(gpio_struct_ptr, pinNumber);
}
logicLevelValue getGpioDataPinValue01(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
logicLevelValue logicLevelValue;
int GpioDataPinMask = (1 << pinNumber);
if ((gpio_struct_ptr->DATA &= GpioDataPinMask) == GpioDataPinMask)
logicLevelValue = HIGH;
else
logicLevelValue = LOW;
return logicLevelValue;
}
logicLevelValue getGpioDataPinValue(portPinArrayPointerArray inputPortPinArrayPointerArray, int pinNumber)
{
int portNumber;
GPIO_TypeDef *gpioStructPointer;
logicLevelValue logicLevelValue;
portNumber = getPortNumber01(inputPortPinArrayPointerArray, pinNumber);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber01(inputPortPinArrayPointerArray, pinNumber);
logicLevelValue = getGpioDataPinValue01(gpioStructPointer, pinNumber);
return logicLevelValue;
}
portNumber getPortNumber(portPinArray portPinArray)
{
int portNumber;
portNumber = portPinArray[PORT_INDEX];
return portNumber;
}
portNumber getPortNumber01(portPinArrayPointerArray portPinArrayPointerArray, deviceNumber deviceNumber)
{
int portNumber;
portNumber = getPortNumber(*portPinArrayPointerArray[deviceNumber - 1]);
return portNumber;
}
pinNumber getPinNumber(portPinArray portPinArray)
{
int pinNumber;
pinNumber = portPinArray[PIN_INDEX];
return pinNumber;
}
pinNumber getPinNumber01(portPinArrayPointerArray portPinArrayPointerArray, deviceNumber deviceNumber)
{
int pinNumber;
pinNumber = getPinNumber(*portPinArrayPointerArray[deviceNumber - 1]);
return pinNumber;
}
// *** set up output pin ***
void initializeOutputPin01(portPinArray portPinArray)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber(portPinArray);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber(portPinArray);
setGpioDataPinOutput(gpioStructPointer, pinNumber);
setGpioDataPinLow (gpioStructPointer, pinNumber);
}
void initializeOutputPin01High(portPinArray portPinArray)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber(portPinArray);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber(portPinArray);
setGpioDataPinOutput(gpioStructPointer, pinNumber);
setGpioDataPinHigh(gpioStructPointer, pinNumber);
}
void initializeOutputPin01Low(portPinArray portPinArray)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber(portPinArray);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber(portPinArray);
setGpioDataPinOutput(gpioStructPointer, pinNumber);
setGpioDataPinLow(gpioStructPointer, pinNumber);
}
void initializeOneOutputPin(portPinArrayPointerArray outputPortPinArrayPointerArray, deviceNumber deviceNumber)
{
int portNumber;
int pinNumber;
portPinArray portPinArray = {0, 0};
portNumber = getPortNumber01(outputPortPinArrayPointerArray, deviceNumber);
pinNumber = getPinNumber01(outputPortPinArrayPointerArray, deviceNumber);
portPinArray[PORT_INDEX] = portNumber;
portPinArray[PIN_INDEX] = pinNumber;
initializeOutputPin01(portPinArray);
}
void initializeOneOutputPinHigh(portPinArrayPointerArray outputPortPinArrayPointerArray, deviceNumber deviceNumber)
{
int portNumber;
int pinNumber;
portPinArray portPinArray = {0, 0};
portNumber = getPortNumber01(outputPortPinArrayPointerArray, deviceNumber);
pinNumber = getPinNumber01(outputPortPinArrayPointerArray, deviceNumber);
portPinArray[PORT_INDEX] = portNumber;
portPinArray[PIN_INDEX] = pinNumber;
initializeOutputPin01High(portPinArray);
}
void initializeAllOutputPins(portPinArrayPointerArray outputPortPinArrayPointerArray, int maxPinNumber)
{
int pinNumber;
for (pinNumber = 1; pinNumber < (maxPinNumber + 1); pinNumber++)
{
initializeOneOutputPin(outputPortPinArrayPointerArray, pinNumber);
}
}
void initializeAllOutputPinsHigh(portPinArrayPointerArray outputPortPinArrayPointerArray, int maxPinNumber)
{
int pinNumber;
for (pinNumber = 1; pinNumber < (maxPinNumber + 1); pinNumber++)
{
initializeOneOutputPinHigh(outputPortPinArrayPointerArray, pinNumber);
}
}
// *** setup input pin ***
void initializeInputPin01(portPinArray portPinArray)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber(portPinArray);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber(portPinArray);
setGpioDataPinInput(gpioStructPointer, pinNumber);
}
void initializeOneInputPin(portPinArrayPointerArray outputPortPinArrayPointerArray, \
deviceNumber deviceNumber)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber01(outputPortPinArrayPointerArray, deviceNumber);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber01(outputPortPinArrayPointerArray, deviceNumber);
setGpioDataPinInput(gpioStructPointer, pinNumber);
}
void initializeAllInputPins(portPinArrayPointerArray inputPortPinArrayPointerArray, int maxPinNumber)
{
int pinNumber;
for (pinNumber = 1; pinNumber < (maxPinNumber + 1); pinNumber++)
{
initializeOneInputPin(inputPortPinArrayPointerArray, pinNumber);
}
}
void initializeAllInputPins40(portPinArrayPointerArray inputPortPinArrayPointerArray)
{
int pinNumber;
int maxPinNumber;
maxPinNumber = sizeof(inputPortPinArrayPointerArray) / sizeof(*inputPortPinArrayPointerArray);
for (pinNumber = 1; pinNumber < (maxPinNumber + 1); pinNumber++)
{
initializeOneInputPin(inputPortPinArrayPointerArray, pinNumber);
}
}
// *** Set GPIO output pin data value ***
void setGpioDataPinHigh01(portPinArray *portPinArrayPointer)
{
pinNumber pinNumber;
portNumber portNumber;
GPIO_TypeDef *gpioStructPointer;
pinNumber = getPinNumber(portPinArrayPointer);
portNumber = getPortNumber(portPinArrayPointer);
gpioStructPointer = getGpioStructPointer(portNumber);
setGpioDataPinHigh(gpioStructPointer, pinNumber);
}
void setGpioDataPinLow01(portPinArray *portPinArrayPointer)
{
pinNumber pinNumber;
portNumber portNumber;
GPIO_TypeDef *gpioStructPointer;
pinNumber = getPinNumber(portPinArrayPointer);
portNumber = getPortNumber(portPinArrayPointer);
gpioStructPointer = getGpioStructPointer(portNumber);
setGpioDataPinLow(gpioStructPointer, pinNumber);
}
// *** Functions 050 ***
void setupGpioPinOutputLow050(portPinArray portPinArray)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber(portPinArray);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber(portPinArray);
setupGpioPinOutput051(gpioStructPointer, pinNumber);
setGpioOutputPinLow051(gpioStructPointer, pinNumber);
}
void setupGpioPinOutput051(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
gpio_struct_ptr->DIR |= (1 << pinNumber);
}
void setGpioOutputPinHigh051(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
gpio_struct_ptr->DATA |= (1 << pinNumber);
}
void setGpioOutputPinLow051(GPIO_TypeDef *gpio_struct_ptr, int pinNumber)
{
gpio_struct_ptr->DATA &= ~(1 << pinNumber);
}
void setupAllGpioPinsOutputLow050(portPinArrayPointerArray portPinArrayPointerArray, int maxPinNumber)
{
int pinNumber;
for (pinNumber = 1; pinNumber < (maxPinNumber + 1); pinNumber++)
{
setupPinOutputLow050(portPinArrayPointerArray, pinNumber);
}
}
void setupPinOutputLow050(portPinArrayPointerArray outputPortPinArrayPointerArray, deviceNumber deviceNumber)
{
int portNumber;
int pinNumber;
portPinArray portPinArray = {0, 0};
portNumber = getPortNumber01(outputPortPinArrayPointerArray, deviceNumber);
pinNumber = getPinNumber01(outputPortPinArrayPointerArray, deviceNumber);
portPinArray[PORT_INDEX] = portNumber;
portPinArray[PIN_INDEX] = pinNumber;
initializeOutputPin01Low(portPinArray);
}
void setupGpioPinInput050(portPinArray portPinArray)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber(portPinArray);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber(portPinArray);
setGpioDataPinInput(gpioStructPointer, pinNumber);
}
void setupAllGpioPinsInput050(portPinArrayPointerArray portPinArrayPointerArray, int maxPinNumber)
{
int pinNumber;
for (pinNumber = 1; pinNumber < (maxPinNumber + 1); pinNumber++)
{
setupGpioPinInput051(portPinArrayPointerArray, pinNumber);
}
}
void setupGpioPinInput051(portPinArrayPointerArray outputPortPinArrayPointerArray, \
deviceNumber deviceNumber)
{
int portNumber;
int pinNumber;
GPIO_TypeDef *gpioStructPointer;
portNumber = getPortNumber01(outputPortPinArrayPointerArray, deviceNumber);
gpioStructPointer = getGpioStructPointer(portNumber);
pinNumber = getPinNumber01(outputPortPinArrayPointerArray, deviceNumber);
setGpioDataPinInput(gpioStructPointer, pinNumber);
}
void setupOlimexGpio050()
{
setupAllGpioPinsOutputLow050(OlimexBoardLedPortPinArrayPointerArray, MAX_OLIMEX_LED_PIN_NUMBER);
setupAllGpioPinsInput050(OlimexBoardKeyPortPinArrayPointerArray, MAX_OLIMEX_KEY_PIN_NUMBER);
}
void setupWhutGpio050()
{
setupAllGpioPinsOutputLow050(WhutBoardLedPortPinArrayPointerArray, MAX_WHUT_LED_PIN_NUMBER);
setupAllGpioPinsInput050(WhutBoardKeyPortPinArrayPointerArray, MAX_WHUT_KEY_PIN_NUMBER);
}
#endif /* GPIO050_HEADER_SEEN */
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// timer050.h 2013oct15hkt1109
// ***********************************************************************
#ifndef DELAY_HEADER_SEEN
#define DELAY_HEADER_SEEN
// *** Delay constants ***
#define ONE_FIFTH_SECOND 2
#define ONE_HALF_SECOND 5
#define ONE_SECOND 10
#define TWO_SECONDS 20
#define ON_ONE_FIFTH_SECOND 2
#define OFF_ONE_FIFTH_SECOND 2
#define ON_ONE_HALF_SECOND 5
#define OFF_ONE_HALF_SECOND 5
#define ON_ONE_SECOND 10
#define OFF_ONE_SECOND 10
// *** Repeat times ***
#define REPEAT_1_TIME 1
#define REPEAT_2_TIMES 2
#define REPEAT_3_TIMES 3
#define REPEAT_4_TIMES 4
#define REPEAT_5_TIMES 5
#define REPEAT_6_TIMES 6
#define REPEAT_8_TIMES 8
#define REPEAT_10_TIMES 10
#define REPEAT_20_TIMES 20
#define BLINK_0_TIME 0
#define BLINK_1_TIME 1
#define BLINK_2_TIMES 2
#define SEQUENCE_1_TIME 1
#define SEQUENCE_2_TIMES 2
#define SEQUENCE_4_TIMES 4
void delayTenthSecond(int count)
{
int i, j, k;
for (i = 0; i < count; i++)
{
for (j = 0; j < 0x4; j++)
{
for (k = 0; k < 0x000BB00; k++)
{
}
}
}
}
void delayTime(int count)
{
delayTenthSecond(count);
}
// *** system timer number, match register number ***
typedef const int timerNumber;
timerNumber Ct16b0 = 0;
timerNumber Ct16b1 = 1;
timerNumber Ct32b0 = 2;
timerNumber Ct32b1 = 3;
typedef const int matchRegisterNumber;
matchRegisterNumber MatchRegister0 = 0;
matchRegisterNumber MatchRegister1 = 1;
matchRegisterNumber MatchRegister2 = 2;
#endif /* DELAY_HEADER_SEEN */
// ***********************************************************************
// * End *
// ***********************************************************************
No comments:
Post a Comment