diff options
author | Jeff Hamilton <jham@android.com> | 2010-10-27 21:29:08 -0500 |
---|---|---|
committer | Jeff Hamilton <jham@android.com> | 2010-10-28 02:02:26 -0500 |
commit | 3e98767aaf73b4779a2bb39601806045b2ba1739 (patch) | |
tree | 6906ecae34f195da704264a2fc25dfd4ab9eb1d4 /Linux_x86/phDal4Nfc_i2c.c | |
parent | 8763a1998eee9b43169bf0824a77b00b3b88a938 (diff) | |
download | external_libnfc-nxp-3e98767aaf73b4779a2bb39601806045b2ba1739.zip external_libnfc-nxp-3e98767aaf73b4779a2bb39601806045b2ba1739.tar.gz external_libnfc-nxp-3e98767aaf73b4779a2bb39601806045b2ba1739.tar.bz2 |
Patch from NXP. Libnfc - Download,Reset mode management and driver workaround with delay
Change-Id: I736e5f50db749c9570b24194fe3963efbacc5c52
Diffstat (limited to 'Linux_x86/phDal4Nfc_i2c.c')
-rw-r--r-- | Linux_x86/phDal4Nfc_i2c.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/Linux_x86/phDal4Nfc_i2c.c b/Linux_x86/phDal4Nfc_i2c.c index 8a54bee..8cd4a1a 100644 --- a/Linux_x86/phDal4Nfc_i2c.c +++ b/Linux_x86/phDal4Nfc_i2c.c @@ -36,6 +36,9 @@ #include <string.h> #endif +#define PN544_RESET_CMD 0 +#define PN544_DOWNLOAD_CMD 1 + typedef struct { int nHandle; @@ -78,7 +81,7 @@ PURPOSE: The application could have opened the link itself. So we just need void phDal4Nfc_i2c_set_open_from_handle(phHal_sHwReference_t * pDalHwContext) { gI2cPortContext.nHandle = (int) pDalHwContext->p_board_driver; - DAL_ASSERT_STR(gComPortContext.nHandle >= 0, "Bad passed com port handle"); + DAL_ASSERT_STR(gI2cPortContext.nHandle >= 0, "Bad passed com port handle"); gI2cPortContext.nOpened = 1; } @@ -183,7 +186,7 @@ PURPOSE: Reads nNbBytesToRead bytes and writes them in pBuffer. int phDal4Nfc_i2c_read(uint8_t * pBuffer, int nNbBytesToRead) { int ret; - DAL_ASSERT_STR(gComPortContext.nOpened == 1, "read called but not opened!"); + DAL_ASSERT_STR(gI2cPortContext.nOpened == 1, "read called but not opened!"); DAL_DEBUG("Reading %d bytes\n", nNbBytesToRead); ret = read(gI2cPortContext.nHandle, pBuffer, nNbBytesToRead); @@ -210,7 +213,7 @@ PURPOSE: Writes nNbBytesToWrite bytes from pBuffer to the link int phDal4Nfc_i2c_write(uint8_t * pBuffer, int nNbBytesToWrite) { int ret; - DAL_ASSERT_STR(gComPortContext.nOpened == 1, "write called but not opened!"); + DAL_ASSERT_STR(gI2cPortContext.nOpened == 1, "write called but not opened!"); DAL_DEBUG("Writing %d bytes\n", nNbBytesToWrite); ret = write(gI2cPortContext.nHandle, pBuffer, nNbBytesToWrite); @@ -224,3 +227,45 @@ int phDal4Nfc_i2c_write(uint8_t * pBuffer, int nNbBytesToWrite) } return ret; } + + +/*----------------------------------------------------------------------------- + +FUNCTION: phDal4Nfc_i2c_reset + +PURPOSE: Reset the PN544, using the VEN pin + +-----------------------------------------------------------------------------*/ +int phDal4Nfc_i2c_reset(long level) +{ + int ret = NFCSTATUS_SUCCESS; + + DAL_DEBUG("phDal4Nfc_i2c_reset, VEN level = %d",level); + + ret = ioctl(gI2cPortContext.nHandle, PN544_RESET_CMD, level); + + return ret; +} + +/*----------------------------------------------------------------------------- + +FUNCTION: phDal4Nfc_i2c_write + +PURPOSE: Put the PN544 in download mode, using the GPIO4 pin + +-----------------------------------------------------------------------------*/ +int phDal4Nfc_i2c_download(long level) +{ + int ret = NFCSTATUS_SUCCESS; + + DAL_DEBUG("phDal4Nfc_i2c_download, GPIO4 level = %d",level); + + ret = ioctl(gI2cPortContext.nHandle, PN544_DOWNLOAD_CMD, level); + + return ret; +} + + + + + |