Skip to content

Commit

Permalink
Updated enable function to set clock source according to recommendati…
Browse files Browse the repository at this point in the history
…on from datasheet.
  • Loading branch information
woolseyj committed Aug 8, 2018
1 parent 24baa5a commit be0de94
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/MPU-6050.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public class MPU6050{

/// Enables or disables the device
public func enable(_ on: Bool){
// PWR_MGMT_1 register, SLEEP bit
i2c.writeByte(address, command: 0x6B, value: UInt8(on ? 0 : 0x40))
// PWR_MGMT_1 register, SLEEP bit, CLKSEL[2:0] bits
i2c.writeByte(address, command: 0x6B, value: UInt8(on ? 0x01 : 0x40))
}

/// Resets the device
public func reset(){
// PWR_MGMT_1 register, SLEEP bit
// PWR_MGMT_1 register, DEVICE_RESET bit
let tmp = i2c.readByte(address, command: 0x6B)
i2c.writeByte(address, command: 0x6B, value: UInt8(0x80))
i2c.writeByte(address, command: 0x6B, value: tmp)
Expand Down

0 comments on commit be0de94

Please sign in to comment.