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
Revision 34:b76765d2cc68, committed 2017-07-12
- Comitter:
- Davidroid
- Date:
- Wed Jul 12 14:22:19 2017 +0000
- Parent:
- 33:e6b7e74be1d5
- Child:
- 35:7b2b4dbed7ae
- Commit message:
- Updated to fit ARM coding style.
Changed in this revision
| m24sr/M24SR.cpp | Show annotated file Show diff for this revision Revisions of this file |
| m24sr/M24SR.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/m24sr/M24SR.cpp Wed Jul 12 14:15:02 2017 +0000
+++ b/m24sr/M24SR.cpp Wed Jul 12 14:22:19 2017 +0000
@@ -58,7 +58,7 @@
/**
* default password, also used to enable super user mode through the I2C channel
*/
-const uint8_tM24SR::DEFAULT_PASSWORD[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+const uint8_t M24SR::DEFAULT_PASSWORD[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/** @addtogroup M24SR_Driver
@@ -124,7 +124,7 @@
* @retval Status (SW1&SW2) : CRC16 residue is correct
* @retval M24SR_ERROR_CRC : CRC16 residue is false
*/
- staticM24SR::StatusTypeDef M24SR_IsCorrectCRC16Residue(uint8_t *DataIn, uint8_t Length) {
+ static M24SR::StatusTypeDef M24SR_IsCorrectCRC16Residue(uint8_t *DataIn, uint8_t Length) {
uint16_t ResCRC = 0x0000;
M24SR::StatusTypeDef status;
/* check the CRC16 Residue */
@@ -141,7 +141,7 @@
ResCRC = M24SR_ComputeCrc(DataIn, 5);
if (ResCRC != 0x0000) {
/* Bad CRC */
- returnM24SR::M24SR_IO_ERROR_CRC;
+ return M24SR::M24SR_IO_ERROR_CRC;
} else {
/* Good CRC, but error status from M24SR */
status= (M24SR::StatusTypeDef) (((DataIn[1] << 8) & 0xFF00)
@@ -230,12 +230,12 @@
* @retval M24SR_SUCCESS : the data is a S-Block
* @retval NFC_ERROR : the data is not a S-Block
*/
- staticM24SR::StatusTypeDef IsSBlock(uint8_t *pBuffer) {
+ static M24SR::StatusTypeDef IsSBlock(uint8_t *pBuffer) {
if ((pBuffer[M24SR_OFFSET_PCB] & M24SR_MASK_BLOCK) == M24SR_MASK_SBLOCK) {
- returnM24SR::M24SR_SUCCESS;
+ return M24SR::M24SR_SUCCESS;
} else {
- returnM24SR::M24SR_ERROR;
+ return M24SR::M24SR_ERROR;
}
}
@@ -279,7 +279,7 @@
* @param FWTbyte : FWT value
* @return M24SR_SUCCESS if no errors
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendFWTExtension(uint8_t FWTbyte) {
+M24SR::StatusTypeDef M24SR::M24SR_SendFWTExtension(uint8_t FWTbyte) {
uint8_t pBuffer[M24SR_STATUSRESPONSE_NBBYTE];
M24SR::StatusTypeDef status;
uint8_t NthByte = 0;
@@ -320,7 +320,7 @@
* @brief This function initialize the M24SR device
* @retval None
*/
-M24SR::StatusTypeDefM24SR::M24SR_Init(M24SR_InitTypeDef *notUsed) {
+M24SR::StatusTypeDef M24SR::M24SR_Init(M24SR_InitTypeDef *notUsed) {
(void) notUsed;
//force to open a i2c session
StatusTypeDef status = M24SR_ForceSession();
@@ -355,7 +355,7 @@
* @param None
* @return M24SR_SUCCESS if no errors
*/
-M24SR::StatusTypeDefM24SR::M24SR_ForceSession(void) {
+M24SR::StatusTypeDef M24SR::M24SR_ForceSession(void) {
uint8_t commandBuffer[] = M24SR_KILLSESSION_COMMAND;
M24SR::StatusTypeDef status;
status = M24SR_IO_SendI2Ccommand(sizeof(commandBuffer), commandBuffer);
@@ -378,7 +378,7 @@
* @brief This function sends the Deselect command (S-Block format)
* @return M24SR_SUCCESS if no errors
*/
-M24SR::StatusTypeDefM24SR::M24SR_Deselect(void) {
+M24SR::StatusTypeDef M24SR::M24SR_Deselect(void) {
uint8_t pBuffer[] = M24SR_DESELECTREQUEST_COMMAND;
M24SR::StatusTypeDef status;
/* send the request */
@@ -404,7 +404,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveDeselect(void) {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveDeselect(void) {
uint8_t pBuffer[4];
M24SR::StatusTypeDef status;
status = M24SR_IO_ReceiveI2Cresponse(sizeof(pBuffer), pBuffer);
@@ -417,7 +417,7 @@
* @retval M24SR_SUCCESS the function is successful.
* @retval Status (SW1&SW2) if operation does not complete.
*/
-M24SR::StatusTypeDefM24SR::M24SR_GetSession(void) {
+M24SR::StatusTypeDef M24SR::M24SR_GetSession(void) {
uint8_t commandBuffer[] = M24SR_OPENSESSION_COMMAND;
M24SR::StatusTypeDef status;
@@ -440,7 +440,7 @@
* @brief This function sends the SelectApplication command
* @return M24SR_SUCCESS if no errors
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendSelectApplication(void) {
+M24SR::StatusTypeDef M24SR::M24SR_SendSelectApplication(void) {
C_APDU command;
M24SR::StatusTypeDef status;
@@ -487,7 +487,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectApplication(void) {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectApplication(void) {
uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
M24SR::StatusTypeDef status;
@@ -504,7 +504,7 @@
return status;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReadID(uint8_t *nfc_id) {
+M24SR::StatusTypeDef M24SR::M24SR_ReadID(uint8_t *nfc_id) {
if (!nfc_id) {
return M24SR_ERROR;
}
@@ -523,7 +523,7 @@
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
* @retval Status (SW1&SW2) if operation does not complete for another reason.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendSelectCCfile(void) {
+M24SR::StatusTypeDef M24SR::M24SR_SendSelectCCfile(void) {
C_APDU command;
M24SR::StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -566,7 +566,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectCCfile(void){
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectCCfile(void){
uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
M24SR::StatusTypeDef status;
@@ -589,7 +589,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendSelectSystemfile(void) {
+M24SR::StatusTypeDef M24SR::M24SR_SendSelectSystemfile(void) {
C_APDU command;
uint8_t *pBuffer = uM24SRbuffer;
@@ -632,7 +632,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectSystemfile() {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectSystemfile() {
uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
M24SR::StatusTypeDef status;
@@ -654,7 +654,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendSelectNDEFfile(uint16_t NDEFfileId) {
+M24SR::StatusTypeDef M24SR::M24SR_SendSelectNDEFfile(uint16_t NDEFfileId) {
C_APDU command;
M24SR::StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -695,7 +695,7 @@
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveSelectNDEFfile(){
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveSelectNDEFfile(){
uint8_t pDataIn[M24SR_STATUSRESPONSE_NBBYTE];
M24SR::StatusTypeDef status;
@@ -721,7 +721,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) {
+M24SR::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) {
NbByteToRead=M24SR_MAX_BYTE_OPERATION_LENGHT;
@@ -768,7 +768,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveReadBinary() {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveReadBinary() {
M24SR::StatusTypeDef status;
const uint16_t length = mLastCommandData.length;
const uint16_t offset = mLastCommandData.offset;
@@ -801,7 +801,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendSTReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) {
+M24SR::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) {
NbByteToRead=M24SR_MAX_BYTE_OPERATION_LENGHT;
@@ -855,7 +855,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendUpdateBinary(uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite) {
+M24SR::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) {
NbByteToWrite=M24SR_MAX_BYTE_OPERATION_LENGHT;
@@ -904,7 +904,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveUpdateBinary() {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveUpdateBinary() {
uint8_t respBuffer[M24SR_STATUSRESPONSE_NBBYTE];
M24SR::StatusTypeDef status;
const uint16_t length = mLastCommandData.length;
@@ -946,7 +946,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendVerify(uint16_t uPwdId, uint8_t NbPwdByte, const uint8_t *pPwd) {
+M24SR::StatusTypeDef M24SR::M24SR_SendVerify(uint16_t uPwdId, uint8_t NbPwdByte, const uint8_t *pPwd) {
C_APDU command;
M24SR::StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1002,7 +1002,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveVerify() {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveVerify() {
M24SR::StatusTypeDef status;
uint8_t respBuffer[M24SR_STATUSRESPONSE_NBBYTE];
mLastCommandSend=NONE;
@@ -1029,7 +1029,7 @@
* @retval Status (SW1&SW2) Satus of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendChangeReferenceData(uint16_t uPwdId, uint8_t *pPwd) {
+M24SR::StatusTypeDef M24SR::M24SR_SendChangeReferenceData(uint16_t uPwdId, uint8_t *pPwd) {
C_APDU command;
M24SR::StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1080,7 +1080,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveChangeReferenceData(){
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveChangeReferenceData(){
M24SR::StatusTypeDef status;
//TODO the size is 3?
uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -1105,7 +1105,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendEnableVerificationRequirement(uint16_t uReadOrWrite) {
+M24SR::StatusTypeDef M24SR::M24SR_SendEnableVerificationRequirement(uint16_t uReadOrWrite) {
C_APDU command;
M24SR::StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1151,7 +1151,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveEnableVerificationRequirement(){
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveEnableVerificationRequirement(){
M24SR::StatusTypeDef status;
//TODO the size is 3?
uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -1175,7 +1175,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendDisableVerificationRequirement(uint16_t uReadOrWrite) {
+M24SR::StatusTypeDef M24SR::M24SR_SendDisableVerificationRequirement(uint16_t uReadOrWrite) {
C_APDU command;
M24SR::StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1221,7 +1221,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveDisableVerificationRequirement() {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveDisableVerificationRequirement() {
M24SR::StatusTypeDef status;
//TODO the size is 3?
uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -1245,7 +1245,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendEnablePermanentState(uint16_t uReadOrWrite) {
+M24SR::StatusTypeDef M24SR::M24SR_SendEnablePermanentState(uint16_t uReadOrWrite) {
C_APDU command;
M24SR::StatusTypeDef status;
@@ -1292,7 +1292,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveEnablePermanentState() {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveEnablePermanentState() {
M24SR::StatusTypeDef status;
//TODO the size is 3?
uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -1316,7 +1316,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendDisablePermanentState(uint16_t uReadOrWrite) {
+M24SR::StatusTypeDef M24SR::M24SR_SendDisablePermanentState(uint16_t uReadOrWrite) {
C_APDU command;
M24SR::StatusTypeDef status;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1362,7 +1362,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_ReceiveDisablePermanentState() {
+M24SR::StatusTypeDef M24SR::M24SR_ReceiveDisablePermanentState() {
M24SR::StatusTypeDef status;
//TODO the size is 3?
uint8_t rensponseBuffer[M24SR_STATUSRESPONSE_NBBYTE];
@@ -1386,7 +1386,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_SendInterrupt(void) {
+M24SR::StatusTypeDef M24SR::M24SR_SendInterrupt(void) {
C_APDU command;
uint8_t *pBuffer = uM24SRbuffer;
@@ -1425,7 +1425,7 @@
* @retval Status (SW1&SW2) Status of the operation to complete.
* @retval M24SR_ERROR_I2CTIMEOUT I2C timeout occurred.
*/
-M24SR::StatusTypeDefM24SR::M24SR_StateControl(uint8_t uSetOrReset) {
+M24SR::StatusTypeDef M24SR::M24SR_StateControl(uint8_t uSetOrReset) {
C_APDU command;
uint8_t *pBuffer = uM24SRbuffer;
uint16_t uP1P2 = 0x001F;
@@ -1465,7 +1465,7 @@
return M24SR_IsCorrectCRC16Residue(pBuffer, M24SR_STATUSRESPONSE_NBBYTE);
}
-M24SR::StatusTypeDefM24SR::M24SR_ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
+M24SR::StatusTypeDef M24SR::M24SR_ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
if (GPOPin.is_connected() == 0) {
return M24SR_IO_PIN_NOT_CONNECTED;
@@ -1482,7 +1482,7 @@
return M24SR_SendSelectApplication();
}
-M24SR::StatusTypeDefM24SR::M24SR_ManageRFGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
+M24SR::StatusTypeDef M24SR::M24SR_ManageRFGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
if(RFDisablePin.is_connected()==0) {
return M24SR_IO_PIN_NOT_CONNECTED;
@@ -1499,7 +1499,7 @@
return M24SR_SendSelectApplication();
}
-M24SR::StatusTypeDefM24SR::M24SR_RFConfig(uint8_t OnOffChoice) {
+M24SR::StatusTypeDef M24SR::M24SR_RFConfig(uint8_t OnOffChoice) {
if (RFDisablePin.is_connected()==0) {
return M24SR_IO_PIN_NOT_CONNECTED;
}
@@ -1512,7 +1512,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::M24SR_IO_SendI2Ccommand(uint8_t NbByte, uint8_t *pBuffer) {
+M24SR::StatusTypeDef M24SR::M24SR_IO_SendI2Ccommand(uint8_t NbByte, uint8_t *pBuffer) {
int ret = dev_I2C.write(address, (char*) pBuffer, NbByte);
if (ret == 0) {
return M24SR_SUCCESS;
@@ -1520,7 +1520,7 @@
return M24SR_IO_ERROR_I2CTIMEOUT;
}
-M24SR::StatusTypeDefM24SR::M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte, uint8_t *pBuffer) {
+M24SR::StatusTypeDef M24SR::M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte, uint8_t *pBuffer) {
int ret = dev_I2C.read(address, (char*) pBuffer, NbByte);
if (ret == 0) {
return M24SR_SUCCESS;
@@ -1529,7 +1529,7 @@
return M24SR_IO_ERROR_I2CTIMEOUT;
}
-M24SR::StatusTypeDefM24SR::M24SR_IO_PollI2C(void) {
+M24SR::StatusTypeDef M24SR::M24SR_IO_PollI2C(void) {
int status = 1;
while (status != 0 ) {
@@ -1539,7 +1539,7 @@
return M24SR_SUCCESS;
}
-M24SR::StatusTypeDefM24SR::manage_event(void){
+M24SR::StatusTypeDef M24SR::manage_event(void){
switch(mLastCommandSend) {
case SELECT_APPLICATION:
--- a/m24sr/M24SR.h Wed Jul 12 14:15:02 2017 +0000
+++ b/m24sr/M24SR.h Wed Jul 12 14:22:19 2017 +0000
@@ -1192,7 +1192,7 @@
if (mType==READ) {
//enable read = disable write only
nfc->getCallback()->on_disable_write_only(nfc,status);
- } else {}
+ } else {
//enable write = disable read only
nfc->getCallback()->on_disable_read_only(nfc,status);
}

X-NUCLEO-NFC01A1 Dynamic NFC Tag