static void imx21_gpio_handler(unsigned int irq_unused, struct irqdesc *desc, struct pt_regs *regs) { unsigned int mask; unsigned int port; unsigned int irq_base; unsigned int irq = 0; for (port = 0; port < 6; port++) { if (ISR(port) & IMR(port)) { break; } } mask = ISR(port); irq_base = IRQ_GPIOA(0) + (port * 32); desc = irq_desc + irq_base; while (mask) { if (mask & 1) { DEBUG_IRQ("handling irq %d (port %d)\n", irq, port); desc->handle(irq + irq_base, desc, regs); ISR(port) = (1 << irq); } irq++; desc++; mask >>= 1; } }
int main (void) { MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(ISR (Queue)); MBED_HOSTTEST_START("RTOS_8"); Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE); Ticker ticker; ticker.attach(queue_isr, 1.0); int isr_puts_counter = 0; bool result = true; while (true) { osEvent evt = queue.get(); if (evt.status != osEventMessage) { printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status); result = false; break; } else { printf("QUEUE_GET: Value(%u) ... [OK]\r\n", evt.value.v); if (evt.value.v == QUEUE_PUT_ISR_VALUE) { isr_puts_counter++; } if (isr_puts_counter >= QUEUE_SIZE) { break; } } } MBED_HOSTTEST_RESULT(result); return 0; }
static void imx21_gpio_ack_irq(unsigned int irq) { DEBUG_IRQ("%s: irq %d isr %d\n", __FUNCTION__, irq, IRQ_TO_REG(irq)); ISR(IRQ_TO_REG(irq)) |= 1 << ((irq - IRQ_GPIOA(0)) % 32); }
static void imx_gpiod_demux_handler(unsigned int irq_unused, struct irq_desc *desc) { unsigned int mask, irq; mask = ISR(3); irq = IRQ_GPIOD(0); imx_gpio_handler(mask, irq, desc); }
static void imx_gpioc_demux_handler(unsigned int irq_unused, struct irqdesc *desc, struct pt_regs *regs) { unsigned int mask, irq; mask = ISR(2); irq = IRQ_GPIOC(0); imx_gpio_handler(mask, irq, desc, regs); }
void InterruptService() { _asm di exx _endasm; ISR(); _asm exx ei _endasm; }
void test_ISR_should_increment_tick(void) //Reqs: { /* Ensure known test state */ tick = 0; /* Setup expected call chain */ /* Call function under test */ ISR(); /* Verify test results */ TEST_ASSERT_EQUAL(1, tick); }
//extern uint8 I_STATUS[MAX_SOCK_NUM]; void EXTI0_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line0) != RESET) { ISR(); /* Clear the Key Button EXTI line pending bit */ EXTI_ClearITPendingBit(EXTI_Line0); } }
static enum handler_return platform_tick(void *arg) { ticks++; volatile uint32_t hole = TIMREG(ISR(0)); // ack the irq if (t_callback) { return t_callback(arg, current_time()); } else { return INT_NO_RESCHEDULE; } }
static irqreturn_t i2s_irq_handler(int irq, void *dev_id) { struct dw_i2s_dev *dev = dev_id; bool irq_valid = false; u32 isr[4]; int i; for (i = 0; i < 4; i++) isr[i] = i2s_read_reg(dev->i2s_base, ISR(i)); i2s_clear_irqs(dev, SNDRV_PCM_STREAM_PLAYBACK); i2s_clear_irqs(dev, SNDRV_PCM_STREAM_CAPTURE); for (i = 0; i < 4; i++) { /* * Check if TX fifo is empty. If empty fill FIFO with samples * NOTE: Only two channels supported */ if ((isr[i] & ISR_TXFE) && (i == 0) && dev->use_pio) { dw_pcm_push_tx(dev); irq_valid = true; } /* * Data available. Retrieve samples from FIFO * NOTE: Only two channels supported */ if ((isr[i] & ISR_RXDA) && (i == 0) && dev->use_pio) { dw_pcm_pop_rx(dev); irq_valid = true; } /* Error Handling: TX */ if (isr[i] & ISR_TXFO) { dev_err(dev->dev, "TX overrun (ch_id=%d)\n", i); irq_valid = true; } /* Error Handling: TX */ if (isr[i] & ISR_RXFO) { dev_err(dev->dev, "RX overrun (ch_id=%d)\n", i); irq_valid = true; } } if (irq_valid) return IRQ_HANDLED; else return IRQ_NONE; }
/*! ******************************************************************************* * main program ******************************************************************************/ int main(void) { bool last_state_mnt; //!< motor mounted bool state_mnt; //!< motor mounted bool err; //!< error bool ref_pos_changed; //!< ref Position changed uint8_t last_statekey; //!< state of keys on last loop uint8_t last_second; //!< RTC-second of last main cycle uint8_t ref_position; //!< desired position in percent motor_speed_t speed; //!< motor speed (fast or quiet) uint8_t display_mode; //!< desired display output uint16_t value16; //!< 16 Bit value int16_t value16s; //!< signed 16 Bit value uint8_t value8; //!< 8 Bit value //! initalization init(); //! load/set default values load_defauls(); //! Enable interrupts sei(); //! show POST Screen LCD_AllSegments(LCD_MODE_ON); // all segments on delay(1000); LCD_AllSegments(LCD_MODE_OFF); LCD_PrintDec(REVHIGH, 1, LCD_MODE_ON); // print version LCD_PrintDec(REVLOW, 0, LCD_MODE_ON); LCD_Update(); delay(1000); LCD_AllSegments(LCD_MODE_OFF); // all off //! \todo Send Wakeup MSG state_mnt=false; ref_pos_changed=true; last_second=99; speed=full; last_statekey = 0; last_state_mnt = false; m_key_action = true; ref_position = 10; display_mode=3; ISR(PCINT1_vect); // get keystate // We should do the following once here to have valid data from the start ADC_Measure_Ub(); ADC_Measure_Temp(); /*! **************************************************************************** * main loop * * 1) process keypresses * - m_state_keys and m_wheel are set from IRQ, only process them * - you can set m_wheel to a new value * - controll content of LCD * 2) \todo calc new valveposition if new temp available * - temp is measured by IRQ * 3) calibrate motor * - start calibration is valve mounted changed to on * (during calibration the main loop stops at least for 10 seconds) * - reset calibration is valve mounted changed to off * 4) start motor if * - actual valveposition != desired valveposition && motor is off * 5) if motor is on call MOTOR_CheckBlocked at least once a second * - that switches motor of if it is blocked * 6) store keystate at end of loop before going to sleep * 7) Check for serial command to process * 8) \todo goto sleep if * - motor is of * - no key is pressed (AUTO, C, PROG) * - no serial communication active ***************************************************************************/ for (;;){ // change displaystate every 10 seconds 0 to 5 // Activate Auto Mode // setautomode(true); // 1) process keypresses if (m_key_action){ m_key_action = false; state_mnt = !(m_state_keys & KEYMASK_MOUNT); // State of keys AUTO, C and PROG and valve mounted if ((m_state_keys & KEYMASK_AUTO) != 0){ display_mode--; LCD_SetHourBarVal(display_mode, LCD_MODE_ON); ref_pos_changed = true; LCD_SetSeg(LCD_SEG_AUTO, LCD_MODE_ON); } else { LCD_SetSeg(LCD_SEG_AUTO, LCD_MODE_OFF); } if ((m_state_keys & KEYMASK_C) != 0){ if (display_mode==9){ m_reftemp = input_temp(m_reftemp); } //LCD_SetHourBarVal(display_mode, LCD_MODE_ON); //ref_pos_changed = true; //LCD_SetSeg(LCD_SEG_MANU, LCD_MODE_ON); } else { LCD_SetSeg(LCD_SEG_MANU, LCD_MODE_OFF); } if ((m_state_keys & KEYMASK_PROG)!= 0){ display_mode++; LCD_SetHourBarVal(display_mode+1, LCD_MODE_ON); ref_pos_changed = true; LCD_SetSeg(LCD_SEG_PROG, LCD_MODE_ON); } else { LCD_SetSeg(LCD_SEG_PROG, LCD_MODE_OFF); } } // 2) calc new valveposition if new temp available // - temp is measured by IRQ // 3) calibrate motor // - start calibration if valve is now mounted // TODO: // (during calibration the main loop stops for a long time // maybe add global var to cancel callibration, e.g.: if // HR20 removed from ther gear) // - reset calibration is valve mounted changed to off if (last_state_mnt != state_mnt) { MOTOR_SetMountStatus(state_mnt); if (state_mnt) { LCD_ClearNumbers(); LCD_PrintChar(LCD_CHAR_C, 3, LCD_MODE_ON); LCD_PrintChar(LCD_CHAR_A, 2, LCD_MODE_ON); LCD_PrintChar(LCD_CHAR_L, 1, LCD_MODE_ON); LCD_Update(); // DEBUG: if next line is disabled, not calibration and no // motor control is done // MOTOR_Calibrate(ref_position, speed); LCD_ClearNumbers(); } } // 4) start motor if // - actual valveposition != desired valveposition // - motor is off // - motor is calibrated if ((ref_pos_changed) && (MOTOR_IsCalibrated())){ err = MOTOR_Goto(ref_position, speed); ref_pos_changed = false; } // 5) if motor is on call MOTOR_CheckBlocked at least once a second // - that switches motor of if it is blocked if (MOTOR_On()){ if (last_second != RTC_GetSecond()){ MOTOR_CheckBlocked(); last_second = RTC_GetSecond(); } } // 6) store keystate at end of loop before going to sleep last_statekey = m_state_keys; last_state_mnt = state_mnt; // 7) Check if there is a serial command to process // Loop until all is processed e_meassure(); // test call to sample values and send them to serial port while( (COM_Process() == true) ){}; // 8) goto sleep if // - motor is of // - no key is pressed (AUTO, C, PROG) // - no serial communication active if (display_mode==1) { // Ub: ADC Value Hex ADC_Measure_Ub(); value16 = ADC_Get_Bat_Val(); LCD_PrintHexW(value16, LCD_MODE_ON); }else if (display_mode==2) { // Ub: ADC Value Decimal ADC_Measure_Ub(); value16 = ADC_Get_Bat_Val(); LCD_PrintDecW(value16, LCD_MODE_ON); }else if (display_mode==3) { // Ub: Voltage [mV] ADC_Measure_Ub(); value16 = ADC_Get_Bat_Voltage(); LCD_PrintDecW(value16, LCD_MODE_ON); }else if (display_mode==4) { // Temp: ADC Value Hex ADC_Measure_Temp(); value16 = ADC_Get_Temp_Val(); LCD_PrintHexW(value16, LCD_MODE_ON); }else if (display_mode==5) { // Temp: ADC Value Decimal ADC_Measure_Temp(); value16 = ADC_Get_Temp_Val(); LCD_PrintDecW(value16, LCD_MODE_ON); }else if (display_mode==6) { // Temp: Temperature (Degree) ADC_Measure_Temp(); value16s = ADC_Get_Temp_Degree(); LCD_PrintTempInt(value16s, LCD_MODE_ON); }else if (display_mode==7) { // - 9,87 °C value16s = -987; LCD_PrintTempInt(value16s, LCD_MODE_ON); }else if (display_mode==8) { // 98,76 °C value16s = 9876; LCD_PrintTempInt(value16s, LCD_MODE_ON); }else{ value16 = display_mode; LCD_PrintDecW(value16, LCD_MODE_ON); } /* // Bar 24 on if calibrated if (MOTOR_IsCalibrated()) { LCD_SetSeg(LCD_SEG_BAR24, LCD_MODE_ON); } else { LCD_SetSeg(LCD_SEG_BAR24, LCD_MODE_OFF); } // Hour 0 on if state_mnt if (state_mnt) { LCD_SetSeg(LCD_SEG_B0, LCD_MODE_ON); } else { LCD_SetSeg(LCD_SEG_B0, LCD_MODE_OFF); } // Hour 1 on if last_state_mnt if (last_state_mnt) { LCD_SetSeg(LCD_SEG_B1, LCD_MODE_ON); } else { LCD_SetSeg(LCD_SEG_B1, LCD_MODE_OFF); } if (!MOTOR_IsCalibrated()) { LCD_PrintChar(LCD_CHAR_E, 3, LCD_MODE_ON); LCD_PrintChar(LCD_CHAR_2, 2, LCD_MODE_ON); } else { LCD_PrintDec(ref_position, 1, LCD_MODE_ON); LCD_PrintDec(MOTOR_GetPosPercent(), 0, LCD_MODE_ON); } */ // impulses = MOTOR_GetImpulses(); // update Display each main loop LCD_Update(); } //End Main loop return 0; }
static void imx_gpio_ack_irq(unsigned int irq) { DEBUG_IRQ("%s: irq %d\n", __func__, irq); ISR(IRQ_TO_REG(irq)) = 1 << ((irq - IRQ_GPIOA(0)) % 32); }