Пример #1
0
void platform_init()
{
	arm_setup();
	mmu_setup();
	tasks_setup();

	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();
	
	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();
	wdt_setup();

	// Other devices
//	uart_setup();
	i2c_setup();

//	dma_setup();

	spi_setup();

	LeaveCriticalSection();

	aes_setup();

	nor_setup();
	syscfg_setup();
	images_setup();
	nvram_setup();

//	lcd_setup();
	framebuffer_hook();	// TODO: Remove once LCD implemented
	framebuffer_setup();

//	audiohw_init();

	framebuffer_setdisplaytext(TRUE);


	gpio_register_interrupt(BUTTONS_HOLD_IRQ, BUTTONS_HOLD_IRQTYPE, BUTTONS_HOLD_IRQLEVEL, BUTTONS_HOLD_IRQAUTOFLIP, gpio_test_handler, 0);
	gpio_interrupt_enable(BUTTONS_HOLD_IRQ);
	gpio_register_interrupt(BUTTONS_HOME_IRQ, BUTTONS_HOME_IRQTYPE, BUTTONS_HOME_IRQLEVEL, BUTTONS_HOME_IRQAUTOFLIP, gpio_test_handler, 1);
	gpio_interrupt_enable(BUTTONS_HOME_IRQ);
	gpio_register_interrupt(BUTTONS_VOLUP_IRQ, BUTTONS_VOLUP_IRQTYPE, BUTTONS_VOLUP_IRQLEVEL, BUTTONS_VOLUP_IRQAUTOFLIP, gpio_test_handler, 2);
	gpio_interrupt_enable(BUTTONS_VOLUP_IRQ);
	gpio_register_interrupt(BUTTONS_VOLDOWN_IRQ, BUTTONS_VOLDOWN_IRQTYPE, BUTTONS_VOLDOWN_IRQLEVEL, BUTTONS_VOLDOWN_IRQAUTOFLIP, gpio_test_handler, 3);
	gpio_interrupt_enable(BUTTONS_VOLDOWN_IRQ);
}
Пример #2
0
int multitouch_setup(const uint8_t* ASpeedFirmware, int ASpeedFirmwareLen, const uint8_t* mainFirmware, int mainFirmwareLen)
{
	bufferPrintf("multitouch: A-Speed firmware at 0x%08x - 0x%08x, Main firmware at 0x%08x - 0x%08x\r\n",
			(uint32_t) ASpeedFirmware, (uint32_t)(ASpeedFirmware + ASpeedFirmwareLen),
			(uint32_t) mainFirmware, (uint32_t)(mainFirmware + mainFirmwareLen));

	OutputPacket = (uint8_t*) malloc(0x400);
	InputPacket = (uint8_t*) malloc(0x400);
	GetInfoPacket = (uint8_t*) malloc(0x400);
	GetResultPacket = (uint8_t*) malloc(0x400);

	memset(GetInfoPacket, 0x82, 0x400);
	memset(GetResultPacket, 0x68, 0x400);

	gpio_register_interrupt(MT_ATN_INTERRUPT, 0, 0, 0, multitouch_atn, 0);
	gpio_interrupt_enable(MT_ATN_INTERRUPT);

	multitouch_on();

	bufferPrintf("multitouch: Sending A-Speed firmware...\r\n");
	if(!loadASpeedFirmware(ASpeedFirmware, ASpeedFirmwareLen))
	{
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		return -1;
	}

	udelay(1000);

	bufferPrintf("multitouch: Sending main firmware...\r\n");
	if(!loadMainFirmware(mainFirmware, mainFirmwareLen))
	{
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		return -1;
	}

	udelay(1000);

	bufferPrintf("multitouch: Determining interface version...\r\n");
	if(!determineInterfaceVersion())
	{
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		return -1;
	}

	uint8_t reportBuffer[MaxPacketSize];
	int reportLen;

	if(!getReport(MT_INFO_FAMILYID, reportBuffer, &reportLen))
	{
		bufferPrintf("multitouch: failed getting family id!\r\n");
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		return -1;
	}

	FamilyID = reportBuffer[0];

	if(!getReport(MT_INFO_SENSORINFO, reportBuffer, &reportLen))
	{
		bufferPrintf("multitouch: failed getting sensor info!\r\n");
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		return -1;
	}

	SensorColumns = reportBuffer[2];
	SensorRows = reportBuffer[1];
	BCDVersion = ((reportBuffer[3] & 0xFF) << 8) | (reportBuffer[4] & 0xFF);
	Endianness = reportBuffer[0];

	if(!getReport(MT_INFO_SENSORREGIONDESC, reportBuffer, &reportLen))
	{
		bufferPrintf("multitouch: failed getting sensor region descriptor!\r\n");
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		return -1;
	}

	SensorRegionDescriptorLen = reportLen;
	SensorRegionDescriptor = (uint8_t*) malloc(reportLen);
	memcpy(SensorRegionDescriptor, reportBuffer, reportLen);

	if(!getReport(MT_INFO_SENSORREGIONPARAM, reportBuffer, &reportLen))
	{
		bufferPrintf("multitouch: failed getting sensor region param!\r\n");
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		free(SensorRegionDescriptor);
		return -1;
	}

	SensorRegionParamLen = reportLen;
	SensorRegionParam = (uint8_t*) malloc(reportLen);
	memcpy(SensorRegionParam, reportBuffer, reportLen);

	if(!getReport(MT_INFO_SENSORDIM, reportBuffer, &reportLen))
	{
		bufferPrintf("multitouch: failed getting sensor surface dimensions!\r\n");
		free(InputPacket);
		free(OutputPacket);
		free(GetInfoPacket);
		free(GetResultPacket);
		free(SensorRegionDescriptor);
		free(SensorRegionParam);
		return -1;
	}

	SensorWidth = *((uint32_t*)&reportBuffer[0]);
	SensorHeight = *((uint32_t*)&reportBuffer[4]);

	int i;

	bufferPrintf("Family ID                : 0x%x\r\n", FamilyID);
	bufferPrintf("Sensor rows              : 0x%x\r\n", SensorRows);
	bufferPrintf("Sensor columns           : 0x%x\r\n", SensorColumns);
	bufferPrintf("Sensor width             : 0x%x\r\n", SensorWidth);
	bufferPrintf("Sensor height            : 0x%x\r\n", SensorHeight);
	bufferPrintf("BCD Version              : 0x%x\r\n", BCDVersion);
	bufferPrintf("Endianness               : 0x%x\r\n", Endianness);
	bufferPrintf("Sensor region descriptor :");
	for(i = 0; i < SensorRegionDescriptorLen; ++i)
		bufferPrintf(" %02x", SensorRegionDescriptor[i]);
	bufferPrintf("\r\n");

	bufferPrintf("Sensor region param      :");
	for(i = 0; i < SensorRegionParamLen; ++i)
		bufferPrintf(" %02x", SensorRegionParam[i]);
	bufferPrintf("\r\n");

	CurNOP = 0x64;

	GotATN = 0;

	while(TRUE)
	{
		EnterCriticalSection();
		if(!GotATN)
		{
			LeaveCriticalSection();
			continue;
		}
		--GotATN;
		LeaveCriticalSection();

		while(readFrame() == 1);
	}

	return 0;
}