2013-11-06

MAX7219 LED matrix testing OK






























Now I know how to display the matrix LED.


testMax7219MatrixLed01(SPI_CHANNEL_0);
testMax7219MatrixLed01(SPI_CHANNEL_1);



// ***************************************************************************
// Function - Test MAX7219 8x8 matrix LED
// Date     - 2013nov06
// ***************************************************************************
void testMax7219MatrixLed01(uint8_t spiChannelNumber)
{
setupSpi051(spiChannelNumber);
max7219MatrixLed01(spiChannelNumber);
}



#define PATTERN_ALL_ON 0xff
#define PATTERN_ALL_OFF 0x00



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

// Function - Display 8x8 matrix LED
// Date     - 2013nov06
// ***************************************************************************
void max7219MatrixLed01(uint8_t spiChannelNumber)
{
    // *** Print project title ***********************************************
printf("\n\n*** Matrix LED 01 - 2013nov06hkt1154 ***\n\n");

// *** Setup MAX7219 digit control register buffer ***********************
#define BUFFER_SIZE 2
#define ADDRESS_INDEX 0
#define DATA_INDEX 1

uint8_t txBuffer[BUFFER_SIZE];
uint8_t rxBuffer[BUFFER_SIZE];

    // *** Setup SPI xferConfig ***
    SSP_DATA_SETUP_Type xferConfig;
    xferConfig.tx_data = txBuffer;
    xferConfig.rx_data = rxBuffer;
    xferConfig.length = BUFFER_SIZE;

    // *** Setup MAX7219 for digit decode and scan limit ***
    setUpMax7219NoDecode(txBuffer, xferConfig, spiChannelNumber);

    // *** Display 8 digits ***
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_7, PATTERN_ALL_ON);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_6, PATTERN_ALL_ON);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_5, PATTERN_ALL_OFF);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_4, PATTERN_ALL_OFF);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_3, PATTERN_ALL_ON);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_ON);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
    displayOneDigit(txBuffer, xferConfig, spiChannelNumber, OPERATION_ADDR, NORMAL);
}




void setUpMax7219NoDecode(uint8_t txBuffer[BUFFER_SIZE], SSP_DATA_SETUP_Type xferConfig, \
                  uint8_t spiChannelNumber)
{
writeLedCommand(txBuffer, xferConfig, spiChannelNumber, SHUTDOWN_ADDR, SHUTDOWN_MODE);
    delayTime(ONE_FIFTH_SECOND);
    writeLedCommand(txBuffer, xferConfig, spiChannelNumber, \
               DECODE_MODE_ADDR, NO_DECODE_ALL_DIGITS);
    writeLedCommand(txBuffer, xferConfig, spiChannelNumber, \
               SCAN_LIMIT_ADDR, DISPLAY_8_DIGITS);
}

.END



No comments:

Post a Comment