Last active
July 8, 2022 07:31
-
-
Save Zyr00/95591c62896efd708ae4b4b9a2284244 to your computer and use it in GitHub Desktop.
Set mangoh yellow nfc slave address back to default of 0x66
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
#include <linux/i2c.h> | |
#include <linux/i2c-help.h> | |
#include <sys/ioctl.h> | |
#include "legato.h" | |
#define ADAPTER "/dev/i2c-8" | |
#define BAD_ADDRESS 0x00 | |
#define GOOD_ADDRESS 0x55 | |
int open_nfc_file(uint8_t address) | |
{ | |
int file = open(ADAPTER, O_RDWD); | |
if (file < 0) | |
{ | |
LE_ERROR("Failed to open adapter."); | |
goto exit; | |
} | |
if (ioctl(file, I2C_SLAVE_FORCE, address) < 0) | |
LE_ERROR("Failed i2c transaction: %m"); | |
exit: | |
return file; | |
} | |
COMPONENT_INIT | |
{ | |
LE_INFO("Starting..."); | |
int file = open_nfc_file(BAD_ADDRESS); | |
if (file < 0) | |
exit(-1); | |
char unsigned buf[17]; | |
buf[0] = 0x00; | |
buf[1] = GOOD_ADDRESS << 1; // This set the address back to 0x55 | |
buf[2] = 0x00; | |
buf[3] = 0x00; | |
buf[4] = 0x00; | |
buf[5] = 0x00; | |
buf[6] = 0x00; | |
buf[7] = 0x00; | |
buf[8] = 0x00; | |
buf[9] = 0x00; | |
buf[10] = 0x00; | |
buf[11] = 0x00; | |
buf[12] = 0x00; | |
buf[13] = 0xE1; | |
buf[14] = 0x10; | |
buf[15] = 0x6D; | |
buf[16] = 0x00; | |
int res = write(file, buf, 17); | |
LE_ERROR_IF(res == -1, "ERROR: %m"); | |
LE_INFO_IF(res != -1, "%m); | |
close(file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://community.nxp.com/t5/NFC/NTAG-NT3H2111-NT3H2211-I-C-Communication-Problem/m-p/1274330
https://community.nxp.com/t5/NFC/initialize-NT3H2111/m-p/1019784