|
|
|
@ -46,24 +46,24 @@ func TestSPISense_success(t *testing.T) {
|
|
|
|
Ops: []conntest.IO{
|
|
|
|
Ops: []conntest.IO{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Write: []byte{0xD0, 0x00},
|
|
|
|
W: []byte{0xD0, 0x00},
|
|
|
|
Read: []byte{0x00, 0x60},
|
|
|
|
R: []byte{0x00, 0x60},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Write: []byte{0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
W: []byte{0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
Read: []byte{0x00, 0xC9, 0x6C, 0x63, 0x65, 0x32, 0x00, 0x77, 0x93, 0x98, 0xD5, 0xD0, 0x0B, 0x67, 0x23, 0xBA, 0x00, 0xF9, 0xFF, 0xAC, 0x26, 0x0A, 0xD8, 0xBD, 0x10, 0x00, 0x4B},
|
|
|
|
R: []byte{0x00, 0xC9, 0x6C, 0x63, 0x65, 0x32, 0x00, 0x77, 0x93, 0x98, 0xD5, 0xD0, 0x0B, 0x67, 0x23, 0xBA, 0x00, 0xF9, 0xFF, 0xAC, 0x26, 0x0A, 0xD8, 0xBD, 0x10, 0x00, 0x4B},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Write: []byte{0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
W: []byte{0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
Read: []byte{0x00, 0x5C, 0x01, 0x00, 0x15, 0x0F, 0x00, 0x1E},
|
|
|
|
R: []byte{0x00, 0x5C, 0x01, 0x00, 0x15, 0x0F, 0x00, 0x1E},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{Write: []byte{0x74, 0xB4, 0x72, 0x05, 0x75, 0xA0, 0x74, 0xB7}},
|
|
|
|
{W: []byte{0x74, 0xB4, 0x72, 0x05, 0x75, 0xA0, 0x74, 0xB7}},
|
|
|
|
// Read.
|
|
|
|
// R.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Write: []byte{0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
W: []byte{0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
|
|
Read: []byte{0x00, 0x51, 0x9F, 0xC0, 0x9E, 0x3A, 0x50, 0x5E, 0x5B},
|
|
|
|
R: []byte{0x00, 0x51, 0x9F, 0xC0, 0x9E, 0x3A, 0x50, 0x5E, 0x5B},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -112,8 +112,8 @@ func TestNewSPI_fail_len(t *testing.T) {
|
|
|
|
Ops: []conntest.IO{
|
|
|
|
Ops: []conntest.IO{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
Write: []byte{0xD0, 0x00},
|
|
|
|
W: []byte{0xD0, 0x00},
|
|
|
|
Read: []byte{0x00},
|
|
|
|
R: []byte{0x00},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DontPanic: true,
|
|
|
|
DontPanic: true,
|
|
|
|
@ -135,8 +135,8 @@ func TestNewSPI_fail_chipid(t *testing.T) {
|
|
|
|
Ops: []conntest.IO{
|
|
|
|
Ops: []conntest.IO{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
Write: []byte{0xD0, 0x00},
|
|
|
|
W: []byte{0xD0, 0x00},
|
|
|
|
Read: []byte{0x00, 0xFF},
|
|
|
|
R: []byte{0x00, 0xFF},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -153,7 +153,7 @@ func TestNewI2C_fail(t *testing.T) {
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
{Addr: 0x76, Write: []byte{0xd0}},
|
|
|
|
{Addr: 0x76, W: []byte{0xd0}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DontPanic: true,
|
|
|
|
DontPanic: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -171,7 +171,7 @@ func TestNewI2C_chipid(t *testing.T) {
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
{Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}},
|
|
|
|
{Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DontPanic: true,
|
|
|
|
DontPanic: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -187,12 +187,12 @@ func TestNewI2C_calib1(t *testing.T) {
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
{Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}},
|
|
|
|
{Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Addr: 0x76,
|
|
|
|
Addr: 0x76,
|
|
|
|
Write: []byte{0x88},
|
|
|
|
W: []byte{0x88},
|
|
|
|
Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DontPanic: true,
|
|
|
|
DontPanic: true,
|
|
|
|
@ -210,15 +210,15 @@ func TestNewI2C_calib2(t *testing.T) {
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
{Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}},
|
|
|
|
{Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Addr: 0x76,
|
|
|
|
Addr: 0x76,
|
|
|
|
Write: []byte{0x88},
|
|
|
|
W: []byte{0x88},
|
|
|
|
Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{Addr: 0x76, Write: []byte{0xe1}, Read: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}},
|
|
|
|
{Addr: 0x76, W: []byte{0xe1}, R: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DontPanic: true,
|
|
|
|
DontPanic: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -257,19 +257,19 @@ func TestI2CSense_fail(t *testing.T) {
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
{Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}},
|
|
|
|
{Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Addr: 0x76,
|
|
|
|
Addr: 0x76,
|
|
|
|
Write: []byte{0x88},
|
|
|
|
W: []byte{0x88},
|
|
|
|
Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{Addr: 0x76, Write: []byte{0xe1}, Read: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}},
|
|
|
|
{Addr: 0x76, W: []byte{0xe1}, R: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}},
|
|
|
|
// Configuration.
|
|
|
|
// Configuration.
|
|
|
|
{Addr: 0x76, Write: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, Read: nil},
|
|
|
|
{Addr: 0x76, W: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, R: nil},
|
|
|
|
// Read.
|
|
|
|
// Read.
|
|
|
|
{Addr: 0x76, Write: []byte{0xf7}},
|
|
|
|
{Addr: 0x76, W: []byte{0xf7}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DontPanic: true,
|
|
|
|
DontPanic: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -292,21 +292,21 @@ func TestI2CSense_success(t *testing.T) {
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
bus := i2ctest.Playback{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
Ops: []i2ctest.IO{
|
|
|
|
// Chipd ID detection.
|
|
|
|
// Chipd ID detection.
|
|
|
|
{Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}},
|
|
|
|
{Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Addr: 0x76,
|
|
|
|
Addr: 0x76,
|
|
|
|
Write: []byte{0x88},
|
|
|
|
W: []byte{0x88},
|
|
|
|
Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// Calibration data.
|
|
|
|
// Calibration data.
|
|
|
|
{Addr: 0x76, Write: []byte{0xe1}, Read: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}},
|
|
|
|
{Addr: 0x76, W: []byte{0xe1}, R: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}},
|
|
|
|
// Configuration.
|
|
|
|
// Configuration.
|
|
|
|
{Addr: 0x76, Write: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, Read: nil},
|
|
|
|
{Addr: 0x76, W: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, R: nil},
|
|
|
|
// Read.
|
|
|
|
// Read.
|
|
|
|
{Addr: 0x76, Write: []byte{0xf7}, Read: []byte{0x4a, 0x52, 0xc0, 0x80, 0x96, 0xc0, 0x7a, 0x76}},
|
|
|
|
{Addr: 0x76, W: []byte{0xf7}, R: []byte{0x4a, 0x52, 0xc0, 0x80, 0x96, 0xc0, 0x7a, 0x76}},
|
|
|
|
// Stop.
|
|
|
|
// Stop.
|
|
|
|
{Addr: 0x76, Write: []byte{0xf4, 0x0}},
|
|
|
|
{Addr: 0x76, W: []byte{0xf4, 0x0}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dev, err := NewI2C(&bus, nil)
|
|
|
|
dev, err := NewI2C(&bus, nil)
|
|
|
|
|