SPI子系统之驱动SSD1306 OLED(11)


static int __devinit spi_ssd1306_probe(struct spi_device *spi)
{
    printk("spi_ssd1306_probe\n");
    spi_ssd1306_dev = spi;
    spi_ssd1306_dev->bits_per_word = 9;

ssd1306_init();
    ssd1306_clear_screen(0x00);
    ssd1306_display_off();

ssd1306_display_string(18, 0, "hello, Linux!", 16, 1);
    ssd1306_display_string(0, 16, "this is a spi driver demo!", 16, 1);
    ssd1306_refresh_gram();
    ssd1306_display_on();
   
    return 0;
}


static int __devexit spi_ssd1306_remove(struct spi_device *spi)
{
    printk("ssd1306_remove\n");
   
    ssd1306_clear_screen(0x00);
    ssd1306_display_off();
    return 0;
}


static struct spi_driver spi_ssd1306_driver = {
    .driver = {
        .name    = "spi_ssd1306",
        .bus    = &spi_bus_type,
        .owner    = THIS_MODULE,
    },
    .probe    = spi_ssd1306_probe,
    .remove    = __devexit_p(spi_ssd1306_remove),
};


static int spi_ssd1306_init(void)
{
    return spi_register_driver(&spi_ssd1306_driver);
}


static void spi_ssd1306_exit(void)
{
    spi_unregister_driver(&spi_ssd1306_driver);
}


module_init(spi_ssd1306_init);
module_exit(spi_ssd1306_exit);

MODULE_LICENSE("GPL");

makefile

KERN_DIR = /work/system/linux-2.6.22.6

all:
    make -C $(KERN_DIR) M=`pwd` modules

clean:
    make -C $(KERN_DIR) M=`pwd` modules clean
    rm -rf modules.order

obj-m    += spi_platform_dev.o
obj-m    += spi_s3c24xx_gpio.o
obj-m    += spi_bitbang.o
obj-m    += spi_ssd1306_drv.o

实验现象:

SPI子系统之驱动SSD1306 OLED

SPI子系统之驱动SSD1306 OLED

SPI子系统之驱动SSD1306 OLED

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/f06f37a19007f6f04167f392c9581460.html