L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
nfc.c File Reference
#include "nfc.h"
#include "nfc_st25dv16kc.h"
#include "mysensors.h"
#include "main.h"
#include "utils/mydefs.h"
#include <string.h>
Include dependency graph for nfc.c:

Go to the source code of this file.

Macros

#define NFC_ADDR   0
#define NFC_INIT   nfc_st25dv16kc_Init
#define NFC_IS   nfc_st25dv16kc_Is
#define NFC_READ   nfc_st25dv16kc_ReadEEPROM
#define NFC_ON   nfc_st25dv16kc_On
#define NFC_OFF   nfc_st25dv16kc_Off
#define NFC_WRITE   nfc_st25dv16kc_WriteEEPROM
#define NFC_MAILBOX   nfc_st25dv16kc_ProcessMailBox

Functions

static HAL_StatusTypeDef nfc_ReadSystemParamsToBck (I2C_HandleTypeDef *hi2c)
 reading data from NFC to _systemParamsBck
static HAL_StatusTypeDef nfc_WriteMeasureNFC (I2C_HandleTypeDef *hi2c)
static HAL_StatusTypeDef nfc_ReadMeasureNFC (I2C_HandleTypeDef *hi2c)
HAL_StatusTypeDef nfc_Init (I2C_HandleTypeDef *hi2c)
 NFC initialization and read NFC tag systemParams from addr 0. If data there are not valid, the default data is written.
HAL_StatusTypeDef nfc_WriteSystemParams (I2C_HandleTypeDef *hi2c)
 Write system params to NFC.
HAL_StatusTypeDef nfc_FactoryReset (I2C_HandleTypeDef *hi2c)
 reset NFC data to factory - default state
HAL_StatusTypeDef nfc_ReadSystemParams (I2C_HandleTypeDef *hi2c)
 reading _systemParams from NFC - all data will be rewrite in _systemParams
HAL_StatusTypeDef nfc_WriteMeasureData (I2C_HandleTypeDef *hi2c, const measureDataNFC_t *data)
 write the measure data paylod in measureDataNFC_t to NFC on next free position - in circular queue
HAL_StatusTypeDef nfc_ProcessMailBox (I2C_HandleTypeDef *hi2c)
 processing if NFC INT is fired

Macro Definition Documentation

◆ NFC_ADDR

#define NFC_ADDR   0

Definition at line 16 of file nfc.c.

Referenced by nfc_FactoryReset(), nfc_ReadSystemParamsToBck(), and nfc_WriteSystemParams().

◆ NFC_INIT

#define NFC_INIT   nfc_st25dv16kc_Init

Definition at line 31 of file nfc.c.

Referenced by nfc_Init().

◆ NFC_IS

◆ NFC_MAILBOX

#define NFC_MAILBOX   nfc_st25dv16kc_ProcessMailBox

Definition at line 37 of file nfc.c.

Referenced by nfc_ProcessMailBox().

◆ NFC_OFF

#define NFC_OFF   nfc_st25dv16kc_Off

◆ NFC_ON

#define NFC_ON   nfc_st25dv16kc_On

◆ NFC_READ

#define NFC_READ   nfc_st25dv16kc_ReadEEPROM

Definition at line 33 of file nfc.c.

Referenced by nfc_ReadMeasureNFC(), and nfc_ReadSystemParamsToBck().

◆ NFC_WRITE

#define NFC_WRITE   nfc_st25dv16kc_WriteEEPROM

Function Documentation

◆ nfc_FactoryReset()

HAL_StatusTypeDef nfc_FactoryReset ( I2C_HandleTypeDef * hi2c)

reset NFC data to factory - default state

Return values
status

Definition at line 169 of file nfc.c.

References _tryInit, i2c_OnOff(), MEASUREDATANFC_ADDR, NFC_ADDR, NFC_IS, NFC_OFF, NFC_ON, and NFC_WRITE.

Referenced by checkResetRestart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nfc_Init()

HAL_StatusTypeDef nfc_Init ( I2C_HandleTypeDef * hi2c)

NFC initialization and read NFC tag systemParams from addr 0. If data there are not valid, the default data is written.

Return values
statusHAL_OK, HAL_ERROR

Definition at line 109 of file nfc.c.

References _systemParams, _systemParamsBck, NFC_INIT, nfc_ReadMeasureNFC(), nfc_ReadSystemParamsToBck(), nfc_WriteMeasureNFC(), nfc_WriteSystemParams(), sensorsBase_CheckCRCMeasureNFC(), sensorsBase_MeasureNFCInit(), systemParams_Correction(), and writeLog().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nfc_ProcessMailBox()

HAL_StatusTypeDef nfc_ProcessMailBox ( I2C_HandleTypeDef * hi2c)

processing if NFC INT is fired

Definition at line 246 of file nfc.c.

References NFC_MAILBOX.

◆ nfc_ReadMeasureNFC()

HAL_StatusTypeDef nfc_ReadMeasureNFC ( I2C_HandleTypeDef * hi2c)
static

Definition at line 91 of file nfc.c.

References _measureNFC, _tryInit, i2c_OnOff(), MEASUREDATANFC_ADDR, NFC_IS, NFC_OFF, NFC_ON, and NFC_READ.

Referenced by nfc_Init(), and nfc_WriteMeasureData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nfc_ReadSystemParams()

HAL_StatusTypeDef nfc_ReadSystemParams ( I2C_HandleTypeDef * hi2c)

reading _systemParams from NFC - all data will be rewrite in _systemParams

Return values
status

Definition at line 189 of file nfc.c.

References _systemParams, _systemParamsBck, _tryInit, i2c_OnOff(), NFC_IS, and nfc_ReadSystemParamsToBck().

Referenced by checkResetRestart(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nfc_ReadSystemParamsToBck()

HAL_StatusTypeDef nfc_ReadSystemParamsToBck ( I2C_HandleTypeDef * hi2c)
static

reading data from NFC to _systemParamsBck

Return values
HAL_OK- the block has beep OK, HAL_ERROR NFC chip read error, HAL_TIMEOUT - CRC non valid, HAL_BUSY - the sign/version is not valid

Definition at line 45 of file nfc.c.

References _systemParamsBck, _tryInit, NFC_ADDR, NFC_IS, NFC_READ, SYSTEMPARAMS_APPVER01, systemParams_CheckCRC(), and SYSTEMPARAMS_SIGN.

Referenced by nfc_Init(), and nfc_ReadSystemParams().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nfc_WriteMeasureData()

HAL_StatusTypeDef nfc_WriteMeasureData ( I2C_HandleTypeDef * hi2c,
const measureDataNFC_t * data )

write the measure data paylod in measureDataNFC_t to NFC on next free position - in circular queue

Definition at line 208 of file nfc.c.

References _measureNFC, _tryInit, i2c_OnOff(), INX_GET, MEASUREDATANFC_ADDR, NFC_IS, nfc_ReadMeasureNFC(), NFC_WRITE, nfc_WriteMeasureNFC(), sensorsBase_CheckCRCMeasureNFC(), sensorsBase_MeasureNFCInit(), and writeLog().

Referenced by myloraWan_MeasureFinish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nfc_WriteMeasureNFC()

HAL_StatusTypeDef nfc_WriteMeasureNFC ( I2C_HandleTypeDef * hi2c)
static

Definition at line 72 of file nfc.c.

References _measureNFC, _tryInit, i2c_OnOff(), MEASUREDATANFC_ADDR, NFC_IS, NFC_OFF, NFC_ON, NFC_WRITE, and sensorsBase_SetCRCMeasureNFC().

Referenced by nfc_Init(), and nfc_WriteMeasureData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nfc_WriteSystemParams()

HAL_StatusTypeDef nfc_WriteSystemParams ( I2C_HandleTypeDef * hi2c)

Write system params to NFC.

Return values
status

Definition at line 149 of file nfc.c.

References _systemParams, _tryInit, i2c_OnOff(), NFC_ADDR, NFC_IS, NFC_OFF, NFC_ON, NFC_WRITE, and systemParams_SetCRCSystemParams().

Referenced by checkResetRestart(), main(), and nfc_Init().

Here is the call graph for this function:
Here is the caller graph for this function: