tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/lsm6ds3tr/lsm6ds3tr_xiao_ble.go (about) 1 //go:build xiao_ble 2 3 package lsm6ds3tr 4 5 import ( 6 "device/nrf" 7 "machine" 8 "time" 9 ) 10 11 // Configure sets up the device for communication. 12 func (d *Device) Configure(cfg Configuration) error { 13 14 // Following lines are XIAO BLE Sense specific, they have nothing to do with sensor per se 15 // Implementation adapted from https://github.com/Seeed-Studio/Seeed_Arduino_LSM6DS3/blob/master/LSM6DS3.cpp#L68-L77 16 17 // Special mode for IMU power pin on this board. 18 // Can not use pin.Configure() directly due to special mode and 32 bit size 19 pinConfig := uint32(nrf.GPIO_PIN_CNF_DIR_Output<<nrf.GPIO_PIN_CNF_DIR_Pos) | 20 uint32(nrf.GPIO_PIN_CNF_INPUT_Disconnect<<nrf.GPIO_PIN_CNF_INPUT_Pos) | 21 uint32(nrf.GPIO_PIN_CNF_PULL_Disabled<<nrf.GPIO_PIN_CNF_PULL_Pos) | 22 uint32(nrf.GPIO_PIN_CNF_DRIVE_H0H1<<nrf.GPIO_PIN_CNF_DRIVE_Pos) | 23 uint32(nrf.GPIO_PIN_CNF_SENSE_Disabled<<nrf.GPIO_PIN_CNF_SENSE_Pos) 24 nrf.P1.PIN_CNF[8].Set(pinConfig) // LSM_PWR == P1_08 25 26 // Enable IMU 27 machine.LSM_PWR.High() 28 29 // Wait a moment 30 time.Sleep(10 * time.Millisecond) 31 32 // Common initialisation code 33 return d.doConfigure(cfg) 34 }