tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/as560x/as5601.go (about) 1 // Product: https://ams.com/as5601 2 // Datasheet: https://ams.com/documents/20143/36005/AS5601_DS000395_3-00.pdf 3 4 package as560x // import tinygo.org/x/drivers/ams560x 5 6 import "tinygo.org/x/drivers" 7 8 // AS5601Device represents an ams AS5601 device driver accessed over I2C 9 type AS5601Device struct { 10 BaseDevice // promote base device 11 } 12 13 // NewAS5601 creates a new AS5601Device given an I2C bus 14 func NewAS5601(bus drivers.I2C) AS5601Device { 15 // Create base device 16 baseDev := newBaseDevice(bus) 17 // Add AS5601 specific registers 18 baseDev.registers[ABN] = newI2CRegister(ABN, 0, 0b1111, 1, reg_read|reg_write|reg_program) 19 baseDev.registers[PUSHTHR] = newI2CRegister(PUSHTHR, 0, 0xff, 1, reg_read|reg_write|reg_program) 20 // Return the device 21 return AS5601Device{baseDev} 22 }