only a few changes to led1642gw code
This commit is contained in:
		
							
								
								
									
										25
									
								
								led1642gw.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								led1642gw.c
									
									
									
									
									
								
							@@ -16,6 +16,7 @@
 | 
			
		||||
 | 
			
		||||
#include "led1642gw_config.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define NUM_LED1642GW_CHANNELS (16) // number of LED channels per IC
 | 
			
		||||
 | 
			
		||||
//total numer of channels. needed to calculate the buffer size.
 | 
			
		||||
@@ -40,26 +41,28 @@ static void write_data(uint16_t data, uint8_t le_clocks)
 | 
			
		||||
{
 | 
			
		||||
  uint16_t mask = 0x8000;
 | 
			
		||||
  int8_t bit;
 | 
			
		||||
 | 
			
		||||
  SET_CLK_L(); 
 | 
			
		||||
  SET_LE_L();
 | 
			
		||||
  for (bit=15; bit>=le_clocks; bit--) {
 | 
			
		||||
	SET_CLK_L(); 
 | 
			
		||||
    if(data&mask) { SET_SDI_H(); }
 | 
			
		||||
    else { SET_SDI_L(); }
 | 
			
		||||
	SET_CLK_H();
 | 
			
		||||
    mask >>= 1;
 | 
			
		||||
	SET_CLK_L(); 
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  SET_LE_H();
 | 
			
		||||
  for (/*noting to initialize*/; bit>=0; bit--) {
 | 
			
		||||
	SET_CLK_L();
 | 
			
		||||
    if(data&mask) { SET_SDI_H(); }
 | 
			
		||||
    else { SET_SDI_L(); }
 | 
			
		||||
	SET_CLK_H();
 | 
			
		||||
    mask >>= 1;
 | 
			
		||||
	SET_CLK_L();
 | 
			
		||||
 }
 | 
			
		||||
  
 | 
			
		||||
  // set all pins to low after transmission
 | 
			
		||||
  SET_CLK_L();
 | 
			
		||||
  //SET_CLK_L();
 | 
			
		||||
  SET_LE_L();
 | 
			
		||||
  SET_SDI_L();
 | 
			
		||||
  
 | 
			
		||||
@@ -148,9 +151,11 @@ void led1642gw_set_gain(uint8_t gain)
 | 
			
		||||
    gain = 0x3f;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs-1); ic++) {
 | 
			
		||||
  uint16_t g = gain;
 | 
			
		||||
 | 
			
		||||
  for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs); ic++) {
 | 
			
		||||
    config_reg[ic] &= ~(0x003f);
 | 
			
		||||
    config_reg[ic] |=  gain;
 | 
			
		||||
    config_reg[ic] |=  g;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -158,9 +163,11 @@ void led1642gw_set_gain(uint8_t gain)
 | 
			
		||||
 | 
			
		||||
void led1642gw_set_current_mode(uint8_t mode)
 | 
			
		||||
{
 | 
			
		||||
  for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs-1); ic++) {
 | 
			
		||||
    if (mode) { config_reg[ic] |= (1<<6); }
 | 
			
		||||
    else { config_reg[ic] &= ~(1<<6); }
 | 
			
		||||
	uint16_t mask = (1<<6);
 | 
			
		||||
 | 
			
		||||
  for (uint8_t ic=0; ic<(NUM_LED1642GW_ICs); ic++) {
 | 
			
		||||
    if (mode) { config_reg[ic] |= mask; }
 | 
			
		||||
    else { config_reg[ic] &= ~mask; }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -209,7 +216,7 @@ void led1642gw_flush(void)
 | 
			
		||||
	  // then, when the brightness data has propagated through the
 | 
			
		||||
	  // shift registers, write all data into the DATA LATCH of
 | 
			
		||||
	  // all of the ICs.
 | 
			
		||||
	  write_data_latch(ledbuffer[channel+(ic*NUM_LED1642GW_CHANNELS)]);
 | 
			
		||||
	  write_data_latch(ledbuffer[channel+(NUM_LED1642GW_CHANNELS*ic)]);
 | 
			
		||||
  }
 | 
			
		||||
  // for the 16th channel, we don't write to the DATA LATCH, but
 | 
			
		||||
  // to the CLOBAL data latch.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user