static portBASE_TYPE prvjoystick_ISR_NonNakedBehaviour( void ) { xLogDef *pxLog; U32 u32CurrentCountValue = xTaskGetTickCount(); // Debouncing: ignore joystick events occuring in less than 250ms before the last // valid joystick event. if((( u32CurrentCountValue >= u32LastCountValue ) && ( u32CurrentCountValue - u32LastCountValue <= 250)) || (( u32CurrentCountValue < u32LastCountValue ) && ( u32CurrentCountValue + (0xFFFFFFFF - u32LastCountValue) <= 250))) { // Clear all interrupts flag (it's no use checking which event has bouncing). gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_PUSH); Clr_bits(x_joystick, JS_EVENT_PUSH); gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_LEFT); Clr_bits(x_joystick, JS_EVENT_LEFT); gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_RIGHT); Clr_bits(x_joystick, JS_EVENT_RIGHT); gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_UP); Clr_bits(x_joystick, JS_EVENT_UP); gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_DOWN); Clr_bits(x_joystick, JS_EVENT_DOWN); return(pdFALSE); } else { // Update last valid joystick event timestamp. u32LastCountValue = u32CurrentCountValue; // Check all events. if (gpio_get_pin_interrupt_flag(GPIO_JOYSTICK_UP)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(GPIO_JOYSTICK_UP)) { /* clear bit UP */ Clr_bits(x_joystick, JS_EVENT_UP); } else { Set_bits(x_joystick, JS_EVENT_UP); } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_UP); } if (gpio_get_pin_interrupt_flag(GPIO_JOYSTICK_DOWN)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(GPIO_JOYSTICK_DOWN)) { Clr_bits(x_joystick, JS_EVENT_DOWN); } else { Set_bits(x_joystick, JS_EVENT_DOWN); } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_DOWN); } if (gpio_get_pin_interrupt_flag(GPIO_JOYSTICK_LEFT)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(GPIO_JOYSTICK_LEFT)) { Clr_bits(x_joystick, JS_EVENT_LEFT); } else { Set_bits(x_joystick, JS_EVENT_LEFT); #ifdef MMILCD_ENABLE vMMI_UserMenuDisplayPreviousItem(pdTRUE); #endif } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_LEFT); } if (gpio_get_pin_interrupt_flag(GPIO_JOYSTICK_RIGHT)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(GPIO_JOYSTICK_RIGHT)) { Clr_bits(x_joystick, JS_EVENT_RIGHT); } else { Set_bits(x_joystick, JS_EVENT_RIGHT); #ifdef MMILCD_ENABLE vMMI_UserMenuDisplayNextItem(pdTRUE); #endif } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_RIGHT); } if (gpio_get_pin_interrupt_flag(GPIO_JOYSTICK_PUSH)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(GPIO_JOYSTICK_PUSH)) { Clr_bits(x_joystick, JS_EVENT_PUSH); } else { Set_bits(x_joystick, JS_EVENT_PUSH); if ( bAlarm == pdTRUE ) { // post alarm to SMTP task v_SMTP_PostFromISR("Joystick Alarm", NULL); } #ifdef MMILCD_ENABLE vMMI_UserMenuValidateItem(pdTRUE); #endif } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(GPIO_JOYSTICK_PUSH); } } // Alloc and init a log. pxLog = pxdatalog_log_alloc_init_FromISR(); if( NULL == pxLog ) return( pdFALSE ); // Init the id field of the log. pxLog->id = DATALOG_ID_JS; /* set log event string */ pxLog->pcStringLog = (portCHAR *)acpc_js_events[x_joystick]; /* set free function pointer */ pxLog->pfFreeStringLog = NULL; /* add the log entry */ return( x_datalog_AddLogFromISR( pxLog ) ); }
static portBASE_TYPE prvpushb_ISR_NonNakedBehaviour( void ) { xLogDef *pxLog; portBASE_TYPE xSwitchRequired = pdFALSE; /* depending on the push buttons */ if (gpio_get_pin_interrupt_flag(PB1_POSITION)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(PB1_POSITION)) { b_pushb1 = PUSHB_EVENT_RELEASE; } else { b_pushb1 = PUSHB_EVENT_PRESS; if ( bAlarm1 == pdTRUE ) { // post alarm to SMTP task v_SMTP_PostFromISR("Push Button 1 Alarm", NULL); } } // Alloc and init a log. pxLog = pxdatalog_log_alloc_init_FromISR(); if( NULL != pxLog ) { // Init the id field of the log. pxLog->id = DATALOG_ID_PB1; /* set log event string */ pxLog->pcStringLog = (portCHAR *)acpc_pushb_events[b_pushb1]; /* set free function pointer */ pxLog->pfFreeStringLog = NULL; /* add the log entry */ xSwitchRequired = x_datalog_AddLogFromISR( pxLog ); } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(PB1_POSITION); } if (gpio_get_pin_interrupt_flag(PB2_POSITION)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(PB2_POSITION)) { b_pushb2 = PUSHB_EVENT_RELEASE; } else { b_pushb2 = PUSHB_EVENT_PRESS; if ( bAlarm2 == pdTRUE ) { // post alarm to SMTP task v_SMTP_PostFromISR("Push Button 2 Alarm", NULL); } } // Alloc and init a log. pxLog = pxdatalog_log_alloc_init_FromISR(); if( NULL != pxLog ) { // Init the id field of the log. pxLog->id = DATALOG_ID_PB2; /* set log event string */ pxLog->pcStringLog = (portCHAR *)acpc_pushb_events[b_pushb2]; /* set free function pointer */ pxLog->pfFreeStringLog = NULL; /* add the log entry */ xSwitchRequired = x_datalog_AddLogFromISR( pxLog ); } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(PB2_POSITION); } if (gpio_get_pin_interrupt_flag(PB3_POSITION)) { /* input is pulled up, if 1 : input is not active */ if (gpio_get_pin_value(PB3_POSITION)) { b_pushb3 = PUSHB_EVENT_RELEASE; } else { b_pushb3 = PUSHB_EVENT_PRESS; if ( bAlarm3 == pdTRUE ) { // post alarm to SMTP task v_SMTP_PostFromISR("Push Button 3 Alarm", NULL); } } // Alloc and init a log. pxLog = pxdatalog_log_alloc_init_FromISR(); if( NULL != pxLog ) { // Init the id field of the log. pxLog->id = DATALOG_ID_PB3; /* set log event string */ pxLog->pcStringLog = (portCHAR *)acpc_pushb_events[b_pushb3]; /* set free function pointer */ pxLog->pfFreeStringLog = NULL; /* add the log entry */ xSwitchRequired = x_datalog_AddLogFromISR( pxLog ); } /* allow new interrupt : clear the IFR flag */ gpio_clear_pin_interrupt_flag(PB3_POSITION); } return( xSwitchRequired ); }