commands

package
v3.6.3+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package commands contains the command that a MFRC522 supports.

Index

Constants

View Source
const (
	PCD_IDLE       = 0x00
	PCD_AUTHENT    = 0x0E
	PCD_RECEIVE    = 0x08
	PCD_TRANSMIT   = 0x04
	PCD_TRANSCEIVE = 0x0C
	PCD_RESETPHASE = 0x0F
	PCD_CALCCRC    = 0x03

	PICC_REQIDL    = 0x26
	PICC_REQALL    = 0x52
	PICC_ANTICOLL  = 0x93
	PICC_ANTICOLL2 = 0x95
	PICC_SElECTTAG = 0x93
	PICC_AUTHENT1A = 0x60
	PICC_AUTHENT1B = 0x61
	PICC_READ      = 0x30
	PICC_WRITE     = 0xA0
	PICC_DECREMENT = 0xC0
	PICC_INCREMENT = 0xC1
	PICC_RESTORE   = 0xC2
	PICC_TRANSFER  = 0xB0
	PICC_HALT      = 0x50
)

Operation constants

View Source
const (
	CommandReg    = 0x01
	CommIEnReg    = 0x02
	DivlEnReg     = 0x03
	CommIrqReg    = 0x04
	DivIrqReg     = 0x05
	ErrorReg      = 0x06
	Status1Reg    = 0x07
	Status2Reg    = 0x08
	FIFODataReg   = 0x09
	FIFOLevelReg  = 0x0A
	WaterLevelReg = 0x0B
	ControlReg    = 0x0C
	BitFramingReg = 0x0D
	CollReg       = 0x0E

	ModeReg        = 0x11
	TxModeReg      = 0x12
	RxModeReg      = 0x13
	TxControlReg   = 0x14
	TxAutoReg      = 0x15
	TxSelReg       = 0x16
	RxSelReg       = 0x17
	RxThresholdReg = 0x18
	DemodReg       = 0x19
	MifareReg      = 0x1C
	SerialSpeedReg = 0x1F

	CRCResultRegM     = 0x21
	CRCResultRegL     = 0x22
	ModWidthReg       = 0x24
	RFCfgReg          = 0x26
	GsNReg            = 0x27
	CWGsPReg          = 0x28
	ModGsPReg         = 0x29
	TModeReg          = 0x2A
	TPrescalerReg     = 0x2B
	TReloadRegH       = 0x2C
	TReloadRegL       = 0x2D
	TCounterValueRegH = 0x2E
	TCounterValueRegL = 0x2F

	TestSel1Reg     = 0x31
	TestSel2Reg     = 0x32
	TestPinEnReg    = 0x33
	TestPinValueReg = 0x34
	TestBusReg      = 0x35
	AutoTestReg     = 0x36
	VersionReg      = 0x37
	AnalogTestReg   = 0x38
	TestDAC1Reg     = 0x39
	TestDAC2Reg     = 0x3A
	TestADCReg      = 0x3B
)

Register constants

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthStatus

type AuthStatus byte

AuthStatus indicates the authentication response, could be one of AuthOk, AuthReadFailure or AuthFailure

const (
	AuthOk AuthStatus = iota
	AuthReadFailure
	AuthFailure
)

Card authentication status enum.

type LowLevel

type LowLevel struct {
	// contains filtered or unexported fields
}

LowLevel is a low-level handler of a MFRC522 RFID reader.

func NewLowLevelSPI

func NewLowLevelSPI(spiPort spi.Port, resetPin gpio.PinOut, irqPin gpio.PinIn) (*LowLevel, error)

NewLowLevelSPI creates and initializes the RFID card reader attached to SPI.

spiPort - the SPI device to use.
resetPin - reset GPIO pin.
irqPin - irq GPIO pin.

func (*LowLevel) Auth

func (r *LowLevel) Auth(mode byte, blockAddress byte, sectorKey [6]byte, serial []byte) (AuthStatus, error)

Auth authenticate the card fof the sector/block using the provided data.

mode - the authentication mode.
sector - the sector to authenticate on.
block - the block within sector to authenticate.
sectorKey - the key to be used for accessing the sector data.
serial - the serial of the card.

func (*LowLevel) CRC

func (r *LowLevel) CRC(inData []byte) ([]byte, error)

CRC calculates the CRC of the data using the card chip.

func (*LowLevel) CardWrite

func (r *LowLevel) CardWrite(command byte, data []byte) ([]byte, int, error)

CardWrite the low-level interface to write some raw commands to the card.

command - the command register
data - the data to write out to the card using the authenticated sector.

func (*LowLevel) ClearBitmask

func (r *LowLevel) ClearBitmask(address, mask int) error

ClearBitmask clears register bit.

func (*LowLevel) DevRead

func (r *LowLevel) DevRead(address int) (byte, error)

DevRead gets data from a device.

func (*LowLevel) DevWrite

func (r *LowLevel) DevWrite(address int, data byte) error

DevWrite sends data to a device.

func (*LowLevel) Halt

func (r *LowLevel) Halt() error

Halt stops the card and cleans up resources.

func (*LowLevel) Init

func (r *LowLevel) Init() error

Init initializes the RFID chip.

func (*LowLevel) Reset

func (r *LowLevel) Reset() error

Reset resets the RFID chip to initial state.

func (*LowLevel) SetAntenna

func (r *LowLevel) SetAntenna(state bool) error

SetAntenna configures the antenna state, on/off.

func (*LowLevel) SetAntennaGain

func (r *LowLevel) SetAntennaGain(gain int)

SetAntennaGain sets the antenna gain for the driver. This method does not update the gain on the device itself. A subsequent call to SetAntenna is necessary to have an effect.

func (*LowLevel) SetBitmask

func (r *LowLevel) SetBitmask(address, mask int) error

SetBitmask sets register bit.

func (*LowLevel) StopCrypto

func (r *LowLevel) StopCrypto() error

StopCrypto stops the crypto chip.

func (*LowLevel) String

func (r *LowLevel) String() string

String implements conn.Resource.

func (*LowLevel) WaitForEdge

func (r *LowLevel) WaitForEdge(timeout time.Duration) error

WaitForEdge waits for an IRQ pin to strobe. If IRQ pin is not set, then always returns false immediately.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL