// Example Configuration function for Pseudo-Switch Analogue Switch Board from OmberTech
// 2018 OmberTech. No warranty. May be used for any purpose.


#define MICROSECOND		// Approximate number of execution cycles required for CPU to complete "for" loop in microsleep function

// Microcontroller outputs connected to Pseudo-Switch:
#define	CLOCK		
#define	RESET		
#define	INHIBIT		


// Delay for specified number of microseconds (alternatively use hardware timer):
void microsleep (unsigned int microseconds)
{
        unsigned long i;
	while ( microseconds-- )
		for ( i = 0 ; i < MICROSECOND ; i++ );
}


// Modify Pseudo-Switch configuration:
void pseudosw ( unsigned int clk,	// Number of switch positions to be advanced
		char rst,			// If 1, reset switch position to "A" before advancing position. Else 0.
		char inh )			// If 1, enable Inhibit mode (no switch contacts selected). If 0, disable Inhibit mode.
{
	INHIBIT = inh;
	if (rst)
		{
			RESET = 1;
			RESET = 0;
			microsleep (5); // Ensure Reset has been disabled
		}
	
	for ( ; clk > 0 ; clk-- )
		{
			CLOCK = 1;
			CLOCK = 0;
		}
	microsleep (5); // Wait for switching time
}
