2013-11-07
mled050.h refactoring notes
// ***********************************************************************
// mled050.h 2013nov07hkt2106
// 4-digit 7-segment and 8x8 matrix LED controlled by MAX7219
// ***********************************************************************
#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 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 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};
// ***************************************************************************
// Function - Display MAX7219 4-digit 7-segment LEDs and 8x8 matrix LEDs
// Date - 2013nov07
// ***************************************************************************
void max7219MatrixLed04(uint8_t spiChannelNumber)
{
// *** Print project title ***********************************************
printf("\n\n*** Matrix LED 04 - 2013nov07hkt2108 ***\n\n");
// *** Setup MAX7219 digit control register buffer ***********************
#define MAX_DEVICE_NUMBER 16 // maximum 16 MAX7219 devices
#define ADDRESS_INDEX 0
#define DATA_INDEX 1
setupLedMatrix04(spiChannelNumber); // 2 matrixes, 2 7-segments
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_7, char_K[0]);
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_6, char_K[1]);
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_5, char_K[2]);
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_4, char_K[3]);
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_3, char_K[4]);
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit02(DEVICE_1, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
writeLedCommand02(DEVICE_1, spiChannelNumber, OPERATION_ADDR, NORMAL);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_7, char_O[0]);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_6, char_O[1]);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_5, char_O[2]);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_4, char_O[3]);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_3, char_O[4]);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit02(DEVICE_2, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
writeLedCommand02(DEVICE_2, spiChannelNumber, OPERATION_ADDR, NORMAL);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_7, DIGIT_1);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_6, DIGIT_1);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_5, DIGIT_0);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_4, DIGIT_7);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_3, DIGIT_0);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_2, DIGIT_0);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_1, DIGIT_0);
displayOneDigit02(DEVICE_3, spiChannelNumber, DIGIT_ADDR_0, DIGIT_1);
writeLedCommand02(DEVICE_3, spiChannelNumber, OPERATION_ADDR, NORMAL);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_7, DIGIT_2);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_6, DIGIT_2);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_5, DIGIT_3);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_4, DIGIT_4);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_3, DIGIT_5);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_2, DIGIT_6);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_1, DIGIT_7);
displayOneDigit02(DEVICE_4, spiChannelNumber, DIGIT_ADDR_0, DIGIT_8);
writeLedCommand02(DEVICE_4, spiChannelNumber, OPERATION_ADDR, NORMAL);
}
void max7219MatrixLed03(uint8_t spiChannelNumber)
{
// *** Print project title ***********************************************
printf("\n\n*** Matrix LED 03 - 2013nov07hkt1203 ***\n\n");
// *** Setup MAX7219 digit control register buffer ***********************
#define MAX_DEVICE_NUMBER 16 // maximum 16 MAX7219 devices
#define ADDRESS_INDEX 0
#define DATA_INDEX 1
uint8_t deviceNumber;
deviceNumber = 1;
// *** Setup MAX7219 for digit decode and scan limit ***
setUpMax7219NoDecode02(deviceNumber, spiChannelNumber);
// *** Display 8 digits ***
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, char_O[0]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, char_O[1]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, char_O[2]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, char_O[3]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, char_O[4]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);
deviceNumber = 2;
// *** Setup MAX7219 for no digit decode and scan limit ***
setUpMax7219NoDecode02(deviceNumber, spiChannelNumber);
// *** Display 8 digits ***
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, char_K[0]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, char_K[1]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, char_K[2]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, char_K[3]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, char_K[4]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);
deviceNumber = 3;
// *** Setup MAX7219 for digit decode and scan limit ***
setUpMax7219BcdCodeB03(deviceNumber, spiChannelNumber);
// *** Display 8 digits ***
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
// *** Display 8 digits ***
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, DIGIT_2);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, DIGIT_0);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, DIGIT_1);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, DIGIT_3);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, DIGIT_1);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, DIGIT_1);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, DIGIT_0);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, DIGIT_7);
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);
deviceNumber = 4;
// *** Setup MAX7219 for digit decode and scan limit ***
setUpMax7219BcdCodeB03(deviceNumber, spiChannelNumber);
// *** Display 8 digits ***
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
// *** Display 8 digits ***
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, DIGIT_1);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, DIGIT_2);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, DIGIT_3);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, DIGIT_4);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, DIGIT_5);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, DIGIT_6);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, DIGIT_7);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, DIGIT_8);
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);
}
void max7219MatrixLed02(uint8_t spiChannelNumber)
{
// *** Print project title ***********************************************
printf("\n\n*** Matrix LED 02 - 2013nov06hkt2100 ***\n\n");
// *** Setup MAX7219 digit control register buffer ***********************
#define MAX_DEVICE_NUMBER 16 // maximum 16 MAX7219 devices
#define ADDRESS_INDEX 0
#define DATA_INDEX 1
uint8_t deviceNumber;
deviceNumber = 1;
// *** Setup MAX7219 for digit decode and scan limit ***
setUpMax7219NoDecode02(deviceNumber, spiChannelNumber);
// *** Display 8 digits ***
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, char_O[0]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, char_O[1]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, char_O[2]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, char_O[3]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, char_O[4]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);
deviceNumber = 2;
// *** Setup MAX7219 for digit decode and scan limit ***
setUpMax7219NoDecode02(deviceNumber, spiChannelNumber);
// *** Display 8 digits ***
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, char_K[0]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, char_K[1]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, char_K[2]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, char_K[3]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, char_K[4]);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);
}
void max7219MatrixLed01(uint8_t spiChannelNumber)
{
// *** Print project title ***********************************************
printf("\n\n*** Matrix LED 01 - 2013nov06hkt1154 ***\n\n");
// *** Setup MAX7219 digit control register buffer ***********************
#define MAX_BUFFER_SIZE 16
#define ADDRESS_INDEX 0
#define DATA_INDEX 1
#define BUFFER_SIZE 2
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 ***
writeLedCommand(txBuffer, xferConfig, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_7, char_A[0]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_6, char_A[1]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_5, char_A[2]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_4, char_A[3]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_3, char_A[4]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
/*
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_7, char_K[0]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_6, char_K[1]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_5, char_K[2]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_4, char_K[3]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_3, char_K[4]);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);
*/
writeLedCommand(txBuffer, xferConfig, spiChannelNumber, OPERATION_ADDR, NORMAL);
}
// ***************************************************************************
// Function - Display 4 digits of 7-segment LED
// Date - 2013nov06
// ***************************************************************************
void max7219SegmentLed01(uint8_t spiChannelNumber)
{
// *** Print project title ***********************************************
printf("\n\n*** Segment LED 01 - 2013nov06hkt1128 ***\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 ***
setUpMax7219BcdCodeB(txBuffer, xferConfig, spiChannelNumber);
// *** Display 8 digits ***
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_7, CHAR_H);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_6, CHAR_E);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_5, CHAR_L);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_4, CHAR_P);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_3, CHAR_BLANK);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_2, CHAR_BLANK);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_1, DIGIT_0);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, DIGIT_ADDR_0, DIGIT_1);
displayOneDigit(txBuffer, xferConfig, spiChannelNumber, OPERATION_ADDR, NORMAL);
}
// ***************************************************************************
// Function - Write MAX7219 command
// Date - 2013nov06
// ***************************************************************************
void writeLedCommand(uint8_t txBuffer[BUFFER_SIZE], SSP_DATA_SETUP_Type xferConfig, \
uint8_t spiChannelNumber, \
uint8_t commandRegisterAddress, uint8_t command)
{
txBuffer[ADDRESS_INDEX] = commandRegisterAddress;
txBuffer[DATA_INDEX] = command;
SpiWriteRead050(xferConfig, spiChannelNumber);
}
void writeLedCommand02(uint8_t deviceNumber, uint8_t spiChannelNumber, \
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;
}
SpiWriteRead050(xferConfig, spiChannelNumber);
}
// ***************************************************************************
// Function - Display 1 digit
// Date - 2013nov06
// ***************************************************************************
void displayOneDigit(uint8_t txBuffer[BUFFER_SIZE], SSP_DATA_SETUP_Type xferConfig, \
uint8_t spiChannelNumber, \
uint8_t digitAddress, uint8_t digitData)
{
writeLedCommand(txBuffer, xferConfig, spiChannelNumber, digitAddress, digitData);
}
void displayOneDigit02(uint8_t deviceNumber, \
uint8_t spiChannelNumber, \
uint8_t digitAddress, uint8_t digitData)
{
writeLedCommand02(deviceNumber, spiChannelNumber, digitAddress, digitData);
}
// ***************************************************************************
// Function - Set up MAX7219 for Code B of all 8 digits, scan 8 digits
// Date - 2013nov06
// ***************************************************************************
void setUpMax7219BcdCodeB(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, CODE_B_ALL_DIGITS);
writeLedCommand(txBuffer, xferConfig, spiChannelNumber, \
SCAN_LIMIT_ADDR, DISPLAY_8_DIGITS);
}
void setUpMax7219BcdCodeB03(uint8_t deviceNumber, uint8_t spiChannelNumber)
{
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
delayTime(ONE_FIFTH_SECOND);
writeLedCommand02(deviceNumber, spiChannelNumber, \
DECODE_MODE_ADDR, CODE_B_ALL_DIGITS);
writeLedCommand02(deviceNumber, spiChannelNumber, \
SCAN_LIMIT_ADDR, DISPLAY_8_DIGITS);
}
// ***************************************************************************
// Function - Set up MAX7219 for no decode all 8 digits, scan 8 digits
// Date - 2013nov06
// ***************************************************************************
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);
}
void setUpMax7219NoDecode02(uint8_t deviceNumber, uint8_t spiChannelNumber)
{
writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
delayTime(ONE_FIFTH_SECOND);
writeLedCommand02(deviceNumber, spiChannelNumber, \
DECODE_MODE_ADDR, NO_DECODE_ALL_DIGITS);
writeLedCommand02(deviceNumber, spiChannelNumber, \
SCAN_LIMIT_ADDR, DISPLAY_8_DIGITS);
}
void setupDecodeMode04(uint8_t spiChannelNumber, uint8_t matrixNumber, uint8_t decodeMode)
{
writeLedCommand02(matrixNumber, spiChannelNumber, DECODE_MODE_ADDR, decodeMode);
}
void setupScanLimit04(uint8_t spiChannelNumber, uint8_t matrixNumber, uint8_t scanLimit)
{
writeLedCommand02(matrixNumber, spiChannelNumber, SCAN_LIMIT_ADDR, scanLimit);
}
void setupLedMatrix04(spiChannelNumber)
{
uint8_t i;
for (i = 1; i < 3; i++)
{
writeLedCommand02(i, spiChannelNumber, DECODE_MODE_ADDR, NO_DECODE_ALL_8_ROWS);
writeLedCommand02(i, spiChannelNumber, SCAN_LIMIT_ADDR, SCAN_ALL_8_ROWS);
writeLedCommand02(i, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
}
for (i = 3; i < 5; i++)
{
writeLedCommand02(i, spiChannelNumber, DECODE_MODE_ADDR, DECODE_ALL_8_DIGITS);
writeLedCommand02(i, spiChannelNumber, SCAN_LIMIT_ADDR, SCAN_ALL_8_DIGITS);
writeLedCommand02(i, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);
}
}
// ***********************************************************************
// End
// ***********************************************************************
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment