void pin_change_init(void) { if (PIN_CHANGE_ENABLE(A)) { bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTA, 1); PIN_CHANGE_SET_IRQC(A); int_enable(IRQ_PORTA); } if (PIN_CHANGE_ENABLE(B)) { bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTB, 1); PIN_CHANGE_SET_IRQC(B); int_enable(IRQ_PORTB); } if (PIN_CHANGE_ENABLE(C)) { bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTC, 1); PIN_CHANGE_SET_IRQC(C); int_enable(IRQ_PORTC); } if (PIN_CHANGE_ENABLE(D)) { bf_set_reg(SIM_SCGC5, SIM_SCGC5_PORTD, 1); PIN_CHANGE_SET_IRQC(D); int_enable(IRQ_PORTD); } }
int level_return(int newlevel) { int flags; int oldlevel; // locking flags = int_disable(); // we don't need locking (spinlocks etc) here - see above oldlevel = cpu_levels[smp_cpu_id()]; // error checking if(newlevel > oldlevel) panic("attempting to raise CPU level with level_return"); // set the new level cpu_levels[smp_cpu_id()] = newlevel; // restore flags if(newlevel < LEVEL_NOINTS) { if(oldlevel == LEVEL_NOINTS) int_enable(cpu_int_restore_flags[smp_cpu_id()]); else int_enable(flags); } // done return oldlevel; }
void pit_init(void) { SIM.scgc6.pit = 1; PIT.mcr.mdis = 0; PIT.mcr.frz = 0; int_enable(IRQ_PIT0); int_enable(IRQ_PIT1); int_enable(IRQ_PIT2); int_enable(IRQ_PIT3); }
static int32_t cpu_porta_control(uint32_t ctrl_cmd, void *param) { uint32_t val32; uint32_t i; switch (ctrl_cmd) { case GPIO_CMD_ENA_BIT_INT: val32 = (uint32_t)param; for (i = 0; i < cpu_dw_gpio_bit_isr_a.int_bit_max_cnt; i ++) { if ((1<<i) & val32) { int_enable(HSDC_GPIO0_ISR + i); } } break; case GPIO_CMD_DIS_BIT_INT: val32 = (uint32_t)param; for (i = 0; i < cpu_dw_gpio_bit_isr_a.int_bit_max_cnt; i ++) { if ((1<<i) & val32) { int_disable(HSDC_GPIO0_ISR + i); } } break; default: break; } return dw_gpio_control(&cpu_port_a, ctrl_cmd, param); }
static void init(void) { /* set modes before to enable the port */ gpio_dir(PROG_BUTTON, GPIO_INPUT); pin_mode(PROG_BUTTON, PIN_MODE_PULLUP); gpio_dir(TARGET_RESET, GPIO_INPUT); gpio_dir(TARGET_LED, GPIO_INPUT); /* set digital debounce/filter */ pin_physport_from_pin(PROG_BUTTON)->dfcr.cs = PORT_CS_LPO; pin_physport_from_pin(PROG_BUTTON)->dfwr.filt = 31; /* button interrupt */ pin_physport_from_pin(PROG_BUTTON)->dfer |= 1 << pin_physpin_from_pin(PROG_BUTTON); pin_physport_from_pin(PROG_BUTTON)->pcr[pin_physpin_from_pin(PROG_BUTTON)].irqc = PCR_IRQC_INT_FALLING; /* reset interrupt */ pin_physport_from_pin(TARGET_RESET)->pcr[pin_physpin_from_pin(TARGET_RESET)].irqc = PCR_IRQC_INT_RISING; /* LED interrupt */ pin_physport_from_pin(TARGET_LED)->pcr[pin_physpin_from_pin(TARGET_LED)].irqc = PCR_IRQC_INT_FALLING; int_enable(IRQ_PORTD); gpio_dir(LED_SUCCESS, GPIO_OUTPUT); gpio_dir(LED_FAIL, GPIO_OUTPUT); timeout_init(); }
/*********************************************************************** * * Function: sd_start_data_write * * Purpose: Start data write transfer operations to a card * * Processing: * If the number of blocks to transfer is 0, return an error status * to the caller. Install the standard data transmit interrupt * handler. Set the data block size and data timeout clocks in the * controller. Clear any latched data interrupts. Fill the transmit * FIFO and decrement the amount to send by the filled amount. * Enable data transfer interrupts as needed by the transmit * interrupt handler. Decrement the number of blocks to transfer in * the interrupt handler. * * Parameters: * cmdreg : Command control register value * * Outputs: None * * Returns: _NO_ERROR if the configuration was ok, otherwise _ERROR * * Notes: None * **********************************************************************/ static STATUS sd_start_data_write(UNS_32 cmdreg) { volatile UNS_32 tmp; UNS_32 datalen; STATUS status = _ERROR; /* Determine data length from block count */ datalen = sdcarddat.dctrl.blocksize * sdcarddat.dctrl.xferdat.blocks; if ((datalen > 0) && (datalen <= 65024)) { /* Number of words to send */ sdcarddat.dctrl.tosend = datalen >> 2; /* Set standard transmit handler */ int_install_irq_handler(IRQ_SD1, (PFV) sd1_tx_interrupt); /* Decrement block count for start of transfer */ sdcarddat.dctrl.xferdat.blocks--; /* Setup blocksize, data length, data timeout, and direction */ sdcarddat.regptr->sd_dtimer = sdcarddat.dctrl.data_to; sdcarddat.regptr->sd_dlen = datalen; sdcarddat.regptr->sd_dctrl &= ~SD_DIR_FROMCARD; /* Start command state machine */ sdcarddat.regptr->sd_cmd = (cmdreg | SD_CPST_EN); int_enable(IRQ_SD1); status = _NO_ERROR; }
/*********************************************************************** * * Function: prep_cmd * * Purpose: Prepare a command register function * * Processing: * The command state machine is setup with the passed argument, * command, expected response type, and busy wait status. If a * response is expected, then the command state machine and expected * interrupts are setup the receive a response. The command * interrupt is cleared and enabled. * * Parameters: * pcmd : Pointer to a command control structure * * Outputs: None * * Returns: Prepared command register word * * Notes: None * **********************************************************************/ static UNS_32 prep_cmd(SD_CMD_T *pcmd) { UNS_32 resp, tmp; /* Write arg register first */ sdcarddat.regptr->sd_arg = pcmd->arg; /* Generate command word */ tmp = pcmd->cmd; resp = prep_cmd_resp(pcmd); switch (pcmd->cmd_resp_size) { case 0: /* No response expected */ break; case 136: tmp |= (SD_RESPONSE | SD_LONGRESP_EN); break; default: tmp |= SD_RESPONSE; break; } /* Clear latched command statuses and enable command state machine interrupts */ sdcarddat.regptr->sd_clear = (resp | SD_CMD_SENT); sdcarddat.regptr->sd_mask0 = (resp | SD_CMD_SENT); int_enable(IRQ_SD0); return tmp; }
/* * Thread trampoline function. */ static void thread_run(thread_func_t *start_func, ulong_t arg) { int_enable(); /* make sure interrupts are enabled */ start_func(arg); thread_exit(0); KASSERT(false); /* not reached */ }
int musb_platform_init(void) { struct musb_regs * const musbr = sep0611_get_base_usb_device(); unsigned int pmu_clk_gt_cfg1 = 0; u8 devctl = 0; u32 tmp32; pmu_clk_gt_cfg1 = readl(PMU_CLK_GT_CFG1); pmu_clk_gt_cfg1 |= 1<<6; writel(PMU_CLK_GT_CFG1,pmu_clk_gt_cfg1); musb_gpio_init(); writeb(0, &musbr->index); devctl = readb(&musbr->devctl); devctl |= MUSB_DEVCTL_SESSION; writeb(devctl, &musbr->devctl); writeb((EP0_INT | EP1_INT), &musbr->intrtxe); writeb((EP3_INT), &musbr->intrrxe); writeb((MUSB_INTR_RESET | MUSB_INTR_SUSPEND | MUSB_INTR_RESUME), &musbr->intrusbe); int_enable(40UL); return 0; }
void BIOSCALL int17_function(pusha_regs_t regs, uint16_t es, uint16_t ds, volatile iret_addr_t iret_addr) { uint16_t addr,timeout; uint8_t val8; int_enable(); addr = read_word(0x0040, (regs.u.r16.dx << 1) + 8); if ((regs.u.r8.ah < 3) && (regs.u.r16.dx < 3) && (addr > 0)) { timeout = read_byte(0x0040, 0x0078 + regs.u.r16.dx) << 8; if (regs.u.r8.ah == 0) { outb(addr, regs.u.r8.al); val8 = inb(addr+2); outb(addr+2, val8 | 0x01); // send strobe outb(addr+2, val8 & ~0x01); while (((inb(addr+1) & 0x40) == 0x40) && (timeout)) { timeout--; } } if (regs.u.r8.ah == 1) { val8 = inb(addr+2); outb(addr+2, val8 & ~0x04); // send init outb(addr+2, val8 | 0x04); } val8 = inb(addr+1); regs.u.r8.ah = (val8 ^ 0x48); if (!timeout) regs.u.r8.ah |= 0x01; ClearCF(iret_addr.flags); } else { SetCF(iret_addr.flags); // Unsupported } }
/*********************************************************************** * * Function: term_init * * Purpose: Initialize terminal I/O interface * * Processing: * Use the UART driver to open and initialize the serial port * session. * * Parameters: None * * Outputs: None * * Returns: Nothing * * Notes: None * **********************************************************************/ void term_init(void) { UART_CBS_T cbs; UART_CONTROL_T ucntl; UART_REGS_T *puartregs = UART5; /* Setup UART */ uartdev = uart_open((void *) puartregs, 0); if (uartdev != 0) { /* 115.2K, 8 data bits, no parity, 1 stop bit */ ucntl.baud_rate = 115200; ucntl.parity = UART_PAR_NONE; ucntl.databits = 8; ucntl.stopbits = 1; uart_ioctl(uartdev, UART_SETUP_TRANSFER, (INT_32) &ucntl); uartbrk = FALSE; /* Setup RX and TX callbacks */ cbs.rxcb = term_dat_recv_cb; cbs.txcb = term_dat_send_cb; cbs.rxerrcb = term_status_cb; uart_ioctl(uartdev, UART_INSTALL_CBS, (INT_32) &cbs); int_enable(IRQ_UART_IIR5); } /* Initialize TX and RX ring buffers */ txfill = txget = rxfill = rxget = txsize = rxsize = 0; }
static inline void main_init( void ) { hw_init(); sys_time_init(); led_init(); usb_serial_init(); int_enable(); }
/** * \brief enable DesignWare SPI send or receive interrupt * \param[in] DEV_SPI_INFO *spi_info_ptr * \param[in] cbrtn control code of callback routine of send or receive */ static int32_t dw_spi_ena_cbr(DEV_SPI_INFO *spi_info_ptr, uint32_t cbrtn) { DW_SPI_CTRL *spi_ctrl_ptr = (DW_SPI_CTRL *)(spi_info_ptr->spi_ctrl); int32_t ercd = E_OK; DW_SPI_CHECK_EXP((spi_info_ptr->status & DW_SPI_IN_XFER) == 0, E_CTX); switch (cbrtn) { case DW_SPI_RDY_SND: spi_info_ptr->status |= DW_SPI_IN_TX; break; case DW_SPI_RDY_RCV: spi_info_ptr->status |= DW_SPI_IN_RX; break; case DW_SPI_RDY_XFER: spi_info_ptr->status |= DW_SPI_IN_XFER; break; default: break; } dw_spi_unmask_interrupt(spi_ctrl_ptr->dw_spi_regs, DW_SPI_IMR_XFER); if ((spi_ctrl_ptr->int_status & DW_SPI_GINT_ENABLE) == 0) { spi_ctrl_ptr->int_status |= DW_SPI_GINT_ENABLE; if (spi_ctrl_ptr->intno != DW_SPI_INVALID_INTNO) { int_enable(spi_ctrl_ptr->intno); } } error_exit: return ercd; }
/********** INIT *************************************************************/ void init_rctx( void ) { hw_init(); sys_time_init(); #ifdef LED led_init(); #endif #ifdef USE_UART1 Uart1Init(); #endif #ifdef ADC adc_init(); adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_adc_buf, DEFAULT_AV_NB_SAMPLE); #endif #ifdef RADIO_CONTROL ppm_init(); #endif int_enable(); /** - wait 0.5s (for modem init ?) */ uint8_t init_cpt = 30; while (init_cpt) { if (sys_time_periodic()) init_cpt--; } #if defined DATALINK #if DATALINK == XBEE xbee_init(); #endif #endif /* DATALINK */ }
int mm_physpage_alloc(int type, int allowblock) { mm_phys_page *p; int flags; flags = int_disable(); spinlock_grab(&mm_phys_pages_lock); if(!mm_phys_pages.head) { // TODO: implement page stealing panic("Out of physical memory"); } p = mm_phys_pages.head; mm_phys_pages.head = p->next; p->type = type; p->refcount = 1; mm_phys_pages.free_pagecount--; spinlock_release(&mm_phys_pages_lock); int_enable(flags); return p->physaddr; }
static inline void main_init( void ) { hw_init(); sys_time_init(); led_init(); uart0_init_tx(); int_enable(); }
static inline void main_init( void ) { hw_init(); sys_time_init(); main_init_adc(); bench_sensors_init(); int_enable(); }
int P1_V(P1_Semaphore sem){ // USLOSS_Console("In P1_V for %s\n",procTable[currPid].name); Check_Your_Privilege(); // interrupt disable HERE! int_disable(); Semaphore* semP=(Semaphore*)sem; // check if the semaphore is valid if(semP==NULL||semP->valid<0){ USLOSS_Console("Semaphore is invalid\n"); return - 1; } semP->value++; if(currPid!=-1&&semP->queue->nextPCB != NULL){ // USLOSS_Console("In P1_V for %s\n",procTable[currPid].name); int PID=semP->queue->nextPCB->PID; // USLOSS_Console("P1_V Pid: %d",PID); //Move first frocess from procQueue to ready queue // if(procTable[PID].state == 4){ procTable[PID].state = 1; // ready status procTable[currPid].waitingOnDevice=0; //removeToProcQue(currPid,*semP); removeFromList(PID); addToReadyList(PID); // USLOSS_Console("ReadyList after P1_V for %s: ",procTable[PID].name); // printList(&readyHead); dispatcher(); // } } int_enable(); // interrupt enable HERE! return 0; }
/** ESC and CPU related HW init * * @param[in] arg = esc_cfg provided by the application */ void ESC_init (const esc_cfg_t * config) { eep_config_t ecat_config; ESC_reset(); scu_configure_ethercat_signals(&port_control); /* read config from emulated EEPROM */ memset(&ecat_config, 0, sizeof(eep_config_t)); EEP_read (0, (uint8_t *) &ecat_config, sizeof(eep_config_t)); ESC_enable(); /* words 0x0-0x3 */ ecat0->EEP_DATA[0U] = ecat_config.dword[0U]; ecat0->EEP_DATA[1U] = ecat_config.dword[1U]; ecat0->EEP_CONT_STAT |= (uint16_t)(BIT(10)); /* ESI EEPROM Reload */ /* words 0x4-0x7 */ ecat0->EEP_DATA[0U] = ecat_config.dword[2U]; ecat0->EEP_DATA[1U] = ecat_config.dword[3U]; ecat0->EEP_CONT_STAT |= (uint16_t)(BIT(10)); /* ESI EEPROM Reload */ while (ecat0->EEP_CONT_STAT & BIT(12)) /* ESI EEPROM loading status */ { /* Wait until the EEPROM_Loaded signal is active */ } /* Configure CPU interrupts */ if(config->use_interrupt != 0) { // ecat_isr_sem = sem_create(0); // task_spawn ("soes_isr", isr_run, 9, 2048, NULL); use_all_interrupts = 0; ecat0->AL_EVENT_MASK = 0; ecat0->AL_EVENT_MASK = (ESCREG_ALEVENT_SMCHANGE | ESCREG_ALEVENT_EEP | ESCREG_ALEVENT_CONTROL | ESCREG_ALEVENT_SM0 | ESCREG_ALEVENT_SM1); int_connect (IRQ_ECAT0_SR0, ecat_isr, NULL); int_enable (IRQ_ECAT0_SR0); // /* Activate for running external sync IRQ */ // scu_put_peripheral_in_reset (SCU_PERIPHERAL_ERU1); // scu_ungate_clock_to_peripheral (SCU_PERIPHERAL_ERU1); // scu_release_peripheral_from_reset (SCU_PERIPHERAL_ERU1); // // eru_configure(&cfg); // /* Let the stack decide when to enable */ // int_disable(cfg.irq); } }
uint32_t mb_tacho_get_duration( void ) { int_disable(); uint32_t my_duration = 0; if (got_one_pulse) { my_duration = mb_tacho_duration; } got_one_pulse = FALSE; int_enable(); return my_duration; }
static inline void main_init( void ) { hw_init(); sys_time_init(); led_init(); uart0_init(); vor_int_demod_init(); VorDacInit(); vor_adc_init(); int_enable(); }
static void rtc_alarm_update() { if (alarm_head) { int_enable(IRQ_RTC_alarm); RTC.tar = alarm_head->time; } else { int_disable(IRQ_RTC_alarm); } }
int P1_P(P1_Semaphore sem){ Check_Your_Privilege(); Semaphore* semP=(Semaphore*)sem; if(semP->valid>Clock_Sema&&semP->valid<MMU_Sema){ // USLOSS_Console("In P1_P for %d,Sem Table Pos: %d\n",currPid,semP->valid); procTable[currPid].waitingOnDevice=1; } // check if the process is killed if(procTable[currPid].state == 2){ return -2; } // check if the semaphore is valid if(semP==NULL||semP->valid<0){ USLOSS_Console("Semaphore is invalid\n"); return - 1; } // move process from ready queueu to semaphore->procQue // USLOSS_Console("In P1_P for %d\n",currPid); while(1){ int_disable(); if(semP->value > 0){ semP->value--; break; } if(currPid!=-1){ procTable[currPid].state = 4; // waiting status // USLOSS_Console("CurrPid %d has state=%d\n",currPid,procTable[currPid].state); removeFromList(currPid); addToProcQue(currPid,*semP); dispatcher(); } int_enable(); // USLOSS_Console("In P1_P for %d\n",currPid); } int_enable(); // USLOSS_Console("Exiting P1_P for %d\n",currPid); //interrupt enable return 0; }
static inline void main_init( void ) { hw_init(); sys_time_init(); led_init(); comm_init(DA_COMM); comm_add_tx_callback(DA_COMM, test_message_tx); comm_add_rx_callback(DA_COMM, test_message_rx); int_enable(); }
/* ----------------------------------------------------------------------------*/ static void prvSetupTimerInterrupt(void) { unsigned int cyc = configCPU_CLOCK_HZ / configTICK_RATE_HZ; int_disable(BOARD_OS_TIMER_INTNO); /* disable os timer interrupt */ timer_stop(BOARD_OS_TIMER_ID); timer_start(BOARD_OS_TIMER_ID, TIMER_CTRL_IE | TIMER_CTRL_NH, cyc); int_handler_install(BOARD_OS_TIMER_INTNO, (INT_HANDLER)vKernelTick); int_enable(BOARD_OS_TIMER_INTNO); }
static inline void main_init( void ) { hw_init(); sys_time_init(); led_init(); comm_init(COMM_TELEMETRY); rc_init(); int_enable(); }
/* Initialize descriptor tables (duh) */ void init_descriptor_tables( void ) { /* global descriptor table */ printk("Initializing GDT\n"); init_gdt(); /* interrupt descriptor table */ printk("Initializing IDT\n"); init_idt(); /* now we can start interrupts */ printk("Enabling interrupts\n"); int_enable(); }
/** * \brief enable designware spi interrupt * \param spi_info_ptr spi information structure pointer */ static void dw_spi_enable_interrupt(DEV_SPI_INFO *spi_info_ptr) { DW_SPI_CTRL *spi_ctrl_ptr = (DW_SPI_CTRL *)(spi_info_ptr->spi_ctrl); if (spi_ctrl_ptr->intno != DW_SPI_INVALID_INTNO) { int_handler_install(spi_ctrl_ptr->intno, spi_ctrl_ptr->dw_spi_int_handler); spi_ctrl_ptr->int_status |= DW_SPI_GINT_ENABLE; /** enable spi interrupt */ int_enable(spi_ctrl_ptr->intno); } else { spi_ctrl_ptr->int_status |= DW_SPI_GINT_ENABLE; } }
int rt_hw_timer_init(void) { unsigned int cyc = BOARD_CPU_CLOCK / RT_TICK_PER_SECOND; int_disable(BOARD_OS_TIMER_INTNO); /* disable os timer interrupt */ arc_timer_stop(BOARD_OS_TIMER_ID); arc_timer_start(BOARD_OS_TIMER_ID, TIMER_CTRL_IE | TIMER_CTRL_NH, cyc); int_handler_install(BOARD_OS_TIMER_INTNO, (INT_HANDLER)rt_hw_timer_isr); int_enable(BOARD_OS_TIMER_INTNO); return 0; }
/*********************************************************************** * * Function: term_dat_out_len * * Purpose: Send a number of characters on the terminal interface * * Processing: * Move data into the UART ring buffer. * * Parameters: * dat : Data to send * chars : Number of bytes to send * * Outputs: None * * Returns: Nothing * * Notes: Will block until all bytes are sent. * **********************************************************************/ void term_dat_out_len(UNS_8 *dat, int chars) { while (chars > 0) { if (txsize < 512) { txbuff[txfill] = *dat; txfill++; if (txfill >= 512) { txfill = 0; } dat++; chars--; int_disable(IRQ_UART_IIR5); txsize++; int_enable(IRQ_UART_IIR5); } int_disable(IRQ_UART_IIR5); term_dat_send_cb(); int_enable(IRQ_UART_IIR5); } }