/*ISR*------------------------------------------------------------------------ * * ISR Name : btn_kernel_isr * Comments : * The interrupt service routine triggered by pusshing button. * The function pointer is assigned into the interrupt vector * table of the processor instead of the kernel interrupt vector table of MQX. * This interrupt handler should be used with good care about following points. * * 1)For native MQX interrupt handling sequence, the _int_kernel_isr() is * invoked as interrupt occurs. The _int_kernel_isr() updates the interrupt * context in the MQX kernel and saves the context of the current program * (which could be the lower priority interrupt). When interrupt handler is * installed directly into the interrupt vector table of processor, the * interrupt fields in the kernel is not updated for that interrupt as it * happens. If user calls any function: _lwevent_set(), _lwsem_post(), * _lwmsgq_send(), _time_delay() the functions _CHECK_RUN_SCHEDULER() is * invoked which then initiate the PendSV exception handler with priority * level higher than the current running task. This results in the Usage * fault exception in the processor and the application crashes. * * The user therefore must not call any function from MQX kernel API * inside this interrupt handler. * 2)The interrupt flag should be cleared at the beginning of the interrupt * handler to overcome the problem of unintentionally invoking the ISR * twice. In detail the deasserting of interrupt signal to NVIC module * in the processor does not happen right after the interrupt flag is * cleared but only after a certain amount of time. This delay is because * of the write_buffer feature integrated into the processor. * * However for the native method of handling interrupt in MQX kernel * in which function _int_kernel_isr() is invoked as interrupt occurs * the interrupt flag can be cleared at any time in the user's ISR without * worrying about that phenomenon. This is because after executing user's * ISR the _int_kernel_isr() function does a number of operations before * exiting and that process always takes longer time than the delay * described previously. This makes the interrupt signal to NVIC module * to be deasserted before processor finishes servicing the interrupt. *END*------------------------------------------------------------------------*/ void btn_kernel_isr ( void ) { lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) (&btn1)); btn_pressed = !btn_pressed; }
static void button_isr ( void *pin ) { lwgpio_toggle_value (&led1); lwgpio_int_clear_flag (pin); _lwevent_set (&app_event, SW_EVENT_MASK); }
static void kbi_callback(pointer kbi_param_ptr) { /* Determine if it was SW2 or SW3 that caused interrupt */ if (SEC_GetInput(SEC_DOOR_INPUT) == OPENED) { SEC_Params.Status = SEC_DOOR_OPEN_STATUS; SEC_SetOutput(SEC_OPEN_OUTPUT, 1); } if (SEC_GetInput(SEC_WINDOW_INPUT) == OPENED) { SEC_Params.Status = SEC_WINDOW_OPEN_STATUS; SEC_SetOutput(SEC_OPEN_OUTPUT, 1); } lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) kbi_param_ptr); }
void EXT_SDDETECT_ISR(void *pin) { int sd_pin; boolean inserted; // if(sd_pin = lwgpio_int_get_flag((LWGPIO_STRUCT_PTR) pin)) { inserted = !lwgpio_get_value((LWGPIO_STRUCT_PTR) pin); // printf("sd detect pin changed %d,insert state %d,cur_musicPlayMS %d\n",sd_pin,inserted,cur_musicPlayMS); //if(cur_musicPlayMS != mp_sBT) { if(inserted) _lwevent_set(&sddetect_event,SD_ATTACHED_EVENT); else _lwevent_set(&sddetect_event,SD_DETTACHED_EVENT); //} lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) pin); // } }
void int_service_routine_btn_pause(void *pin) //SW1 { lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) pin); pause_trigger = !pause_trigger; if(TRUE == pause_trigger) //pause a song { if((mp_sMicroSDplay == cur_musicPlayMS)||(mp_sMSDplay == cur_musicPlayMS)) { _lwevent_clear(&player_event, PLAYER_EVENT_MSK_SONG_RESUME); } else if(mp_sAccessory == cur_musicPlayMS) { //AccessoryPausePlay(); AccessroyHidEvent |= ACCPAUSEPLAY; } else if(mp_sBT == cur_musicPlayMS) { BtAVRCPEvent |= ACCPAUSEPLAY; } printf("Paused\n"); } else //resume a song { if((mp_sMicroSDplay == cur_musicPlayMS)||(mp_sMSDplay == cur_musicPlayMS)) { _lwevent_set(&player_event, PLAYER_EVENT_MSK_SONG_RESUME); } else if(mp_sAccessory == cur_musicPlayMS) { //AccessoryResumePlay(); AccessroyHidEvent |= ACCRESUMEPLAY; } else if(mp_sBT == cur_musicPlayMS) { BtAVRCPEvent |= ACCRESUMEPLAY; } printf("Resume\n"); } //decoding = FALSE; //printf("SW1 pressed. %d \n", trigger); }
void int_service_routine_btn_stop(void *pin) //SW2 { lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) pin); #if 0 //_lwevent_set(&player_event, PLAYER_EVENT_MSK_PREV_BTN_PRESSED); if(TRUE == trigger) _lwevent_set(&player_event, PLAYER_EVENT_MSK_SONG_RESUME); //if pause a song, resume firstly decoding = FALSE; #endif if ((ModeSwitchEvent & MODESWITCH) == 0) ModeSwitchEvent |= MODESWITCH; printf("Auto\n"); //printf("SW2 pressed.\n"); }
static void em9301_isr(void *parameter) { lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR)parameter); _lwsem_post(&IRQ_SEM); }
static void _dspi_em9301_isr(void *parameter) { SPI_DRIVER_DATA_STRUCT_PTR driver_data= parameter; lwgpio_int_clear_flag(&driver_data->SPI_IRQ_PIN); _lwsem_post(&driver_data->IRQ_SEM); }
static void irq_isr (void * param) { LWGPIO_STRUCT_PTR gpio = (LWGPIO_STRUCT_PTR)param; lwgpio_int_clear_flag(gpio); _lwevent_set(&IRQ_EV_STRUCT, IRQ_EVENT); }