代码拉取完成,页面将自动刷新
/*
* /linux-3.0.8/drivers/spi/gt2440_rc522.h
*/
#ifndef __RC522_TEST_H
#define __RC522_TEST_H
#include <linux/types.h>
/***** user transfer data structure *****/
#define CARD_TYPE_SIZE 2
#define CARD_ID_SIZE 4
#define CARD_IDCSUM_SIZE 1
#define CARD_CAP_SIZE 1
#define CARD_MSG_SIZE 2
#define CARD_BLK_SIZE 16
#define CARD_PLUS_SIZE 4
#define CARD_KEYA_SIZE 6
#define CARD_CTRL_SIZE 4
#define CARD_KEYB_SIZE 6
#define CARD_CRC_SIZE 2
#define CARD_INC_SIZE 4
#define CARD_SECT_NBLK 4
/***** user can modify the value to decrease locked sector *****/
#define CARD_LOCK_NSECT 10
enum rc522_ioc_type {
RC522_IOC_NONE_0 = 0, // avoid bad operation
RC522_IOC_INIT_CHIP,
RC522_IOC_HALT_CHIP,
RC522_IOC_ON_ANTE,
RC522_IOC_OFF_ANTE,
RC522_IOC_REQ_CARD,
RC522_IOC_ON_CHIP,
RC522_IOC_OFF_CHIP,
RC522_IOC_NONE_1, // recerve operation
RC522_IOC_NONE_2, // recerve operation
RC522_IOC_READ_CARD = 10,
RC522_IOC_WRITE_CARD,
RC522_IOC_INC_CARD,
RC522_IOC_DEC_CARD,
RC522_IOC_READ_KEYA,
RC522_IOC_READ_KEYB,
RC522_IOC_WRITE_KEYA,
RC522_IOC_WRITE_KEYB,
RC522_IOC_READ_CTRL,
RC522_IOC_WRITE_CTRL,
/* add multi ioc cmd */
};
enum rc522_sect_num {
RC522_SECT_0 = 0,
RC522_SECT_1,
RC522_SECT_2,
RC522_SECT_3,
RC522_SECT_4,
RC522_SECT_5,
RC522_SECT_6,
RC522_SECT_7,
RC522_SECT_8,
RC522_SECT_9,
RC522_SECT_10,
RC522_SECT_11,
RC522_SECT_12,
RC522_SECT_13,
RC522_SECT_14,
RC522_SECT_15,
};
enum rc522_blk_num {
RC522_BLK_0 = 0,
RC522_BLK_1,
RC522_BLK_2,
RC522_BLK_3,
};
enum rc522_key_type {
RC522_KEY_A = 0,
RC522_KEY_B = 1,
RC522_KEY_A_B = 2,
};
enum rc522_sect_lock {
RC522_SECT_LOCK = 0,
RC522_SECT_UNLOCK = 1,
};
struct rc522_ioc_transfer {
__u32 speed_hz;
__u32 pad;
__u16 delay_usecs;
__u8 bits_per_word;
__u8 cs_change;
enum rc522_ioc_type ioc_type; /* io ctrl cmd : req, read, write... */
enum rc522_key_type key_type; /* key type: key a, key b, key a and b */
enum rc522_sect_num sect_num; /* sector number: 0~15 */
enum rc522_blk_num blk_num; /* block number: 0~4 */
enum rc522_sect_lock sect_lock; /* sect lock: 0=lock, 1=unlock */
__u8 keya_buf[CARD_KEYA_SIZE]; /*key a space: 6 Bytes*/
__u8 ctrl_buf[CARD_CTRL_SIZE]; /*ctrl space: 4 Bytes*/
__u8 keyb_buf[CARD_KEYB_SIZE]; /*key b space: 6 Bytes*/
__u8 id_buf[CARD_ID_SIZE]; /*id space: 4Bytes for auth card*/
__u8 txrx_buf[CARD_BLK_SIZE + CARD_PLUS_SIZE]; /*w, r space: 16 + 4 Bytes*/
};
/***** spi mode *****/
#define SPI_CPHA 0x01
#define SPI_CPOL 0x02
#define SPI_MODE_0 (0|0)
#define SPI_MODE_1 (0|SPI_CPHA)
#define SPI_MODE_2 (SPI_CPOL|0)
#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
#define SPI_CS_HIGH 0x04
#define SPI_LSB_FIRST 0x08
#define SPI_3WIRE 0x10
#define SPI_LOOP 0x20
#define SPI_NO_CS 0x40
#define SPI_READY 0x80
#define SPI_IOC_MAGIC 'k'
#define SPI_MSGSIZE(N) \
((((N)*(sizeof (struct rc522_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \
? ((N)*(sizeof (struct rc522_ioc_transfer))) : 0)
#define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])
#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, __u8)
#define SPI_IOC_WR_MODE _IOW(SPI_IOC_MAGIC, 1, __u8)
#define SPI_IOC_RD_LSB_FIRST _IOR(SPI_IOC_MAGIC, 2, __u8)
#define SPI_IOC_WR_LSB_FIRST _IOW(SPI_IOC_MAGIC, 2, __u8)
#define SPI_IOC_RD_BITS_PER_WORD _IOR(SPI_IOC_MAGIC, 3, __u8)
#define SPI_IOC_WR_BITS_PER_WORD _IOW(SPI_IOC_MAGIC, 3, __u8)
#define SPI_IOC_RD_MAX_SPEED_HZ _IOR(SPI_IOC_MAGIC, 4, __u32)
#define SPI_IOC_WR_MAX_SPEED_HZ _IOW(SPI_IOC_MAGIC, 4, __u32)
#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \
| SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP \
| SPI_NO_CS | SPI_READY)
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。