Exemple #1
0
// This function initializes all hardware used by our system.
void InitializeHardware() {
  RIT128x96x4Init(1000000);
  //Initializes the LED
  //LED_init();
  //Initializes the ADC
  ADCInit();
  //Initializes the keys on the keypad on the Stellaris Board
  key_init();
  //Initializes GPIO PORT E and enables its interrupts
  init_GPIOE();
  //Initializes GPIO PORT F and enables its interrupts
  init_GPIOF();
  // Initializes the PWM's used
  PWMinit();
  // Initializes Port D to use for sending signals to the H-bridge
  PORTD_init();
  PORTC_init();
  // This method is used by FreeRtos
  prvSetupHardware();
  // This initializes the speaker
  speakerInit();
  //Sets the UART port
  uARTInit();

}
Exemple #2
0
/*
 * Runs user initialization code. This function will be started in its own task with the default
 * priority and stack size once when the robot is starting up. It is possible that the VEXnet
 * communication link may not be fully established at this time, so reading from the VEX
 * Joystick may fail.
 *
 * This function should initialize most sensors (gyro, encoders, ultrasonics), LCDs, global
 * variables, and IMEs.
 *
 * This function must exit relatively promptly, or the operatorControl() and autonomous() tasks
 * will not start. An autonomous mode selection menu like the pre_auton() in other environments
 * can be implemented in this task if desired.
 */
void initialize() {

	lcdInit(uart1);
	lcdClear(uart1);
	speakerInit();

	eLeft = encoderInit(ENC_L_A, ENC_L_B,false);
	eRight = encoderInit(ENC_R_A, ENC_R_B,true);
}
Exemple #3
0
void cortexPortsInit() {
	speakerInit();
	CortexPort *port = ports;
	for (int i = 0; i < 21; i++) {
		port->port = i;
		if ((i >= 13) && (i <= 20)) {
			port->analogCapabilites = true;
			port->mode = INPUT_ANALOG;
		} else {
			port->analogCapabilites = false;
			port->mode = INPUT;
		}
		port++;
	}
}
//*************************************************************************************************
//	Main program to initialize hardware and execute Tasks.
//*************************************************************************************************
void main()  {
	//  Initialize system counters
	systemInit();

	// Initialize tasks
	OLEDInit();
	LEDInit();
	speakerInit();

	// Execute tasks repeatedly
    while(true){
    	OLEDExec();
    	LEDExec();
    	speakerExec();
    }
}
//*************************************************************************************************
//	Main program to initialize hardware and execute Tasks.
//*************************************************************************************************
void main(void)  {
	//  Initialize system counters
	systemInit();

	// Initialize tasks
	OLEDInit();
	LEDInit();
	speakerInit();
	buttonInit();

	// Execute tasks repeatedly
    while(true){
    	OLEDExec();
    	LEDExec();
    	if (freq != 0) {
        	speakerExec();
    	}
    	buttonExec();

    }
}
Exemple #6
0
/**
 * \brief Initializes all the subsystems for this Droplet. This function MUST be called
 * by the user before using any other functions in the API.
 */ 
static void initAllSystems(void){
	cli();
	Config32MHzClock();
	
	calculateIdNumber();
	
	schedulerInit();			INIT_DEBUG_PRINT("SCHEDULER INIT\r\n");
	pcCommInit();				INIT_DEBUG_PRINT("PC COM INIT\r\n");
	rgbLEDinit();				INIT_DEBUG_PRINT("LED INIT\r\n");
	powerInit();				INIT_DEBUG_PRINT("POWER INIT\r\n");
	i2cInit();					INIT_DEBUG_PRINT("I2C INIT\r\n");
	
	enableInterrupts();	
	
	rangeAlgsInit();			INIT_DEBUG_PRINT("RANGE ALGORITHMS INIT\r\n");
	rgbSensorInit();			INIT_DEBUG_PRINT("RGB SENSE INIT\r\n");
	irLedInit();				INIT_DEBUG_PRINT("IR LED INIT\r\n");
	irSensorInit();			INIT_DEBUG_PRINT("IR SENSE INIT\r\n");
	
	#ifdef AUDIO_DROPLET
		speakerInit();			INIT_DEBUG_PRINT("SPEAKER INIT\r\n");
		micInit();				INIT_DEBUG_PRINT("MIC INIT\r\n"); //Must occur after ir_sensor_init.
	#endif
		
	motorInit();				INIT_DEBUG_PRINT("MOTOR INIT\r\n");
	randomInit();				INIT_DEBUG_PRINT("RAND INIT\r\n"); //This uses adc readings for a random seed, and so requires that the adcs have been initialized.
	localizationInit();		INIT_DEBUG_PRINT("LOCALIZATION INIT\r\n"); 
	
	#ifdef SYNCHRONIZED
		fireflySyncInit();
	#endif

	setAllirPowers(256);
	startupLightSequence();
	
	irCommInit();				INIT_DEBUG_PRINT("IR COM INIT\r\n");
	#ifdef AUDIO_DROPLET
		enableMicInterrupt();
	#endif
}
Exemple #7
0
/*
 * Runs the user operator control code. This function will be started in its own task with the
 * default priority and stack size whenever the robot is enabled via the Field Management System
 * or the VEX Competition Switch in the operator control mode. If the robot is disabled or
 * communications is lost, the operator control task will be stopped by the kernel. Re-enabling
 * the robot will restart the task, not resume it from where it left off.
 *
 * If no VEX Competition Switch or Field Management system is plugged in, the VEX Cortex will
 * run the operator control task. Be warned that this will also occur if the VEX Cortex is
 * tethered directly to a computer via the USB A to A cable without any VEX Joystick attached.
 *
 * Code running in this task can take almost any action, as the VEX Joystick is available and
 * the scheduler is operational. However, proper use of delay() or taskDelayUntil() is highly
 * recommended to give other tasks (including system tasks such as updating LCDs) time to run.
 *
 * This task should never exit; it should end with some kind of infinite loop, even if empty.
 */
void operatorControl() {
	speakerInit();
	// Play a tune on the speaker
//	speakerPlayRtttl("Super Mario:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,"
//		"8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,"
//		"8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,"
//		"8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,"
//		"8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,8p.,"
//		"8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,"
//		"8p,16d#6,8p,16d6,8p,16c6");
	// Play a polyphonic tune on the speaker with 2 tracks
//	const char * rtttl[] = {
//			"BlackSabbath_Iron_Man:d=4,o=5,b=85:2g#.6, 2p, g#6, g#6, g#6, 2g#.6, 2p, g#6, g#6, g#6, 2g#.6, 2p, g#6, g#6, g#6, d6, f6, 8f6, 8g6, g6, 16a#6, 16a6, 16a#6, 16a6, 16a#6, 16a6, 8f6, 8f6, 8g6, g6, d6, f6, 8f6, 8g6, g6, 16a#6, 16a6, 16a#6, 16a6, 16a#6, 16a6, 8f6, 8f6, 8g6, g6, d6, f6, 8f6, 8g6, g6, 16a#6, 16a6, 16a#6, 16a6, 16a#6, 16a6"	,NULL};
//	while (1) {
	const char * rtttl[] = {
	        "Super Mario:d=4,o=5,b=100:"
	        "16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,"
	        "8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,"
	        "8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,"
	        "8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,"
	        "8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,8p.,"
	        "8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,"
	        "8p,16d#6,8p,16d6,8p,16c6",
	        "Super Mario:d=4,o=4,b=100:"
	        "16d,16d,32p,8d,16d,8d,8g5,8p,8g,8p,"
	        "8g5,16p,8e,16p,8c,16p,8f,8g,16f#,8f,16e.,16c5,16e5,8f5,16d5,8e5,8c5,16a,16b,8g,16p,"
	        "8g5,16p,8e,16p,8c,16p,8f,8g,16f#,8f,16e.,16c5,16e5,8f5,16d5,8e5,8c5,16a,16b,8g,16p,"
	        "8c,16p,16g,8p,8c5,8f,16p,16c5,16c5,16c5,8f,"
	        "8c,16p,16e,8p,16g,16c5,p.,8g,"
	        "8c,16p,16g,8p,8c5,8f,16p,16c5,16c5,16c5,8f,"
	        "8c,16g#,8p,16a#,8p,16c5",
	        NULL
	    };
	    speakerPlayArray(rtttl);
//	speakerPlayRtttl("Mission Impossible (Long):d=4,o=6,b=100:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,16g,8p,16g,8p,16a#,16p,16c7,16p,16g,8p,16g,8p,16f,16p,16f#,16p,16g,8p,16g,8p,16a#,16p,16c7,16p,16g,8p,16g,8p,16f,16p,16f#,16p,16a#,16g,2d,32p,16a#,16g,2c#,32p,16a#,16g,2c,16p,16a#5,16c");
//  speakerPlayRtttl("Axel F:d=8,o=6,b=125:4e,g.,e,16e,a,e,d,4e,b.,e,16e,c7,b,g,e,b,e7,16e,d,16d,b5,f#,4e,2p,4e,g.,e,16e,a,e,d,4e,b.,e,16e,c7,b,g,e,b,e7,16e,d,16d,b5,f#,4e");
//	speakerPlayRtttl("Ghostbusters:d=4,o=5,b=112:");
//		delay(20);
//	}
}
Exemple #8
0
/****************************************************************************
  Function:
    void PIC24HSKInit(void)
  Description:
	Intialize the starter kit board: switches, speaker driver.
  Precondition:
    None.
  Parameters:
    None.
  Returns:
    None
  Remarks:
    None
  ***************************************************************************/
void PIC24HSKInit(void)
{
	// Configuring I/O ports used by LED matrix
	TRISA = 0x0000;
	TRISB = 0x0000;
	TRISC = 0x0000;
	LATA = 0x0000;
	LATB = 0x0000;
	LATC = 0x0000;
	
	AD1PCFGL = 0xFFFF;
	
	// Initialize switches
	SWITCH_S1_TRIS = 1;
	SWITCH_S2_TRIS = 1;
	
	// Initialize speaker
   	if(enableSoundFlag)
		speakerInit();									
					
	// Initialize timer 4 to activate switch press listener
   	initTmr4(); 													
}
//*****************************************************************************
//
//	Main program to initialize hardware and execute Tasks.
//
//*****************************************************************************
int main( void )  {
	//
	//  Initialize the system clock and systick interrupt
	//
	SysTickInit();
	
    //
    //	Task Initializations
    //
    BlinkInit();
    TickDisplayInit();
    speakerInit();
    buttonInit();

    //
    //	Task Execution
    //
    while (1) {
    	BlinkExecute( );
    	TickDisplayExecute( );
    	speakerExecute();
    }
}