/**
*
* This function disables the interrupts for the GPIO
*
* @param	IntcInstancePtr is a pointer to the Interrupt Controller
*		driver Instance
* @param	InstancePtr is a pointer to the GPIO driver Instance
* @param	IntrId is XPAR_<INTC_instance>_<GPIO_instance>_IP2INTC_IRPT_INTR
*		value from xparameters.h
* @param	IntrMask is the GPIO channel mask
*
* @return	None
*
* @note		None.
*
******************************************************************************/
void GpioDisableIntr(XIntc* IntcInstancePtr, XGpio* InstancePtr,
                     u16 IntrId, u16 IntrMask)
{
    XGpio_InterruptDisable(InstancePtr, IntrMask);
    XIntc_Disable(IntcInstancePtr, IntrId);
    return;
}
Пример #2
0
void PushBtnHandler(void * CallBackRef)
{
    state1 = XGpio_DiscreteRead(&Btns, 1);
    pshBtn = 1;
    XGpio_InterruptDisable(&Btns, 1);
    Delay_50ms();
    XGpio_InterruptClear(&Btns, 1);
    XGpio_InterruptEnable(&Btns, 1);
}
Пример #3
0
void Switch_INTr_Handler(void *InstancePtr)
{// Disable GPIO interrupts
	XGpio_InterruptDisable(&SwitchInst, SWITCH_INT);
	// Ignore additional button presses
	if ((XGpio_InterruptGetStatus(&SwitchInst) & SWITCH_INT) != SWITCH_INT) {
			return;
		}

	//DO SOMETHING HERE FOR THE INTERRUPT

    (void)XGpio_InterruptClear(&SwitchInst, SWITCH_INT);
    // Enable GPIO interrupts
    XGpio_InterruptEnable(&SwitchInst, SWITCH_INT);
}
Пример #4
0
void BTNS_Intr_Handler()
{
    //Xil_ExceptionDisable();
    XGpio_InterruptDisable(&ButtonsInstancePtr, GPIO_BTNS_ID);

    int btn_value = XGpio_DiscreteRead(&ButtonsInstancePtr, 1);
    if( btn_value == 0x1) {
        XGpio_DiscreteWrite(&LedsInstancePtr, 1, 0x5);
        xil_printf("Button pressed");
    }

    //Xil_ExceptionEnable();
    XGpio_InterruptEnable(&ButtonsInstancePtr, GPIO_BTNS_ID);
}
Пример #5
0
static void gpioInterruptHandler(void *CallBackRef)
{
	XGpio_InterruptDisable(&gpioInstance, XGPIO_IR_CH1_MASK);
	XGpio *gpio = (XGpio *) CallBackRef;
	int status = XGpio_InterruptGetStatus(gpio);
	if( status & XGPIO_IR_CH1_MASK )
	{
		XGpio_InterruptClear(&gpioInstance, XGPIO_IR_CH1_MASK);
		int gpioReg = XGpio_DiscreteRead(&gpioInstance, 1);
		if((gpioReg & RF_INTERRUPT_MASK) == 1)
			dataRec = true;
	}
	XGpio_InterruptEnable(&gpioInstance, XGPIO_IR_CH1_MASK);
}
void GpioIsr(void *InstancePtr){
	XGpio *GpioPtr = (XGpio *)InstancePtr;
	u32 gpio_read;

	XGpio_InterruptDisable(GpioPtr, GPIO_INPUT_INTERRUPT);
	gpio_read = XGpio_DiscreteRead(GpioPtr, GPIO_INPUT_CHANNEL);

	if(gpio_read & GPIO_MASK_PB_U) pb_u_callback();
	if(gpio_read & GPIO_MASK_PB_M) pb_m_callback();
	if(gpio_read & GPIO_MASK_PB_D) pb_d_callback();

	(void)XGpio_InterruptClear(GpioPtr, GPIO_INPUT_INTERRUPT);
	XGpio_InterruptEnable(GpioPtr, GPIO_INPUT_INTERRUPT);

	return;
}
Пример #7
0
void GpioHandler(void *InstancePtr)
{
	/*
	Game System Interface (16 bits)
	#define GAME_TRUCK_IS_BASE_M		0x0001
	#define GAME_HAVE_FLAG_M			0x0002
	#define GAME_TRUCK_ALIVE_M			0x0004
	#define GAME_TRUCK_REGISTERED_M		0x0008
	#define GAME_TEAM_NUM_1_M			0x0010
	#define GAME_TEAM_NUM_0_M			0x0020
	#define GAME_STATE_1_M				0x0040		//stop, go, pause, win
	#define GAME_STATE_0_M				0x0080
	#define GAME_KILL_SHOT				0x0100
	#define GAME_PASS_SHOT				0x0200
	#define GAME_REVIVE_SHOT			0x0400
	#define GAME_HIT_ACK				0x0800
	#define GAME_MISS_ACK				0x1000
	#define HELIOS_ENABLE_GYRO			0x2000
	#define GAME_NOT_IN_PLAY			0x4000
	#define GAME_WAIT_TO_SHOOT			0x8000
	 */

	XGpio *GpioPtr = (XGpio *)InstancePtr;
	u32 gameSystem;
	//u32 gameSystemChanged = 0;
	static u32 gameSystemPrevious = 0;

	/*
	 * Disable the interrupt
	 */
	XGpio_InterruptDisable(GpioPtr, XGPIO_IR_CH2_MASK);

	/*
	 * There should not be any other interrupts occuring other than the
	 * the button changes
	 */
	if ((XGpio_InterruptGetStatus(GpioPtr) & XGPIO_IR_CH2_MASK) !=
			XGPIO_IR_CH2_MASK) {
		return;
	}

	/*
	 * Read state of push buttons and determine which ones changed
	 * states from the previous interrupt. Save a copy of the buttons
	 * for the next interrupt
	 */
	gameSystem = XGpio_DiscreteRead(GpioPtr, GAME_SYSTEM_GPIO_CHANNEL);
	//gameSystemChanged = gameSystem ^ gameSystemPrevious;


	if (((~gameSystemPrevious) & GAME_WAIT_TO_SHOOT) && (gameSystem & GAME_WAIT_TO_SHOOT)) {
		// Wait to shoot went from low to high
		XGpio_DiscreteClear(&Gpio, GAME_SYSTEM_GPIO_CHANNEL, CurrentShotType);
		CurrentShotType = 0;
	}

	/* Clear the interrupt such that it is no longer pending in the GPIO */

	(void)XGpio_InterruptClear(GpioPtr, XGPIO_IR_CH2_MASK);

	/*
	 * Enable the interrupt
	 */

	gameSystemPrevious = gameSystem;
	XGpio_InterruptEnable(GpioPtr, XGPIO_IR_CH2_MASK);
}
/**
* This function is the Interrupt Service Routine for the GPIO device.  It
* will be called by the processor whenever an interrupt is asserted by the
* device.
*
* This function will detect the push button on the board has changed state
* and then turn on or off the LED.
*
* @param	InstancePtr is the GPIO instance pointer to operate on.
*		It is a void pointer to meet the interface of an interrupt
*		processing function.
*
* @return	None.
*
* @note		None.
*
*****************************************************************************/
void GpioIsr(void *InstancePtr)
{
	XGpio *GpioPtr = (XGpio *)InstancePtr;
	u32 Led;
	u32 LedState;
	u32 Buttons;
	u32 ButtonFound;
	u32 ButtonsChanged = 0;
	static u32 PreviousButtons;

	/*
	 * Disable the interrupt
	 */
	XGpio_InterruptDisable(GpioPtr, BUTTON_INTERRUPT);

	/* Keep track of the number of interrupts that occur */

	InterruptCount++;

	/*
	 * There should not be any other interrupts occuring other than the
	 * the button changes
	 */
	if ((XGpio_InterruptGetStatus(GpioPtr) & BUTTON_INTERRUPT) !=
		BUTTON_INTERRUPT) {
		return;
	}


	/*
	 * Read state of push buttons and determine which ones changed
	 * states from the previous interrupt. Save a copy of the buttons
	 * for the next interrupt
	 */
	Buttons = XGpio_DiscreteRead(GpioPtr, BUTTON_CHANNEL);
	ButtonsChanged = Buttons ^ PreviousButtons;
	PreviousButtons = Buttons;

	/*
	 * Handle all button state changes that occurred since the last
	 * interrupt
	 */
	while (ButtonsChanged != 0) {
		/*
		 * Determine which button changed state and then get
		 * the current state of the associated LED
		 */
		 Led = MapButton2Led(ButtonsChanged, &ButtonFound);
		 LedState = XGpio_DiscreteRead(GpioPtr, LED_CHANNEL) & Led;

		 /*
		  * Clear the button that is being processed so that it is
		  * done and others can be handled also
		  */
		 ButtonsChanged &= ~ButtonFound;

		 /* Toggle the state of the LED */
		 if (LedState) {
			 XGpio_DiscreteClear(GpioPtr, LED_CHANNEL, Led);
		 } else {
			 XGpio_DiscreteSet(GpioPtr, LED_CHANNEL, Led);
		 }
	 }

	 /* Clear the interrupt such that it is no longer pending in the GPIO */

	 (void)XGpio_InterruptClear(GpioPtr, BUTTON_INTERRUPT);

	 /*
	  * Enable the interrupt
	  */
	 XGpio_InterruptEnable(GpioPtr, BUTTON_INTERRUPT);

}
Пример #9
0
/**
* This function is the Interrupt Service Routine for the GPIO device.
*
* This function will detect the push button on the board has changed state
* and then prepare data to be sent to the host upon receiving the Get
*
* @param	InstancePtr is the GPIO component to operate on. It is a void
*		pointer to meet the interface of an interrupt processing
* 		function.
*
* @return 	None.
*
* @note		None.
*
*****************************************************************************/
void GpioIsr(void *InstancePtr)
{
	XGpio *GpioPtr = (XGpio *)InstancePtr;
	u32 Buttons;
	u32 ButtonsChanged = 0;
	static u32 PreviousButtons;
	u8 Index = 0;
	static u8 State = 0;
	const u8 Position[] = {-4, -4, -4, 0, 4, 4, 4, 0, -4, -4};
	u8 TxBuf[4];


	/*
	 * Disable the interrupt
	 */
	XGpio_InterruptDisable(GpioPtr, BUTTON_INTERRUPT);


	/*
	 * There should not be any other interrupts occurring other than the
	 * the button changes.
	 */
	if ((XGpio_InterruptGetStatus(GpioPtr) & BUTTON_INTERRUPT) !=
		BUTTON_INTERRUPT) {
		return;
	}

	/*
	 * Read state of push buttons and determine which ones changed
	 * states from the previous interrupt. Save a copy of the buttons
	 * for the next interrupt.
	 */
	Buttons = (XGpio_DiscreteRead(GpioPtr, BUTTON_CHANNEL) & 0x1F) ;
	ButtonsChanged = Buttons ^ PreviousButtons;
	PreviousButtons = Buttons;

	/*
	 * Handle all button state changes that occurred since the last
	 * interrupt
	 */
	while (ButtonsChanged != 0) {

		/*
		 * Determine which button changed state and then get
		 * the current state of the associated LED
		 */
		if (ButtonsChanged & 0x1F){

				if (ButtonsChanged & EXIT_BUTTON){
					StopTest = TRUE;
					break;
				}
				TxBuf[1] = Position [State];
				TxBuf[2] = Position [State+2];
				++State;
				for (Index =0; Index < 5; Index++){
					XUsb_EpDataSend(&UsbInstance, 1,
						(unsigned char *)&TxBuf[0], 4);
				}

				if (State > 7)
					State = 0;
		}
		break;
	}

	/*
	 * Clear the interrupt such that it is no longer pending in the GPIO
	 */
	(void)XGpio_InterruptClear(GpioPtr, BUTTON_INTERRUPT);

	/*
	 * Enable the interrupt
	 */
	XGpio_InterruptEnable(GpioPtr, BUTTON_INTERRUPT);

}
Пример #10
0
void BTN_Intr_Handler(void *InstancePtr)
{

	// Ignore additional button presses
		if ((XGpio_InterruptGetStatus(&BTNInst) & BTN_INT) !=
				BTN_INT) {
				return;

		// Disable GPIO interrupts
		XGpio_InterruptDisable(&BTNInst, BTN_INT);
				 }


		btn_value = XGpio_DiscreteRead(&BTNInst, 1);
		switch (btn_value){

					//Checking if BTNC was pressed. Action: Show Alex in the middle
					case 1:
						x=8;
						y=2;
						clear_OLED();
						show_alex(x,y);
					break;

					//Checking if BTND was pressed. Action: Check for boundary and move Alex down.
					case 2:
						if (y<3)
							{
								y=y+1;
								clear_OLED();
								show_alex(x,y);
							}
					break;

					//Checking if BTNL was pressed. Action: Check for boundary and move Alex left.
					case 4:
						if (x>0)
							{
								x=x-1;
								clear_OLED();
								show_alex(x,y);
							}
					break;

					//Checking if BTNR was pressed. Action: Check for boundary and move Alex right.
					case 8:
						if (x<15)
							{
								x=x+1;
								clear_OLED();
								show_alex(x,y);
							}
					break;

					//Checking if BTNU was pressed. Action: Check for boundary and move Alex up.
					case 16:
						if (y>0)
							{
								y=y-1;
								clear_OLED();
								show_alex(x,y);
							}
					break;

					default:
					break;
						}


		// Acknowledge GPIO interrupts
	    (void)XGpio_InterruptClear(&BTNInst, BTN_INT);
	    // Enable GPIO interrupts
	    XGpio_InterruptEnable(&BTNInst, BTN_INT);

}
Пример #11
0
void disableButtonInterrupt(void) {
	xil_printf("\r\nDisabling button interrupts...");
	XGpio_InterruptDisable(&pshBtns, lBtnChannel);
	XGpio_InterruptGlobalDisable(&pshBtns);
	xil_printf("done");
}
Пример #12
0
void disable_interrupt_gpio( cyg_uint32 mask )
{
    XGpio_InterruptDisable(&gpio_manager_device, mask);
}