rtems_status_code rtems_bsp_enable_interrupt( uint32_t bank, uint32_t pin, rtems_gpio_interrupt interrupt ) { /* Enable IRQ generation for the specific pin */ mmio_set(bbb_reg(bank, AM335X_GPIO_IRQSTATUS_SET_0), BIT(pin)); switch ( interrupt ) { case FALLING_EDGE: /* Enables asynchronous falling edge detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_FALLINGDETECT), BIT(pin)); break; case RISING_EDGE: /* Enables asynchronous rising edge detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_RISINGDETECT), BIT(pin)); break; case BOTH_EDGES: /* Enables asynchronous falling edge detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_FALLINGDETECT), BIT(pin)); /* Enables asynchronous rising edge detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_RISINGDETECT), BIT(pin)); break; case LOW_LEVEL: /* Enables pin low level detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_LEVELDETECT0), BIT(pin)); break; case HIGH_LEVEL: /* Enables pin high level detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_LEVELDETECT1), BIT(pin)); break; case BOTH_LEVELS: /* Enables pin low level detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_LEVELDETECT0), BIT(pin)); /* Enables pin high level detection. */ mmio_set(bbb_reg(bank, AM335X_GPIO_LEVELDETECT1), BIT(pin)); break; case NONE: default: return RTEMS_UNSATISFIED; } /* The detection starts after 5 clock cycles as per AM335X TRM * This period is required to clean the synchronization edge/ * level detection pipeline */ asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); return RTEMS_SUCCESSFUL; }
void omap3_timer_init(unsigned freq) { u32_t tisr; /* Stop timer */ mmio_clear(OMAP3_GPTIMER1_TCLR, OMAP3_TCLR_ST); /* Use 32 KHz clock source for GPTIMER1 */ mmio_clear(OMAP3_CM_CLKSEL_WKUP, OMAP3_CLKSEL_GPT1); /* Use 1-ms tick mode for GPTIMER1 TRM 16.2.4.2.1 */ mmio_write(OMAP3_GPTIMER1_TPIR, 232000); mmio_write(OMAP3_GPTIMER1_TNIR, -768000); mmio_write(OMAP3_GPTIMER1_TLDR, 0xffffffe0); mmio_write(OMAP3_GPTIMER1_TCRR, 0xffffffe0); /* Set up overflow interrupt */ tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG | OMAP3_TISR_TCAR_IT_FLAG; mmio_write(OMAP3_GPTIMER1_TISR, tisr); /* Clear interrupt status */ mmio_write(OMAP3_GPTIMER1_TIER, OMAP3_TIER_OVF_IT_ENA); omap3_irq_unmask(OMAP3_GPT1_IRQ); /* Start timer */ mmio_set(OMAP3_GPTIMER1_TCLR, OMAP3_TCLR_OVF_TRG|OMAP3_TCLR_AR|OMAP3_TCLR_ST); }
static rtems_status_code bbb_select_pin_function( uint32_t bank, uint32_t pin, uint32_t type ) { if ( type == BBB_DIGITAL_IN ) { mmio_set(bbb_reg(bank, AM335X_GPIO_OE), BIT(pin)); } else { mmio_clear(bbb_reg(bank, AM335X_GPIO_OE), BIT(pin)); } return RTEMS_SUCCESSFUL; }
rtems_status_code rtems_gpio_bsp_clear(uint32_t bank, uint32_t pin) { mmio_set(bbb_reg(bank, AM335X_GPIO_CLEARDATAOUT), BIT(pin)); return RTEMS_SUCCESSFUL; }
rtems_status_code rtems_gpio_bsp_multi_clear(uint32_t bank, uint32_t bitmask) { mmio_set(bbb_reg(bank, AM335X_GPIO_CLEARDATAOUT), bitmask); return RTEMS_SUCCESSFUL; }