示例#1
0
///////// Score Count Function Update //////////
void ScoreBoard()
{
	++score;
	score1 = Write7Seg(score % 10);
	score2 = Write7Seg(score / 10);
	dataScore = ((score1 << 8) + score2);
	transmit_dataD1(~dataScore);
}
示例#2
0
/////////////// Score Task Manager ///////////////
void ScoreTask()
{
	switch(ScoreState)
	{
		case -1:
		{
			transmit_dataD1(0xFFFF);
			if(startTheGame)
			{
				score = 0;
				score1 = Write7Seg(score % 10);
				score2 = Write7Seg(score / 10);
				dataScore = ((score1 << 8) + score2);
				transmit_dataD1(~dataScore);
				ScoreState = NothingScore;
			}				
			break;
		}
		case NothingScore:
		{
			ReadData = (PINC&0xF);
			if((ReadData) == IncrementMC)
			{
				ScoreState = IncrementScore;
				ScoreBoard();
			}
			break;
		}
		case IncrementScore:
		{
			ReadData = (PINC&0xF);
			if((ReadData) != IncrementMC)
			{
				ScoreState = NothingScore;
			}				
			break;
		}
		default:
		{
			transmit_dataD1(0xFFFF);
			if(startTheGame)
			{
				score = 0;
				score1 = Write7Seg(score % 10);
				score2 = Write7Seg(score / 10);
				dataScore = ((score1 << 8) + score2);
				transmit_dataD1(~dataScore);
				ScoreState = NothingScore;
			}				
			break;
		}
	}
}
示例#3
0
uhc_enum_status_t uhi_hid_manta_install(uhc_device_t* dev)
{
	bool b_iface_supported;
	uint16_t conf_desc_lgt;
	usb_iface_desc_t *ptr_iface;
	//char *product = NULL;

	//product = uhc_dev_get_string(dev,dev->dev_desc.iProduct);
	//while(product == NULL);
	
	//lcd_clear_line(2);
	//dip204_printf_string("%x",dev->dev_desc.idProduct);
	Write7Seg(55);
	if (uhi_hid_manta_dev.dev != NULL)
		return UHC_ENUM_SOFTWARE_LIMIT; // Device already allocated
	conf_desc_lgt = le16_to_cpu(dev->conf_desc->wTotalLength);
	ptr_iface = (usb_iface_desc_t*)dev->conf_desc;
	b_iface_supported = false;
	
	while(conf_desc_lgt)
	{
		switch (ptr_iface->bDescriptorType) 
		{
			case USB_DT_INTERFACE:
				if ((ptr_iface->bInterfaceClass   == HID_CLASS)
					&& (ptr_iface->bInterfaceProtocol == HID_PROTOCOL_GENERIC)
					&& dev->dev_desc.idProduct == 0x2424)
				{
					int i;
					// USB HID Manta interface found
					// Start allocation endpoint(s)
					b_iface_supported = true;
					// initialize button states to 0
					for(i=0; i<48; i++)
					{
						butt_states[i]=0;
						pastbutt_states[i]=0;
						//notestack[i] = -1;
					}
				} 
				else
				{
					b_iface_supported = false; // Stop allocation endpoint(s)
					return UHC_ENUM_UNSUPPORTED; // No interface supported
				}
				
			break;

			case USB_DT_ENDPOINT:
				//  Allocation of the endpoint
				if (!b_iface_supported) 
					break;

				if (!uhd_ep_alloc(dev->address, (usb_ep_desc_t*)ptr_iface))
					return UHC_ENUM_HARDWARE_LIMIT; // Endpoint allocation fail

				if(((usb_ep_desc_t*)ptr_iface)->bEndpointAddress & USB_EP_DIR_IN)
				{
					uhi_hid_manta_dev.ep_in = ((usb_ep_desc_t*)ptr_iface)->bEndpointAddress;
					uhi_hid_manta_dev.report_size =
					le16_to_cpu(((usb_ep_desc_t*)ptr_iface)->wMaxPacketSize);
					uhi_hid_manta_dev.report = malloc(uhi_hid_manta_dev.report_size);
					
				}
				else
					uhi_hid_manta_dev.ep_out = ((usb_ep_desc_t*)ptr_iface)->bEndpointAddress;
				break;
			// Ignore descriptor
			default: break;
		}	
		Assert(conf_desc_lgt>=ptr_iface->bLength);
		conf_desc_lgt -= ptr_iface->bLength;
		ptr_iface = (usb_iface_desc_t*)((uint8_t*)ptr_iface + ptr_iface->bLength);
	}
	if (uhi_hid_manta_dev.report == NULL) {
		Assert(false);
		return UHC_ENUM_MEMORY_LIMIT; // Internal RAM allocation fail
	}
	
	if(uhi_hid_manta_dev.ep_in != 0 && uhi_hid_manta_dev.ep_out != 0)		
	{		
		uhi_hid_manta_dev.dev = dev;
		// All endpoints of all interfaces supported allocated
		return UHC_ENUM_SUCCESS;
	}
	
	return UHC_ENUM_UNSUPPORTED; // No interface supported
}