ST / M24SR

Dependencies:   ST_INTERFACES

Dependents:   X_NUCLEO_NFC01A1

Fork of M24SR by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

Drv_M24SR

This file contains the driver which implements all the M24SR commands. More...

Data Structures

struct  C_APDU_Header
 APDU-Header command structure. More...
struct  C_APDU_Body
 APDU-Body command structure. More...
struct  C_APDU
 APDU Command structure. More...
struct  R_APDU
 SC response structure. More...

Modules

 Lib_M24SR_Exported_Constants

Enumerations

enum  M24SR_GPO_MODE
 

GPO mode structure.

More...

Functions

static uint16_t M24SR_UpdateCrc (uint8_t ch, uint16_t *lpwCrc)
 This function updates the CRC.
static uint16_t M24SR_ComputeCrc (uint8_t *Data, uint8_t Length)
 This function returns the CRC 16.
static M24SR::StatusTypeDef M24SR_IsCorrectCRC16Residue (uint8_t *DataIn, uint8_t Length)
 This function computes the CRC16 residue as defined by CRC ISO/IEC 13239.
static void M24SR_BuildIBlockCommand (uint16_t CommandStructure, C_APDU *Command, uint8_t uDIDbyte, uint16_t *NbByte, uint8_t *pCommand)
 This functions creates an I block command according to the structures CommandStructure and Command.
static M24SR::StatusTypeDef IsSBlock (uint8_t *pBuffer)
 This function returns M24SR_STATUS_SUCCESS if the pBuffer is an s-block.
 M24SR (const uint8_t address, I2C &I2C, gpoEventCallback eventCallback, const PinName &GPOPinName, const PinName &RFDISPinName)
 Constructor.
virtual ~M24SR (void)
 Destructor.
StatusTypeDef M24SR_SendFWTExtension (uint8_t FWTbyte)
 This function sends the FWT extension command (S-Block format)
StatusTypeDef M24SR_Init (M24SR_InitTypeDef *)
 This function initialize the M24SR device.
StatusTypeDef M24SR_ForceSession (void)
 This function sends the KillSession command to the M24SR device.
StatusTypeDef M24SR_Deselect (void)
 This function sends the Deselect command (S-Block format)
StatusTypeDef M24SR_GetSession (void)
 This function sends the GetSession command to the M24SR device.
StatusTypeDef M24SR_SendSelectApplication (void)
 This function sends the SelectApplication command.
StatusTypeDef M24SR_SendSelectCCfile (void)
 This function sends the SelectCCFile command.
StatusTypeDef M24SR_SendSelectSystemfile (void)
 This function sends the SelectSystemFile command.
StatusTypeDef M24SR_SendSelectNDEFfile (uint16_t NDEFfileId)
 This function sends the SelectNDEFfile command.
StatusTypeDef M24SR_SendReadBinary (uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead)
 This function sends a read binary command.
StatusTypeDef M24SR_SendSTReadBinary (uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead)
 This function sends a ST read binary command (no error if access is not inside NDEF file)
StatusTypeDef M24SR_SendUpdateBinary (uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite)
 This function sends a Update binary command.
StatusTypeDef M24SR_SendVerify (uint16_t uPwdId, uint8_t NbPwdByte, const uint8_t *pPwd)
 This function sends the Verify command.
StatusTypeDef M24SR_SendChangeReferenceData (uint16_t uPwdId, uint8_t *pPwd)
 This function sends the ChangeReferenceData command.
StatusTypeDef M24SR_SendEnableVerificationRequirement (uint16_t uReadOrWrite)
 This function sends the EnableVerificationRequirement command.
StatusTypeDef M24SR_SendDisableVerificationRequirement (uint16_t uReadOrWrite)
 This function sends the DisableVerificationRequirement command.
StatusTypeDef M24SR_SendEnablePermanentState (uint16_t uReadOrWrite)
 This function sends the EnablePermananentState command.
StatusTypeDef M24SR_SendDisablePermanentState (uint16_t uReadOrWrite)
 This function sends the DisablePermanentState command.
StatusTypeDef M24SR_SendInterrupt (void)
 This function generates an interrupt on GPO pin.
StatusTypeDef M24SR_StateControl (uint8_t uSetOrReset)
 This function forces GPO pin to low state or high Z.
StatusTypeDef M24SR_IO_SendI2Ccommand (uint8_t NbByte, uint8_t *pBuffer)
 Send a command to the component.
StatusTypeDef M24SR_IO_ReceiveI2Cresponse (uint8_t NbByte, uint8_t *pBuffer)
 Read a command response.
StatusTypeDef M24SR_IO_PollI2C (void)
 Do an active polling on the I2C bus until the answer is ready.
StatusTypeDef manage_event ()
 Function to call when the component fire an interrupt.
NDefLib::NDefNfcTag & get_NDef_tag ()
 Get an implementation of NDefNfcTag to use the library NDefLib.

Detailed Description

This file contains the driver which implements all the M24SR commands.


Enumeration Type Documentation

GPO mode structure.

Definition at line 88 of file m24sr_def.h.


Function Documentation

NDefLib::NDefNfcTag & get_NDef_tag (  ) [inherited]

Get an implementation of NDefNfcTag to use the library NDefLib.

Returns:
an object of type NdefNfcTag

Definition at line 1577 of file M24SR.cpp.

static M24SR::StatusTypeDef IsSBlock ( uint8_t *  pBuffer ) [static]

This function returns M24SR_STATUS_SUCCESS if the pBuffer is an s-block.

Parameters:
pBuffer: pointer to the data
Return values:
M24SR_SUCCESS: the data is a S-Block
NFC_ERROR: the data is not a S-Block

Definition at line 233 of file M24SR.cpp.

M24SR ( const uint8_t  address,
I2C &  I2C,
gpoEventCallback  eventCallback,
const PinName &  GPOPinName,
const PinName &  RFDISPinName 
) [inherited]

Constructor.

Parameters:
addressI2C address of the component.
I2CI2C device to be used for communication.
eventCallbackFunction that will be called when the gpo pin status changes.
GPOPinNamePin used as GPIO.
RFDISPinNamePin used to disable the RF function.

Definition at line 243 of file M24SR.cpp.

static void M24SR_BuildIBlockCommand ( uint16_t  CommandStructure,
C_APDU Command,
uint8_t  uDIDbyte,
uint16_t *  NbByte,
uint8_t *  pCommand 
) [static]

This functions creates an I block command according to the structures CommandStructure and Command.

Parameters:
Command: structure which contains the field of the different parameters
CommandStructure: structure of the command
NbByte: number of bytes of the command
pCommand: pointer to the command created

Definition at line 165 of file M24SR.cpp.

static uint16_t M24SR_ComputeCrc ( uint8_t *  Data,
uint8_t  Length 
) [static]

This function returns the CRC 16.

Parameters:
Data: pointer on the data used to compute the CRC16
Length: number of bytes of the data
Return values:
CRC16

Definition at line 108 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_Deselect ( void   ) [protected, inherited]

This function sends the Deselect command (S-Block format)

Returns:
M24SR_SUCCESS if no errors

Definition at line 381 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_ForceSession ( void   ) [protected, inherited]

This function sends the KillSession command to the M24SR device.

Parameters:
None
Returns:
M24SR_SUCCESS if no errors

Definition at line 358 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_GetSession ( void   ) [protected, inherited]

This function sends the GetSession command to the M24SR device.

Return values:
M24SR_SUCCESSthe function is successful.
Status(SW1&SW2) if operation does not complete.

Definition at line 420 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_Init ( M24SR_InitTypeDef *  notUsed ) [protected, inherited]

This function initialize the M24SR device.

Return values:
None

Definition at line 323 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_IO_PollI2C ( void   ) [protected, inherited]

Do an active polling on the I2C bus until the answer is ready.

Returns:
M24SR_SUCCESS if no errors

Definition at line 1533 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_IO_ReceiveI2Cresponse ( uint8_t  NbByte,
uint8_t *  pBuffer 
) [protected, inherited]

Read a command response.

Parameters:
NbByteNumber of bytes to read.
pBufferBuffer to store the response into.
Returns:
M24SR_SUCCESS if no errors

Definition at line 1524 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_IO_SendI2Ccommand ( uint8_t  NbByte,
uint8_t *  pBuffer 
) [protected, inherited]

Send a command to the component.

Parameters:
NbByteLength of the command.
pBufferBuffer containing the command.
Returns:
M24SR_SUCCESS if no errors

Definition at line 1516 of file M24SR.cpp.

static M24SR::StatusTypeDef M24SR_IsCorrectCRC16Residue ( uint8_t *  DataIn,
uint8_t  Length 
) [static]

This function computes the CRC16 residue as defined by CRC ISO/IEC 13239.

Parameters:
DataIn: input data
Length: Number of bits of DataIn
Return values:
Status(SW1&SW2) : CRC16 residue is correct
M24SR_ERROR_CRC: CRC16 residue is false

Definition at line 127 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendChangeReferenceData ( uint16_t  uPwdId,
uint8_t *  pPwd 
) [protected, inherited]

This function sends the ChangeReferenceData command.

Parameters:
uPwdIdPasswordId ( 0x0001 : Read NDEF pwd or 0x0002 : Write NDEF pwd or 0x0003 : I2C pwd)
pPwdpointer to the passwaord
Return values:
Status(SW1&SW2) Satus of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 1033 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendDisablePermanentState ( uint16_t  uReadOrWrite ) [protected, inherited]

This function sends the DisablePermanentState command.

Parameters:
uReadOrWriteenable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 1320 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendDisableVerificationRequirement ( uint16_t  uReadOrWrite ) [protected, inherited]

This function sends the DisableVerificationRequirement command.

Parameters:
uReadOrWriteenable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 1179 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendEnablePermanentState ( uint16_t  uReadOrWrite ) [protected, inherited]

This function sends the EnablePermananentState command.

Parameters:
uReadOrWriteenable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 1249 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendEnableVerificationRequirement ( uint16_t  uReadOrWrite ) [protected, inherited]

This function sends the EnableVerificationRequirement command.

Parameters:
uReadOrWriteenable the read or write protection ( 0x0001 : Read or 0x0002 : Write )
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 1109 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendFWTExtension ( uint8_t  FWTbyte ) [protected, inherited]

This function sends the FWT extension command (S-Block format)

Parameters:
FWTbyte: FWT value
Returns:
M24SR_SUCCESS if no errors

Definition at line 282 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendInterrupt ( void   ) [protected, inherited]

This function generates an interrupt on GPO pin.

Parameters:
None
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 1390 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendReadBinary ( uint16_t  Offset,
uint8_t  NbByteToRead,
uint8_t *  pBufferRead 
) [protected, inherited]

This function sends a read binary command.

Parameters:
Offsetfirst byte to read
NbByteToReadnumber of bytes to read
pBufferReadpointer to the buffer read from the M24SR device
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 725 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendSelectApplication ( void   ) [protected, inherited]

This function sends the SelectApplication command.

Returns:
M24SR_SUCCESS if no errors

Definition at line 443 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendSelectCCfile ( void   ) [protected, inherited]

This function sends the SelectCCFile command.

Return values:
M24SR_SUCCESSthe function is successful.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.
Status(SW1&SW2) if operation does not complete for another reason.

Definition at line 526 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendSelectNDEFfile ( uint16_t  NDEFfileId ) [protected, inherited]

This function sends the SelectNDEFfile command.

Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 657 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendSelectSystemfile ( void   ) [protected, inherited]

This function sends the SelectSystemFile command.

Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 592 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendSTReadBinary ( uint16_t  Offset,
uint8_t  NbByteToRead,
uint8_t *  pBufferRead 
) [protected, inherited]

This function sends a ST read binary command (no error if access is not inside NDEF file)

Parameters:
Offsetfirst byte to read
NbByteToReadnumber of bytes to read
pBufferReadpointer to the buffer read from the M24SR device
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 805 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendUpdateBinary ( uint16_t  Offset,
uint8_t  NbByteToWrite,
uint8_t *  pDataToWrite 
) [protected, inherited]

This function sends a Update binary command.

Parameters:
Offsetfirst byte to read
NbByteToWritenumber of bytes to write
pBufferReadpointer to the buffer read from the M24SR device
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 859 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_SendVerify ( uint16_t  uPwdId,
uint8_t  NbPwdByte,
const uint8_t *  pPwd 
) [protected, inherited]

This function sends the Verify command.

Parameters:
uPwdIdPasswordId ( 0x0001 : Read NDEF pwd or 0x0002 : Write NDEF pwd or 0x0003 : I2C pwd)
NbPwdByteNumber of bytes ( 0x00 or 0x10)
pPwdpointer to the password
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 950 of file M24SR.cpp.

M24SR::StatusTypeDef M24SR_StateControl ( uint8_t  uSetOrReset ) [protected, inherited]

This function forces GPO pin to low state or high Z.

Parameters:
uSetOrResetselect if GPO must be low (reset) or HiZ
Return values:
Status(SW1&SW2) Status of the operation to complete.
M24SR_ERROR_I2CTIMEOUTI2C timeout occurred.

Definition at line 1429 of file M24SR.cpp.

static uint16_t M24SR_UpdateCrc ( uint8_t  ch,
uint16_t *  lpwCrc 
) [static]

This function updates the CRC.

Parameters:
None
Return values:
None

Definition at line 94 of file M24SR.cpp.

M24SR::StatusTypeDef manage_event ( void   ) [inherited]

Function to call when the component fire an interrupt.

Returns:
last operation status

Definition at line 1543 of file M24SR.cpp.

~M24SR ( void   ) [virtual, inherited]

Destructor.

Definition at line 273 of file M24SR.cpp.