mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-04 06:57:48 +00:00
lis2mdl: starting point for adding unit tests
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
+4
-3
@@ -6,14 +6,15 @@
|
||||
package lis2mdl // import "tinygo.org/x/drivers/lis2mdl"
|
||||
|
||||
import (
|
||||
"machine"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
)
|
||||
|
||||
// Device wraps an I2C connection to a LIS2MDL device.
|
||||
type Device struct {
|
||||
bus machine.I2C
|
||||
bus drivers.I2C
|
||||
Address uint8
|
||||
PowerMode uint8
|
||||
SystemMode uint8
|
||||
@@ -31,7 +32,7 @@ type Configuration struct {
|
||||
// configured.
|
||||
//
|
||||
// This function only creates the Device object, it does not touch the device.
|
||||
func New(bus machine.I2C) Device {
|
||||
func New(bus drivers.I2C) Device {
|
||||
return Device{bus: bus, Address: MAG_ADDRESS}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package lis2mdl
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"tinygo.org/x/drivers/tester"
|
||||
)
|
||||
|
||||
func TestI2CAddress(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
bus := tester.NewI2CBus(c)
|
||||
dev := New(bus)
|
||||
c.Assert(dev.Address, qt.Equals, uint8(MAG_ADDRESS))
|
||||
}
|
||||
Reference in New Issue
Block a user