Please I want to modify this code to turn on a particular group of LEDs at a particular time. I have give some suggestions here. Please I will appreciate if some one can help me
Code:
#include "usartSPI.h"#include "tlc5971_poecie.h"
#include <avr/io.h>
// The sendBits() is used to send bits to address of the particular struct
void sendBits(struct TLC5971 *ptlc) /* ptlc points to the struct TLC5971 */
{
uint8_t n, *p = (uint8_t*)ptlc; /* copy the structure pointed to by ptlc to the structure pointed to by p*/
for (n = 28; n-- > 0; ) /* Looping 28 times to send the 28 bytes for one LED driver */
{
usartSPI_transfer(p[n]); /* Using SPI to send each of the 28 bytes */
}
}
int main(void)
{
static struct TLC5971 tlcarray[22]; /* Declare an array of 22 structure TLC5971 */
struct TLC5971 *ptlc; /* ptlc is a pointer to a structure */
ptlc = &tlcarray[0]; /* ptlc is assigned the address of tlcarray[0] */
ptlc->BCR = 3;
ptlc->BCG = 3;
ptlc->BCB = 3;
ptlc->TMGRST = 1;
ptlc->EXTGCK = 1;
ptlc->cmd = 0x25;
ptlc->GS[0][BLUE] = 0x1000; // OUTB0
ptlc->GS[0][GREEN] = 0x1000; // OUTG0
ptlc->GS[0][RED] = 0x1000; // OUTR0
ptlc->GS[1][BLUE] = 0x1000; // OUTB1
ptlc->GS[1][GREEN] = 0x1000; // OUTG1
ptlc->GS[1][RED] = 0x1000; // OUTR1
ptlc->GS[2][BLUE] = 0x1000; // OUTB2
ptlc->GS[2][GREEN] = 0x1000; // OUTG2
ptlc->GS[2][RED] = 0x1000; // OUTR2
ptlc->GS[3][BLUE] = 0x1000; // OUTB3
ptlc->GS[3][GREEN] = 0x1000; // OUTG3
ptlc->GS[3][RED] = 0x1000; // OUTR3
usartSPI_init();
while (1)
{
/*
for (uint8_t testCase = 0; testCase < 3 ; testCase++)
{
switch(testCase)
{
case 0: tlcarray[0];
tlcarray[1];
tlcarray[2];
tlcarray[3];
tlcarray[4];
tlcarray[5];
tlcarray[6];
tlcarray[7];
break;
case 1: tlcarray[8];
tlcarray[9];
tlcarray[10];
tlcarray[11];
tlcarray[12];
tlcarray[13];
tlcarray[14];
tlcarray[15];
break;
case 2: tlcarray[16];
tlcarray[17];
tlcarray[18];
tlcarray[19];
tlcarray[20];
tlcarray[21];
break;
default:
break;
}
while (1)
{
sendBits(&tlcarray[testCase]);
break;
}
_delay_ms(500);
}
*/
for (uint8_t num = 0; num <22 ; num++) // Number of LED drivers
{
sendBits(&tlcarray[num]); // For First TLC5971
}
// Stop SCKI at high or Low for 8 times the period between 224*N
PORTD &= ~(1 << PD4);
_delay_us(5); // Atleast: 8*Period T + 1.34us
// Send one SCKI clock with SDTI Low after 1.34us
PORTD |= (1 << PD4);
PORTD &= ~(1 << PD3);
// OUTXn are Turned ON
tlc5971.BLANK = 0;
}
}