关注Twitter上的更新:https://twitter.com/mistertechblog/status/1454200499247349760
洛拉(Lora)的松树背板包括...
Semtech SX1262 LORA收发器(SPI)和天线
https://www.semtech.com/products/wireless-rf/lora-core/sx1262
与松树上的I2C端口(POGO引脚)匹配的I2C连接器
https://wiki.pine64.org/index.php/pinephone#pogo_pins
I2C-TO-SPI桥(ATTINY84)将I2C连接器连接到Lora收发器(SPI)
https://github.com/zschroeder6212/tiny-i2c-pi
示意图:https://wiki.pine64.org/wiki/pinedio#pinephone_backplate
让我们用海盗探测Lora背板,以传输一些SX1262命令并阅读响应:http://dangercorprototypes.com/docs/i2c
更新:请参阅JF的这些出色文章...
“首先看一下松树的洛拉背板”
“为松木闪烁洛拉背板”
“洛拉背板的驱动器”
Arduino源代码:https://github.com/zschroeder6212/tiny-i2c-pi/blob/master/master/src/main.c.c
桥在I2C地址0x28上运行:
#include "USI_TWI_Slave.h"
#define I2C_ADDR 0x28
int main ( void )
{
/* init I2C */
usiTwiSlaveInit ( I2C_ADDR );
/* set received/requested callbacks */
usi_onReceiverPtr = I2C_received ;
usi_onRequestPtr = I2C_requested ;当收到第一个字节为0x01时,桥将数据传输到SPI:
#define CMD_TRANSMIT 1
#define CMD_CONFIGURE 2
void I2C_received ( uint8_t bytes_recieved )
{
uint8_t command = usiTwiReceiveByte ();
switch ( command )
{
case CMD_TRANSMIT :
{
CS_PORT &= ~( 1 << CS );
for ( int i = 1 ; i < bytes_recieved ; i ++ )
{
uint8_t received_byte = SPI_transfer ( usiTwiReceiveByte ());
SPI_buffer [ received_index ++ ] = received_byte ;当桥接收读取命令时,它将返回从SPI接收到的字节:
void I2C_requested ()
{
usiTwiTransmitByte ( SPI_buffer [ transmit_index ++ ]);
if ( transmit_index >= BUFFER_SIZE )
{
transmit_index = 0 ;
}
} usi函数在此处定义:https://github.com/zschroeder6212/tiny-i2c-pi/blob/blob/master/src/usi_twi_slave.c.c.c.c
基于:
http://dangericprototypes.com/docs/i2c
https://lupyuen.github.io/articles/i2c#appendix-test-bme280-with-bus-pirate
将巴士海盗连接到洛拉背板:
| 公交海盗别针 | 背板销 |
|---|---|
MOSI | SDA |
CLK | SCL |
5V | USB-5V |
GND | GND |
输入I2C模式,电源打开:
m
I2C > HW > 400
W
扫描I2C巴士:
(1)
I2C扫描结果:
Searching I2C address space. Found devices at:
0x00 (0x00 W) 0x01 (0x00
或者
Searching I2C address space. Found devices at:
0x40(0x20 W) 0x41(0x20
问题:扫描时,海盗公共汽车悬挂。 Lora背板的I2C地址应为0x28,而不是0x00。为什么?
阅读I2C地址0x28:
[0x51 r]
(因为0x51 = 0x28 * 2 + 1)
结果:
I2C START BIT
WRITE: 0x51 ACK
READ: 0x00
NACK
问题:从Lora背板阅读I2C地址0x28时,公交海盗悬挂。为什么?
阅读I2C地址0x20:
[0x41 r]
(因为0x41 = 0x20 * 2 + 1)
与上面相同的问题。
阅读I2C地址0x00:
[0x01 r]
(因为0x01 = 0x00 * 2 + 1)
与上面相同的问题。
当我们探索洛拉背板的突破板时,也会发生同样的事情...
TODO:写和阅读I2C地址0x28寄存器0x01:
[0x50 0x01 0x00] [0x51 r]
TODO:写和阅读I2C地址0x00寄存器0x01?
[0x00 0x01 0x00] [0x01 r]
在带有Manjaro Phosh的Pinephone上,扫描I2C总线3与i2cdetect :
[manjaro@manjaro-arm ~ ]$ sudo pacman -Syu i2c-tools
[manjaro@manjaro-arm ~ ]$ i2cdetect -l
i2c-0 unknown DesignWare HDMI N/A
i2c-1 unknown mv64xxx_i2c adapter N/A
i2c-2 unknown mv64xxx_i2c adapter N/A
i2c-3 unknown mv64xxx_i2c adapter N/A
i2c-4 unknown i2c-csi N/A
i2c-5 unknown i2c-2-mux (chan_id 0) N/A
[manjaro@manjaro-arm ~ ]$ sudo i2cdetect 3
WARNING ! This program can confuse your I2C bus, cause data loss and worse !
I will probe file /dev/i2c-3.
I will probe address range 0x08-0x77.
Continue ? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --问题: i2cdetect无法检测Lora背板的I2C地址(0x28)。为什么?
Lora背板是否用正确的固件闪烁?
I2C-TO-SPI桥上的Attiny84:https://github.com/zschroeder6212/tiny-i2c-pi
当我们扫描I2C总线0至5时,Lora背板(I2C地址0x28)不会出现
[manjaro@manjaro-arm ~ ]$ sudo i2cdetect 0
WARNING ! This program can confuse your I2C bus, cause data loss and worse !
I will probe file /dev/i2c-0.
I will probe address range 0x08-0x77.
Continue ? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- 32 -- -- 35 -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[manjaro@manjaro-arm ~ ]$ sudo i2cdetect 1
WARNING ! This program can confuse your I2C bus, cause data loss and worse !
I will probe file /dev/i2c-1.
I will probe address range 0x08-0x77.
Continue ? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- UU -- -- -- UU -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[manjaro@manjaro-arm ~ ]$ sudo i2cdetect 2
WARNING ! This program can confuse your I2C bus, cause data loss and worse !
I will probe file /dev/i2c-2.
I will probe address range 0x08-0x77.
Continue ? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[manjaro@manjaro-arm ~ ]$ sudo i2cdetect 3
WARNING ! This program can confuse your I2C bus, cause data loss and worse !
I will probe file /dev/i2c-3.
I will probe address range 0x08-0x77.
Continue ? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[manjaro@manjaro-arm ~ ]$ sudo i2cdetect 4
WARNING ! This program can confuse your I2C bus, cause data loss and worse !
I will probe file /dev/i2c-4.
I will probe address range 0x08-0x77.
Continue ? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[manjaro@manjaro-arm ~ ]$ sudo i2cdetect 5
WARNING ! This program can confuse your I2C bus, cause data loss and worse !
I will probe file /dev/i2c-5.
I will probe address range 0x08-0x77.
Continue ? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --(不,它不能是I2C总线2,因为我们期望为I2C Pogo引脚提供一整辆公共汽车)
将此与其他松树I2C设备进行比较:
https://github.com/jnavarro7/pineeye_for_pinephone
https://dev.to/pcvonz/ic-on-the-pinephone-5090
更新:请参阅JF的这些出色文章...
“首先看一下松树的洛拉背板”
“为松木闪烁洛拉背板”
“洛拉背板的驱动器”