|
L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
|
Go to the source code of this file.
Functions | |
| static HAL_StatusTypeDef | nfc_st25dv16kc_WriteGPO (I2C_HandleTypeDef *hi2c, uint8_t value) |
| Present the default I2C password to open a security session. The payload is: [0x09 validation code] + [8-byte pwd] + [8-byte pwd]. Default password is 8 x 0x00. | |
| int8_t | nfc_st25dv16kc_Is (I2C_HandleTypeDef *hi2c, int8_t tryInit) |
| Check whether the ST25DV16KC has been successfully initialised. | |
| HAL_StatusTypeDef | nfc_st25dv16kc_Init (I2C_HandleTypeDef *hi2c) |
| Check the I2C bus and try to find the NFC chip. Enables the mailbox, clears it, and turns GPO off (low-power state). | |
| HAL_StatusTypeDef | nfc_st25dv16kc_IsOn (I2C_HandleTypeDef *hi2c, uint8_t *onOff) |
| HAL_StatusTypeDef | nfc_st25dv16kc_On (I2C_HandleTypeDef *hi2c) |
| Turn the NFC GPO ON (all events: MsgReady, FieldChange, RFWrite). Enables host-side reading/writing via the Mailbox. | |
| HAL_StatusTypeDef | nfc_st25dv16kc_Off (I2C_HandleTypeDef *hi2c) |
| Turn the NFC GPO OFF and enable GPO RF to achieve minimum current (~1 µA). | |
| HAL_StatusTypeDef | nfc_st25dv16kc_WriteEEPROM (I2C_HandleTypeDef *hi2c, uint16_t addr, uint8_t *pData, uint16_t len) |
| Write data to the EEPROM user memory (4-byte page writes). | |
| HAL_StatusTypeDef | nfc_st25dv16kc_ReadEEPROM (I2C_HandleTypeDef *hi2c, uint16_t addr, uint8_t *pData, uint16_t len) |
| Read data from the EEPROM user memory. | |
| HAL_StatusTypeDef | nfc_st25dv16kc_ProcessMailBox (I2C_HandleTypeDef *hi2c) |
| Process incoming data from the RF Mailbox. Checks MB_CTRL_DYN for an RF message; if present reads it and invokes nfc_st25dv16kc_OnMailboxData(). | |
| HAL_StatusTypeDef | nfc_st25dv16kc_WriteMailBox (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t len) |
| Write raw data into the Mailbox so the RF reader (phone) can retrieve it. | |
| __weak void | nfc_st25dv16kc_OnMailboxData (uint8_t *data, uint16_t len) |
| Weak callback invoked by nfc_st25dv16kc_ProcessMailBox() when new data has arrived in the Mailbox. Override in main.c or application code to process the received message. | |
Variables | |
| static int8_t | _isNfc = 0 |
| static int8_t | _isOnOff = 1 |
| #define EEPROM_TIMEOUT 5000 |
Definition at line 101 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_ReadEEPROM(), and nfc_st25dv16kc_WriteEEPROM().
| #define ST25DV16KC_EH_FIELD_ON 0x04U |
RF field is currently detected
Definition at line 81 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_ALL_EN |
GPO value used by nfc_st25dv16kc_On(): all events enabled
Definition at line 59 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_On().
| #define ST25DV16KC_GPO_EN 0x80U |
GPO output enable
Definition at line 49 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_IsOn(), and nfc_st25dv16kc_Off().
| #define ST25DV16KC_GPO_FIELD_CHANGE 0x08U |
GPO on RF field change
Definition at line 53 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_INT_EN (ST25DV16KC_GPO_EN | ST25DV16KC_GPO_FIELD_CHANGE) |
GPO value used by nfc_st25dv16kc_INT_On(): field-change interrupt only
Definition at line 63 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_MSG_READY_EN 0x40U |
GPO on mailbox message-ready
Definition at line 50 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_RF_ACTIVITY 0x20U |
GPO on RF activity
Definition at line 51 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_RF_GET_MSG 0x02U |
GPO when RF reads mailbox
Definition at line 55 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_RF_INTERRUPT 0x10U |
GPO on RF interrupt
Definition at line 52 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_RF_PUT_MSG 0x04U |
GPO when RF writes to mailbox
Definition at line 54 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_GPO_RF_WRITE 0x01U |
GPO on RF EEPROM write
Definition at line 56 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_I2C_ADDR_SYSTEM (0x57 << 1) |
System configuration
Definition at line 25 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_I2C_ADDR_USER (0x53 << 1) |
User memory / EEPROM
Definition at line 24 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_Init(), nfc_st25dv16kc_IsOn(), nfc_st25dv16kc_Off(), nfc_st25dv16kc_ProcessMailBox(), nfc_st25dv16kc_ReadEEPROM(), nfc_st25dv16kc_WriteEEPROM(), nfc_st25dv16kc_WriteGPO(), and nfc_st25dv16kc_WriteMailBox().
| #define ST25DV16KC_MB_EN 0x01U |
Enable mailbox
Definition at line 68 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_Init(), and nfc_st25dv16kc_WriteMailBox().
| #define ST25DV16KC_MB_I2C_PUT_MSG 0x04U |
I2C host has written to mailbox
Definition at line 70 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_MB_RF_PUT_MSG 0x02U |
RF has written to mailbox
Definition at line 69 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_ProcessMailBox().
| #define ST25DV16KC_MB_SIZE 256U |
Mailbox buffer size in bytes
Definition at line 92 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_ProcessMailBox(), and nfc_st25dv16kc_WriteMailBox().
| #define ST25DV16KC_REG_EH_CTRL_DYN 0x2001U |
Energy-harvesting ctrl (dyn)
Definition at line 31 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_REG_GPO_CTRL_DYN 0x2000U |
GPO control (dynamic)
Definition at line 30 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_IsOn(), and nfc_st25dv16kc_WriteGPO().
| #define ST25DV16KC_REG_I2C_SSO_DYN 0x2003U |
I2C security-session open
Definition at line 33 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_REG_MB_CTRL_DYN 0x2006U |
Mailbox control (dynamic)
Definition at line 34 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_Init(), nfc_st25dv16kc_ProcessMailBox(), and nfc_st25dv16kc_WriteMailBox().
| #define ST25DV16KC_REG_MB_DATA 0x2008U |
Mailbox RAM start (256 bytes)
Definition at line 36 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_ProcessMailBox(), and nfc_st25dv16kc_WriteMailBox().
| #define ST25DV16KC_REG_MB_LEN_DYN 0x2007U |
Mailbox message length (dyn)
Definition at line 35 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_ProcessMailBox().
| #define ST25DV16KC_REG_RF_MNGT_DYN 0x2002U |
RF management (dynamic)
Definition at line 32 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_Off().
| #define ST25DV16KC_RF_BUSY_TIMEOUT 20U |
Maximum number of 5 ms wait cycles before giving up (100 ms total).
Definition at line 87 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_RF_DISABLE 0x02U |
Fully disable RF interface
Definition at line 76 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_RF_SLEEP 0x01U |
Put RF analog block to sleep
Definition at line 75 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_Off().
| #define ST25DV16KC_SYS_REG_I2C_PWD 0x0900U |
I2C password register
Definition at line 44 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_SYS_REG_MB_MODE 0x000DU |
Mailbox enable (static)
Definition at line 43 of file nfc_st25dv16kc.c.
| #define ST25DV16KC_SYS_REG_RF_MNGT 0x0003U |
RF_MNGT static register
Definition at line 42 of file nfc_st25dv16kc.c.
| HAL_StatusTypeDef nfc_st25dv16kc_Init | ( | I2C_HandleTypeDef * | hi2c | ) |
Check the I2C bus and try to find the NFC chip. Enables the mailbox, clears it, and turns GPO off (low-power state).
| hi2c | Pointer to I2C handle. |
| HAL_OK | – NFC found and initialised, HAL_ERROR – not on the bus. |
< User memory / EEPROM
< Enable mailbox
< User memory / EEPROM
< Mailbox control (dynamic)
< User memory / EEPROM
< Mailbox control (dynamic)
Definition at line 161 of file nfc_st25dv16kc.c.
References _isNfc, HAL_Delay(), I2C_IsDeviceReadyMT(), nfc_st25dv16kc_Off(), ST25DV16KC_I2C_ADDR_USER, ST25DV16KC_MB_EN, and ST25DV16KC_REG_MB_CTRL_DYN.
Referenced by nfc_st25dv16kc_Is().
| int8_t nfc_st25dv16kc_Is | ( | I2C_HandleTypeDef * | hi2c, |
| int8_t | tryInit ) |
Check whether the ST25DV16KC has been successfully initialised.
| hi2c | Pointer to I2C handle. |
| tryInit | When 1, attempt Init() if not yet initialised; 0 – no retry. |
| 1 | – NFC present and ready, 0 – not available. |
Definition at line 154 of file nfc_st25dv16kc.c.
References _isNfc, and nfc_st25dv16kc_Init().
| HAL_StatusTypeDef nfc_st25dv16kc_IsOn | ( | I2C_HandleTypeDef * | hi2c, |
| uint8_t * | onOff ) |
< User memory / EEPROM
< GPO control (dynamic)
< GPO output enable
Definition at line 208 of file nfc_st25dv16kc.c.
References _isNfc, ST25DV16KC_GPO_EN, ST25DV16KC_I2C_ADDR_USER, and ST25DV16KC_REG_GPO_CTRL_DYN.
| HAL_StatusTypeDef nfc_st25dv16kc_Off | ( | I2C_HandleTypeDef * | hi2c | ) |
Turn the NFC GPO OFF and enable GPO RF to achieve minimum current (~1 µA).
| hi2c | Pointer to I2C handle. |
| HAL_OK | on success, HAL_ERROR if NFC not available. |
< GPO output enable
< Put RF analog block to sleep
< User memory / EEPROM
< RF management (dynamic)
Definition at line 239 of file nfc_st25dv16kc.c.
References _isNfc, _isOnOff, nfc_st25dv16kc_WriteGPO(), ST25DV16KC_GPO_EN, ST25DV16KC_I2C_ADDR_USER, ST25DV16KC_REG_RF_MNGT_DYN, and ST25DV16KC_RF_SLEEP.
Referenced by nfc_st25dv16kc_Init().
| HAL_StatusTypeDef nfc_st25dv16kc_On | ( | I2C_HandleTypeDef * | hi2c | ) |
Turn the NFC GPO ON (all events: MsgReady, FieldChange, RFWrite). Enables host-side reading/writing via the Mailbox.
| hi2c | Pointer to I2C handle. |
| HAL_OK | on success, HAL_ERROR if NFC not available. |
< GPO output enable
< GPO on mailbox message-ready
< GPO on RF field change
< GPO on RF EEPROM write
Definition at line 222 of file nfc_st25dv16kc.c.
References _isNfc, _isOnOff, nfc_st25dv16kc_WriteGPO(), and ST25DV16KC_GPO_ALL_EN.
| __weak void nfc_st25dv16kc_OnMailboxData | ( | uint8_t * | data, |
| uint16_t | len ) |
Weak callback invoked by nfc_st25dv16kc_ProcessMailBox() when new data has arrived in the Mailbox. Override in main.c or application code to process the received message.
| data | Pointer to received data buffer. |
| len | Number of bytes received. |
Definition at line 409 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_ProcessMailBox().
| HAL_StatusTypeDef nfc_st25dv16kc_ProcessMailBox | ( | I2C_HandleTypeDef * | hi2c | ) |
Process incoming data from the RF Mailbox. Checks MB_CTRL_DYN for an RF message; if present reads it and invokes nfc_st25dv16kc_OnMailboxData().
| hi2c | Pointer to I2C handle. |
| HAL_OK | – message read, HAL_ERROR – no message or NFC absent. |
< User memory / EEPROM
< Mailbox control (dynamic)
< RF has written to mailbox
< User memory / EEPROM
< Mailbox message length (dyn)
< Mailbox buffer size in bytes
< Mailbox buffer size in bytes
< Mailbox buffer size in bytes
< User memory / EEPROM
< Mailbox RAM start (256 bytes)
Definition at line 348 of file nfc_st25dv16kc.c.
References _isNfc, nfc_st25dv16kc_OnMailboxData(), ST25DV16KC_I2C_ADDR_USER, ST25DV16KC_MB_RF_PUT_MSG, ST25DV16KC_MB_SIZE, ST25DV16KC_REG_MB_CTRL_DYN, ST25DV16KC_REG_MB_DATA, and ST25DV16KC_REG_MB_LEN_DYN.
| HAL_StatusTypeDef nfc_st25dv16kc_ReadEEPROM | ( | I2C_HandleTypeDef * | hi2c, |
| uint16_t | addr, | ||
| uint8_t * | pData, | ||
| uint16_t | len ) |
Read data from the EEPROM user memory.
| hi2c | Pointer to I2C handle. |
| addr | Start address within EEPROM. |
| pData | Pointer to destination buffer. |
| len | Number of bytes to read. |
| HAL_OK | on success, HAL_ERROR on failure or NFC absent. |
< User memory / EEPROM
Definition at line 339 of file nfc_st25dv16kc.c.
References _isNfc, EEPROM_TIMEOUT, and ST25DV16KC_I2C_ADDR_USER.
| HAL_StatusTypeDef nfc_st25dv16kc_WriteEEPROM | ( | I2C_HandleTypeDef * | hi2c, |
| uint16_t | addr, | ||
| uint8_t * | pData, | ||
| uint16_t | len ) |
Write data to the EEPROM user memory (4-byte page writes).
| hi2c | Pointer to I2C handle. |
| addr | Start address within EEPROM (0x0000–0x07FF for 16Kbit). |
| pData | Pointer to data buffer to write. |
| len | Number of bytes to write. |
| HAL_OK | on success, HAL_ERROR on failure or NFC absent. |
< User memory / EEPROM
Definition at line 288 of file nfc_st25dv16kc.c.
References _isNfc, EEPROM_TIMEOUT, HAL_Delay(), and ST25DV16KC_I2C_ADDR_USER.
|
static |
Present the default I2C password to open a security session. The payload is: [0x09 validation code] + [8-byte pwd] + [8-byte pwd]. Default password is 8 x 0x00.
| hi2c | Pointer to I2C handle. |
| HAL_StatusTypeDef | result of the I2C write. |
static HAL_StatusTypeDef nfc_st25dv16kc_PresentPassword(I2C_HandleTypeDef *hi2c) { HAL_StatusTypeDef status; uint8_t pwd_payload[17]; pwd_payload[0] = 0x09; // Validation code
memset(&pwd_payload[1], 0x00, 16); // 8-byte pwd repeated twice (default)
status = HAL_I2C_Mem_Write(hi2c, ST25DV16KC_I2C_ADDR_SYSTEM, ST25DV16KC_SYS_REG_I2C_PWD, I2C_MEMADD_SIZE_16BIT, pwd_payload, 17, 200); return status; }
Write a value to GPO_CTRL_DYN with retry to tolerate transient NACKs from the RF field.
| hi2c | Pointer to I2C handle. |
| value | Byte value to write to GPO_CTRL_DYN. |
| HAL_StatusTypeDef | result of the last I2C write attempt. |
< User memory / EEPROM
< GPO control (dynamic)
Definition at line 132 of file nfc_st25dv16kc.c.
References _isNfc, HAL_Delay(), ST25DV16KC_I2C_ADDR_USER, and ST25DV16KC_REG_GPO_CTRL_DYN.
Referenced by nfc_st25dv16kc_Off(), and nfc_st25dv16kc_On().
| HAL_StatusTypeDef nfc_st25dv16kc_WriteMailBox | ( | I2C_HandleTypeDef * | hi2c, |
| uint8_t * | pData, | ||
| uint16_t | len ) |
Write raw data into the Mailbox so the RF reader (phone) can retrieve it.
| hi2c | Pointer to I2C handle. |
| pData | Pointer to data buffer. |
| len | Number of bytes to write (max ST25DV16KC_MB_SIZE). |
| HAL_OK | on success, HAL_ERROR on failure or NFC absent. |
< Mailbox buffer size in bytes
< Mailbox buffer size in bytes
< Enable mailbox
< User memory / EEPROM
< Mailbox control (dynamic)
< User memory / EEPROM
< Mailbox RAM start (256 bytes)
Definition at line 384 of file nfc_st25dv16kc.c.
References _isNfc, ST25DV16KC_I2C_ADDR_USER, ST25DV16KC_MB_EN, ST25DV16KC_MB_SIZE, ST25DV16KC_REG_MB_CTRL_DYN, and ST25DV16KC_REG_MB_DATA.
|
static |
1 when the chip is present and successfully initialised, 0 otherwise.
Definition at line 99 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_Init(), nfc_st25dv16kc_Is(), nfc_st25dv16kc_IsOn(), nfc_st25dv16kc_Off(), nfc_st25dv16kc_On(), nfc_st25dv16kc_ProcessMailBox(), nfc_st25dv16kc_ReadEEPROM(), nfc_st25dv16kc_WriteEEPROM(), nfc_st25dv16kc_WriteGPO(), and nfc_st25dv16kc_WriteMailBox().
|
static |
Definition at line 100 of file nfc_st25dv16kc.c.
Referenced by nfc_st25dv16kc_Off(), nfc_st25dv16kc_On(), tempHum_onOff(), tmphm_sht45_IsOn(), and tmphm_sht45_Read().