Ikuti pembaruan di Twitter: https://twitter.com/mistertechblog/status/1454200499247349760
Lora backplate untuk pinephone terdiri dari ...
Semtech sx1262 lora transceiver (SPI) dan antena
https://www.semtech.com/products/wireless-rf/lora-core/sx1262
Konektor I2C yang cocok dengan port I2C (pin pogo) di pinephone
https://wiki.pine64.org/index.php/pinephone#pogo_pins
Jembatan I2C-to-SPI (attiny84) yang menghubungkan konektor I2C ke transceiver LORA (SPI)
https://github.com/zschroeder6212/tiny-i2c-spi
Skema: https://wiki.pine64.org/wiki/pinedio#pinephone_backplate
Mari kita selidiki pelat belakang Lora dengan bajak laut bus, untuk mengirimkan beberapa perintah SX1262 dan membaca tanggapannya: http://dangerousprototypes.com/docs/i2c
UPDATE: Lihat artikel bagus ini oleh JF ...
"Pertama -tama lihat lempengan lora untuk pinephone"
"Mengedipkan pelat belakang Lora untuk pinephone"
"Seorang pengemudi untuk pelat belakang Lora untuk pinephone"
Kode Sumber Arduino: https://github.com/zschroeder6212/tiny-i2c-spi/blob/master/src/main.c
Jembatan berjalan di alamat 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 ;Jembatan mengirimkan data ke SPI ketika byte pertama yang diterima adalah 0x01:
#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 ;Ketika jembatan menerima perintah baca, ia mengembalikan byte yang diterima dari SPI:
void I2C_requested ()
{
usiTwiTransmitByte ( SPI_buffer [ transmit_index ++ ]);
if ( transmit_index >= BUFFER_SIZE )
{
transmit_index = 0 ;
}
} Fungsi usi didefinisikan di sini: https://github.com/zschroeder6212/tiny-i2c-pi/blob/master/src/usi_twi_slave.c
Berdasarkan:
http://dangerousprototypes.com/docs/i2c
https://lupyuen.github.io/articles/i2c#appendix-test-bme280-with-bus-birate
Connect Bus Pirate ke Lora Backplate:
| Pin bajak laut bus | Pin pelat belakang |
|---|---|
MOSI | SDA |
CLK | SCL |
5V | USB-5V |
GND | GND |
Masukkan mode I2C, power on:
m
I2C > HW > 400
W
Pindai Bus I2C:
(1)
Hasil pemindaian I2C:
Searching I2C address space. Found devices at:
0x00 (0x00 W) 0x01 (0x00
atau
Searching I2C address space. Found devices at:
0x40(0x20 W) 0x41(0x20
Masalah: Bajak laut bus menggantung saat memindai. Dan Alamat I2C dari Lora Backplate harus 0x28, bukan 0x00. Mengapa?
Baca Alamat I2C 0x28:
[0x51 r]
(Karena 0x51 = 0x28 * 2 + 1)
Hasil:
I2C START BIT
WRITE: 0x51 ACK
READ: 0x00
NACK
MASALAH: BUKU BUS HANG saat membaca Alamat I2C 0x28 dari Lora Backplate. Mengapa?
Baca Alamat I2C 0x20:
[0x41 r]
(Karena 0x41 = 0x20 * 2 + 1)
Masalah yang sama seperti di atas.
Baca Alamat I2C 0x00:
[0x01 r]
(Karena 0x01 = 0x00 * 2 + 1)
Masalah yang sama seperti di atas.
Hal yang sama terjadi saat kami menyelidiki papan pelarian untuk lempeng backa Lora ...
TODO: Tulis dan baca Alamat I2C 0x28 Register 0x01:
[0x50 0x01 0x00] [0x51 r]
TODO: Tulis dan baca alamat I2C 0x00 Register 0x01?
[0x00 0x01 0x00] [0x01 r]
Di pinephone dengan Manjaro Phosh, memindai I2C Bus 3 dengan 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: -- -- -- -- -- -- -- -- Masalah: i2cdetect gagal mendeteksi alamat I2C (0x28) dari pelat belakang LORA. Mengapa?
Apakah Lora Backplate telah dilontarkan dengan firmware yang tepat?
I2C-to-SPI Bridge di Attiny84: https://github.com/zschroeder6212/tiny-i2c-spi
Lora Backplate (Alamat I2C 0x28) tidak muncul saat kami memindai bus I2C 0 hingga 5:
[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: -- -- -- -- -- -- -- --(Tidak mungkin I2C Bus 2 karena kami mengharapkan seluruh bus yang didedikasikan untuk pin pogo I2C)
Bandingkan ini dengan perangkat Pinephone I2C lainnya:
https://github.com/jnavarro7/pineeye_for_pinephone
https://dev.to/pcvonz/ic-on-the-pinephone-5090
UPDATE: Lihat artikel bagus ini oleh JF ...
"Pertama -tama lihat lempengan lora untuk pinephone"
"Mengedipkan pelat belakang Lora untuk pinephone"
"Seorang pengemudi untuk pelat belakang Lora untuk pinephone"