if (pp->pin >= PORT0_NB_PINS) {
return;
}
- /* Movable (offset0 & 0x80) or Fixed pin function */
+ /* Movable and GPIO have (offset0 & 0x80) */
if (pp->offset0 & 0x80) {
/* Disable fixed pin functions for this pin */
if ((pp->offset0 & 0x7F) <= 31) {
if (pp->offset1 <= 31) {
matrix->pin_enable[0] |= (1 << pp->offset1);
}
- /* Assign the function to the pin if not a GPIO or fixed pin function */
+ /* Assign the function to the pin if not a GPIO */
if ((me != NULL) && (me->reg_offset < LPC_MATRIX_NB_PIN_ASSIGN)) {
matrix->pin_assign[me->reg_offset] &= ~(0xFF << me->bit_shift);
matrix->pin_assign[me->reg_offset] |= (pp->pin << me->bit_shift);
handle = pio_regs_handles_port0[pp->pin];
*handle = mode;
} else {
+ /* Fixed pin function */
/* Maybe disable the other fixed pin entry ? */
if (pp->offset1 <= 31) {
matrix->pin_enable[0] |= (1 << pp->offset1);
struct lpc_sys_config* sys_conf = LPC_SYS_CONFIG;
uint32_t irq = 0;
- /* Register the callback */
if (gpio->pin >= PORT0_NB_PINS)
return -EINVAL;
- /* Get the next available interrupt */
+ /* Get the next available interrupt and register the callback if empty slot found. */
for (irq = 0; irq < NB_PININT_INTERRUPTS; irq++) {
if (gpio_callbacks[irq] == NULL) {
gpio_callbacks[irq] = callback;
static inline uint32_t gpio_read(const struct pio gpio)
{
struct lpc_gpio* gpio_port = LPC_GPIO_REGS(0);
- return (gpio_port->val & (1 << gpio.pin));
+ return (gpio_port->bval[gpio.pin]);
}