2013-12-22

SPI testing notes
































// ***************************************************************************
// Program  - Fong EKG v0.98
// Function - Testing Olimex EKG
// Author   - TL Fong
// Build    - 2013.12.22.01
// Date     - 2013dec21hkt2101
// 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();

// testMax7219DisplayEightDigitV09f();

}

// ***************************************************************************

// End
// ***************************************************************************



// ***********************************************************************
// test050.h 2013dec22hkt2101
// ***********************************************************************

#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 testMax7219DisplayEightDigitV09f()

{
printf("\n*** Test Max7219 digit and matrix mode ***\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);

setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_7); // set up Slave select 7

setupSpiSlaveSelectPortV0909(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_8); // set up Slave select 8

// *** 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);

// setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_7);

// setupMax7219DigitModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_8);

setupMax7219MatrixModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_7); // Slave select 7 = matrix mode

setupMax7219MatrixModeV090c(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_8); // Slave select 8 = matrix mode

// *** 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);

// displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_7, TEST_DIGIT_ARRAY_15);

// displayMax7219EightDigitV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_8, TEST_DIGIT_ARRAY_16);

// printf("\n*** Display 8 matrix columns ***\n\n");

// displayMax7219MatrixV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_7, TEST_DIGIT_ARRAY_16); //

displayMax7219MatrixV090d(WUYINS_01, SPI_CHANNEL_0, SLAVE_SELECT_8, MatrixChar_K);

}

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
// ***************************************************************************


No comments:

Post a Comment