2013-12-03
SPI function refactoring notes
// ***************************************************************************
// Program - Fong EKG v0.97
// Function - Testing Olimex EKG
// Author - TL Fong
// Build - 2013.12.03.02
// Date - 2013dec01hkt2137
// Hardware - WuyinS/Olimex/CooCox/MagicBlue/WHUT/Somy LPC1114/C14/301
// Olimex EKG/EMG R.B 2011
// Software - CoIDE 1.7.5, CoLinkEx 1.1, Flash Magic v7.66, GCC ARM 4.7
// **************************************************************************
#include "test050.h"
// ***************************************************************************
// Main Function
// ***************************************************************************
int main()
{
testMax7219DisplayEightDigitV09d();
}
// ***************************************************************************
// End
// ***************************************************************************
// ***********************************************************************
// test050.h 2013dec03hkt2137
// ***********************************************************************
#include "led050.h"
#include "key050.h"
#include "adc050.h"
#include "eeprom050.h"
#include "spi080.h"
#include "mled080.h"
#define DEBUG 1
#define NO_DEBUG 0
void testMax7219DisplayEightDigitV09d()
{
printf("\n*** testMax7219DisplayEightDigit() ***\n\n");
// *** Set up SPI channels ***
printf("\n*** Set up SPI channels ***\n\n");
setupOneSpiChannel080(SPI_CHANNEL_0);
setupOneSpiChannel080(SPI_CHANNEL_1);
// *** Set up SPI slave select ports ***
printf("\n*** Set up Slave select ports ***\n\n");
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_0);
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_1);
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_2);
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_3);
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_0);
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_4);
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_5);
setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_6);
// *** Set up Max7219 display mode ***
printf("\n*** Set up Max7219 display mode ***\n\n");
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_0);
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_1);
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_2);
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_3);
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_0);
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_4);
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_5);
setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_6);
// *** Display 8 digits ***
printf("\n*** Display 8 digits ***\n\n");
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_0, TEST_DIGIT_ARRAY_00);
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_1, TEST_DIGIT_ARRAY_01);
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_2, TEST_DIGIT_ARRAY_02);
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_3, TEST_DIGIT_ARRAY_03);
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_0, TEST_DIGIT_ARRAY_10);
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_4, TEST_DIGIT_ARRAY_14);
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_5, TEST_DIGIT_ARRAY_15);
displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_1, SLAVE_SELECT_6, TEST_DIGIT_ARRAY_16);
}
// ***************************************************************************
// End
// ***************************************************************************
// ***********************************************************************
// mled080.h 2013dec03hkt2139
// ***********************************************************************
#include "ledcode080.h"
// *** MAX7219 Register Addresses ***
#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 Commands ***
#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 MATRIX_0 0
#define MATRIX_1 1
#define MATRIX_2 2
#define MATRIX_3 3
#define MATRIX_4 4
#define MATRIX_5 5
#define MATRIX_6 6
#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_MATRIX_NUMBER 16
#define MAX_BUFFER_SIZE 32
// ***************************************************************************
// MAx7219 Functions
// ***************************************************************************
#define TEST_DIGIT_ARRAY_00 0
#define TEST_DIGIT_ARRAY_01 1
#define TEST_DIGIT_ARRAY_02 2
#define TEST_DIGIT_ARRAY_03 3
#define TEST_DIGIT_ARRAY_10 4
#define TEST_DIGIT_ARRAY_14 5
#define TEST_DIGIT_ARRAY_15 6
#define TEST_DIGIT_ARRAY_16 7
typedef int eightDigitArray[8];
typedef eightDigitArray *eightDigitArrayPointerArray[8];
eightDigitArray EightDigitArraySpi00 = {5, 14, 1, 15, 0, 0, 15, 5};
eightDigitArray EightDigitArraySpi01 = {5, 14, 1, 15, 0, 1, 15, 5};
eightDigitArray EightDigitArraySpi02 = {5, 14, 1, 15, 0, 2, 15, 5};
eightDigitArray EightDigitArraySpi03 = {5, 14, 1, 15, 0, 3, 15, 5};
eightDigitArray EightDigitArraySpi10 = {5, 14, 1, 15, 1, 0, 15, 5};
eightDigitArray EightDigitArraySpi14 = {5, 14, 1, 15, 1, 4, 15, 5};
eightDigitArray EightDigitArraySpi15 = {5, 14, 1, 15, 1, 5, 15, 5};
eightDigitArray EightDigitArraySpi16 = {5, 14, 1, 15, 1, 6, 15, 5};
eightDigitArrayPointerArray EightDigitArrayPointerArrayTest01 = \
{
&EightDigitArraySpi00, \
&EightDigitArraySpi01, \
&EightDigitArraySpi02, \
&EightDigitArraySpi03, \
&EightDigitArraySpi10, \
&EightDigitArraySpi14, \
&EightDigitArraySpi15, \
&EightDigitArraySpi16
};
void displayMax7219EightDigitV090d(uint8_t mcuBoardNumber, uint8_t spiChannelNumber, uint8_t slaveSelectNumber, \
uint8_t testDigitArrayNumber)
{
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
OPERATION_ADDR, SHUT_DOWN);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_7, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[0]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_6, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[1]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_5, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[2]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_4, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[3]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_3, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[4]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_2, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[5]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_1, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[6]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DIGIT_ADDR_0, (*EightDigitArrayPointerArrayTest01[testDigitArrayNumber])[7]);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
OPERATION_ADDR, NORMAL);
}
void writeMax7219CommandV0909(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, \
portPinArray *portPinArrayPointer, \
uint8_t commandRegisterAddress, uint8_t command)
{
uint8_t txBuffer[2];
uint8_t rxBuffer[2];
SSP_DATA_SETUP_Type xferConfig;
xferConfig.tx_data = txBuffer;
xferConfig.rx_data = rxBuffer;
xferConfig.length = 2;
txBuffer[ADDRESS_INDEX] = commandRegisterAddress;
txBuffer[DATA_INDEX] = command;
spiTransmit0909(spiChannelNumber, slaveSelectNumber, portPinArrayPointer, xferConfig);
}
void setupMax7219DigitModeV090c(uint8_t mcuBoardNumber, uint8_t spiChannelNumber, uint8_t slaveSelectNumber)
{
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
OPERATION_ADDR, SHUT_DOWN);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
DECODE_MODE_ADDR, DECODE_ALL_8_DIGITS);
writeMax7219CommandV0909(spiChannelNumber, slaveSelectNumber, \
(*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber], \
SCAN_LIMIT_ADDR, SCAN_ALL_8_DIGITS);
}
// ***************************************************************************
// End
// ***************************************************************************
// ***********************************************************************
// spi080.h 2013dec03hkt2044
// ***********************************************************************
#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 #defines ***
#define MAX_SPI_CHANNEL_NUMBER 2
#define MAX_SPI_SLAVE_SELECT_NUMBER 9
#define SPI_CHANNEL_TOTAL 2
#define SPI_SLAVE_SELECT_TOTAL 9
#define SPI_CHANNEL_0 0
#define SPI_CHANNEL_1 1
#define SLAVE_SELECT_0 0
#define SLAVE_SELECT_1 1
#define SLAVE_SELECT_2 2
#define SLAVE_SELECT_3 3
#define SLAVE_SELECT_4 4
#define SLAVE_SELECT_5 5
#define SLAVE_SELECT_6 6
#define SLAVE_SELECT_7 8
#define SLAVE_SELECT_8 8
typedef int slaveSelectPortPinArray[2];
typedef slaveSelectPortPinArray *slaveSelectPortPinArrayPointerArray[SPI_SLAVE_SELECT_TOTAL];
typedef slaveSelectPortPinArrayPointerArray *slaveSelectPortPinArrayPointerArrayPointerArray[SPI_CHANNEL_TOTAL];
slaveSelectPortPinArray SlaveSelectPortPinArray00 = {PORT0, PIN2};
slaveSelectPortPinArray SlaveSelectPortPinArray01 = {PORT3, PIN0};
slaveSelectPortPinArray SlaveSelectPortPinArray02 = {PORT3, PIN1};
slaveSelectPortPinArray SlaveSelectPortPinArray03 = {PORT3, PIN2};
slaveSelectPortPinArray SlaveSelectPortPinArray04 = {PORT3, PIN3};
slaveSelectPortPinArray SlaveSelectPortPinArray05 = {PORT2, PIN6};
slaveSelectPortPinArray SlaveSelectPortPinArray06 = {PORT2, PIN7};
slaveSelectPortPinArray SlaveSelectPortPinArray07 = {PORT2, PIN8};
slaveSelectPortPinArray SlaveSelectPortPinArray08 = {PORT2, PIN9};
slaveSelectPortPinArray SlaveSelectPortPinArray10 = {PORT2, PIN0};
slaveSelectPortPinArray SlaveSelectPortPinArray11 = {PORT3, PIN0};
slaveSelectPortPinArray SlaveSelectPortPinArray12 = {PORT3, PIN1};
slaveSelectPortPinArray SlaveSelectPortPinArray13 = {PORT3, PIN2};
slaveSelectPortPinArray SlaveSelectPortPinArray14 = {PORT3, PIN3};
slaveSelectPortPinArray SlaveSelectPortPinArray15 = {PORT2, PIN6};
slaveSelectPortPinArray SlaveSelectPortPinArray16 = {PORT2, PIN7};
slaveSelectPortPinArray SlaveSelectPortPinArray17 = {PORT2, PIN8};
slaveSelectPortPinArray SlaveSelectPortPinArray18 = {PORT2, PIN9};
slaveSelectPortPinArrayPointerArray WuyinsSlaveSelectPortPinArrayPointerArraySp0V095[SPI_SLAVE_SELECT_TOTAL] = \
{&SlaveSelectPortPinArray00, &SlaveSelectPortPinArray01, &SlaveSelectPortPinArray02, \
&SlaveSelectPortPinArray03, &SlaveSelectPortPinArray04, &SlaveSelectPortPinArray05, \
&SlaveSelectPortPinArray06, &SlaveSelectPortPinArray07, &SlaveSelectPortPinArray08};
slaveSelectPortPinArrayPointerArray WuyinsSlaveSelectPortPinArrayPointerArraySp1V095[SPI_SLAVE_SELECT_TOTAL] = \
{&SlaveSelectPortPinArray10, &SlaveSelectPortPinArray11, &SlaveSelectPortPinArray12, \
&SlaveSelectPortPinArray13, &SlaveSelectPortPinArray14, &SlaveSelectPortPinArray15, \
&SlaveSelectPortPinArray16, &SlaveSelectPortPinArray17, &SlaveSelectPortPinArray18};
slaveSelectPortPinArrayPointerArrayPointerArray \
WuyinsSlaveSelectPortPinArrayPointerArrayPointerArrayV095[SPI_CHANNEL_TOTAL] = \
{&WuyinsSlaveSelectPortPinArrayPointerArraySp0V095, \
&WuyinsSlaveSelectPortPinArrayPointerArraySp1V095};
slaveSelectPortPinArrayPointerArray SlaveSelectPortPinArrayPointerArrayWuyinsSpi0 = \
{
&SlaveSelectPortPinArray00, \
&SlaveSelectPortPinArray01, \
&SlaveSelectPortPinArray02, \
&SlaveSelectPortPinArray03, \
&SlaveSelectPortPinArray04, \
&SlaveSelectPortPinArray05, \
&SlaveSelectPortPinArray06, \
&SlaveSelectPortPinArray07, \
&SlaveSelectPortPinArray08
};
slaveSelectPortPinArrayPointerArray SlaveSelectPortPinArrayPointerArrayWuyinsSpi1 = \
{
&SlaveSelectPortPinArray10, \
&SlaveSelectPortPinArray11, \
&SlaveSelectPortPinArray12, \
&SlaveSelectPortPinArray13, \
&SlaveSelectPortPinArray14, \
&SlaveSelectPortPinArray15, \
&SlaveSelectPortPinArray16, \
&SlaveSelectPortPinArray17, \
&SlaveSelectPortPinArray18
};
slaveSelectPortPinArrayPointerArrayPointerArray SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi = \
{
&SlaveSelectPortPinArrayPointerArrayWuyinsSpi0, \
&SlaveSelectPortPinArrayPointerArrayWuyinsSpi1
};
// *** SPI PortPinArray assignment ***
portPinArray PortPinArraySsel0 = {PORT0, PIN2};
portPinArray PortPinArraySsel1 = {PORT2, PIN0};
portPinArray PortPinArraySsel00 = {PORT0, PIN2};
portPinArray PortPinArraySsel01 = {PORT3, PIN0};
portPinArray PortPinArraySsel02 = {PORT3, PIN1};
portPinArray PortPinArraySsel03 = {PORT3, PIN2};
portPinArray PortPinArraySsel04 = {PORT3, PIN3};
portPinArray PortPinArraySsel05 = {PORT2, PIN6};
portPinArray PortPinArraySsel06 = {PORT2, PIN7};
portPinArray PortPinArraySsel07 = {PORT2, PIN8};
portPinArray PortPinArraySsel08 = {PORT2, PIN9};
portPinArray PortPinArraySsel10 = {PORT2, PIN0};
portPinArray PortPinArraySsel11 = {PORT3, PIN0};
portPinArray PortPinArraySsel12 = {PORT3, PIN1};
portPinArray PortPinArraySsel13 = {PORT3, PIN2};
portPinArray PortPinArraySsel14 = {PORT3, PIN3};
portPinArray PortPinArraySsel15 = {PORT2, PIN6};
portPinArray PortPinArraySsel16 = {PORT2, PIN7};
portPinArray PortPinArraySsel17 = {PORT2, PIN8};
portPinArray PortPinArraySsel18 = {PORT2, PIN9};
portPinArray *Olimex2SlaveSelectPortPinArrayPointerArray0[] = {&PortPinArraySsel00, \
&PortPinArraySsel01, &PortPinArraySsel02, &PortPinArraySsel03, \
&PortPinArraySsel04, &PortPinArraySsel05, &PortPinArraySsel06};
portPinArray *Olimex2SlaveSelectPortPinArrayPointerArray1[] = {&PortPinArraySsel10, \
&PortPinArraySsel11, &PortPinArraySsel12, &PortPinArraySsel13, \
&PortPinArraySsel14, &PortPinArraySsel15, &PortPinArraySsel16};
portPinArray *Olimex20SlaveSelectPortPinArrayPointerArrayArray[2][7] = \
{&PortPinArraySsel00, &PortPinArraySsel01, &PortPinArraySsel02, \
&PortPinArraySsel03, &PortPinArraySsel04, &PortPinArraySsel05, \
&PortPinArraySsel06, \
&PortPinArraySsel10, &PortPinArraySsel11, &PortPinArraySsel12, \
&PortPinArraySsel13, &PortPinArraySsel14, &PortPinArraySsel15, \
&PortPinArraySsel16};
portPinArray *Olimex21SlaveSelectPortPinArrayPointerArrayArray[2][7] = \
{Olimex2SlaveSelectPortPinArrayPointerArray0, \
Olimex2SlaveSelectPortPinArrayPointerArray1};
portPinArray *WuyinsSpi0SselPortPinArrayPointerArray[] = {&PortPinArraySsel00, \
&PortPinArraySsel01, &PortPinArraySsel02, &PortPinArraySsel03, \
&PortPinArraySsel04, &PortPinArraySsel05, &PortPinArraySsel06};
portPinArray *WuyinsSpi1SselPortPinArrayPointerArray[] = {&PortPinArraySsel10, \
&PortPinArraySsel11, &PortPinArraySsel12, &PortPinArraySsel13, \
&PortPinArraySsel14, &PortPinArraySsel15, &PortPinArraySsel16};
portPinArray *WuyinsSpi0SselPortPinArrayPointerArrayV092[] = {&PortPinArraySsel00, \
&PortPinArraySsel01, &PortPinArraySsel02, &PortPinArraySsel03, \
&PortPinArraySsel04, &PortPinArraySsel05, &PortPinArraySsel06, \
&PortPinArraySsel07, &PortPinArraySsel08};
portPinArray *WuyinsSpi1SselPortPinArrayPointerArrayV092[] = {&PortPinArraySsel10, \
&PortPinArraySsel11, &PortPinArraySsel12, &PortPinArraySsel13, \
&PortPinArraySsel14, &PortPinArraySsel15, &PortPinArraySsel16, \
&PortPinArraySsel17, &PortPinArraySsel18};
slaveSelectPortPinArrayPointerArray *WuyinsSpi1SselPortPinArrayPointerArrayArrayV094[] = \
{&WuyinsSpi0SselPortPinArrayPointerArrayV092, \
&WuyinsSpi0SselPortPinArrayPointerArrayV092};
// typedef int portPinArray[2];
// typedef portPinArray *portPinArrayPointerArray[MAX_DEVICE_NUMBER];
// typedef portPinArray *slaveSelectPortPinArrayPointerArray[MAX_SLAVE_SELECT_NUMBER];
slaveSelectPortPinArrayPointerArray *WuyinsSpi0SselPortPinArrayPointerArrayV095[] = \
{&PortPinArraySsel00, &PortPinArraySsel01, &PortPinArraySsel02, \
&PortPinArraySsel03, &PortPinArraySsel04, &PortPinArraySsel05, \
&PortPinArraySsel06, &PortPinArraySsel07, &PortPinArraySsel08};
slaveSelectPortPinArrayPointerArray *WuyinsSpi1SselPortPinArrayPointerArrayV095[] = \
{&PortPinArraySsel10, &PortPinArraySsel11, &PortPinArraySsel12, \
&PortPinArraySsel13, &PortPinArraySsel14, &PortPinArraySsel15, \
&PortPinArraySsel16, &PortPinArraySsel17, &PortPinArraySsel18};
slaveSelectPortPinArrayPointerArray *WuyinsSpiSselPortPinArrayPointerArrayArrayV095[] = \
{&WuyinsSpi0SselPortPinArrayPointerArrayV092, \
&WuyinsSpi0SselPortPinArrayPointerArrayV092};
// ***************************************************************************
// SPI Functions
// ***************************************************************************
void setupSpiSlaveSelectPortV0909(uint8_t mcuBoardNumber, uint8_t spiChannelNumber, uint8_t slaveSelectNumber)
{
initializeOutputPin01HighV093((*SlaveSelectPortPinArrayPointerArrayPointerArrayWuyinsSpi[spiChannelNumber])[slaveSelectNumber]);
}
void spiTransmit0909(uint8_t spiChannelNumber, uint8_t slaveSelectNumber, \
portPinArray *portPinArrayPointer, \
SSP_DATA_SETUP_Type xferConfig)
{
setGpioDataPinLow01(*portPinArrayPointer);
if (spiChannelNumber == 0)
SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
else // (spiChannelNumber == 1)
SSP_ReadWrite(LPC_SSP1, &xferConfig, SSP_TRANSFER_POLLING);
setGpioDataPinHigh01(*portPinArrayPointer);
}
// ***************************************************************************
// End
// ***************************************************************************
.END
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment