Provide hooks into the GPIO lines and the ability to set/clear

interrupts from them.  This should be more generalized, but is
sufficient for now.

Submitted by:	Hans Petter Selasky
This commit is contained in:
imp 2008-08-19 22:17:14 +00:00
parent 22fa49d382
commit 22fd66a829
2 changed files with 47 additions and 0 deletions

View File

@ -349,6 +349,49 @@ at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask)
PIO[PIO_CODR / 4] = data_mask;
}
uint8_t
at91_pio_gpio_get(uint32_t pio, uint32_t data_mask)
{
uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
data_mask &= PIO[PIO_PDSR / 4];
return (data_mask ? 1 : 0);
}
void
at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch)
{
uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
if (use_deglitch)
PIO[PIO_IFER / 4] = data_mask;
else
PIO[PIO_IFDR / 4] = data_mask;
return;
}
void
at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask,
int enable_interrupt)
{
uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
if (enable_interrupt)
PIO[PIO_IER / 4] = data_mask;
else
PIO[PIO_IDR / 4] = data_mask;
return;
}
uint32_t
at91_pio_gpio_clear_interrupt(uint32_t pio)
{
uint32_t *PIO = (uint32_t *)(AT91RM92_BASE + pio);
/* reading this register will clear the interrupts */
return (PIO[PIO_ISR / 4]);
}
static device_method_t at91_pio_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, at91_pio_probe),

View File

@ -35,5 +35,9 @@ void at91_pio_gpio_output(uint32_t pio, uint32_t output_enable_mask,
int use_pullup);
void at91_pio_gpio_set(uint32_t pio, uint32_t data_mask);
void at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask);
uint8_t at91_pio_gpio_get(uint32_t pio, uint32_t data_mask);
void at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch);
void at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask, int enable_interrupt);
uint32_t at91_pio_gpio_clear_interrupt(uint32_t pio);
#endif /* ARM_AT91_AT91_PIOVAR_H */