mfrc522

package
v0.0.0-...-91ef8d6 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_LEN = 16

	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_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
)
View Source
const (
	MI_OK          = 0
	MI_NOTAGERR    = 1
	MI_ERR         = 2
	MI_ERR_CRC     = 3
	MI_ERR_CRC_LEN = 4
	MI_ERR_SEND    = 5
	MI_ERR_REQUEST = 6
	MI_ERR_TIMEOUT = 7
	// Status2Reg register MFCrypto1On bit not set
	// indicates that the MIFARE Crypto1 unit is switched on and
	// therefore all data communication with the card is encrypted
	MI_ERR_CRYPTO = 8
)
View Source
const (
	Reserved00    = 0x00
	CommandReg    = 0x01
	ComIEnReg     = 0x02
	DivlEnReg     = 0x03
	ComIrqReg     = 0x04
	DivIrqReg     = 0x05
	ErrorReg      = 0x06
	Status1Reg    = 0x07
	Status2Reg    = 0x08
	FIFODataReg   = 0x09
	FIFOLevelReg  = 0x0A
	WaterLevelReg = 0x0B
	ControlReg    = 0x0C
	BitFramingReg = 0x0D
	CollReg       = 0x0E
	Reserved01    = 0x0F

	Reserved10     = 0x10
	ModeReg        = 0x11
	TxModeReg      = 0x12
	RxModeReg      = 0x13
	TxControlReg   = 0x14
	TxAutoReg      = 0x15
	TxSelReg       = 0x16
	RxSelReg       = 0x17
	RxThresholdReg = 0x18
	DemodReg       = 0x19
	Reserved11     = 0x1A
	Reserved12     = 0x1B
	MifareReg      = 0x1C
	Reserved13     = 0x1D
	Reserved14     = 0x1E
	SerialSpeedReg = 0x1F

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

	Reserved30      = 0x30
	TestSel1Reg     = 0x31
	TestSel2Reg     = 0x32
	TestPinEnReg    = 0x33
	TestPinValueReg = 0x34
	TestBusReg      = 0x35
	AutoTestReg     = 0x36
	VersionReg      = 0x37
	AnalogTestReg   = 0x38
	TestDAC1Reg     = 0x39
	TestDAC2Reg     = 0x3A
	TestADCReg      = 0x3B
	Reserved31      = 0x3C
	Reserved32      = 0x3D
	Reserved33      = 0x3E
	Reserved34      = 0x3F
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mfrc522

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

Mfrc522 : instance Mfrc522 device struct

func GetInstance

func GetInstance() *Mfrc522

GetInstance : singleton instance

func (*Mfrc522) AntennaOff

func (mfrc522 *Mfrc522) AntennaOff()

AntennaOff : set antenna off

func (*Mfrc522) AntennaOn

func (mfrc522 *Mfrc522) AntennaOn()

AntennaOn : set antenna on

func (*Mfrc522) Anticoll

func (mfrc522 *Mfrc522) Anticoll() ([]byte, error)

Anticoll : dump anticoll

func (*Mfrc522) Auth

func (mfrc522 *Mfrc522) Auth(authMode byte, blockAddr byte, sectorkey []byte, serNum []byte) int

Auth : Auth This command manages MIFARE authentication to enable a secure communication to any MIFARE Mini, MIFARE 1K and MIFARE 4K card. The following data is written to the FIFO buffer before the command can be activated • Authentication command code (60h, 61h) • Block address • Sector key byte 0 • Sector key byte 1 • Sector key byte 2 • Sector key byte 3 • Sector key byte 4 • Sector key byte 5 • Card serial number byte 0 • Card serial number byte 1 • Card serial number byte 2 • Card serial number byte 3

func (*Mfrc522) ClearBitMask

func (mfrc522 *Mfrc522) ClearBitMask(reg byte, mask byte)

ClearBitMask : reset bit mask

func (*Mfrc522) DumpClassic1K

func (mfrc522 *Mfrc522) DumpClassic1K(Key []byte) (error, string, []byte, []types.Mfrc522Sector16)

DumpClassic1K : handler for DumpClassic1K

func (*Mfrc522) Read

func (mfrc522 *Mfrc522) Read(addr byte) (byte, error)

Read : read on mfrc522 component

func (*Mfrc522) ReadCard

func (mfrc522 *Mfrc522) ReadCard(blockAddr byte) (byte, []byte, error)

ReadCard : read from card

func (*Mfrc522) Request

func (mfrc522 *Mfrc522) Request(reqMode byte) (int, []byte)

Request : request

func (*Mfrc522) RequestIdle

func (mfrc522 *Mfrc522) RequestIdle() (string, error)

RequestIdle : RequestIdle Output tagType 0x4400 = Mifare_UltraLight 0x0400 = Mifare_One(S50) 0x0200 = Mifare_One(S70) 0x0800 = Mifare_Pro(X) 0x4403 = Mifare_DESFire

func (*Mfrc522) Reset

func (mfrc522 *Mfrc522) Reset()

Reset : reset mfrc522 component

func (*Mfrc522) SelectTag

func (mfrc522 *Mfrc522) SelectTag(serNum []byte) (int, int)

SelectTag : Tag

func (*Mfrc522) SetBitMask

func (mfrc522 *Mfrc522) SetBitMask(reg byte, mask byte)

SetBitMask : reset bit mask

func (*Mfrc522) StopCrypto1

func (mfrc522 *Mfrc522) StopCrypto1()

StopCrypto1 : set antenna off

func (*Mfrc522) ToCard

func (mfrc522 *Mfrc522) ToCard(command byte, sendData []byte, expected int) (int, []byte)

ToCard : write to card

func (*Mfrc522) WaitForTag

func (mfrc522 *Mfrc522) WaitForTag() (error, string, []byte)

WaitForTag : handler for WaitForTag

func (*Mfrc522) Write

func (mfrc522 *Mfrc522) Write(addr byte, val byte)

Write : write on mfrc522 component

func (*Mfrc522) WriteCard

func (mfrc522 *Mfrc522) WriteCard(blockAddr byte, writeData []byte) (byte, []byte, error)

WriteCard : write from card

func (*Mfrc522) WriteClassic1K

func (mfrc522 *Mfrc522) WriteClassic1K(key []byte, uid []byte, sector byte, data []byte) error

WriteClassic1K : WriteClassic1K

Jump to

Keyboard shortcuts

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