forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SPI using GPIO's plus driver for MFRC522
- Loading branch information
1 parent
fdf4f4b
commit 6c7ecbe
Showing
42 changed files
with
2,594 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package mfrc522 | ||
|
||
import "fmt" | ||
|
||
func (d *MFRC522Common) readByteData(reg uint8) (uint8, error) { | ||
if d.connection == nil { | ||
return 0, fmt.Errorf("not connected") | ||
} | ||
return d.connection.ReadByteData(reg) | ||
} | ||
|
||
func (d *MFRC522Common) writeByteData(reg uint8, data uint8) error { | ||
if d.connection == nil { | ||
return fmt.Errorf("not connected") | ||
} | ||
return d.connection.WriteByteData(reg, data) | ||
} | ||
|
||
func (d *MFRC522Common) setRegisterBitMask(reg uint8, mask uint8) error { | ||
val, err := d.readByteData(reg) | ||
if err != nil { | ||
return err | ||
} | ||
if err := d.writeByteData(reg, val|mask); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (d *MFRC522Common) clearRegisterBitMask(reg uint8, mask uint8) error { | ||
val, err := d.readByteData(reg) | ||
if err != nil { | ||
return err | ||
} | ||
if err := d.writeByteData(reg, val&^mask); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.