/****************************************************************

This example copies the buttons on the LEDs

It is referenced in the QuickStart document and serves as basis for it.

Make sure that the enabling jumpers are set for the buttons and the LEDs

Also make sure that the boot mode selected on the board is the same as the mode 
 selected in the target options. (RAM by default)

****************************************************************

This program will only work with the STR71x devices.

****************************************************************/


 #include "STR71x.h"

  
 void Init(void)
 {
	// bits 10, 9, 8, 6, 5, 4 of P1 as open drain outputs,
	// other P1 bits as HiZ inputs
 	GPIO1->PC0 = 0x0000;
 	GPIO1->PC1 = 0x0000;
 	GPIO1->PC2 = 0x0770;
 	
	// P0[14..10] as pull up/down inputs,
	// P0[15, 9..0] as HiZ inputs
 	GPIO0->PC0 = 0x7C00;
 	GPIO0->PC1 = 0x7C00;
 	GPIO0->PC2 = 0x0000;
 }
 
 
 int main(void)
 {
	Init();

 	while(1)
 	{
			//P1[9]	= P0[14]
			if (GPIO0->PD & 0x4000)
				GPIO1->PD |= 0x0200;
			else
				GPIO1->PD &= ~0x0200;

			//P1[8]	= P0[13]
			if (GPIO0->PD & 0x2000)
				GPIO1->PD |= 0x0100;
			else
				GPIO1->PD &= ~0x0100;

			//P1[6]	= P0[12]
			if (GPIO0->PD & 0x1000)
				GPIO1->PD |= 0x0040;
			else
				GPIO1->PD &= ~0x0040;

			//P1[5]	= P0[11]
			if (GPIO0->PD & 0x0800)
				GPIO1->PD |= 0x0020;
			else
				GPIO1->PD &= ~0x0020;

			//P1[4]	= P0[10]
			if (GPIO0->PD & 0x0400)
				GPIO1->PD |= 0x0010;
			else
				GPIO1->PD &= ~0x0010;
 
 	}
 }
 
 

