2013-11-21

Olimex SPI testing notes


// ***************************************************************************
// Program  - Fong EKG v5.09
// Function - Testing Olimex EKG
// Author   - TL Fong
// Build    - 2013.11.21.01
// Date     - 2013nov21hkt1146
// 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()
{
testSpiSselPin();
}


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



// ***********************************************************************
// test050.h 2013nov21hkt1147
// ***********************************************************************

#include "led050.h"
#include "key050.h"
#include "spi050.h"
#include "adc050.h"
#include "eeprom050.h"
#include "mled050.h"
#include "spi080.h"

void testSpiSselPin()
{
testSpiSselPin0801();
}

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

// ***********************************************************************
// spi080.h 2013nov21hkt1151
// ***********************************************************************

#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 7

#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

// *** 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 PortPinArraySsel10 = {PORT2, PIN0};
portPinArray PortPinArraySsel11 = {PORT2, PIN0};
portPinArray PortPinArraySsel12 = {PORT2, PIN0};
portPinArray PortPinArraySsel13 = {PORT2, PIN0};
portPinArray PortPinArraySsel14 = {PORT2, PIN0};
portPinArray PortPinArraySsel15 = {PORT2, PIN0};
portPinArray PortPinArraySsel16 = {PORT2, PIN0};

portPinArray *Olimex2SlaveSelectPortPinArrayPointerArray0[] = {&PortPinArraySsel00, \
    &PortPinArraySsel01, &PortPinArraySsel02, &PortPinArraySsel03, \
    &PortPinArraySsel04, &PortPinArraySsel05, &PortPinArraySsel06};

portPinArray *Olimex2SlaveSelectPortPinArrayPointerArray1[] = {&PortPinArraySsel10, \
    &PortPinArraySsel11, &PortPinArraySsel12, &PortPinArraySsel13, \
    &PortPinArraySsel14, &PortPinArraySsel15, &PortPinArraySsel16};

portPinArray *Olimex2SlaveSelectPortPinArrayPointerArrayArray[2][7] = \
     {&PortPinArraySsel00, &PortPinArraySsel01, &PortPinArraySsel02, \
          &PortPinArraySsel03, &PortPinArraySsel04, &PortPinArraySsel05, \
          &PortPinArraySsel06, \
          &PortPinArraySsel10, &PortPinArraySsel11, &PortPinArraySsel12, \
          &PortPinArraySsel13, &PortPinArraySsel14, &PortPinArraySsel15, \
          &PortPinArraySsel16};

portPinArray *Olimex21SlaveSelectPortPinArrayPointerArrayArray[2][7] = \
{Olimex2SlaveSelectPortPinArrayPointerArray0, Olimex2SlaveSelectPortPinArrayPointerArray1};


// ***************************************************************************
// Function - Test SPI0 SSEL pins
// Notes    - Use a scope to display the waveform of each blinkig ssel pin
// Date     - 2013nov21
// ***************************************************************************
void testSpiSselPin0801()
{
initializeOutputPin01High(PortPinArrayP02);

initializeOutputPin01High(PortPinArrayP30);
initializeOutputPin01High(PortPinArrayP31);
initializeOutputPin01High(PortPinArrayP32);
initializeOutputPin01High(PortPinArrayP33);

initializeOutputPin01High(PortPinArrayP26);
initializeOutputPin01High(PortPinArrayP27);

uint8_t i;
for (i = 0; i < 10000; i++)
{
blinkOneLed080(PortPinArrayP02, 1, 1, 200);

  blinkOneLed080(PortPinArrayP30, 1, 1, 200);
  blinkOneLed080(PortPinArrayP31, 1, 1, 200);
  blinkOneLed080(PortPinArrayP32, 1, 1, 200);
  blinkOneLed080(PortPinArrayP33, 1, 1, 200);

  blinkOneLed080(PortPinArrayP26, 1, 1, 200);
  blinkOneLed080(PortPinArrayP27, 1, 1, 200);
}
}

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




No comments:

Post a Comment