Matrix - Compact Kit

From FriendlyELEC WiKi
Revision as of 10:29, 30 December 2015 by Yftan (Talk | contribs) (Features)

Jump to: navigation, search

查看中文

1 Introduction

Matrix-Compact Kit.png
  • The Matrix-Compact Kit is a compact board with various hardware resources, interfaces and ports including user button, LED, buzzer, ADC, compass, temperature sensor, IR receiver, TFT port and etc. This board can be connected to the NanoPi, NanoPi 2 and Raspberry Pi via its 40 pin header. In addition you can connect other external modules to its GPIOs.

2 Features

Matrix - Compact Kit has the following onboard resources:

  • 0.9 TFT LCD
  • 3 x tact switch
  • 4 x 5mm LED
  • Buzzer
  • ADC
  • Sliding rheostat
  • 40 pin female connector
  • 4 pin header - I2C interface
  • 4 pin header - UART interface
  • 3 pin double row pin-header - 3.3V and GND
  • 18B20 temperature sensor
  • IR receiver
  • 10 x 3 pin header - 3 x AIO, 7 x DIO (two of them can be configured to PWM and four of them can be configured to SPI)
  • Compass

3 特性

  • PCB尺寸(mm):

Matrix-Compact Kit PCB.png

Matrix-Compact_Kit接口布局
  • 40pin排母GPIO管脚定义
Pin# Name Pin# Name
1 VDD_SYS_3.3V 2 VDD_5V
3 I2C0_SDA 4 VDD_5V
5 I2C0_SCL 6 DGND
7 GPIOB28 8 UART3_TXD
9 DGND 10 UART3_RXD
11 GPIOB29 12 GPIOB26
13 GPIOB30 14 DGND
15 GPIOB31 16 PWM2
17 VDD_SYS_3.3V 18 GPIOB27
19 SPI0_MOSI 20 DGND
21 SPI0_MISO 22 PWM0
23 SPI0_CLK 24 SPI0_CS
25 DGND 26 PWM1
27 I2C1_SDA 28 I2C1_SCL
29 GPIOC8 30 DGND
31 SPI2_CLK 32 GPIOC28
33 SPI2_CS 34 DGND
35 SPI2_MOSI 36 GPIOC7
37 SPI2_MISO 38 ALIVEGPIO2
39 DGND 40 ALIVEGPIO3
Matrix-Compact_Kit接口布局
  • 30pin排针管脚定义
Pin# Name Pin# Name Pin# Name
1 GND 2 VDD_5V 3 A1_PCF
4 GND 5 VDD_5V 6 A2_PCF
7 GND 8 VDD_5V 9 A3_PCF
10 GND 11 VDD_5V 12 D1_Pi11
13 GND 14 VDD_5V 15 D2_Pi26
16 GND 17 VDD_5V 18 D3_Pi16
19 GND 20 VDD_5V 21 D4_Pi19
22 GND 23 VDD_5V 24 D5_Pi21
25 GND 26 VDD_5V 27 D6_Pi23
28 GND 29 VDD_5V 30 D7_Pi24
18B20和红外接收接口布局
  • 18B20和红外接收管脚定义
Pin# Name Pin# Name Pin# Name
1 VDD_5V 2 DATA 3 GND
1 DATA 2 GND 3 VDD_5V

4 下载Matrix源码

Matrix配件相关的代码是完全开源的,统一由一个仓库进行管理:https://github.com/friendlyarm/matrix.git
该仓库里不同的分支代表着Matrix配件所支持的不同开发板。

  • nanopi分支用于支持NanoPi;
  • nanopi2分支用于支持NanoPi 2;
  • tiny4412分支用于支持Tiny4412;
  • raspberrypi分支用于支持RaspberryPi;

在主机PC上安装git,以Ubuntu14.04为例

$ sudo apt-get install git

克隆Matrix配件代码仓库

$ git clone https://github.com/friendlyarm/matrix.git

克隆完成后会得到一个名为matrix的目录,里面存放着所有Matrix配件的代码。

5 与NanoPi 2连接使用

5.1 硬件连接

参考下图连接模块Matrix-Compact_Kit和NanoPi 2:
Matrix-Compact_Kit_nanopi2

5.2 编译测试程序

进入Matrix代码仓库,切换到nanopi2分支

$ cd matrix
$ git checkout nanopi2

编译Matrix配件代码

$ make CROSS_COMPILE=arm-linux- clean
$ make CROSS_COMPILE=arm-linux-
$ make CROSS_COMPILE=arm-linux- install

注意:请确保你的主机PC当前使用的交叉编译器为NanoPi 2配套的arm-linux-gcc-4.9.3。
编译成功后库文件位于install/lib目录下,测试程序位于install/usr/bin目录下,硬件驱动模块位于modules目录。

5.3 拷贝测试程序

将带有Debian系统的SD卡插入一台运行Linux的电脑,可以挂载SD卡上的boot和rootfs分区。
假设rootfs分区的挂载路径为/media/rootfs,执行以下命令将Matrix的硬件驱动、库文件和测试程序拷贝到NanoPi 2的文件系统上。

$ cp modules /media/rootfs/ -r
$ cp install/lib/* /media/rootfs/lib/ -d
$ cp install/usr/bin/* /media/rootfs/usr/bin/

5.4 测试LCD显示

将SD卡重新插入NanoPi 2,上电启动,在Debian的shell终端中执行以下命令。

$ cd /modules
$ insmod fbtft_device.ko name=matrix-st7735s gpios=dc:58,reset:63,cs:59
$ sudo FRAMEBUFFER=/dev/fb-st7735s startx &

fbtft_device是LCD驱动,成功加载驱动后,可以看到LCD被清屏。
startx命令会将1寸屏作为桌面显示设备,运行效果如下:
matrix-cpt_kit_result_lcd

5.5 测试AD转换

执行以下命令获得Channel 0的AD转换值:

$ matrix-adc

通过旋转可调电阻可以改变AD转换值,运行效果如下:
matrix-cpt_kit_result_ad

5.6 测试指南针

执行以下命令获得当前方向:

$ matrix-compass

通过改变开发板的朝向可以获得不同的方向值,运行效果如下:
matrix-cpt_kit_result_cps

5.7 读按键值

按键 CPU GPIO linux索引号
KEY1 GPIOC7 71
KEY2 ALIVEGPIO2 162
KEY3 ALIVEGPIO3 163

以KEY1为例,执行以下命令读取按键值:

$ cd /sys/class/gpio/
$ echo 71 > export
$ echo in > gpio71/direction
$ cat gpio71/value

当KEY1按下时value=0,KEY1弹起时value=1。

5.8 控制LED

LED CPU GPIO linux索引号
LED1 GPIOC10 74
LED2 GPIOC9 73
LED3 GPIOC11 75
LED4 GPIOC12 76

以LED1为例,执行以下命令控制LED:

$ cd /sys/class/gpio/
$ echo 74 > export
$ echo out > gpio74/direction
$ echo 1 > gpio74/value

1表示点亮LED1,0表示熄灭LED1。

6 与NanoPi连接使用

7 与Tiny4412连接使用

8 与RaspberryPi连接使用

9 与Arduino连接使用

10 相关资料

  • [Schematic]()