|
|
|
@ -8,6 +8,24 @@
|
|
|
|
|
|
|
|
|
|
//#include "ked/device_drivers/max7219/max7219.h "
|
|
|
|
|
|
|
|
|
|
typedef enum{
|
|
|
|
|
NO_DECODE_DIGIT_7_TO_0 = 0x00,
|
|
|
|
|
CODE_B_DECODE_ONLY_DIGIT_0 = 0x01,
|
|
|
|
|
CODE_B_DECODE_ONLY_DIGIT_3_TO_0 = 0x0F,
|
|
|
|
|
CODE_B_DECOD_DIGIT_7_TO_0 = 0xFF
|
|
|
|
|
}max7219_decodeMode_t;
|
|
|
|
|
|
|
|
|
|
typedef enum{
|
|
|
|
|
DISPLAY_DIGIT_0 = 0x00,
|
|
|
|
|
DISPLAY_DIGIT_1_TO_0 = 0x01,
|
|
|
|
|
DSIPLAX_DIGIT_2_TO_0 = 0x02,
|
|
|
|
|
DSIPLAX_DIGIT_3_TO_0 = 0x03,
|
|
|
|
|
DSIPLAX_DIGIT_4_TO_0 = 0x04,
|
|
|
|
|
DSIPLAX_DIGIT_5_TO_0 = 0x05,
|
|
|
|
|
DSIPLAX_DIGIT_6_TO_0 = 0x06,
|
|
|
|
|
DSIPLAX_DIGIT_7_TO_0 = 0x07
|
|
|
|
|
}max7219_scanLimit_t;
|
|
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
|
|
spi_ch_t *spiCH;
|
|
|
|
|
}max7219_t;
|
|
|
|
@ -26,6 +44,58 @@ void max7219_testDisplay(
|
|
|
|
|
spiWriteReg(display->spiCH,0x0F, (logic) ? 0x01 : 0x00);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max7219_shutdownDiaply(
|
|
|
|
|
max7219_t *display,
|
|
|
|
|
uint8_t logic)
|
|
|
|
|
{
|
|
|
|
|
spiWriteReg(display->spiCH,0x0C, (logic) ? 0x00 : 0x01);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max7219_setDecodeMode(
|
|
|
|
|
max7219_t *display,
|
|
|
|
|
max7219_decodeMode_t dmode)
|
|
|
|
|
{
|
|
|
|
|
spiWriteReg(display->spiCH,0x09,(uint8_t) dmode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max7219_setIntensity(
|
|
|
|
|
max7219_t *display,
|
|
|
|
|
uint8_t intensity)
|
|
|
|
|
{
|
|
|
|
|
spiWriteReg(display->spiCH, 0x0A, intensity & 0x0F);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max7219_setScanLimit(
|
|
|
|
|
max7219_t *display,
|
|
|
|
|
max7219_scanLimit_t slimit)
|
|
|
|
|
{
|
|
|
|
|
spiWriteReg(display->spiCH, 0x0B, ((uint8_t) slimit) & 0x0F);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max7219_setAllLEDsOff(
|
|
|
|
|
max7219_t *display)
|
|
|
|
|
{
|
|
|
|
|
uint8_t i;
|
|
|
|
|
for(i = 0; i < 9; i++) {
|
|
|
|
|
spiWriteReg(display->spiCH, i, 0x00);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max7219_ledMatrixSetLED(
|
|
|
|
|
max7219_t *display,
|
|
|
|
|
uint8_t row,
|
|
|
|
|
uint8_t col)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
uint8_t val = 0xAE;
|
|
|
|
|
|
|
|
|
|
row = (row & 0x07) + 1;
|
|
|
|
|
col = 1 << (col & 0x07);
|
|
|
|
|
|
|
|
|
|
spiWriteReg(display->spiCH, row,col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void dispTest(max7219_t *disp)
|
|
|
|
|
{
|
|
|
|
@ -35,6 +105,7 @@ void dispTest(max7219_t *disp)
|
|
|
|
|
delayMs(500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void max7219_test_display(spi_ch_t* spi_ch)
|
|
|
|
|
{
|
|
|
|
|
// set mode to display test
|
|
|
|
@ -76,7 +147,7 @@ void max7219_test_display(spi_ch_t* spi_ch)
|
|
|
|
|
delayMs(1000);*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void max7219_setIntensity(spi_ch_t* spi_ch, uint8_t intensity)
|
|
|
|
|
void max7219_SetIntensity(spi_ch_t* spi_ch, uint8_t intensity)
|
|
|
|
|
{
|
|
|
|
|
spiWrite16bit(spi_ch, 0x0A00 | intensity);
|
|
|
|
|
}
|
|
|
|
@ -85,7 +156,7 @@ void max7219_setIntensity(spi_ch_t* spi_ch, uint8_t intensity)
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
|
|
uint8_t j = 0;
|
|
|
|
|
spi_ch_t spi_test_channel;
|
|
|
|
|
max7219_t ledMatrix;
|
|
|
|
|
|
|
|
|
@ -168,12 +239,40 @@ int main(int argc, char *argv[])
|
|
|
|
|
delayMs(50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
max7219_testDisplay(&ledMatrix,1);
|
|
|
|
|
delayMs(500);
|
|
|
|
|
max7219_testDisplay(&ledMatrix,0);
|
|
|
|
|
max7219_shutdownDiaply(&ledMatrix,0);
|
|
|
|
|
max7219_setDecodeMode(&ledMatrix, NO_DECODE_DIGIT_7_TO_0);
|
|
|
|
|
max7219_setScanLimit(&ledMatrix, DSIPLAX_DIGIT_7_TO_0);
|
|
|
|
|
max7219_setIntensity(&ledMatrix,0x01);
|
|
|
|
|
|
|
|
|
|
max7219_ledMatrixSetLED(&ledMatrix,0,0);
|
|
|
|
|
delayMs(1000);
|
|
|
|
|
max7219_setAllLEDsOff(&ledMatrix);
|
|
|
|
|
/*
|
|
|
|
|
for(i=0; i < 8; i++) {
|
|
|
|
|
max7219_ledMatrixSetLED(&ledMatrix,i,i);
|
|
|
|
|
delayMs(100);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
while(1) {
|
|
|
|
|
for(i=0; i < 0x8; i++) {
|
|
|
|
|
max7219_ledMatrixSetLED(&ledMatrix,i,i+j);
|
|
|
|
|
//delayMs(20);
|
|
|
|
|
}
|
|
|
|
|
delayMs(50);
|
|
|
|
|
j++;
|
|
|
|
|
if(j > 7) j =0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
while(1){
|
|
|
|
|
pinToggle(pinB3);
|
|
|
|
|
dispTest(&ledMatrix);
|
|
|
|
|
//max7219_test_display(&spi_test_channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
for(i = 0 ; i < 100 ; i++) {
|
|
|
|
|
pinWrite(pinB3, 1);
|
|
|
|
|
//pinWrite(pinA4,1);
|
|
|
|
|