Beispiel #1
0
void vs_pause(void)
{
  GPIOPinIntDisable(GPIO_PORTA_BASE, GPIO_PIN_1); //disable dreq irq
  GPIOPinIntClear(GPIO_PORTA_BASE, GPIO_PIN_1);

  return;
}
Beispiel #2
0
//ISR INIT
void ctl_buttons_isr_init(CTL_ISR_FN_t fn)
{
int en; int32u proba;
en=ctl_global_interrupts_set(0);
buttons_isr=fn;
SysCtlPeripheralEnable(PUSHBUTTON_PERIPH);
//UNLOCKOLNI KELL A PF0 REGISZTERT MERT NMI-RE VAN ALLITVA
HWREG(PUSHBUTTON_PORT + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(PUSHBUTTON_PORT + GPIO_O_CR) |= 0x01;
HWREG(PUSHBUTTON_PORT + GPIO_O_LOCK) = 0;

GPIODirModeSet(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH , GPIO_DIR_MODE_IN);
GPIOPadConfigSet(PUSHBUTTON_PORT,LEFT_SWITCH | RIGHT_SWITCH , GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPinIntDisable(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH);
if((GPIOPinIntStatus(PUSHBUTTON_PORT, 1)) == LEFT_SWITCH )
{
 GPIOPinIntClear(PUSHBUTTON_PORT, LEFT_SWITCH );
}
if((GPIOPinIntStatus(PUSHBUTTON_PORT, 1)) == RIGHT_SWITCH )
{
 GPIOPinIntClear(PUSHBUTTON_PORT, RIGHT_SWITCH );
}
ctl_set_priority(PUSHBUTTON_IRQ_PRIORITY, 1);
ctl_unmask_isr(PUSHBUTTON_IRQ_PRIORITY);
ctl_global_interrupts_set(en);
GPIOIntTypeSet(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH , GPIO_BOTH_EDGES); //GPIO_BOTH_EDGES
GPIOPinIntEnable(PUSHBUTTON_PORT, LEFT_SWITCH | RIGHT_SWITCH );
}
Beispiel #3
0
void
GPIOFIntHandler(void)
{
    // Clear the GPIO interrupt.
    GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);

    y = 0;
    // Counter for how long the snooze button was pressed
    while (GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1)==0){
    	y++;
       }
    // If the snooze button was held long enough, add 5 minutes to the alarm
    if (y>500000){
    	int z;
    	for (z=0; z<5; z++){
    		IncrementTimeA();
        }
    }
    // Clear the screen
    RIT128x96x4Clear();
    // Turn off the LED
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
    // Turn off the alarm
    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, false);
    PWMGenDisable(PWM0_BASE, PWM_GEN_0);
    // Disable the interrupt so that snooze and turn off alarm cannot be used
    GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_1);
}
Beispiel #4
0
/***********************************************************************************
* @fn      halRfDisableRxInterrupt
*
* @brief   Clear and disable RX interrupt.
*
* @param   none
*
* @return  none
*/
void halRfDisableRxInterrupt(void)
{
    // Clear the exception and the IRQ
    CLEAR_EXC_RX_FRM_DONE();
//	GPIOPinIntClear(INT_GPIOD, GPIO_PIN_1);
	GPIOPinIntDisable(GPIO_PORTD_BASE, GPIO_PIN_0);
}
Beispiel #5
0
void GPIO_PortF_IntHandler(void) {
	GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);
	GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_4);
	Encoder_Count++;
	GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4);

}
Beispiel #6
0
/******** Transceiver_receiveMessage *****************************************
// dequeue transceiver packet
// Input: 
//	  *pkt - pointer to received message 
// Output: status
// ------------------------------------------------------------------------*/
unsigned char Transceiver_ReceiveMessage ( TransceiverPacket *pkt )
{
	unsigned char rx[TRANSCEIVER_MAX_PAYLOAD];
	unsigned char index;
	unsigned char status = SUCCESS;

	GPIOPinIntDisable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );
	if ( pdPASS == xQueueReceive(Transceiver_RX_Queue, rx, (portTickType)0) )
	{
		pkt->srcID = rx[SOURCE_ID_INDEX];
		pkt->destID = rx[DEST_ID_INDEX];
		pkt->msgID = rx[MSG_ID_INDEX];
		pkt->dataSize = rx[DATA_SIZE_INDEX];
		for ( index = 0; index < pkt->dataSize; index++ )
		{
			pkt->data[index] = rx[index+PACKET_HEADER_SIZE];
		}
		Debug_NetworkTransceiver_PrintPacket(pkt);
	}
	else
	{
		// empty queue
		status = ERROR_QUEUE_EMPTY;
		Debug_Printf ("Transceiver_ReceiveMessage 0x%x\n", status);
		if ( EmptyQueueCallBack != NULL )
			xTaskCreate( Transceiver_EmptyQueueCallBack, ( signed portCHAR * ) "Transceiver_EmptyQueueCallBack", 
				 DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
	}

	GPIOPinIntEnable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );

	return status;
}
Beispiel #7
0
/******** Transceiver_SendMessage *******************************************
// unpack transceiver packet and send out
// Input:
//    pkt - transceiver packet to be sent 
// Output: status
// ------------------------------------------------------------------------*/
unsigned char Transceiver_SendMessage ( TransceiverPacket pkt )
{
	unsigned char tx[TRANSCEIVER_MAX_PAYLOAD];
	unsigned char index, length;
	unsigned char status = SUCCESS;

	// validate packet
	Debug_NetworkTransceiver_PrintPacket(&pkt);

	if ( MAX_DATA_SIZE < pkt.dataSize )
	{
		status = ERROR_INVALID_PAKCET;
		Debug_Printf ("Transceiver_SendMessage: Error 0x%x\n", status);
		goto exit;
	}

	// unpack transceiver packet
	tx[SOURCE_ID_INDEX] = pkt.srcID;
	tx[DEST_ID_INDEX] = pkt.destID;
	tx[MSG_ID_INDEX] = pkt.msgID;
	tx[DATA_SIZE_INDEX] = pkt.dataSize;
	length = DATA_INDEX;
	for ( index = 0; index < pkt.dataSize; index++,length++ )
	{
		tx[length] = pkt.data[index];
	}

	Debug_NetworkTransceiver_PrintPayload(tx);

	// lock transceiver
	while ( xSemaphoreTake(Transceiver_Mutex, portMAX_DELAY) != pdTRUE );
	GPIOPinIntDisable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );

	nrf24l01_set_as_tx();
	nrf24l01_write_tx_payload ( tx, TRANSCEIVER_MAX_PAYLOAD, true );

	//wait until the packet has been sent or the maximum number of retries has been active
	while( !( nrf24l01_irq_pin_active() && (nrf24l01_irq_tx_ds_active()||nrf24l01_irq_max_rt_active()) ) );
	if ( nrf24l01_irq_max_rt_active() )	
	{
		// hit maximum number of retries
		nrf24l01_flush_tx();
		status = ERROR_MAX_RETRIES;
		Debug_Printf ("Transceiver_SendMessage: Error 0x%x\n", status);
	}

	// reset transceiver
	nrf24l01_irq_clear_all();
	nrf24l01_set_as_rx(true);
	Delay_US(130);

	//unlock transceiver
	GPIOPinIntEnable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );
	while ( xSemaphoreGive(Transceiver_Mutex) != pdTRUE );

exit:
	return status;
}
Beispiel #8
0
void flipPancake(void) {
	GPIOPinIntDisable(GPIO_PORTA_BASE, GPIO_PIN_2);
	WaitUS(2000);
	GPIOPinIntClear(GPIO_PORTA_BASE, GPIO_PIN_2);
	if(!GPIOPinRead(GPIO_PORTA_BASE,GPIO_PIN_2))
	{
		UARTprintf("Triggered.\n");
		SetServoPosition(PANCAKE_POSITION,100*pancake);
		pancake = !pancake;
	}
	GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_2);
}
Beispiel #9
0
void deployJames(bool on) {
	if(on)
	{
		//GPIOPinWrite(GPIO_PORTA_BASE, JAMES_POSITION, 0x00);
		GPIOPinIntEnable(GPIO_PORTA_BASE, TRIGGER_POSITION);
		shooting = true;
	}
	else
	{
		//SetServoPosition2(JAMES_Position2,255);
		//GPIOPinWrite(GPIO_PORTA_BASE, JAMES_POSITION, 0xff);
		GPIOPinIntDisable(GPIO_PORTA_BASE, TRIGGER_POSITION);
		shooting = false;
	}
}
/******** Debug_NetworkTransceiver_FullQueue *******************************
// FAILED - test failure on receiving more packets than queue size
// Input: none
// Output: none
// ------------------------------------------------------------------------*/
void Debug_NetworkTransceiver_FullQueue ( void )
{
    unsigned char status;
    unsigned char tx[TRANSCEIVER_MAX_PAYLOAD];

    Transceiver_SetCallBack ( FULL_QUEUE_CALL_BACK, Dummy_FullQueueCallBack );

    GPIOPinIntDisable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );
    while ( pdPASS == xQueueSend(Transceiver_RX_Queue, tx, (portTickType)0) );
    GPIOPinIntEnable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );

    UARTprintf ( "Queue is full. Turn on transmitter and send a packet now...5>" );
    Delay_S(1);
    UARTprintf ( "4>" );
    Delay_S(1);
    UARTprintf ( "3>" );
    Delay_S(1);
    UARTprintf ( "2>" );
    Delay_S(1);
    UARTprintf ( "1>" );
    Delay_S(1);
    UARTprintf ( "0\n" );
    Delay_S(1);

    switch ( testID )
    {
    case '0':
        xTaskCreate( Debug_NetworkTransceiver_EmptyQueue, ( signed portCHAR * ) "Debug_NetworkTransceiver_EmptyQueue",
                     DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
        break;

    case '7':
        break;

    default:
        Delay_S ( 1 );
        xTaskCreate( Debug_NetworkTransceiver, ( signed portCHAR * ) "Debug_NetworkTransceiver",
                     DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
        break;
    }

    vTaskDelete ( NULL );
}
Beispiel #11
0
Datei: ping.c Projekt: jrife/rtos
static void pingHandler(ping_config_t* ping) {
	int peripheral = ping->peripheral;
	int portBase = ping->portBase;
	int pin = ping->pin;
	int pulseStarted = ping->pulseStarted;
	UINT reload = OS_RawTimerReload();
	
	GPIOPinIntClear(portBase, pin);
	
	// this is the rising edge
	if(!pulseStarted && GPIOPinRead(portBase, pin)) {
		ping->pulseStartTime = reload - OS_RawTimerTime();
		ping->pulseStarted = TRUE;
	}
	else if(pulseStarted) {
		ping->pulseStarted = FALSE;
		ping->pulseEndTime = reload - OS_RawTimerTime();
		GPIOPinIntDisable(portBase, pin);
		ping->sampleHandler(OS_TimeDifference(ping->pulseEndTime, ping->pulseStartTime, reload));
	}
}
/******** Debug_NetworkTransceiver_EmptyQueue ******************************
// FAILED - receive packet from empty queue
// Input: none
// Output: none
// ------------------------------------------------------------------------*/
void Debug_NetworkTransceiver_EmptyQueue ( void )
{
    unsigned char status;
    unsigned char rx[TRANSCEIVER_MAX_PAYLOAD];
    TransceiverPacket pkt;

    Transceiver_SetCallBack ( EMPTY_QUEUE_CALL_BACK, Dummy_EmptyQueueCallBack );

    GPIOPinIntDisable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );
    while ( pdPASS == xQueueReceive(Transceiver_RX_Queue, rx, (portTickType)0) );
    status = Transceiver_ReceiveMessage ( &pkt );
    GPIOPinIntEnable ( nrf24l01_IRQ_IOREGISTER, nrf24l01_IRQ_PIN );

    if ( status == ERROR_QUEUE_EMPTY )
        UARTprintf ("EmptyQueue test PASSED: Status = 0x%x\n", status);
    else
        UARTprintf ("EmptyQueue test FAILED: Status = 0x%x\n", status);

    UARTprintf ("-----------------------------------------\n");

    switch ( testID )
    {
    case '0':
        xTaskCreate( Debug_NetworkTransceiver_MaxRetries, ( signed portCHAR * ) "Debug_NetworkTransceiver_MaxRetries",
                     DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
        break;

    case '7':
        break;

    default:
        Delay_S ( 1 );
        xTaskCreate( Debug_NetworkTransceiver, ( signed portCHAR * ) "Debug_NetworkTransceiver",
                     DEFAULT_STACK_SIZE, NULL, DEFAULT_PRIORITY, NULL );
        break;
    }

    vTaskDelete ( NULL );
}
Beispiel #13
0
// Internally used function to register a pin interrupt
static void CallOnPinType(tCallback callback, void *data, tPin pin, unsigned long type) {
    tPinTask *task = &pinTaskBuffer[pin];

    // Stop the interrupt first to avoid a race condition
    GPIOPinIntDisable(PORT_VAL(pin), PIN_VAL(pin));
    task->callback = Dummy;
    
    // Make sure the pin is setup as an input
    GPIOPinTypeGPIOInput(PORT_VAL(pin), PIN_VAL(pin));
    
    // If a null pointer is passed then we just leave the Dummy
    // to unregister the callback
    if (callback) {
        task->data = data;
        task->callback = callback;
        
        // Setup the interrupts
        GPIOIntTypeSet(PORT_VAL(pin), PIN_VAL(pin), type);
        GPIOPinIntClear(PORT_VAL(pin), PIN_VAL(pin));
        GPIOPinIntEnable(PORT_VAL(pin), PIN_VAL(pin));
    }
}
Beispiel #14
0
// *************** GPIO_DisableInterrupts *************** 	   
void GPIO_DisableInterrupts( GPIO_PORT_T port, GPIO_PIN_T pins )
{  					  
//	IntDisable( GPIO_IntAssignment[port] );
 	GPIOPinIntDisable( GPIO_PortBase[port], pins );
}
Beispiel #15
0
/*
** This function configures given source for standby wakeup.
*/
void enableStandbyWakeSrc(unsigned int wakeSource)
{
    /* Disable interrupt of SW pin to avoid wake through SW for other src sel */
    GPIOPinIntDisable(GPIO_INST_BASE_SW, GPIO_INT_LINE_1, GPIO_SW_PIN_NUM);
    GPIOPinIntDisable(GPIO_INST_BASE_SW, GPIO_INT_LINE_2, GPIO_SW_PIN_NUM);

    /* IO Pad Configuration */
    pmStdbySrcIOPin.padConfig.slewRate = 0;
    pmStdbySrcIOPin.padConfig.mode = 7;
    pmStdbySrcIOPin.padConfig.type = CONTROL_CONF_RXACTIVE;
    pmStdbySrcIOPin.padConfig.pullEnable = CONTROL_CONF_PULLUDDISABLE;
    pmStdbySrcIOPin.padConfig.pullSel = 0;

    /* GPIO Pin Configuration */
    pmStdbySrcIOPin.gpioConfig.dir = GPIO_DIR_INPUT;
    pmStdbySrcIOPin.gpioConfig.debouEnable = GPIO_DEBOUNCE_FUNC_DISABLE;
    pmStdbySrcIOPin.gpioConfig.intrEnable = 1;
    pmStdbySrcIOPin.gpioConfig.intrType = GPIO_INT_TYPE_BOTH_EDGE;

    switch(wakeSource)
    {
        case WAKE_SOURCE_TSC:

            /* Skip Touchscreen for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_ADC_TSC);

            /* Enable hardware pen event interrupt */
            TSCADCEventInterruptEnable(TSC_ADC_INSTANCE,
                                       TSCADC_ASYNC_HW_PEN_EVENT_INT);
            break;

        case WAKE_SOURCE_UART:

            /* Skip GPIO for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_GPIO1);


            /* Enable GPIO Interrupt on UART RXD Pin */
            pmStdbySrcIOPin.ioPadOff = GPIO_UART_RDX_PAD_OFFSET;
            pmStdbySrcIOPin.pinNum = GPIO_UART_RDX_PIN_NUM;
            pmStdbySrcIOPin.gpioBaseAddr = GPIO_INST_BASE_UART_RXD;
            pmStdbySrcIOPin.gpioConfig.intrLine = GPIO_UART_RXD_INTR_LINE;
            pmStdbySrcIOPin.intrNum = GPIO_UART_RXD_SYS_INT_NUM;
            pmStdbySrcIOPin.gpioIsr = gpioStdbyUartIsr;

            DemoGpioPinStandbySrcConfig(&pmStdbySrcIOPin);
            break;

        case WAKE_SOURCE_TMR:

            /* Skip Timer for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_TIMER6);

            ConsoleUtilsPrintf("\r\n Peripheral domain Timer is configured as"
                               "wake source.\r\n\r\n ... system will release "
                               "from standby in 20 seconds ...\r\n\r\n");

            /* Configure Timer 6 */
            Timer6Config();

            /* Set the counter value */
            DMTimerCounterSet(DMTIMER6_BASE_ADDR, TIMER_OVRFLW_20_SECOND_24MHZ);

            /* Start the timer */
            Timer6Start();
            break;

        case WAKE_SOURCE_GPIO:

            /* Skip GPIO for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_GPIO0);

            /* Enable GPIO Interrupt on UART RXD Pin */
            pmStdbySrcIOPin.ioPadOff = GPIO_SW_PAD_OFFSET;
            pmStdbySrcIOPin.pinNum = GPIO_SW_PIN_NUM;
            pmStdbySrcIOPin.gpioBaseAddr = GPIO_INST_BASE_SW;
            pmStdbySrcIOPin.gpioConfig.intrLine = GPIO_SW_INTR_LINE;
            pmStdbySrcIOPin.intrNum = GPIO_SW_SYS_INT_NUM;
            pmStdbySrcIOPin.gpioIsr = gpioStdbyGPIOIsr;

            DemoGpioPinStandbySrcConfig(&pmStdbySrcIOPin);
            break;

        case WAKE_SOURCE_RTC:

            /* Include GPIO for Enable/Disable Module  */
            ModuleListConfig(FALSE, CLK_RTC);

            ConsoleUtilsPrintf("\t..Alarm is configured to wakeup system after "
                               "20 Sec..");
            configWakeRTC();
            enableRTCAlarmIntr();
            break;

        default:
            break;
    }
}
Beispiel #16
0
void Extint::disable()
{
    GPIOPinIntDisable(this->GpioPortBase, this->GpioPin);
}
Beispiel #17
0
void
GPIOEIntHandler(void)
{
	// Clear the GPIO interrupt
	GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3);

	// Disable Interrupts
	GPIOPinIntDisable(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3);
	GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_0);

	// If the clock has been set before, we need to disable SysTickInt
	if (start==1){
		SysTickIntDisable();
	}

	// Clear the OLED
	RIT128x96x4Clear();

	// If the left button got us here, display that we are in set clock mode
	// If the right button got us here, display that we are in set alarm mode
	if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0){
		RIT128x96x4StringDraw("Set Clock", 40, 0, 15);
		DisplayTime();
	}
	else if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){
		RIT128x96x4StringDraw("Set Alarm", 40, 0, 15);
		DisplayTimeA();
	}

	// If the left button is held down enable the time to be set
	while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0){
		// While the up button is being pressed, the clock will increment
		if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0){
			// In order to slow the incrementing we count to 10000 first
			x++;
			if (x>9999){
				// Show the increment
				DisplayIncrementedTime();
				x = 0;
			}
		}
		// While the down button is being pressed, the clock will decrement
		if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){
			// In order to slow the decrementing we count to 10000 first
			x++;
			if (x>9999){
				// Show the decrement
				DisplayDecrementedTime();
				x = 0;
			}
		}
	}

	// If the right button is held down enable the alarm to be set
	while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){
		// While the up button is being pressed, the clock will increment
		if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0){
			// In order to slow the decrementing we count to 10000 first
			x++;
			if (x>9999){
				// Show the increment
				DisplayIncrementedAlarm();
				x = 0;
			}
		}
		// While the down button is being pressed, the clock will decrement
		if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){
			// In order to slow the decrementing we count to 10000 first
			x++;
			if (x>9999){
				// Show the decrement
				DisplayDecrementedAlarm();
				x = 0;
			}
		}
		alarmSet = 1;
	}

	RIT128x96x4Clear();

	// Enable the interrupts
	GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3);
	GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0);

	// If the start variable is not set, we set it and start SysTick
	if (!start){
		start++;
		t = 0;
		SysTickIntEnable();
		SysTickEnable();
	}
	else {
		SysTickIntEnable();
	}
}
Beispiel #18
0
void
GPIOFIntHandler(void){
	// Method for handling multiple functions for a select button press

	// Clear the GPIO interrupt
	GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);

	// Disable Interrupts
	GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinIntDisable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

	// Check which state we are in
	if (state==0){
		// This state handles the main menu

		if (pointer==0){
			// Begin Classic Mode
			state = 1;
			startClassic();
		}
		else if (pointer==1){
			// Begin Continuous Mode
			state = 3;
			startClassic();
		}
		else if (pointer==2){
			// Show the instructions
			state = 2;
			RIT128x96x4Clear();
			displayInstructions();
			done = 1;
		}
		else if (pointer==3){
			// Show the high scores
			state = 2;
			RIT128x96x4Clear();
			displayScores();
			done = 1;
		}
		else if (pointer==4){
			state = 0;
			initMain();
		}
	}
	else if (state==1){
		// This state handles classic mode

		// Black out the letter that was selected
		int idx = position + position2;
		int pos = 0;
		char *puc_letter = alpha[idx];
		if (idx>12){
			pos = position2 * 10;
			RIT128x96x4StringDraw(puc_letter, pos, 87, 2);
		}
		else {
			pos = position * 10;
			RIT128x96x4StringDraw(puc_letter, pos, 75, 2);
		}

		// Add the letter to the list of selected letters
		int i;
		int wrong = 1;
		int used = 0;
		// Loop through the list until we find an empty spot to place the letter
		for (i=0; i<26; i++){
			if (strcmp(selected[i],"!")==0){
				selected[i] = puc_letter;
				break;
			}
			if (strcmp(selected[i],puc_letter)==0){
				wrong = 0;
				used = 1;
				break;
			}
		}

		// Check to see if the letter was already used
		if (!used){
			// Check the word to see if a letter matches the one selected. If it
			// does, we need to display the letters instead of an underscore
			for (i=0; i<strlen(words[wotd]); i++){
				char w_let = words[wotd][i];
				static char g[3];
				usprintf(g, "%d", w_let);
				char p_let = *puc_letter;
				if (w_let==p_let){
					wrong = 0;
					// Display the letter selected
					RIT128x96x4StringDraw(puc_letter, 10+i*10, 53, 15);
					correct++;
				}
			}
		}

		// Check to see if it was a wrong selection
		if (wrong==1){
			// Increment the number of wrong attempts
			try++;
			// If the selection was wrong, we need to draw a piece of the hangman
			if (try==1){
				drawHead();
			}
			else if (try==2){
				drawBody();
			}
			else if (try==3){
				drawRightArm();
			}
			else if (try==4){
Beispiel #19
0
void
GPIOEIntHandler(void)
{
	// Method for handling directional pad interrupts. The left and right
	// buttons allow the user to move the alphabet cursor left and right. This
	// behavior is handled here.

	// Clear the GPIO interrupt
	GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

	// Disable Interrupts
	GPIOPinIntDisable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

	if (state==0){
		while(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0 ||
			GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){
			// Increment the counter
			x++;
			if (x>19999){
				if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0){
					if (pointer!=0){
						clearPointer(50+(pointer*10));
						pointer--;
						drawPointer(50+(pointer*10));
					}
					x = 0;
					break;
				}
				if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){
					if (pointer!=3){
						clearPointer(50+(pointer*10));
						pointer++;
						drawPointer(50+(pointer*10));
					}
					x = 0;
					break;
				}
			}
		}
		x = 0;
	}
	else if (state==1 || state==3){
		// Count to 15000 so that we don't move the cursor too fast
		while(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0 ||
				GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){
			// Increment the counter
			x++;
			if (x>14999){
				// Check to see which button was pressed
				if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0){
					// Check if the cursor is not in the original position on the
					// top row. If it is, we do nothing
					if (position>0){
						// Check if the cursor is not in the original position on
						// the bottom row
						if (position2>0){
							// Move the cursor one spot to the left
							position2--;
						}
						else {
							// Move the cursor one spot to the left
							position--;
						}
					}
				}
				else if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){
					// Check if the cursor is at the last possible position on the
					// bottom row. If it is, we do nothing
					if (position2<12){
						// Check if the cursor is at the last spot on the top row
						if (position<13){
							// Move the cursor one spot to the right
							position++;
						}
						else {
							// Move the cursor one spot to the right
							position2++;
						}
					}
				}
				// Update the position of the cursor
				moveCursor();
				break;
			}
		}
		x = 0;
	}

	// Enable Interrupts
	GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
}
Beispiel #20
0
void joystick_disable(void){
	GPIOPinIntDisable(JOY_PORT, JOY_MASK);
    ADCIntDisable(ADC0_BASE, 0);
    ADCIntDisable(ADC0_BASE, 1);
//	GPIOPinIntDisable(JOG_Z_PORT, JOG_Z_MASK);
}
Beispiel #21
0
void GpioIn::disableInterrupts(void)
{
    // Disable the interrupt
    GPIOPinIntDisable(gpio_.port, gpio_.pin);
}
Beispiel #22
0
void SpiPauseSpi(void)
{
  GPIOPinIntDisable( 2, 0 );
}