2018年6月3日日曜日

MCP23S09制御用のFON2405E(LEDE・Openwrt)向けドライバ作成

気づけば、毎年同じようなことをやっているような気がするけど。。。
SPI接続のIOエキスパンダ(MCP23S09)を使う+ドライバ作成練習として
7セグ制御を行うドライバを書いてみた




0.前提

・カスタムファーム入りFON2405E
http://continue-to-challenge.blogspot.com/2018/02/fon2405eledeopenwrtspi.html
http://continue-to-challenge.blogspot.com/2018/02/fon2405eledeopenwrtspi144.html

・MCP23S09
3.3Vで動くSPI-IOエキスパンダ
https://www.microchip.com/wwwproducts/jp/MCP23S09


1.手順

(1)eclipceで空のプロジェクト作成
  Makefile project → Empty Project
(2)ソースファイル・Makefile作成
  ソースは末尾のgist参照、Makefileは


(3)ビルド
(4)ターゲットボードに転送
  scpとかで
(5)動作確認
  insmod /tmp/mcp23s09_7seg.ko


2.ソース


3.参考
 ・Raspberry Piで学ぶARMデバイスドライバープログラミング
 ・LINUXデバイスドライバ 第3版
 ・ci-bridge-spi
https://android.googlesource.com/kernel/msm/+/android-msm-hammerhead-3.4-kk-r1/drivers/misc/ci-bridge-spi.c
 ・spike
https://github.com/scottellis/spike/blob/master/spike.c