Sunday, September 25, 2016

raspberry pi (mac os x)

Not yet there.

http://www.jaredwolff.com/blog/cross-compiling-on-mac-osx-for-raspberry-pi/

git:
https://github.com/raspberrypi

buildroot sample
https://github.com/gamaral/rpi-buildroot/

PiLFS
http://www.intestinate.com/pilfs/
http://www.intestinate.com/pilfs/guide.html

GPIO

gpio.c

#include <linux/module.h>
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/gpio.h>

int irq_number;

static irqreturn_t gpio_interrupt_handler(int irq, void* dev_id) {
        printk(KERN_ERR "gpio0 IRQ %d event",irq_number);
        return(IRQ_HANDLED);
}


static int __init gpio_init(void) {
        irq_number = gpio_to_irq(25);

        if ( request_irq(irq_number, gpio_interrupt_handler, IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING|IRQF_ONESHOT, "gpio_reset", NULL) ) {
                printk(KERN_ERR "GPIO_RESET: trouble requesting IRQ %d",irq_number);
                return(-EIO);
        } else {
                printk(KERN_ERR "GPIO_RESET: requesting IRQ %d-> fine\n",irq_number);
        }

        return 0;
}

static void __exit gpio_exit(void) {
        free_irq(irq_number, NULL);
        printk ("gpio_reset module unloaded\n");
        return;
}

module_init(gpio_init);
module_exit(gpio_exit);

MODULE_LICENSE("GPL");

Makefile

CCPREFIX=arm-linux-gnueabihf-

obj-m += gpio.o

all:
 make ARCH=arm CROSS_COMPILE=${CCPREFIX} -C /home/fcm/rpi/rpi-buildroot/output/build/linux-rpi-4.4.y M=$(PWD) modules
clean:
 rm *.ko
 rm *.o
 rm *.mod*

No comments:

Post a Comment