Ejemplo n.º 1
0
void cliFunc_current( char* args )
{
	print( NL );
	info_msg("Current available: ");
	printInt16( Output_current_available() );
	print(" mA");
}
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
uint8_t Connect_receive_IdReport( uint8_t id, uint16_t *pending_bytes, uint8_t uart_num )
{
	dbug_print("IdReport");
	// Check the directionality
	if ( uart_num == UART_Master )
	{
		erro_print("Invalid IdRequest direction...");
	}

	// Track Id response if master
	if ( Connect_master )
	{
		info_msg("Id Reported: ");
		printHex( id );
		print( NL );

		// Check if this is the highest ID
		if ( id > Connect_maxId )
		{
			Connect_maxId = id;
		}

		// Send available current
		Connect_currentChange( Output_current_available() );

		return 1;
	}
	// Propagate id if yet another slave
	else
	{
		Connect_send_IdReport( id );
	}

	return 1;
}
Ejemplo n.º 4
0
// Update external current (mA)
// Triggers power change event
void Output_update_external_current( unsigned int current )
{
	// Only signal if changed
	if ( current == Output_ExtCurrent_Available )
		return;

	// Update external current
	Output_ExtCurrent_Available = current;

	unsigned int total_current = Output_current_available();
	info_msg("External Available Current Changed. Total Available: ");
	printInt32( total_current );
	print(" mA" NL);

	// Send new total current to the Scan Modules
	Scan_currentChange( Output_current_available() );
}
Ejemplo n.º 5
0
// Update USB current (mA)
// Triggers power change event
void Output_update_usb_current( unsigned int current )
{
	// Only signal if changed
	if ( current == Output_USBCurrent_Available )
		return;

	// Update USB current
	Output_USBCurrent_Available = current;

	/* XXX Affects sleep states due to USB messages
	unsigned int total_current = Output_current_available();
	info_msg("USB Available Current Changed. Total Available: ");
	printInt32( total_current );
	print(" mA" NL);
	*/

	// Send new total current to the Scan Modules
	Scan_currentChange( Output_current_available() );
}
Ejemplo n.º 6
0
uint8_t Connect_receive_CableCheck( uint8_t byte, uint16_t *pending_bytes, uint8_t uart_num )
{
	// Check if this is the first byte
	if ( *pending_bytes == BYTE_COUNT_START )
	{
		*pending_bytes = byte;

		if ( Connect_debug )
		{
			dbug_msg("PENDING SET -> ");
			printHex( byte );
			print(" ");
			printHex( *pending_bytes );
			print( NL );
		}
	}
	// Verify byte
	else
	{
		(*pending_bytes)--;

		// The argument bytes are always 0xD2 (11010010)
		if ( byte != CABLE_CHECK_ARG )
		{
			warn_print("Cable Fault!");

			// Check which side of the chain
			if ( uart_num == UART_Slave )
			{
				Connect_cableFaultsSlave++;
				Connect_cableOkSlave = 0;
				print(" Slave ");
			}
			else
			{
				// Lower current requirement during errors
				// Half of USB negotiation minimum (50 mA)
				// Only if this is not the master node
				if ( Connect_id != 0 )
				{
					Output_update_external_current( 50 );
				}

				Connect_cableFaultsMaster++;
				Connect_cableOkMaster = 0;
				print(" Master ");
			}
			printHex( byte );
			print( NL );

			// Signal that the command should wait for a SYN again
			return 1;
		}
		else
		{
			// Check which side of the chain
			if ( uart_num == UART_Slave )
			{
				Connect_cableChecksSlave++;
			}
			else
			{
				// If we already have an Id, then set max current again
				if ( Connect_id != 255 && Connect_id != 0 )
				{
					Output_update_external_current( Output_current_available() );
				}
				Connect_cableChecksMaster++;
			}
		}
	}

	// If cable check was successful, set cable ok
	if ( *pending_bytes == 0 )
	{
		if ( uart_num == UART_Slave )
		{
			Connect_cableOkSlave = 1;
		}
		else
		{
			Connect_cableOkMaster = 1;
		}
	}

	if ( Connect_debug )
	{
		dbug_msg("CABLECHECK RECEIVE - ");
		printHex( byte );
		print(" ");
		printHex( *pending_bytes );
		print( NL );
	}

	// Check whether the cable check has finished
	return *pending_bytes == 0 ? 1 : 0;
}