Exemplo 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_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 );
	}
}
Exemplo 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_ledEnableMask, sizeof( LED_ledEnableMask ), 0 );

	// Disable Software shutdown of ISSI chip
	LED_writeReg( 0x0A, 0x01, 0x0B );
}
Exemplo n.º 3
0
void my_LED_write_page( uint16_t *brightness, uint32_t len, uint8_t page ) {
  int ch = 0;
  uint8_t bus  = LED_ChannelMapping[ ch ].bus;
  uint8_t addr = LED_ChannelMapping[ ch ].addr;

  LED_sendPage( bus, addr, brightness, len, page );
  delay_ms( 30 ); // wait 30[ms]
} // my_LED_write_page
Exemplo n.º 4
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 );

}
Exemplo n.º 5
0
void LED_control( LedControl *control )
{
	// Only send if we've completed all other transactions
	/*
	if ( I2C_TxBuffer.sequencePos > 0 )
		return;
	*/

	// Configure based upon the given mode
	// TODO Perhaps do gamma adjustment?
	switch ( control->mode )
	{
	case LedControlMode_brightness_decrease:
		// Don't worry about rolling over, the cycle is quick
		LED_pageBuffer.buffer[ control->index ] -= control->amount;
		break;

	case LedControlMode_brightness_increase:
		// Don't worry about rolling over, the cycle is quick
		LED_pageBuffer.buffer[ control->index ] += control->amount;
		break;

	case LedControlMode_brightness_set:
		LED_pageBuffer.buffer[ control->index ] = control->amount;
		break;

	case LedControlMode_brightness_decrease_all:
		for ( uint8_t channel = 0; channel < LED_TotalChannels; channel++ )
		{
			// Don't worry about rolling over, the cycle is quick
			LED_pageBuffer.buffer[ channel ] -= control->amount;
		}
		break;

	case LedControlMode_brightness_increase_all:
		for ( uint8_t channel = 0; channel < LED_TotalChannels; channel++ )
		{
			// Don't worry about rolling over, the cycle is quick
			LED_pageBuffer.buffer[ channel ] += control->amount;
		}
		break;

	case LedControlMode_brightness_set_all:
		for ( uint8_t channel = 0; channel < LED_TotalChannels; channel++ )
		{
			LED_pageBuffer.buffer[ channel ] = control->amount;
		}
		break;
	}

	// Sync LED buffer with ISSI chip buffer
	// TODO Support multiple frames
	LED_pageBuffer.i2c_addr = 0xE8; // Chip 1
	LED_pageBuffer.reg_addr = 0x24; // Brightness section
	LED_sendPage( (uint8_t*)&LED_pageBuffer, sizeof( LED_Buffer ), 0 );
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
0
void cliFunc_ledTest( char* args )
{
	print( NL ); // No \r\n by default after the command is entered
	LED_sendPage( (uint8_t*)LED_defaultBrightness1, sizeof( LED_defaultBrightness1 ), 0 );
}
Exemplo n.º 8
0
void cliFunc_ledTest( char* args )
{
	print( NL ); // No \r\n by default after the command is entered
	LED_sendPage( (uint8_t*)examplePage, sizeof( examplePage ), 0 );
}
Exemplo n.º 9
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;
}