Exemplo n.º 1
0
static void handle_button_interrupts(void* context, alt_u32 id)
{
    /* Cast context to edge_capture's type. It is important that this
    be declared volatile to avoid unwanted compiler optimization. */
    volatile int* edge_capture_ptr = (volatile int*) context;
    /*
    * Read the edge capture register on the button PIO.
    * Store value.
    */
    *edge_capture_ptr =
    IORD_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE);
    /* Write to the edge capture register to reset it. */
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE, 0);
    /* Read the PIO to delay ISR exit. This is done to prevent a
    spurious interrupt in systems with high processor -> pio
    latency and fast interrupts. */
    IORD_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE);
    printf("Handler captured!\n");
}
Exemplo n.º 2
0
static void handle_button_interrupts(void* context, alt_u32 id)
#endif
{
  /* Cast context to edge_capture's type.
   * It is important to keep this volatile,
   * to avoid compiler optimization issues.
   */
  volatile int* edge_capture_ptr = (volatile int*) context;
  /* Store the value in the Button's edge capture register in *context. */
  *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);
  /* Reset the Button's edge capture register. */
  IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0);

  /*
   * Read the PIO to delay ISR exit. This is done to prevent a spurious
   * interrupt in systems with high processor -> pio latency and fast
   * interrupts.
   */
  IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);
}
Exemplo n.º 3
0
static void handle_button_interrupt(void* context)
{
	/* cast context to edge_capture's type. it is important that this
	   be declared volatile to avoid unwanted compiler optimization. */
	volatile int* edge_capture_ptr = (volatile int*) context;

	/*
	 * read the edge capture register on the button pio.
	 * store value.
	 */
	*edge_capture_ptr =	IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_BASE);

	/* write to the edge capture register to reset it. */
	IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_BASE, 0);

	/* read the pio to delay isr exit. this is done to prevent a
	   spurious interrupt in systems with high processor -> pio
	   latency and fast interrupts. */
	IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_BASE);

	OSSemPost(SEM_REPORT);
}
Exemplo n.º 4
0
//------------------------------------------------------------------------------
UINT8 gpio_getAppInput(void)
{
    UINT8    key;

#ifdef HOST_0_BUTTON_PIO_BASE
    key = (UINT8)IORD_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_BUTTON_PIO_BASE);
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_BUTTON_PIO_BASE, FPGA_PB_ALL_BIT_MASK);
#else
    key = 0;
#endif

    return key;
}
Exemplo n.º 5
0
static void BUTTON_ISR(void* context, alt_u32 id)
{
    if(stop_flag == 0)
    	stop_flag = 1;
    else
    	stop_flag = 0;

    /* Store the value in the Button's edge capture register in *context. */
    edge_capture = IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);

    /* Reset the Button's edge capture register. */
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0);

}
Exemplo n.º 6
0
/*		Key Setups 		*/
static void handle_button_interrupts(void* context, alt_u32 id)
{
	/* cast the context pointer to an integer pointer. */
	volatile int* edge_capture_ptr = (volatile int*) context;
	/*
	* Read the edge capture register on the button PIO.
	* Store value.
	*/
	*edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE);
	/* Write to the edge capture register to reset it. */
	IOWR_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE, 0);
	/* reset interrupt capability for the Button PIO. */
	IOWR_ALTERA_AVALON_PIO_IRQ_MASK(KEY_BASE, 0xf);
}
Exemplo n.º 7
0
void button_interrupts_function(void* context, alt_u32 id)
{
	int buttonValue = 0;
  // need to cast the context first before using it
	printf("button pressed \n");

	BaseType_t xHigherPriorityTaskWoken;

	buttonValue = IORD_ALTERA_AVALON_PIO_EDGE_CAP(PUSH_BUTTON_BASE);
	// clears the edge capture register
	IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PUSH_BUTTON_BASE, 0x7);
	printf("buttonValue %d\n", buttonValue);
	//buttonValue &= 0x4;

	if (buttonValue == 0x4){
		user_management_mode ^= 1;
	}


	//portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
 }
Exemplo n.º 8
0
void button_isr(void* context, alt_u32 id) {
    static alt_u32 NextActiveTime = 0;
    bool bUpdateVPG = FALSE;
    // static alt_u8 disp_mode = 0;
    alt_u8 pushbutton_mask;

    if (id != PIO_BUTTON_IRQ)
        return;

    // get the edge capture mask
    pushbutton_mask = IORD_ALTERA_AVALON_PIO_EDGE_CAP(
                          PIO_BUTTON_BASE) & 0x03;  // button0/1

    // Reset the edge capture register
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_BUTTON_BASE,0);

//    // the following function only work for tx-only mode
//    if (gDemoMode != DEMO_TX_ONLY)
//        return;

    if (pushbutton_mask & 0x02) { // BUTTON[1]     // play tone
//        gbPlayTone = TRUE;
//        #ifndef TX_VPG_COLOR_CTRL_DISABLED
        OS_PRINTF("===> BUTTON 1 \n");

//RxActivePort = RX_PORT_A;
//                    // 1. power down hdmi
//PowerDownHDMI();
//                    // 2. Select HDMI Port
        SelectHDMIPort(CAT_HDMI_PORTA);
////                    // 3. Call InitIT6605
        InitIT6605();

        if (alt_nticks() > NextActiveTime) {
//                gVpgColor++;
//                if (gVpgColor == COLOR_YUV422 && !HDMITX_IsSinkSupportYUV422())
//                    gVpgColor++;
//                if (gVpgColor == COLOR_YUV444 && !HDMITX_IsSinkSupportYUV444())
//                    gVpgColor++;
//                if (gVpgColor == COLOR_MODE_NUM)
//                    gVpgColor = 0;  // RGB
//                bUpdateVPG = TRUE;
//gh00st
            NextActiveTime = alt_nticks() + alt_ticks_per_second()/2;
        }
//        #endif //TX_VPG_COLOR_CTRL_DISABLED
    } else if (pushbutton_mask & 0x01) { // BUTTON[0]    // change pattern generotor's pattern
        OS_PRINTF("===> BUTTON 0 \n");
//RxActivePort = RX_PORT_B;
//                    // 1. power down hdmi
//PowerDownHDMI();
//                    // 2. Select HDMI Port
        SelectHDMIPort(CAT_HDMI_PORTB);
//                    // 3. Call InitIT6605
        InitIT6605();
        if (alt_nticks() > NextActiveTime) { // note. timer should have a highter IRQ priority than button
//            // next mode
//            if (gVpgMode == MODE_1920x1080i120)
//                gVpgMode = MODE_720x480;
//            else
//                gVpgMode++;
//            bUpdateVPG = TRUE;
            NextActiveTime = alt_nticks() + alt_ticks_per_second()/2;
        }
    }

    if (bUpdateVPG) {
        HDMITX_DisableVideoOutput();
        VPG_Config(gVpgMode, gVpgColor);
        SetupTxVIC(gVpgMode);
        SetupColorSpace();
        HDMITX_EnableVideoOutput();
    }

}