code/WPILib/DigitalModule.cpp
/**
 * Allocate Digital I/O channels.
 * Allocate channels so that they are not accidently reused. Also the direction is set at the
 * time of the allocation.
 */
Allocate Digital I/O channels.
Allocate channels so that they are not accidently reused. Also the direction is set at the
time of the allocation.
Allocate Digital I / O channels . Allocate channels so that they are not accidently reused . Also the direction is set at the time of the allocation .
bool DigitalModule::AllocateDIO(UINT32 channel, bool input)
{
	status = 0;
	DIOChannels->Allocate(kDigitalChannels * SlotToIndex(m_slot) + channel - 1);
	UINT32 outputEnable = m_fpgaDIO->readOutputEnable(&status);
	UINT32 bitToSet = 1 << (RemapDigitalChannel(channel - 1));
	UINT32 outputEnableValue;
	if (input)
	{
		outputEnableValue = outputEnable & (~ bitToSet ); 
	}
	else
	{
		outputEnableValue = outputEnable | bitToSet; 
	}
	m_fpgaDIO->writeOutputEnable(outputEnableValue, &status);
	wpi_assertCleanStatus(status);
	return true;
}
bool DigitalModule :: AllocateDIO ( UINT32 channel , bool input ) { status = 0 ; DIOChannels -> Allocate ( kDigitalChannels * SlotToIndex ( m_slot ) + channel - 1 ) ; UINT32 outputEnable = m_fpgaDIO -> readOutputEnable ( & status ) ; UINT32 bitToSet = 1 << ( RemapDigitalChannel ( channel - 1 ) ) ; UINT32 outputEnableValue ; if ( input ) { outputEnableValue = outputEnable & ( ~ bitToSet ) ; } else { outputEnableValue = outputEnable | bitToSet ; } m_fpgaDIO -> writeOutputEnable ( outputEnableValue , & status ) ; wpi_assertCleanStatus ( status ) ; return true ; }
Allocate Digital I/O channels.
Allocate Digital I / O channels .
// clear the bit for read // set the bit for write