ipad 用カバー
普段 iPad をもち歩くので、カバーがないとやっぱり不安。
あんまり薄いとこれも不安なので、しっかりしたものにする。
多少重くても気にしないことにする。
選んだのはエレコムのこれ。
エレコム iPad 10.5 ケース フラップカバー ソフトレザー フリーアングルスタンド ブラック TB-A17PLFDTBK
- 出版社/メーカー: エレコム
- 発売日: 2017/06/07
- メディア: Personal Computers
- この商品を含むブログを見る
Apple Pencil も一応収納できるようになっているけど、ピッタリというわけでなく、少しはみ出た形になってしまうのが欠点。 少しはみ出るため、カバンの中にいれたとき、ひっかかりやすい。これが気になる人はおすすめしない。それ以外は文句なし。
I2C実験 その3(ロジアナでの動作確認)
I2Cアクセスの様子をロジアナで見てみる。
アマゾンでそこそこ評判のあるロジアナを購入。
今回購入したのはこれ。
zmart LA1010 USB ロジック アナライザ 100M 最大 サンプルレート 16チャンネル 10Bサンプル MCU ARM FPGA デバッグツール
OSはWindowsに対応しているので、ソフト(KingstVIS)とドライバをインストールする。
Windows10で問題なく認識できた。
BBBに接続したEEPROMのI2CとGNDをロジアナに接続する。
CH0にSDA、CH1にSCL、GNDにGNDを接続する。
Windows側でKingstVISを起動し、CH0とCH1をI2Cとして解析するように設定する。
5Mサンプリング@10MHz、データの立ち下がりエッジでトリガーをかけた状態でBBB側でリードを行うと、リードした信号が解析される。
アドレスとデータの2回に分けてアクセスしているのがわかる。
ライトに関しても同様の手順で確認できる。
こちらは1回のアクセスで書き込みを行っているのがわかる。
I2C実験 その2(プログラム作成)
I2Cアクセスのプログラムを作る。
今回使用したEEPROMはページアクセスすることも可能だが、今回はバイトアクセスのみ確認する。
1. リード
データシートによると、リードするには、
1.アドレスをHigh,Lowに分けて書き込む
2.データの読み込み
を行う必要がある。
そのとおりに、アプリケーションを実装する。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>#define DEVICE "/dev/i2c-1"
#define SLAVE_ADDR (0x50)int main(int argc, char **argv)
{
int fd = 0;
int ret = 0;
unsigned char data;
unsigned char address[2];if( argc != 3 ){
fprintf(stderr, "usage: read [high address] [low address]\n");
return 1;
}fd = open( DEVICE, O_RDWR );
if( fd < 0 ){
fprintf(stderr, "file open error\n");
return 1;
}ret = ioctl( fd, I2C_SLAVE, SLAVE_ADDR );
if( ret < 0 ){
fprintf(stderr, "slave access error\n");
close( fd );
return 1;
}// write address
address[0] = (unsigned char)strtol(argv[1], NULL, 0); // address(high)
address[1] = (unsigned char)strtol(argv[2], NULL, 0); // addrees(low)
printf("read address = 0x%x%x\n", address[0], address[1]);
ret = write( fd, address, 2 );
if( ret != 2 ){
fprintf(stderr, "write error\n");close( fd );
return 1;
}// read data
ret = read( fd, &data, 1 );
if( ret != 1 ){
fprintf(stderr, "read error\n");
close( fd );
return 1;
}printf("read data = 0x%x\n", data );
close( fd );
return 0;
}
実行結果
debian@beaglebone:~/eepromtest$ ./read 0x00 0x00
read address = 0x00
read data = 0x12
2. ライト
ライトするには、アドレス(High)、アドレス(Low)、データ、を一度に書き込む。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>#define DEVICE "/dev/i2c-1"
#define SLAVE_ADDR (0x50)int main(int argc, char **argv)
{
int fd = 0;
int ret = 0;
unsigned char data[3];if( argc != 4 ){
fprintf(stderr, "usage: write [high address] [low address] [data]\n");
return 1;
}fd = open( DEVICE, O_RDWR );
if( fd < 0 ){
fprintf(stderr, "file open error\n");
return 1;
}ret = ioctl( fd, I2C_SLAVE, SLAVE_ADDR );
if( ret < 0 ){
fprintf(stderr, "slave access error\n");
close( fd );
return 1;
}// write address
data[0] = (unsigned char)strtol(argv[1], NULL, 0); // address(high)
data[1] = (unsigned char)strtol(argv[2], NULL, 0); // addrees(low)
data[2] = (unsigned char)strtol(argv[3], NULL, 0); // data
printf( "write address = 0x%x%x data=0x%x\n", data[0], data[1], data[2]);
ret = write( fd, data, 3 );
if( ret != 3 ){
fprintf(stderr, "write error\n");
close( fd );
return 1;
}close( fd );
return 0;
}
実行結果
debian@beaglebone:~/eepromtest$ ./write 0x00 0x00 0x12
write address = 0x00 data=0x12
参考
Raspberry Pi でI2C: C言語プログラミング - 猫ぱーんち!
I2C実験 その1(ハードの準備)
I2Cの実験をBeagleBoneBlackでしてみる。
アクセスする対象は安いデバイスということで、EEPROMにしてみる。
値段は秋月でIC一個50円。
部品
接続
購入した24FC64は、8個の端子があるIC。方針は以下の2点。
1.A0、A1、A2はGNDへ接続する。
2.WPをGNDへ接続する。
接続図
実際に、接続する先は、BBBのマニュアル(SRM)より、I2C2はコネクタP9で、
pin19 -> I2C2_SCL
pin20 -> I2C2_SDA
となっている。P9はピンソケットなので、ブレッドボードで使うジャンパーワイヤーの片方を切って、基板に直接はんだ付けした。
赤=Vcc
黒=GND
青=SCL
黃=SDA
A0〜A2, Vss, WPの接続はジャンパで。
BeagleBoneBblackとの接続は以下。
Vcc -> P9 pin3 (DC 3.3V)
GND -> P9 pin1 (GND)
SCL -> P9 pin19 (I2C2_SCL)
SCA -> P9 pin20 (I2C2_SDA)
これで、I2C-1の先にデバイスが接続される。
デバイスの見えるアドレスは、データシートより、
1 0 1 0 A2 A1 A0
で、今回、A2=A1=A0=0なので、
1 0 1 0 0 0 0
となり、 0x50として認識される。
i2cdetectコマンドで見ると、認識されているのがわかる。
debian@beaglebone:~$ i2cdetect -r 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
0x50が認識されている。ブログ上の表示で、縦横がずれているが、実際は揃って表示される。