The Acme Systems shipping office will be closed for holidays from 14 august to 22 august

PCF8574 keypad

Inside the kernel is available a simple input driver that can be used in conjunction with D22 to create a simple keypad.

The driver is available inside linux/driver/input/misc/pcf8574_keypad.c.

This code is also an excellent example on how to use i2c bus and interrupt, generated by D22, inside the kernel.

Using the interrupt function

The Daisy-22 allow you also to use the irq capability of PCF8574, those chip return a irq each time that one of the pins change it status. Also if YOU provocate that change.

Anyway to receive the irq you should write a kernel module. For your convenience some code as draft.


//This is not a ready to use linux driver, but just a concept.

#include "linux/gpio.h"
#include "linux/interrupt.h"
#include "linux/i2c.h"

#define GPIO_INT 95   /* the gpio id for irq input (PB31 in the example) */

int state, oldstate;
struct i2c_client *     client;
//...

static irqreturn_t my_driver_irq_handler(int irq, void *dev_id)
{
    unsigned char state = i2c_smbus_read_byte(client);

    if (oldstate != state) {
    // do something
    }

    return IRQ_HANDLED;
}

int __init my_driver_init(void) {
    //...somethings

    at91_gpio_request(GPIO_INT, 0);
    ret = request_irq(GPIO_INT, NULL, my_driver_irq_handler,
        DRV_NAME, NULL);
    if (ret) {
        dev_err(client, "IRQ %d is not free\n", client);
        goto fail_free_device;
    }
}

module_init(my_driver_init);
/* Good luck! */