This commit is contained in:
lmx
2025-11-25 16:40:37 +08:00
parent 51788e4b88
commit 8089cf5b3a
3 changed files with 8 additions and 6 deletions

View File

@ -288,6 +288,7 @@ void rfid_task_fuc(void)
}
gpio_direction_output(IO_PORTA_05,0);
// 3. 读取芯片版本号,确认通信是否正常
GetReg(REG_VERSION, &reg_data);
@ -297,4 +298,5 @@ void rfid_task_fuc(void)
// TYPE_B_EVENT();
TYPE_V_EVENT();
// TYPE_F_EVENT();
gpio_direction_output(IO_PORTA_05,1);
}

View File

@ -85,7 +85,7 @@ unsigned char FM176XX_SoftReset(void){
unsigned char FM176XX_HardInit(void){
gpio_set_direction(IO_PORTA_05,0); //nss
gpio_set_output_value(IO_PORTA_05, 1); //初始设置为高
spi_open(SPI1); //初始化spi1PC3、PC5
return SUCCESS;
}
@ -107,7 +107,7 @@ unsigned char GetReg(unsigned char address, unsigned char *reg_data){
addr_byte = (address << 1) | 0x01;
// ---- 开始SPI事务 ----
gpio_direction_output(IO_PORTA_05,0);
// gpio_direction_output(IO_PORTA_05,0);
// 1. 发送地址字节,忽略接收到的数据
spi_send_byte(SPI1, addr_byte);
@ -116,7 +116,7 @@ unsigned char GetReg(unsigned char address, unsigned char *reg_data){
*reg_data = spi_recv_byte(SPI1, &err);
// ---- 结束SPI事务 ----
gpio_direction_output(IO_PORTA_05,1);
// gpio_direction_output(IO_PORTA_05,1);
if (err != 0) {
xlog("GetReg error\n");
@ -139,12 +139,12 @@ unsigned char SetReg(unsigned char address, unsigned char reg_data){
unsigned char addr_byte = (address << 1) & 0xFE; // Bit0=0 for write
int err1, err2;
gpio_direction_output(IO_PORTA_05,0); // <<-- CS拉低开始事务
// gpio_direction_output(IO_PORTA_05,0); // <<-- CS拉低开始事务
err1 = spi_send_byte(SPI1, addr_byte); // 发送地址
err2 = spi_send_byte(SPI1, reg_data); // 发送数据
gpio_direction_output(IO_PORTA_05,1); // <<-- CS拉高结束事务
// gpio_direction_output(IO_PORTA_05,1); // <<-- CS拉高结束事务
if (err1 != 0 || err2 != 0) {
return FAIL;

View File

@ -213,7 +213,7 @@ void le_user_app_event_handler(struct sys_event* event){
extern void i2c_scanner_probe(void);
// i2c_scanner_probe();
extern void rfid_task_fuc(void);
create_process(&rfid_fuc_id,"rfid",NULL,rfid_task_fuc,2000);
create_process(&rfid_fuc_id,"rfid",NULL,rfid_task_fuc,4000);
break;
default:
break;