Ejemplo n.º 1
0
// Setup
inline void LED_setup()
{
	// Register Scan CLI dictionary
	CLI_registerDictionary( ledCLIDict, ledCLIDictName );

	// Initialize I2C
	I2C_setup();

	// Zero out Frame Registers
	// This needs to be done before disabling the hardware shutdown (or the leds will do undefined things)
	LED_zeroPages( 0x0B, 1, 0x00, 0x0C ); // Control Registers

	// Disable Hardware shutdown of ISSI chip (pull high)
	GPIOB_PDDR |= (1<<16);
	PORTB_PCR16 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
	GPIOB_PSOR |= (1<<16);

	// Clear LED Pages
	LED_zeroPages( 0x00, 8, 0x00, 0xB4 ); // LED Registers

	// Enable LEDs based upon mask
	LED_sendPage( (uint8_t*)LED_ledEnableMask, sizeof( LED_ledEnableMask ), 0 );

	// Disable Software shutdown of ISSI chip
	LED_writeReg( 0x0A, 0x01, 0x0B );
}
Ejemplo n.º 2
0
// Setup
inline void LED_setup()
{
	// Register Scan CLI dictionary
	CLI_registerDictionary( ledCLIDict, ledCLIDictName );

	// Initialize I2C
	I2C_setup();

	// Zero out Frame Registers
	// This needs to be done before disabling the hardware shutdown (or the leds will do undefined things)
	LED_zeroPages( 0x0B, 1, 0x00, 0x0C ); // Control Registers

	// Disable Hardware shutdown of ISSI chip (pull high)
	GPIOB_PDDR |= (1<<16);
	PORTB_PCR16 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
	GPIOB_PSOR |= (1<<16);

	// Clear LED Pages
	LED_zeroPages( 0x00, 8, 0x00, 0xB4 ); // LED Registers

	// Enable LEDs based upon mask
	LED_sendPage( (uint8_t*)LED_ledEnableMask1, sizeof( LED_ledEnableMask1 ), 0 );

	// Set default brightness
	LED_sendPage( (uint8_t*)LED_defaultBrightness1, sizeof( LED_defaultBrightness1 ), 0 );

	// Do not disable software shutdown of ISSI chip unless current is high enough
	// Require at least 150 mA
	// May be enabled/disabled at a later time
	if ( Output_current_available() >= 150 )
	{
		// Disable Software shutdown of ISSI chip
		LED_writeReg( 0x0A, 0x01, 0x0B );
	}
}
Ejemplo n.º 3
0
void cliFunc_ledStart( char* args )
{
	print( NL ); // No \r\n by default after the command is entered
	LED_zeroPages( 0x0B, 1, 0x00, 0x0C ); // Control Registers
	//LED_zeroPages( 0x00, 8, 0x00, 0xB4 ); // LED Registers
	LED_writeReg( 0x0A, 0x01, 0x0B );
	LED_sendPage( (uint8_t*)LED_ledEnableMask1, sizeof( LED_ledEnableMask1 ), 0 );

}
Ejemplo n.º 4
0
void my_LED_write_Auto_Play_Control_Reg2() {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;
  char s[3];

  LED_writeReg( bus, addr, 0x03, fdt, ISSI_ConfigPage ); // Auto Play Control Register (0x03)
  my_LED_itoa( fdt, s );
  my_LCD_set_str( s, 3, 19 );
  my_LCD_display_image( 3 );
} // my_LED_write_Auto_Play_Control_Reg2
Ejemplo n.º 5
0
void my_LED_write_Picture_Display_Reg() {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;
  char s[3];

  LED_writeReg( bus, addr, 0x01, pfs, ISSI_ConfigPage ); // Picture Display Register (0x01)
  my_LED_itoa( pfs, s );
  my_LCD_set_str( s, 2, 4 );
  my_LCD_display_image( 3 );
} // my_LED_write_Picture_Display_Reg
Ejemplo n.º 6
0
void LED_setBrightness(uint8_t brightness) {
	LED_brightness = brightness;

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3732_define == 1 || ISSI_Chip_31FL3736_define == 1
	// Update brightness
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3736_define == 1
		LED_writeReg( bus, addr, 0x01, LED_brightness, ISSI_ConfigPage );
#elif ISSI_Chip_31FL3732_define == 1
		LED_writeReg( bus, addr, 0x04, LED_brightness, ISSI_ConfigPage );
#endif
	}
#elif ISSI_Chip_31FL3731_define == 1
	// XXX (HaaTa) - Brightness is emulated
#endif
}
Ejemplo n.º 7
0
void cliFunc_ledSet( char* args )
{
	print( NL ); // No \r\n by default after the command is entered

	char* curArgs;
	char* arg1Ptr;
	char* arg2Ptr = args;

	// Process speed argument if given
	curArgs = arg2Ptr;
	CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );

	// Reset brightness
	if ( *arg1Ptr == '\0' )
	{
		LED_brightness = ISSI_Global_Brightness_define;
	}
	else
	{
		LED_brightness = numToInt( arg1Ptr );
	}

	info_msg("LED Brightness Set");

#if ISSI_Chip_31FL3733_define || ISSI_Chip_31FL3732_define
	// Update brightness
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1
		LED_writeReg( bus, addr, 0x01, LED_brightness, ISSI_ConfigPage );
#elif ISSI_Chip_31FL3732_define == 1
		LED_writeReg( bus, addr, 0x04, LED_brightness, ISSI_ConfigPage );
#elif ISSI_Chip_31FL3731_define == 1
		// XXX (HaaTa) - This is emulated, see LED_scan and LED_linkedSend for implementation
#endif
	}
#endif
}
Ejemplo n.º 8
0
void my_LED_write_Breath_Control_Reg1() {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;
  uint8_t fot_fit;
  char s[3];

  fot_fit = ( fot << 4 ) | fit;
  LED_writeReg( bus, addr, 0x08, fot_fit, ISSI_ConfigPage ); // Breath Control Register 1 (0x08)
  my_LED_itoa( fot, s ); my_LCD_set_str( s, 4, 14 );
  my_LED_itoa( fit, s ); my_LCD_set_str( s, 4,  9 );
  my_LCD_display_image( 3 );
} // my_LED_write_Breath_Control_Reg1
Ejemplo n.º 9
0
void my_LED_write_Auto_Play_Control_Reg1() {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;
  uint8_t cns_fns;
  char s[3];

  cns_fns = ( cns << 4 ) | fns;
  LED_writeReg( bus, addr, 0x02, cns_fns, ISSI_ConfigPage ); // Auto Play Control Register (0x02)
  my_LED_itoa( cns, s ); my_LCD_set_str( s, 3,  9 );
  my_LED_itoa( fns, s ); my_LCD_set_str( s, 3, 14 );
  my_LCD_display_image( 3 );
} // my_LED_write_Auto_Play_Control_Reg1
Ejemplo n.º 10
0
void my_LED_write_Configuration_Reg() {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;
  uint8_t mode_fs;
  char s[3];

  mode_fs = ( mode << 3 ) | fs;
  LED_writeReg( bus, addr, 0x00, mode_fs, ISSI_ConfigPage ); // Configuration Register (0x00)
  my_LED_itoa( mode, s ); my_LCD_set_str( s, 1, 19 );
  my_LED_itoa(   fs, s ); my_LCD_set_str( s, 3,  4 );
  my_LCD_display_image( 3 );
} // my_LED_write_Configuration_Reg
Ejemplo n.º 11
0
void my_LED_write_Breath_Control_Reg2() {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;
  uint8_t b_en_et;
  char s[3];

  b_en_et = ( b_en << 4 ) | et;
  LED_writeReg( bus, addr, 0x09, b_en_et, ISSI_ConfigPage ); // Breath Control Register 2 (0x09)
  my_LED_itoa( b_en, s ); my_LCD_set_str( s, 4,  4 );
  my_LED_itoa(   et, s ); my_LCD_set_str( s, 4, 19 );
  my_LCD_display_image( 3 );
} // my_LED_write_Breath_Control_Reg2
Ejemplo n.º 12
0
inline uint8_t LED_scan()
{
	// Check for current change event
	if ( LED_currentEvent )
	{
		// TODO dim LEDs in low power mode instead of shutting off
		if ( LED_currentEvent < 150 )
		{
			// Enable Software shutdown of ISSI chip
			LED_writeReg( 0x0A, 0x00, 0x0B );
		}
		else
		{
			// Disable Software shutdown of ISSI chip
			LED_writeReg( 0x0A, 0x01, 0x0B );
		}

		LED_currentEvent = 0;
	}

	return 0;
}
Ejemplo n.º 13
0
void my_LED_write_Display_Option_Reg() {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;
  uint8_t ic_be_bpt;
  char s[3];

  ic_be_bpt = ( ic << 5 ) | ( be << 3 ) | bpt;
  LED_writeReg( bus, addr, 0x05, ic_be_bpt, ISSI_ConfigPage ); // Display Option Register (0x05)
  my_LED_itoa(  ic, s ); my_LCD_set_str( s, 2,  9 );
  my_LED_itoa(  be, s ); my_LCD_set_str( s, 2, 14 );
  my_LED_itoa( bpt, s ); my_LCD_set_str( s, 2, 19 );
  my_LCD_display_image( 3 );
} // my_LED_write_Display_Option_Reg
Ejemplo n.º 14
0
// Read address
uint8_t LED_readReg( uint8_t bus, uint8_t addr, uint8_t reg, uint8_t page )
{
	/*
	info_msg("I2C Read Bus: ");
	printHex( bus );
	print(" Addr: ");
	printHex( addr );
	print(" Reg: ");
	printHex( reg );
	print(" Page: ");
	printHex( page );
	print( NL );
	*/

#if ISSI_Chip_31FL3731_define == 1 || ISSI_Chip_31FL3732_define == 1
	// Software shutdown must be enabled to read registers
	LED_writeReg( bus, addr, 0x0A, 0x00, ISSI_ConfigPage );
#endif

	// Setup page
	LED_setupPage( bus, addr, page );

	// Register Read Command
	uint16_t regReadCmd[] = { addr, reg, I2C_RESTART, addr | 0x1, I2C_READ };
	uint8_t recv_data;

	// Request single register byte
	while ( i2c_read( bus, regReadCmd, sizeof( regReadCmd ) / 2, &recv_data ) == -1 )
		delay_us( ISSI_SendDelay );

#if ISSI_Chip_31FL3731_define == 1 || ISSI_Chip_31FL3732_define == 1
	// Disable software shutdown
	LED_writeReg( bus, addr, 0x0A, 0x01, ISSI_ConfigPage );
#endif

	return recv_data;
}
Ejemplo n.º 15
0
void LED_readPage( uint8_t len, uint8_t page )
{
	// Software shutdown must be enabled to read registers
	LED_writeReg( 0x0A, 0x00, 0x0B );

	// Page Setup
	uint8_t pageSetup[] = { 0xE8, 0xFD, page };

	// Setup page
	while ( I2C_Send( pageSetup, sizeof( pageSetup ), 0 ) == 0 )
		delay(1);

	// Register Setup
	uint8_t regSetup[] = { 0xE8, 0x00 };

	// Read each register in the page
	for ( uint8_t reg = 0; reg < len; reg++ )
	{
		// Update register to read
		regSetup[1] = reg;

		// Configure register
		while ( I2C_Send( regSetup, sizeof( regSetup ), 0 ) == 0 )
			delay(1);

		// Register Read Command
		uint8_t regReadCmd[] = { 0xE9 };

		// Request single register byte
		while ( I2C_Send( regReadCmd, sizeof( regReadCmd ), 1 ) == 0 )
			delay(1);
		dbug_print("NEXT");
	}

	// Disable software shutdown
	LED_writeReg( 0x0A, 0x01, 0x0B );
}
Ejemplo n.º 16
0
// Detect short or open circuit in Matrix
// Only works with IS31FL3733
void LED_shortOpenDetect()
{
#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3736_define == 1
	// Pause ISSI processing
	LED_pause = 1;

	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

		// Set Global Current Control (needed for accurate reading)
		LED_writeReg( bus, addr, 0x01, 0x01, ISSI_ConfigPage );

		// Enable master sync for the first chip and disable software shutdown
		// Also enable OSD (Open/Short Detect)
		if ( ch == 0 )
		{
			LED_writeReg( bus, addr, 0x00, 0x45, ISSI_ConfigPage );
		}
		// Slave sync for the rest and disable software shutdown
		// Also enable OSD (Open/Short Detect)
		else
		{
			LED_writeReg( bus, addr, 0x00, 0x85, ISSI_ConfigPage );
		}

		// Wait for 3.3 ms before reading the value
		// Needs at least 3.264 ms to query the information
		delay_us(3300);

		// Read registers
		info_msg("Bus: ");
		printHex( bus );
		print(" Addr: ");
		printHex( addr );
		print(" - 0x18 -> 0x2F + 0x30 -> 0x47");
		print(NL);

		// Validate open detection
		// TODO
		for ( uint8_t reg = 0x18; reg < 0x30; reg++ )
		{
			uint8_t val = LED_readReg( bus, addr, reg, ISSI_LEDControlPage );
			printHex_op( val, 2 );
			print(" ");
		}
		print(NL);

		// Validate short detection
		// TODO
		for ( uint8_t reg = 0x30; reg < 0x48; reg++ )
		{
			uint8_t val = LED_readReg( bus, addr, reg, ISSI_LEDControlPage );
			printHex_op( val, 2 );
			print(" ");
		}
		print(NL);
	}

	// We have to adjust various settings in order to get the correct reading
	// Reset ISSI configuration
	LED_reset();
#endif
}
Ejemplo n.º 17
0
void LED_reset()
{
	// Force PixelMap to stop during reset
	Pixel_FrameState = FrameState_Sending;

	// Disable FPS by default
	LED_displayFPS = 0;

	// Enable Hardware shutdown (pull low)
	GPIO_Ctrl( hardware_shutdown_pin, GPIO_Type_DriveSetup, GPIO_Config_Pullup );
	GPIO_Ctrl( hardware_shutdown_pin, GPIO_Type_DriveLow, GPIO_Config_Pullup );
	delay_us(50);

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3736_define == 1
	// Reset I2C bus
	GPIO_Ctrl( iirst_pin, GPIO_Type_DriveSetup, GPIO_Config_Pullup );
	GPIO_Ctrl( iirst_pin, GPIO_Type_DriveHigh, GPIO_Config_Pullup );
	delay_us(50);
	GPIO_Ctrl( iirst_pin, GPIO_Type_DriveLow, GPIO_Config_Pullup );
#endif

	// Disable Hardware shutdown of ISSI chips (pull high)
	if ( LED_enable && LED_enable_current )
	{
		GPIO_Ctrl( hardware_shutdown_pin, GPIO_Type_DriveHigh, GPIO_Config_Pullup );
	}

	// Clear LED Pages
	// Enable LEDs based upon mask
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3736_define == 1
		// POR (Power-on-Reset)
		// Clears all registers to default value (i.e. zeros)
		LED_readReg( bus, addr, 0x11, ISSI_ConfigPage );

		// Set the enable mask
		LED_sendPage(
			bus,
			addr,
			(uint16_t*)&LED_ledEnableMask[ ch ],
			sizeof( LED_EnableBuffer ) / 2,
			0
		);
#else
		// Clear LED control pages
		LED_zeroPages( bus, addr, 0x00, ISSI_LEDPages, 0x00, ISSI_PageLength ); // LED Registers

		// Copy enable mask to send buffer
		for ( uint8_t reg = 0; reg < LED_EnableBufferLength; reg++ )
		{
			LED_pageBuffer[ ch ].ledctrl[ reg ] =  LED_ledEnableMask[ ch ].buffer[ reg ];
		}
#endif
	}

	// Reset global brightness
	LED_brightness = settings.brightness;

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3736_define == 1
	// Enable pull-up and pull-down anti-ghosting resistors
	// Set global brightness control
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

		LED_writeReg( bus, addr, 0x01, LED_brightness, ISSI_ConfigPage );
		LED_writeReg( bus, addr, 0x0F, 0x07, ISSI_ConfigPage ); // Pull-up
		LED_writeReg( bus, addr, 0x10, 0x07, ISSI_ConfigPage ); // Pull-down
	}
#elif ISSI_Chip_31FL3732_define == 1
	// Set global brightness control
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

		LED_writeReg( bus, addr, 0x04, LED_brightness, ISSI_ConfigPage );
	}
#endif

	// Setup ISSI frame and sync modes; then disable software shutdown
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3736_define == 1
		// Enable master sync for the last chip and disable software shutdown
		// XXX (HaaTa); The last chip is used as it is the last chip all of the frame data is sent to
		// This is imporant as it may take more time to send the packet than the ISSI chip can handle
		// between frames.
		if ( ch == ISSI_Chips_define - 1 )
		{
			LED_writeReg( bus, addr, 0x00, 0x41, ISSI_ConfigPage );
		}
		// Slave sync for the rest and disable software shutdown
		else
		{
			LED_writeReg( bus, addr, 0x00, 0x81, ISSI_ConfigPage );
		}

#elif ISSI_Chip_31FL3732_define == 1
		// Enable master sync for the first chip
		if ( ch == 0 )
		{
			LED_writeReg( bus, addr, 0x00, 0x40, ISSI_ConfigPage );
		}
		// Slave sync for the rest
		else
		{
			LED_writeReg( bus, addr, 0x00, 0x80, ISSI_ConfigPage );
		}

		// Disable Software shutdown of ISSI chip
		LED_writeReg( bus, addr, 0x0A, 0x01, ISSI_ConfigPage );
#else
		// Set MODE to Picture Frame
		LED_writeReg( bus, addr, 0x00, 0x00, ISSI_ConfigPage );

		// Disable Software shutdown of ISSI chip
		LED_writeReg( bus, addr, 0x0A, 0x01, ISSI_ConfigPage );
#endif
	}

	// Force PixelMap to be ready for the next frame
	Pixel_FrameState = FrameState_Update;

	// Un-pause ISSI processing
	LED_pause = 0;
}
Ejemplo n.º 18
0
void LED_control( LedControl control, uint8_t arg )
{
	switch ( control )
	{
	case LedControl_brightness_decrease_all:
		LED_enable = 1;
		// Only decrease to zero
		if ( LED_brightness - arg < 0 )
			LED_brightness = 0;
		else
			LED_brightness -= arg;
		break;

	case LedControl_brightness_increase_all:
		LED_enable = 1;
		// Only increase to max
		if ( LED_brightness + arg > 0xFF )
			LED_brightness = 0xFF;
		else
			LED_brightness += arg;
		break;

	case LedControl_brightness_set_all:
		LED_enable = 1;
#if ISSI_Chip_31FL3731_define == 1
		LED_brightness = ISSI_Global_Brightness_define;
#else
		LED_brightness = arg;
#endif
		break;

	case LedControl_off:
		LED_enable = 0;
		return;

	case LedControl_on:
		LED_enable = 1;
		return;

	case LedControl_toggle:
		LED_enable = !LED_enable;
		return;
	}

#if ISSI_Chip_31FL3733_define || ISSI_Chip_31FL3732_define
	// Update brightness
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1
		LED_writeReg( bus, addr, 0x01, LED_brightness, ISSI_ConfigPage );
#elif ISSI_Chip_31FL3732_define == 1
		LED_writeReg( bus, addr, 0x04, LED_brightness, ISSI_ConfigPage );
#elif ISSI_Chip_31FL3731_define == 1
		// XXX (HaaTa) - This is emulated, see LED_scan for implementation
#endif
	}
#endif
}
Ejemplo n.º 19
0
void LED_control( LedControl control, uint8_t arg )
{
	switch ( control )
	{
	case LedControl_brightness_decrease_all:
		LED_enable = 1;
		// Only decrease to zero
		if ( LED_brightness - arg < 0 )
		{
			LED_brightness = 0;
		}
		else
		{
			LED_brightness -= arg;
		}
		break;

	case LedControl_brightness_increase_all:
		LED_enable = 1;
		// Only increase to max
		if ( LED_brightness + arg > 0xFF )
		{
			LED_brightness = 0xFF;
		}
		else
		{
			LED_brightness += arg;
		}
		break;

	case LedControl_brightness_set_all:
		LED_enable = 1;
		LED_brightness = arg;
		break;

	case LedControl_off:
		LED_enable = 0;
		return;

	case LedControl_on:
		LED_enable = 1;
		return;

	case LedControl_toggle:
		LED_enable = !LED_enable;
		return;

	case LedControl_set_fps:
		LED_framerate = (uint32_t)arg;
		return;

	case LedControl_increase_fps:
		if ( LED_framerate > 0 )
		{
			// Smaller timeout, higher FPS
			LED_framerate -= arg;
		}
		return;

	case LedControl_decrease_fps:
		if ( LED_framerate < 0xFF )
		{
			// Higher timeout, lower FPS
			LED_framerate += arg;
		}
		return;

	case LedControl_default_fps:
		LED_framerate = ISSI_FrameRate_ms_define;
		return;

	case LedControl_brightness_default:
		LED_brightness = ISSI_Global_Brightness_define;
		return;
	}

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3732_define == 1 || ISSI_Chip_31FL3736_define == 1
	// Update brightness
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1 || ISSI_Chip_31FL3736_define == 1
		LED_writeReg( bus, addr, 0x01, LED_brightness, ISSI_ConfigPage );
#elif ISSI_Chip_31FL3732_define == 1
		LED_writeReg( bus, addr, 0x04, LED_brightness, ISSI_ConfigPage );
#endif
	}
#elif ISSI_Chip_31FL3731_define == 1
	// XXX (HaaTa) - Brightness is emulated
#endif
}
Ejemplo n.º 20
0
void LED_reset()
{
	// Force PixelMap to stop during reset
	Pixel_FrameState = FrameState_Sending;

	// Disable FPS by default
	LED_displayFPS = 0;

#if ISSI_Chip_31FL3733_define == 1
	// Reset I2C bus
	GPIOC_PSOR |= (1<<5);
	delay_us(200);
	GPIOC_PCOR |= (1<<5);
#endif

	// Clear LED Pages
	// Enable LEDs based upon mask
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1
		// POR (Power-on-Reset)
		// Clears all registers to default value (i.e. zeros)
		LED_readReg( bus, addr, 0x11, ISSI_ConfigPage );
#else
		// Clear LED control pages
		LED_zeroPages( bus, addr, 0x00, ISSI_LEDPages, 0x00, ISSI_PageLength ); // LED Registers
#endif

		// Set the enable mask
		LED_sendPage(
			bus,
			addr,
			(uint16_t*)&LED_ledEnableMask[ ch ],
			sizeof( LED_EnableBuffer ) / 2,
			0
		);
	}

#if ISSI_Chip_31FL3733_define == 1
	// Enable pull-up and pull-down anti-ghosting resistors
	// Set global brightness control
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

		LED_writeReg( bus, addr, 0x01, LED_brightness, ISSI_ConfigPage );
		LED_writeReg( bus, addr, 0x0F, 0x07, ISSI_ConfigPage ); // Pull-up
		LED_writeReg( bus, addr, 0x10, 0x07, ISSI_ConfigPage ); // Pull-down
	}
#elif ISSI_Chip_31FL3732_define == 1
	// Set global brightness control
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

		LED_writeReg( bus, addr, 0x04, LED_brightness, ISSI_ConfigPage );
	}
#endif

	// Setup ISSI frame and sync modes; then disable software shutdown
	for ( uint8_t ch = 0; ch < ISSI_Chips_define; ch++ )
	{
		uint8_t addr = LED_ChannelMapping[ ch ].addr;
		uint8_t bus = LED_ChannelMapping[ ch ].bus;

#if ISSI_Chip_31FL3733_define == 1
		// Enable master sync for the first chip and disable software shutdown
		if ( ch == 0 )
		{
			LED_writeReg( bus, addr, 0x00, 0x41, ISSI_ConfigPage );
		}
		// Slave sync for the rest and disable software shutdown
		else
		{
			LED_writeReg( bus, addr, 0x00, 0x81, ISSI_ConfigPage );
		}

#elif ISSI_Chip_31FL3732_define == 1
		// Enable master sync for the first chip
		if ( ch == 0 )
		{
			LED_writeReg( bus, addr, 0x00, 0x40, ISSI_ConfigPage );
		}
		// Slave sync for the rest
		else
		{
			LED_writeReg( bus, addr, 0x00, 0x80, ISSI_ConfigPage );
		}

		// Disable Software shutdown of ISSI chip
		LED_writeReg( bus, addr, 0x0A, 0x01, ISSI_ConfigPage );
#else
		// Set MODE to Picture Frame
		LED_writeReg( bus, addr, 0x00, 0x00, ISSI_ConfigPage );

		// Disable Software shutdown of ISSI chip
		LED_writeReg( bus, addr, 0x0A, 0x01, ISSI_ConfigPage );
#endif
	}

	// Force PixelMap to be ready for the next frame
	Pixel_FrameState = FrameState_Update;

	// Un-pause ISSI processing
	LED_pause = 0;
}