2013-11-10
MAX7219 function refactoring notes
// ***********************************************************************
// Program - Fong EKG v5.03
// Function - Olimex EKG Board Evaluation
// Author - TL Fong
// Build - 2013.11.10.02
// Date - 2013nov10hkt1150
// Hardware - Olimex/CooCox/MagicBlue/WHUT/Somy LPC1114/C14/301/FN28
// Olimex EKG board (SHIELD-EKG/EMG Rev B, Bulgaria 2011)
// Software - GCC ARM 4.7, CoIDE 1.7.5, CoLinkEx 1.1, Flash Magic v7.66
// ***********************************************************************
#include "test050.h"
// ***********************************************************************
// Main Function
// ***********************************************************************
int main()
{
testBlinkLpc1114LedP03(); // testing system LED
// testAdc04(SPI_CHANNEL_1); // testing ADC
// testMax7219MatrixLed05(SPI_CHANNEL_0); // testing 7-segment/8x8 matrix LED
testLedArray060(SPI_CHANNEL_0, SLAVE_SELECT_0); // testing 7-segment/8x8 matrix LED
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// test050.h 2013nov10hkt1151
// ***********************************************************************
#include "led050.h"
#include "key050.h"
#include "spi050.h"
#include "adc050.h"
#include "eeprom050.h"
#include "mled050.h"
// ***************************************************************************
// Function - Test MAX7219 8-digit 7-segment and 8x8 matrix LED
// Date - 2013nov10
// ***************************************************************************
void testLedArray060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber)
{
spiSetup060(spiChannelNumber, slaveSelectNumber);
testDisplayLedArray060(spiChannelNumber, slaveSelectNumber);
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// mled050.h 2013nov10hkt1152
// MAX7219 4-digit 7-segment and 8x8 matrix LED
// ***********************************************************************
#include "spi050.h"
// *** MAX7219 Register Address Map ***
#define NO_OP_ADDR 0x00
#define DIGIT_ADDR_0 0x01
#define DIGIT_ADDR_1 0x02
#define DIGIT_ADDR_2 0x03
#define DIGIT_ADDR_3 0x04
#define DIGIT_ADDR_4 0x05
#define DIGIT_ADDR_5 0x06
#define DIGIT_ADDR_6 0x07
#define DIGIT_ADDR_7 0x08
#define DECODE_MODE_ADDR 0x09
#define INTENSITY_ADDR 0x0a
#define SCAN_LIMIT_ADDR 0x0b
#define OPERATION_ADDR 0x0c // Shutdown address actually
#define DISPLAY_TEST_ADDR 0x0f
// *** MAX7219 Command Format ***
#define SHUT_DOWN 0x00
#define NORMAL 0x01
#define CODE_B_ALL_DIGITS 0xff
#define NO_DECODE_ALL_DIGITS 0x00
#define DECODE_ALL_8_DIGITS 0xff
#define NO_DECODE_ALL_8_DIGITS 0x00
#define NO_DECODE_ALL_8_ROWS 0x00
#define DISPLAY_8_DIGITS 0x07
#define SCAN_ALL_8_DIGITS 0x07
#define SCAN_ALL_8_ROWS 0x07
// *** Data Constants ***
#define DEVICE_1 1
#define DEVICE_2 2
#define DEVICE_3 3
#define DEVICE_4 4
#define LED_DRIVER_1 1
#define LED_DRIVER_2 2
#define LED_DRIVER_3 3
#define LED_DRIVER_4 4
#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 CHAR_HYPHEN 10
#define CHAR_E 11
#define CHAR_H 12
#define CHAR_L 13
#define CHAR_P 14
#define CHAR_BLANK 15
#define PATTERN_ALL_ON 0xff
#define PATTERN_ALL_OFF 0x00
#define ADDRESS_INDEX 0
#define DATA_INDEX 1
#define MAX_DEVICE_NUMBER 16
#define MAX_BUFFER_SIZE 32
#define MAX_MATRIX_NUMBER 4
uint8_t char_A[5] = {0x7E, 0x11, 0x11, 0x11, 0x7E};
uint8_t char_K[5] = {0x41, 0x22, 0x14, 0x08, 0x7f};
uint8_t char_O[5] = {0x3E, 0x41, 0x41, 0x41, 0x3E};
uint8_t CharBigO[8] = {0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x00};
uint8_t CharBigK[8] = {0x41, 0x22, 0x14, 0x08, 0x7F, 0x00, 0x00, 0x00};
uint8_t TriGram0[8] = {0x54, 0x54, 0x54, 0x00, 0x54, 0x54, 0x54, 0x00};
// *** Version 6 2013nov10 ***
void testDisplayLedArray060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber)
{
printf("\n\n*** Display LED Array 060 - 2013nov10hkt1152 ***\n\n");
setupLedDriver060(spiChannelNumber, slaveSelectNumber); // drivers 1, 2 for matrix, 3, 4 for 7-segment
displayLedMatrix060(spiChannelNumber, slaveSelectNumber, LED_DRIVER_1, CharBigO);
displayLedMatrix060(spiChannelNumber, slaveSelectNumber, LED_DRIVER_2, CharBigK);
display8LedDigit060(spiChannelNumber, slaveSelectNumber, LED_DRIVER_3, 1, 2, 3, 4, 5, 6, 7, 8);
display8LedDigit060(spiChannelNumber, slaveSelectNumber, LED_DRIVER_4, 8, 7, 6, 5, 4, 3, 2, 1);
delayTenthSecond(10);
display8LedDigit060(spiChannelNumber, slaveSelectNumber, LED_DRIVER_3, 0, 5, 5, 5, 5, 5, 5, 5);
display8LedDigit060(spiChannelNumber, slaveSelectNumber, LED_DRIVER_4, 6, 6, 6, 6, 6, 6, 6, 6);
}
void setupLedDriver060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber)
{
uint8_t i;
for (i = 1; i < 3; i++) // drivers 1, 2 for matrix
{
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, i, DECODE_MODE_ADDR, NO_DECODE_ALL_8_ROWS);
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, i, SCAN_LIMIT_ADDR, SCAN_ALL_8_ROWS);
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, i, OPERATION_ADDR, SHUT_DOWN);
}
for (i = 3; i < 5; i++) // drivers 3, 4, for digit
{
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, i, DECODE_MODE_ADDR, DECODE_ALL_8_DIGITS);
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, i, SCAN_LIMIT_ADDR, SCAN_ALL_8_DIGITS);
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, i, OPERATION_ADDR, SHUT_DOWN);
}
}
void displayLedMatrix060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, \
uint8_t ledDriverNumber, uint8_t matrixPattern[8])
{
shutDownLedDriver060(spiChannelNumber, slaveSelectNumber, ledDriverNumber);
uint8_t columnNumber;
uint8_t digitAddress;
for (columnNumber = 0; columnNumber < 8; columnNumber++)
{
digitAddress = columnNumber + 1;
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, \
digitAddress, matrixPattern[7 - columnNumber]);
}
startUpLedDriver060(spiChannelNumber, slaveSelectNumber, ledDriverNumber);
}
void displayLedDigit060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, \
uint8_t deviceNumber, uint8_t digitAddress, uint8_t digitData)
{
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, deviceNumber, digitAddress, digitData);
}
void display8LedDigit060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, uint8_t ledDriverNumber, \
uint8_t digit1, uint8_t digit2, uint8_t digit3, uint8_t digit4, \
uint8_t digit5, uint8_t digit6, uint8_t digit7, uint8_t digit8)
{
shutDownLedDriver060(spiChannelNumber, slaveSelectNumber, ledDriverNumber);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_7, digit1);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_6, digit2);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_5, digit3);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_4, digit4);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_3, digit5);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_2, digit6);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_1, digit7);
displayLedDigit060(spiChannelNumber, slaveSelectNumber, ledDriverNumber, DIGIT_ADDR_0, digit8);
startUpLedDriver060(spiChannelNumber, slaveSelectNumber, ledDriverNumber);
}
void writeLedDriverCommand060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, \
uint8_t deviceNumber, uint8_t commandRegisterAddress, uint8_t command)
{
uint8_t txBuffer[MAX_BUFFER_SIZE];
uint8_t rxBuffer[MAX_BUFFER_SIZE];
SSP_DATA_SETUP_Type xferConfig;
xferConfig.tx_data = txBuffer;
xferConfig.rx_data = rxBuffer;
xferConfig.length = deviceNumber * 2;
txBuffer[ADDRESS_INDEX] = commandRegisterAddress;
txBuffer[DATA_INDEX] = command;
int i;
for (i = 1; i < deviceNumber; i++)
{
txBuffer[(i * 2) + ADDRESS_INDEX] = NO_OP_ADDR;
}
spiTransmit060(spiChannelNumber, slaveSelectNumber, xferConfig);
}
void setupDecodeMode060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, uint8_t driverNumber, uint8_t decodeMode)
{
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, driverNumber, DECODE_MODE_ADDR, decodeMode);
}
void setupScanLimit060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, uint8_t driverNumber, uint8_t scanLimit)
{
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, driverNumber, SCAN_LIMIT_ADDR, scanLimit);
}
void shutDownLedDriver060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, uint8_t driverNumber)
{
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, driverNumber, OPERATION_ADDR, SHUT_DOWN);
}
void startUpLedDriver060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, uint8_t driverNumber)
{
writeLedDriverCommand060(spiChannelNumber, slaveSelectNumber, driverNumber, OPERATION_ADDR, NORMAL);
}
// ***********************************************************************
// End
// ***********************************************************************
// ***********************************************************************
// spi050.h 2013nov10hkt1118
// ***********************************************************************
#include "gpio050.h"
#include "led050.h"
#include "lpc11xx_ssp.h"
#include "semihosting.h"
#include "stdio.h"
#include "config050.h"
#ifndef SPI_HEADER_SEEN
#define SPI_HEADER_SEEN
// *** SPI Functions ***
#define SPI_CHANNEL_0 0
#define SPI_CHANNEL_1 1
#define SLAVE_SELECT_0 0
#define SLAVE_SELECT_1 1
// *** version 060 ***
// ***************************************************************************
// Function - Setup SPI channel and slave select GPIO port
// Date - 2013nov10
// Notes - 1. Port P06 selected as default, BUT DISABLED!!!
// 2. There is a bug in lpc11xx_iocon.c v1.0
// 3. SlaveSelect GPIO port is initialized to output Low
// 4. portPinArray PortPinArraySsel0 = {PORT0, PIN2}; // SSEL0
// portPinArray PortPinArraySsel1 = {PORT2, PIN0}; // SSEL1
// ***************************************************************************
void spiSetup060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber)
{
if (spiChannelNumber == 0)
{
// Enable SSP0 block clock
SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_SSP0, ENABLE);
// Reset SSP0 and clock divider
SYSCON_PeriphResetCmd(SYSCON_RSTPeriph_SSP0, ENABLE);
SYSCON_PeriphResetCmd(SYSCON_RSTPeriph_SSP0, DISABLE);
SYSCON_SetSPI0ClockDiv(10);
// Assign GPIO pins for SPI
SSP_SSP0PinsInit(SCK0_PIO0_6, DISABLE); // Select P06, BUT disable
// Initialize SSP with default configuration (Master mode, 8 bit data)
SSP_CFG_Type SSP_ConfigStruct;
SSP_ConfigStructInit(&SSP_ConfigStruct);
SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
// Enable SSP peripheral
SSP_Cmd(LPC_SSP0, ENABLE);
}
else // (if spiChannelNumber == 1)
{
// Enable SSP1 block clock
SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_SSP1, ENABLE);
// Reset SSP1 and clock divider
SYSCON_PeriphResetCmd(SYSCON_RSTPeriph_SSP1, ENABLE);
SYSCON_PeriphResetCmd(SYSCON_RSTPeriph_SSP1, DISABLE);
SYSCON_SetSPI1ClockDiv(10);
// No need to assign GPIO pins for SPI1, just disable
SSP_SSP1PinsInit(DISABLE); // disable SSEL
// Note: A bug!!! in Coocox lpc11xx_iocon.c v1.0 26Jan2010
// IOCON_SetPinFunc(IOCON_PIO2_2, PIO2_2_FUN_MISO1);
// IOCON_SetPinFunc(IOCON_PIO2_3, PIO2_3_FUN_PIO_MOSI1);
// IOCON_SetPinFunc(IOCON_PIO2_1, PIO2_1_FUN_SCK1);
// if(useSSEL == ENABLE) {
// IOCON_SetPinFunc(IOCON_PIO2_0, PIO2_0_FUN_SSEL1);
// Initialize SSP with default configuration (Master mode, 8 bit data)
SSP_CFG_Type SSP_ConfigStruct;
SSP_ConfigStructInit(&SSP_ConfigStruct);
SSP_Init(LPC_SSP1, &SSP_ConfigStruct);
// Enable SSP1 peripheral
SSP_Cmd(LPC_SSP1, ENABLE);
}
// *** Setup Ssel0 ***
portPinArray *slaveSelectPortPinArrayPointer;
slaveSelectPortPinArrayPointer = SlaveSelectPortPinArrayPointerArrayArray[spiChannelNumber][slaveSelectNumber];
setupGpioPinOutputLow050(*slaveSelectPortPinArrayPointer);
}
// ***************************************************************************
// Function - SPI transmit
// Date - 2013nov10
// ***************************************************************************
void spiTransmit060(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, \
SSP_DATA_SETUP_Type xferConfig)
{
portPinArray *slaveSelectPortPinArrayPointer;
slaveSelectPortPinArrayPointer = SlaveSelectPortPinArrayPointerArrayArray[spiChannelNumber][slaveSelectNumber];
if (spiChannelNumber == 0)
{
setGpioDataPinLow01(*SlaveSelectPortPinArrayPointerArrayArray[spiChannelNumber][slaveSelectNumber]);
SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
setGpioDataPinHigh01(*SlaveSelectPortPinArrayPointerArrayArray[spiChannelNumber][slaveSelectNumber]);
}
else // (spiChannelNumber == 1)
{
setGpioDataPinLow01(*SlaveSelectPortPinArrayPointerArrayArray[spiChannelNumber][slaveSelectNumber]);
SSP_ReadWrite(LPC_SSP1, &xferConfig, SSP_TRANSFER_POLLING);
setGpioDataPinHigh01(*SlaveSelectPortPinArrayPointerArrayArray[spiChannelNumber][slaveSelectNumber]);
}
}
// ***********************************************************************
// 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 PortPinArrayP02 = {PORT0, PIN2};
portPinArray PortPinArrayP03 = {PORT0, PIN3};
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};
portPinArray PortPinArraySsel = {PORT0, PIN2};
portPinArray PortPinArraySsel0 = {PORT0, PIN2};
portPinArray PortPinArraySsel1 = {PORT2, PIN0};
portPinArray PortPinArraySsel00 = {PORT0, PIN2};
portPinArray PortPinArraySsel01 = {PORT2, PIN0};
portPinArray PortPinArraySsel02 = {PORT2, PIN0};
portPinArray PortPinArraySsel10 = {PORT0, PIN2};
portPinArray PortPinArraySsel11 = {PORT2, PIN0};
portPinArray PortPinArraySsel12 = {PORT2, PIN0};
portPinArray *SlaveSelectPortPinArrayPointerArray0[] = {&PortPinArraySsel00, &PortPinArraySsel01};
portPinArray *SlaveSelectPortPinArrayPointerArray1[] = {&PortPinArraySsel00, &PortPinArraySsel01};
portPinArray *SlaveSelectPortPinArrayPointerArrayArray[2][3] =
{&PortPinArraySsel00, &PortPinArraySsel01, &PortPinArraySsel02, \
&PortPinArraySsel10, &PortPinArraySsel11, &PortPinArraySsel12};
// *** 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 *
// ***********************************************************************
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment