2014-01-17
SPI test - config050.h
// ***********************************************************************
// config050.h - 2013oct15hk1107
// ***********************************************************************
#include "lpc11xx_syscon.h"
#include "lpc11xx_gpio.h"
#include "lpc11xx_iocon.h"
#ifndef CONFIG_HEADER_SEEN
#define CONFIG_HEADER_SEEN
// *** Board number ***
#define WUYINS_01 0
// *** 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 MAX_SLAVE_SELECT_NUMBER 9
#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 pointers ***
#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 PortPinArrayP02 = {PORT0, PIN2};
portPinArray PortPinArrayP03 = {PORT0, PIN3};
portPinArray PortPinArrayP04 = {PORT0, PIN4};
portPinArray PortPinArrayP05 = {PORT0, PIN5};
portPinArray PortPinArrayP07 = {PORT0, PIN7};
portPinArray PortPinArrayP08 = {PORT0, PIN8};
portPinArray PortPinArrayP09 = {PORT0, PIN9};
portPinArray PortPinArrayP011 = {PORT0, PIN11};
portPinArray PortPinArrayP10 = {PORT1, PIN0};
portPinArray PortPinArrayP11 = {PORT1, PIN1};
portPinArray PortPinArrayP12 = {PORT1, PIN2};
portPinArray PortPinArrayP14 = {PORT1, PIN4};
portPinArray PortPinArrayP15 = {PORT1, PIN5}; // WuyinS Key
portPinArray PortPinArrayP19 = {PORT1, PIN9}; // WuyinS Key
portPinArray PortPinArrayP24 = {PORT2, PIN4}; // USB 2 D-
portPinArray PortPinArrayP25 = {PORT2, PIN5}; // USB 2 D+
portPinArray PortPinArrayP26 = {PORT2, PIN6};
portPinArray PortPinArrayP27 = {PORT2, PIN7};
portPinArray PortPinArrayP28 = {PORT2, PIN8};
portPinArray PortPinArrayP29 = {PORT2, PIN9}; // KEY1
portPinArray PortPinArrayP210 = {PORT2, PIN10};
portPinArray PortPinArrayP211 = {PORT2, PIN11};
portPinArray PortPinArrayP30 = {PORT3, PIN0}; // LED1
portPinArray PortPinArrayP31 = {PORT3, PIN1}; //
portPinArray PortPinArrayP32 = {PORT3, PIN2}; //
portPinArray PortPinArrayP33 = {PORT3, PIN3}; // WuyinS LED
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
// ***SPI port pin assignments 2013nov10 ***
//portPinArray PortPinArraySsel02 = {PORT2, PIN5}; // MagicBlue p121
//portPinArray PortPinArraySsel02 = {PORT0, PIN3}; // MagicBlue p121
// *** 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
// *** 7 Segment LED 1 ***
portPinArray OlimexBoardSevenSegmentLedPortPinArraySclk1 = {PORT2, PIN8}; // Serial Clock
portPinArray OlimexBoardSevenSegmentLedPortPinArrayDin1 = {PORT2, PIN9}; // Data in
portPinArray OlimexBoardSevenSegmentLedPortPinArrayLatch1 = {PORT2, PIN10}; // Latch
portPinArrayPointerArray OlimexBoardSevenSegmentLedPortPinArrayPointerArray1[MAX_OLIMEX_7_SEG_LED_PIN_NUMBER] = \
{&OlimexBoardSevenSegmentLedPortPinArraySclk1, &OlimexBoardSevenSegmentLedPortPinArrayDin1, \
&OlimexBoardSevenSegmentLedPortPinArrayLatch1};
// *** 7 segment LED 2 ***
portPinArray OlimexBoardSevenSegmentLedPortPinArraySclk2 = {PORT2, PIN11}; // Serial Clock
portPinArray OlimexBoardSevenSegmentLedPortPinArrayDin2 = {PORT3, PIN0}; // Data in (Olimex Led0)
portPinArray OlimexBoardSevenSegmentLedPortPinArrayLatch2 = {PORT3, PIN1}; // Latch (Olimex Led1)
portPinArrayPointerArray OlimexBoardSevenSegmentLedPortPinArrayPointerArray2[MAX_OLIMEX_7_SEG_LED_PIN_NUMBER] = \
{&OlimexBoardSevenSegmentLedPortPinArraySclk2, &OlimexBoardSevenSegmentLedPortPinArrayDin2, \
&OlimexBoardSevenSegmentLedPortPinArrayLatch2};
#endif /* CONFIG_HEADER_SEEN */
// *** WHUT SPI Connecor pin number ***
// SSPCLK P04 C404
// MISO0 P08 C409
// MOSI0 P09 C410
// SSEL0 P02 C316
// ***********************************************************************
// * End *
// ***********************************************************************
.END
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment