Firmware library for the X-NUCLEO-NFC01A1 Dynamic NFC Tag board.
Dependencies: M24SR
Dependents: NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more
Fork of X_NUCLEO_NFC01A1 by
X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board Firmware Package
Introduction
This firmware package includes Components Device Drivers, Board Support Package and example applications for STMicroelectronics X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board based on M24SR.
Firmware Library
Class X_NUCLEO_NFC01A1 is intended to represent the Dynamic NFC Tag Expansion Board with the same name.
It provides an API to access to the M24SR component and to the three onboard LEDs.
It is intentionally implemented as a singleton because only one X_NUCLEO_NFC01A1 at a time might be deployed in a HW component stack.
The library also provides an implementation of the NDEF library API for M24SR, providing an simple way to read/write NDEF formatted messages from/to the M24SR dynamic NFC tag.
Example applications
1. Hello World
2. Asynchronous Hello World
Diff: m24sr/m24sr_class.cpp
- Revision:
- 26:2090378b0b51
- Parent:
- 25:caa16fd0e50b
- Child:
- 27:3881985097bb
--- a/m24sr/m24sr_class.cpp Wed Feb 03 08:52:54 2016 +0000
+++ b/m24sr/m24sr_class.cpp Wed Feb 03 09:01:05 2016 +0000
@@ -89,7 +89,7 @@
* @param None
* @retval None
*/
-static uint16_t M24SR_UpdateCrc(uint8_t ch, uint16_t *lpwCrc) {
+ static uint16_t M24SR_UpdateCrc(uint8_t ch, uint16_t *lpwCrc) {
ch = (ch ^ (uint8_t) ((*lpwCrc) & 0x00FF));
ch = (ch ^ (ch << 4));
*lpwCrc = (*lpwCrc >> 8) ^ ((uint16_t) ch << 8) ^ ((uint16_t) ch << 3)
@@ -104,7 +104,7 @@
* @param Length : number of bytes of the data
* @retval CRC16
*/
-static uint16_t M24SR_ComputeCrc(uint8_t *Data, uint8_t Length) {
+ static uint16_t M24SR_ComputeCrc(uint8_t *Data, uint8_t Length) {
uint8_t chBlock;
uint16_t wCrc = 0x6363; // ITU-V.41
@@ -123,7 +123,7 @@
* @retval Status (SW1&SW2) : CRC16 residue is correct
* @retval M24SR_ERROR_CRC : CRC16 residue is false
*/
-static NFC_StatusTypeDef M24SR_IsCorrectCRC16Residue(uint8_t *DataIn, uint8_t Length) {
+ static NFC_StatusTypeDef M24SR_IsCorrectCRC16Residue(uint8_t *DataIn, uint8_t Length) {
uint16_t ResCRC = 0x0000;
/* check the CRC16 Residue */
@@ -155,7 +155,7 @@
* @param NbByte : number of bytes of the command
* @param pCommand : pointer to the command created
*/
-static void M24SR_BuildIBlockCommand(uint16_t CommandStructure, C_APDU *Command,
+ static void M24SR_BuildIBlockCommand(uint16_t CommandStructure, C_APDU *Command,
uint8_t uDIDbyte, uint16_t *NbByte, uint8_t *pCommand) {
uint16_t uCRC16;
static uint8_t BlockNumber = 0x01;
@@ -222,7 +222,7 @@
* @retval NFC_SUCCESS : the data is a S-Block
* @retval NFC_ERROR : the data is not a S-Block
*/
-static NFC_StatusTypeDef IsSBlock(uint8_t *pBuffer) {
+ static NFC_StatusTypeDef IsSBlock(uint8_t *pBuffer) {
if ((pBuffer[M24SR_OFFSET_PCB] & M24SR_MASK_BLOCK) == M24SR_MASK_SBLOCK) {
return NFC_SUCCESS;
@@ -237,7 +237,7 @@
* @param FWTbyte : FWT value
* @return NFC_SUCCESS if no errors
*/
-NFC_StatusTypeDef M24SR::M24SR_SendFWTExtension(uint8_t FWTbyte) {
+ NFC_StatusTypeDef M24SR::M24SR_SendFWTExtension(uint8_t FWTbyte) {
uint8_t pBuffer[M24SR_STATUSRESPONSE_NBBYTE];
NFC_StatusTypeDef status;
uint8_t NthByte = 0;
@@ -278,7 +278,7 @@
* @brief This function initialize the M24SR device
* @retval None
*/
-NFC_StatusTypeDef M24SR::M24SR_Init(M24SR_InitTypeDef *notUsed) {
+ NFC_StatusTypeDef M24SR::M24SR_Init(M24SR_InitTypeDef *notUsed) {
(void) notUsed;
//force to open a i2c session
errchk(M24SR_ForceSession())
@@ -297,7 +297,7 @@
* @param None
* @return NFC_SUCCESS if no errors
*/
-NFC_StatusTypeDef M24SR::M24SR_ForceSession(void) {
+ NFC_StatusTypeDef M24SR::M24SR_ForceSession(void) {
uint8_t commandBuffer[] = M24SR_KILLSESSION_COMMAND;
NFC_StatusTypeDef status;
status = M24SR_IO_SendI2Ccommand(sizeof(commandBuffer), commandBuffer);
@@ -320,7 +320,7 @@
* @brief This function sends the Deselect command (S-Block format)
* @return NFC_SUCCESS if no errors
*/
-NFC_StatusTypeDef M24SR::M24SR_Deselect(void) {
+ NFC_StatusTypeDef M24SR::M24SR_Deselect(void) {
uint8_t pBuffer[] = M24SR_DESELECTREQUEST_COMMAND;
NFC_StatusTypeDef status;
/* send the request */
@@ -361,7 +361,7 @@
* @retval NFC_SUCCESS the function is successful.
* @retval Status (SW1&SW2) if operation does not complete.
*/
-NFC_StatusTypeDef M24SR::M24SR_GetSession(void) {
+ NFC_StatusTypeDef M24SR::M24SR_GetSession(void) {
uint8_t commandBuffer[] = M24SR_OPENSESSION_COMMAND;
NFC_StatusTypeDef status;
@@ -384,7 +384,7 @@
* @brief This function sends the SelectApplication command
* @return NFC_SUCCESS if no errors
*/
-NFC_StatusTypeDef M24SR::M24SR_SendSelectApplication(void) {
+ NFC_StatusTypeDef M24SR::M24SR_SendSelectApplication(void) {
C_APDU command;
NFC_StatusTypeDef status;
@@ -471,7 +471,7 @@
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
* @retval Status (SW1&SW2) if operation does not complete for another reason.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendSelectCCfile(void) {
+ NFC_StatusTypeDef M24SR::M24SR_SendSelectCCfile(void) {
C_APDU command;
NFC_StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -539,7 +539,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendSelectSystemfile(void) {
+ NFC_StatusTypeDef M24SR::M24SR_SendSelectSystemfile(void) {
C_APDU command;
uint8_t *pBuffer = uM24SRbuffer;
@@ -606,7 +606,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendSelectNDEFfile(uint16_t NDEFfileId) {
+ NFC_StatusTypeDef M24SR::M24SR_SendSelectNDEFfile(uint16_t NDEFfileId) {
C_APDU command;
NFC_StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -676,7 +676,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendReadBinary(uint16_t Offset, uint8_t NbByteToRead,
+ NFC_StatusTypeDef M24SR::M24SR_SendReadBinary(uint16_t Offset, uint8_t NbByteToRead,
uint8_t *pBufferRead) {
//clamp the buffer to the max size
if(NbByteToRead>M24SR_MAX_BYTE_OPERATION_LENGHT)
@@ -758,7 +758,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendSTReadBinary(uint16_t Offset,
+ NFC_StatusTypeDef M24SR::M24SR_SendSTReadBinary(uint16_t Offset,
uint8_t NbByteToRead, uint8_t *pBufferRead) {
//clamp the buffer to the max size
if(NbByteToRead>M24SR_MAX_BYTE_OPERATION_LENGHT)
@@ -813,7 +813,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendUpdateBinary(uint16_t Offset,
+ NFC_StatusTypeDef M24SR::M24SR_SendUpdateBinary(uint16_t Offset,
uint8_t NbByteToWrite, uint8_t *pDataToWrite) {
//clamp the buffer to the max size
if(NbByteToWrite>M24SR_MAX_BYTE_OPERATION_LENGHT)
@@ -908,7 +908,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendVerify(uint16_t uPwdId, uint8_t NbPwdByte,
+ NFC_StatusTypeDef M24SR::M24SR_SendVerify(uint16_t uPwdId, uint8_t NbPwdByte,
const uint8_t *pPwd) {
C_APDU command;
NFC_StatusTypeDef status;
@@ -995,7 +995,7 @@
* @retval Status (SW1&SW2) Satus of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendChangeReferenceData(uint16_t uPwdId,
+ NFC_StatusTypeDef M24SR::M24SR_SendChangeReferenceData(uint16_t uPwdId,
uint8_t *pPwd) {
C_APDU command;
NFC_StatusTypeDef status;
@@ -1078,7 +1078,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendEnableVerificationRequirement(
+ NFC_StatusTypeDef M24SR::M24SR_SendEnableVerificationRequirement(
uint16_t uReadOrWrite) {
C_APDU command;
NFC_StatusTypeDef status;
@@ -1156,7 +1156,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendDisableVerificationRequirement(
+ NFC_StatusTypeDef M24SR::M24SR_SendDisableVerificationRequirement(
uint16_t uReadOrWrite) {
C_APDU command;
NFC_StatusTypeDef status;
@@ -1235,7 +1235,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendEnablePermanentState(uint16_t uReadOrWrite) {
+ NFC_StatusTypeDef M24SR::M24SR_SendEnablePermanentState(uint16_t uReadOrWrite) {
C_APDU command;
NFC_StatusTypeDef status;
@@ -1313,7 +1313,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendDisablePermanentState(uint16_t uReadOrWrite) {
+ NFC_StatusTypeDef M24SR::M24SR_SendDisablePermanentState(uint16_t uReadOrWrite) {
C_APDU command;
NFC_StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1389,7 +1389,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_SendInterrupt(void) {
+ NFC_StatusTypeDef M24SR::M24SR_SendInterrupt(void) {
C_APDU command;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1432,7 +1432,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-NFC_StatusTypeDef M24SR::M24SR_StateControl(uint8_t uSetOrReset) {
+ NFC_StatusTypeDef M24SR::M24SR_StateControl(uint8_t uSetOrReset) {
C_APDU command;
uint8_t *pBuffer = uM24SRbuffer;
uint16_t uP1P2 = 0x001F;

X-NUCLEO-NFC01A1 Dynamic NFC Tag