Example #1
0
int main(void) {


	InitializeHardware(); //set up ports, timers, interrupts

	ConfigureADC(); //get ADC set up to start reading values

	BlinkLEDs();

	myCalibrationState = XMaxState; //change to init later?
	StartCalibration(myCalibrationState, &gPushButton);

	//InitGame(); //initialize AFTER configuration so get random number based off of time to calibrate

	//after calibration finished, need user to press button to indicate they are ready to begin game
	BlinkLEDs();

	//METHOD HERE TO WAIT FOR BUTTON PRESS TO START GAME
	//startGame(); //NEED TO PUSH BUTTON TO START


    while(1) {

    	update(); //calls all different states of game


    }

	return 0;
}
Example #2
0
int main(void)
	{
	static struct {int a[8], b[8], sum ; } testcase[] =
		{
		{{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,1},0},
		{{1,1,1,1,1,1,1,1},{1,0,0,0,0,0,0,0},0},
		{{1,0,1,0,1,0,1,0},{1,0,1,0,1,0,1,0},-86},
		{{1,1,0,1,0,0,0,0},{0,1,1,0,1,1,1,1},1},
		{{1,0,1,0,1,0,1,0},{0,1,0,1,0,1,0,1},-1}
		} ;
	int k ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		for (k = 0; k < ENTRIES(testcase); k++)
			{
			int *a = testcase[k].a ;
			int *b = testcase[k].b ;
			int sum[8] ;
			uint32_t before, after, cycles ;

			printf(" Test Case %d: ", k+1) ;
			PrintBits(a) ;
			printf("+") ;
			PrintBits(b) ;
			printf("\n") ;

			printf("   Correct Sum: ") ;
			PrintByte(testcase[k].sum) ;
			printf("\n") ;

            before = GetClockCycleCount() ;
			AddBinary(a, b, sum) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("      Your Sum: ") ;
			if (PrintBits(sum) != (uint8_t) testcase[k].sum) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;
			printf("  Clock Cycles: %lu\n", cycles) ;

			printf("\n") ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
	}
int main(void)
	{
	static struct
		{
		uint32_t	word ;
		int			lsb ;
		int			width ;
		uint32_t	value ;
		} testcase[] =
		{
		{0xFFFFFFFF,  5, 7,  0},
		{0x00000000, 22, 5, -1}
		} ;
	int k ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		for (k = 0; k < ENTRIES(testcase); k++)
			{
			uint32_t	word	= testcase[k].word ;
			int			lsb		= testcase[k].lsb ;
			int			width	= testcase[k].width ;
			uint32_t	value	= testcase[k].value ;
			uint32_t	result, answer	= BFI(word, lsb, width, value) ;
			uint32_t    before, after, cycles ;

            before = GetClockCycleCount() ;
			result = BitFieldInsert(word, lsb, width, value) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("   Test Case %d: %08X,%d,%d,%d\n", k+1,
				(unsigned) word, lsb, width, (int) value) ;

			printf("Correct Result: %08X\n", (unsigned) answer) ;

			printf("   Your Result: %08X", (unsigned) result) ;
			if (result != answer) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;

			printf("  Clock Cycles: %lu\n\n", cycles) ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
	}
int main(void)
    {
	static uint32_t testcase[] =
		{
		0x12345678,	0x0000FFFF,	0x00FF00FF
		} ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		int k ;

		for (k = 0; k < ENTRIES(testcase); k++)
			{
			uint32_t word = testcase[k] ;
			uint32_t result, answer = REV(word) ;
			uint32_t before, after, cycles ;

            before = GetClockCycleCount() ;
			result = ReverseByteOrder(word) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("   Test Case %d: %08X (hex)\n", k+1, (unsigned) word) ;

			printf("Correct Result: %08X\n", (unsigned) answer) ;

			printf("   Your Result: %08X", (unsigned) result) ;
			if (result != answer) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;

			printf("  Clock Cycles: %lu\n\n", cycles) ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
    }
Example #5
0
BOOL
CSDHCBase::Init(
                LPCTSTR pszActiveKey
                )
{
    BOOL fRet = FALSE;
    SD_API_STATUS status;
    HKEY    hkDevice = NULL;

    hkDevice = OpenDeviceKey(pszActiveKey);
    if (!hkDevice || !m_regDevice.Open(hkDevice, _T(""))) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC: Failed to open device key\n")));
        goto EXIT;
    }

    // Get a handle to our parent bus.
    m_hBusAccess = CreateBusAccessHandle(pszActiveKey);
    if (m_hBusAccess == NULL) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC: Could not get handle to parent\n")));
        goto EXIT;
    }

    m_cSlots = DetermineSlotCount();
    if (m_cSlots == 0) {
        goto EXIT;
    }

    ValidateSlotCount();
	RETAILMSG(0,(TEXT("CSDHCBase::Init  m_cSlots=%d\n"),m_cSlots)); // jylee
    m_pSlotInfos = (PSDHC_SLOT_INFO) LocalAlloc(LPTR, 
        sizeof(SDHC_SLOT_INFO) * m_cSlots);
    if (m_pSlotInfos == NULL) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to allocate slot info objects\n")));
        goto EXIT;
    }

    status = SDHCDAllocateContext(m_cSlots, &m_pHCDContext);
    if (!SD_API_SUCCESS(status)) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to allocate context : 0x%08X \n"),
            status));
        goto EXIT;
    }
    
    // Set our extension 
    m_pHCDContext->pHCSpecificContext = this;

    if (!InitializeHardware()) {
        goto EXIT;
    }
	RETAILMSG(0,(TEXT("AllocateSlotObjects\n")));
    // Allocate slot objects
    m_pSlots = AllocateSlotObjects(m_cSlots);
    if (m_pSlots == NULL) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to allocate slot objects\n")));
        goto EXIT;
    }

    // Initialize the slots
    for (DWORD dwSlot = 0; dwSlot < m_cSlots; ++dwSlot) {
        PSDHC_SLOT_INFO pSlotInfo = &m_pSlotInfos[dwSlot];
        PCSDHCSlotBase pSlot = GetSlot(dwSlot);

		RETAILMSG(0,(TEXT("pSlot->Init\n")));
        RETAILMSG(0,(TEXT("pSlotInfo->pucRegisters : 0x%x\r\n"),pSlotInfo->pucRegisters));
        if (!pSlot->Init(dwSlot, pSlotInfo->pucRegisters, m_pHCDContext, 
            m_dwSysIntr, m_hBusAccess, m_interfaceType, m_dwBusNumber, &m_regDevice)) {
                goto EXIT;
            }
    }

    // set the host controller name
    SDHCDSetHCName(m_pHCDContext, TEXT("HSMMC"));

    // set init handler
    SDHCDSetControllerInitHandler(m_pHCDContext, CSDHCBase::SDHCInitialize);
    // set deinit handler    
    SDHCDSetControllerDeinitHandler(m_pHCDContext, CSDHCBase::SDHCDeinitialize);
    // set the Send packet handler
    SDHCDSetBusRequestHandler(m_pHCDContext, CSDHCBase::SDHCBusRequestHandler);   
    // set the cancel I/O handler
    SDHCDSetCancelIOHandler(m_pHCDContext, CSDHCBase::SDHCCancelIoHandler);   
    // set the slot option handler
    SDHCDSetSlotOptionHandler(m_pHCDContext, CSDHCBase::SDHCSlotOptionHandler);

    // These values must be set before calling SDHCDRegisterHostController()
    // because they are used during that call.
    m_dwPriority = m_regDevice.ValueDW(SDHC_PRIORITY_KEY, SDHC_CARD_CONTROLLER_PRIORITY);
	RETAILMSG(0,(TEXT("SDHCDRegisterHostController\n"))); // jylee
    // now register the host controller 
    status = SDHCDRegisterHostController(m_pHCDContext);

    if (!SD_API_SUCCESS(status)) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to register host controller: %0x08X \n"), 
            status));
        goto EXIT;
    }

    m_fRegisteredWithBusDriver = TRUE;
    fRet = TRUE;
	RETAILMSG(0,(TEXT("CSDHCBase::Init Finished.\n"))); // jylee
EXIT:
    if (hkDevice) RegCloseKey(hkDevice);

    return fRet;
}
XboxTankDriveProfile::XboxTankDriveProfile() {
	InitializeHardware();
	InitializeSoftware();
	
	m_drive->SetExpiration(0.1);
}
Example #7
0
File: main.c Project: eeshanl/ee472
int main() {

  // Initializes all necessary hardware for the system.
  InitializeHardware();


  /**************************************/
  // These includes provided by FreeRTOS

  #if mainINCLUDE_WEB_SERVER != 0
  {
    /*
    Create the uIP task if running on a processor that includes a MAC and PHY.
    */

    if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) )
    {
      xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
    }
  }
  #endif



  // These includes provided by FreeRTOS
  /**************************************/


  /* Our Tasks
   * NOTE: The xTaskCreate function is provided by FreeRTOS, we use them to create our tasks that we made.
   */

  /* Start the tasks */

  //creates the task for ADC sensors
  xTaskCreate(vTaskADC, "Task ADC", 100, NULL, 2, NULL);
  //creates the task that averages the ADC samples
  xTaskCreate(vTaskADCAverage, "Task Average", 100, NULL, 2, NULL);
  //creates the task that controls the motor via kepad/bluetooth
  xTaskCreate(vTaskControlMotor, "Task Control Motor", 100, NULL, 2, NULL); //3
  //creates the task that does the autonomous motion of the tank
  xTaskCreate(vAutoMotor, "Task Auto Motor", 100, NULL, 3, NULL); // 5
  //creates the task that controls the semi-autonomous mode for the tank
  xTaskCreate(vSemiMotor, "Task Semi-Motor", 100, NULL, 3, NULL); // 5
  //creates the task that controls the speaker
  xTaskCreate(vTaskSpeaker, "Task Control Motor", 100, NULL, 1, NULL);
  //creates the task the displays to the OLED Display
  xTaskCreate(vTaskDisplay, "Task OLED Display", 100, NULL, 3, NULL); // 4
  //creates the task that prints the distance from the distance sensors on the
  //OLED Display
  xTaskCreate(vPrintDistance, "Task Distance Please", 100, NULL, 2, NULL);
  // blinks LEDS
  xTaskCreate(vBlinkLED, "Blink", 100, NULL, 2, NULL);


  /**************************************/
  // These includes provided by FreeRTOS

  /*
  Configure the high frequency interrupt used to measure the interrupt
  jitter time.
  */

  vSetupHighFrequencyTimer();

  /*
  Start the scheduler.
  */

  vTaskStartScheduler();

  /* Will only get here if there was insufficient memory to create the idle task. */

  // These includes provided by FreeRTOS
  /**************************************/

  return 0;
}
Example #8
0
/*****************************************
 *int main (void)
 *****************************************/
int main (void)
{
    InitializeHardware();
    HardwareButtonInit();
    InitAllLEDs();
    
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH     
	GFX_DRIVER_AutoUpdPart();		// Turn on widget auto update, partial update for less flashing
#endif
    
    InitTick();
	GOLInit();

    SetColor(WHITE);
    ClearDevice();

	// Set proper display rotation
#if(DISP_ORIENTATION == 90)
    GFX_DRIVER_InitRotmode(ROTATE_90);
#else
#error "This PICTail display orientation must be 90."
#endif
       
	// make sure that the correct hex file is loaded
    CheckExternalFlashHex();

	// Create cursor in GFX_CURSOR_LAYER with Alpha Color = 0xA
	GFX_DRIVER_CreateLayer( GFX_CURSOR_LAYER, GFX_LAYER_TRANS_EN | 0xA, GetX(), GetY(), GetX() + 31, GetY() + 31 );
	GFX_DRIVER_ActivateLayer( GFX_CURSOR_LAYER );
	PutImage(0, 0, (void *)&mouse_cursor_icon_270, IMAGE_NORMAL); 
	GFX_DRIVER_ActivateLayer( GFX_MAIN_LAYER );
	
	// Start demo screen 
	demoScreens = DEMO_INTRO_SCREEN_CREATE;
	
    while(1)
	{
        GOLDraw();
#ifndef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
	#if defined( ONE_CYCLE_DRAWING	) 
		// The screen drawing starts and completes during one while(1) cycle loop in main().
		// This Demo is one cycle drawing application.
        if ( GFX_DRIVER_IsUpdateRequested() || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) )
        {
	    	GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); 
	    	g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED;   
	    }
	#else
		// This way can be used when drawing may take few or more cycles of while(1) loop in main().
		// See "tick.c" file for details.
        if ( g_UpdateNow || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) )
        {
	        g_UpdateNow = 0;
	    	GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); 
	    	g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED;   
	    }	
	#endif
#endif		 
	}	

    return (-1);
}
Example #9
0
MainRobot::MainRobot() {
	InitializeHardware();
	InitializeSoftware();
}
Example #10
0
// initialize the USB KITL driver
BOOL PDDInit(
  RNDIS_PDD_CHARACTERISTICS* pRndisPddCharacteristics,
  PBYTE pBaseAddress
)
{
    PDDZONE0 = 0;
    PDDZONE = 0;
    MDDZONE0 = 0;
    MDDZONE = 1;
    MDDZONE2 = 1;
    MDDZONE3 = 1;
    MDDZONE4 = 1;
    MDDZONE5 = 0;

    OALMSG(OAL_ETHER&&OAL_FUNC, (L"+RNDIS_USBFN_PDDInit\r\n"));

    g_mddInterface.dwVersion = 1;
    g_mddInterface.pfnNotify = NotifyHandler;

    memset( &g_pddInterface, 0, sizeof(g_pddInterface) );
    g_pddInterface.dwVersion = 1;

    // configure clock, I2C cotroller, USB OTG transceiver and USB OTG controller
    InitializeHardware();

    // initialize usb function unit
    if( UfnPdd_Init( NULL, NULL, &g_mddInterface, &g_pddInterface ) != ERROR_SUCCESS )
    {
        OALMSG(OAL_ERROR, (L"UfnPdd_Init failed!"));
        return FALSE;
    }

    // register device
    RegisterUSBDevice();

    // attach device to USB bus
    g_pddInterface.pfnStart( g_pddInterface.pvPddContext );

    SetRNDISMACAddress();
    SetRNDISSerialNumber();

    //
    // Everything ok, fill up our characteristics.
    //
    memset(pRndisPddCharacteristics, 0x00, sizeof(RNDIS_PDD_CHARACTERISTICS));

    pRndisPddCharacteristics->SendRndisMessageHandler = PDD_SendRndisMessage;
    pRndisPddCharacteristics->SendRndisPacketHandler = PDD_SendRndisPacket;
    pRndisPddCharacteristics->SetHandler = PDD_Set;
    pRndisPddCharacteristics->GetHandler = PDD_Get;
    pRndisPddCharacteristics->ISRHandler = PDD_ISR;
    pRndisPddCharacteristics->dwIRQ = -1;       // @todo : check this
    pRndisPddCharacteristics->dwMaxRx = MAX_INCOMING_BUFFER;
    pRndisPddCharacteristics->dwBaseAddr = (DWORD)pBaseAddress;
    pRndisPddCharacteristics->IndicateRndisPacketCompleteHandler = PDD_IndicateRndisPacketComplete;

    // we are not a PCI device
    pRndisPddCharacteristics->bPCIDevice = FALSE;

    //
    // Everything is fine... Proceed!
    //
    InitializeListHead(&g_RndisKitlDev.listTxRndisMessageQueue);

    OALMSG(OAL_ETHER&&OAL_FUNC, (
        L" RNDIS_USBFN_PDDInit: initialization completed\r\n"
    ));

    OALMSG(OAL_ETHER&&OAL_FUNC, (L"-RNDIS_USBFN_PDDInit\r\n"));

    PDDZONE0 = 0;
    PDDZONE = 0;
    MDDZONE0 = 0;
    MDDZONE = 0;
    MDDZONE2 = 0;
    MDDZONE3 = 0; // 1
    MDDZONE4 = 0;
    MDDZONE5 = 0;

    return TRUE;
}