Пример #1
0
//=======================================================================
// LED_Open - Called when driver opened
// Use dwAccess and dwShare flags to manage access rights
//
DWORD LED_Open(DWORD dwContext, DWORD dwAccess, DWORD dwShare){
	PDRVCONTEXT pDrv = (PDRVCONTEXT)dwContext;

	RETAILMSG(RETAIL_ON, (DTAG TEXT("LED_Open++ dwContext: %x\r\n"), dwContext));

	// Verify that the context handle is valid
	if(pDrv && (pDrv->dwSize != sizeof(DRVCONTEXT))){
		return 0;
	}

	GPIOREG* pGPIORegs = (GPIOREG*)MapRegister(GPIO_BASE);
	if (pGPIORegs)
	{
		pDrv->pGpioRegs = pGPIORegs;
	}
	else
	{
		return 0;
	}
	
	initPushButtons(pGPIORegs);
	initSwitches(pGPIORegs);

	// Count the number of opens
	InterlockedIncrement((long *)&pDrv->nNumOpens);

	RETAILMSG(RETAIL_ON, (TEXT("LED_Open-- \r\n")));

	return (DWORD)pDrv;
}
void Hackerling_Shield::begin(uint8_t flags){
	//Dependents:
	//Serial
	  //io-expanders
	mcp23017.begin(0);
	mcp23008.begin(1);
	initSwitches();
	initButtons();
	initBarGraph();
	initAnalog();
	speaker.begin();
	   // Buttons
	   // Bar Graph
	   // dip switch
	if(!(flags & NO_LCD))
		lcd.begin(16,2);


	if(!(flags & NO_IR))
	IR.begin();
}