Naming and coding style convention, new linter tool. (#945)

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379245 additions and 373421 deletions

229
lib/ST25RFAL002/include/rfal_nfcf.h Executable file → Normal file
View File

@@ -49,7 +49,6 @@
*
*/
#ifndef RFAL_NFCF_H
#define RFAL_NFCF_H
@@ -68,66 +67,90 @@
******************************************************************************
*/
#define RFAL_NFCF_NFCID2_LEN 8U /*!< NFCID2 (FeliCa IDm) length */
#define RFAL_NFCF_SENSF_RES_LEN_MIN 16U /*!< SENSF_RES minimum length */
#define RFAL_NFCF_SENSF_RES_LEN_MAX 18U /*!< SENSF_RES maximum length */
#define RFAL_NFCF_SENSF_RES_PAD0_LEN 2U /*!< SENSF_RES PAD0 length */
#define RFAL_NFCF_SENSF_RES_PAD1_LEN 2U /*!< SENSF_RES PAD1 length */
#define RFAL_NFCF_SENSF_RES_RD_LEN 2U /*!< SENSF_RES Request Data length */
#define RFAL_NFCF_SENSF_RES_BYTE1 1U /*!< SENSF_RES first byte value */
#define RFAL_NFCF_SENSF_SC_LEN 2U /*!< Felica SENSF_REQ System Code length */
#define RFAL_NFCF_SENSF_PARAMS_SC1_POS 0U /*!< System Code byte1 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_SC2_POS 1U /*!< System Code byte2 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_RC_POS 2U /*!< Request Code position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_TSN_POS 3U /*!< Time Slot Number position in the SENSF_REQ */
#define RFAL_NFCF_POLL_MAXCARDS 16U /*!< Max number slots/cards 16 */
#define RFAL_NFCF_NFCID2_LEN 8U /*!< NFCID2 (FeliCa IDm) length */
#define RFAL_NFCF_SENSF_RES_LEN_MIN 16U /*!< SENSF_RES minimum length */
#define RFAL_NFCF_SENSF_RES_LEN_MAX 18U /*!< SENSF_RES maximum length */
#define RFAL_NFCF_SENSF_RES_PAD0_LEN 2U /*!< SENSF_RES PAD0 length */
#define RFAL_NFCF_SENSF_RES_PAD1_LEN 2U /*!< SENSF_RES PAD1 length */
#define RFAL_NFCF_SENSF_RES_RD_LEN 2U /*!< SENSF_RES Request Data length */
#define RFAL_NFCF_SENSF_RES_BYTE1 1U /*!< SENSF_RES first byte value */
#define RFAL_NFCF_SENSF_SC_LEN 2U /*!< Felica SENSF_REQ System Code length */
#define RFAL_NFCF_SENSF_PARAMS_SC1_POS 0U /*!< System Code byte1 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_SC2_POS 1U /*!< System Code byte2 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_RC_POS 2U /*!< Request Code position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_TSN_POS 3U /*!< Time Slot Number position in the SENSF_REQ */
#define RFAL_NFCF_POLL_MAXCARDS 16U /*!< Max number slots/cards 16 */
#define RFAL_NFCF_CMD_POS 0U /*!< Command/Responce code length */
#define RFAL_NFCF_CMD_LEN 1U /*!< Command/Responce code length */
#define RFAL_NFCF_LENGTH_LEN 1U /*!< LEN field length */
#define RFAL_NFCF_HEADER_LEN (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CMD_LEN) /*!< Header length*/
#define RFAL_NFCF_CMD_POS 0U /*!< Command/Responce code length */
#define RFAL_NFCF_CMD_LEN 1U /*!< Command/Responce code length */
#define RFAL_NFCF_LENGTH_LEN 1U /*!< LEN field length */
#define RFAL_NFCF_HEADER_LEN (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CMD_LEN) /*!< Header length*/
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_POS \
0U /*!< NFCID2 byte1 position */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_POS \
1U /*!< NFCID2 byte2 position */
#define RFAL_NFCF_SENSF_NFCID2_PROT_TYPE_LEN \
2U /*!< NFCID2 length for byte 1 and byte 2 indicating NFC-DEP or T3T support */
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP \
0x01U /*!< NFCID2 byte1 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP \
0xFEU /*!< NFCID2 byte2 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_POS 0U /*!< NFCID2 byte1 position */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_POS 1U /*!< NFCID2 byte2 position */
#define RFAL_NFCF_SYSTEMCODE \
0xFFFFU /*!< SENSF_RES Default System Code Digital 1.0 6.6.1.1 */
#define RFAL_NFCF_SENSF_NFCID2_PROT_TYPE_LEN 2U /*!< NFCID2 length for byte 1 and byte 2 indicating NFC-DEP or T3T support */
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP 0x01U /*!< NFCID2 byte1 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP 0xFEU /*!< NFCID2 byte2 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_BLOCK_LEN \
16U /*!< NFCF T3T Block size T3T 1.0 4.1 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST1_POS \
9U /*!< Check|Update Res Status Flag 1 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST2_POS \
10U /*!< Check|Update Res Status Flag 2 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_NOB_POS \
11U /*!< Check|Update Res Number of Blocks position T3T 1.0 Table 8 */
#define RFAL_NFCF_SYSTEMCODE 0xFFFFU /*!< SENSF_RES Default System Code Digital 1.0 6.6.1.1 */
#define RFAL_NFCF_STATUS_FLAG_SUCCESS \
0x00U /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_STATUS_FLAG_ERROR \
0xFFU /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_BLOCK_LEN 16U /*!< NFCF T3T Block size T3T 1.0 4.1 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST1_POS 9U /*!< Check|Update Res Status Flag 1 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST2_POS 10U /*!< Check|Update Res Status Flag 2 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_NOB_POS 11U /*!< Check|Update Res Number of Blocks position T3T 1.0 Table 8 */
#define RFAL_NFCF_STATUS_FLAG_SUCCESS 0x00U /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_STATUS_FLAG_ERROR 0xFFU /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_BLOCKLISTELEM_LEN 0x80U /*!< Block List Element Length bit (2|3 bytes) T3T 1.0 5.6.1 */
#define RFAL_NFCF_SERVICECODE_RDONLY 0x000BU /*!< NDEF Service Code as Read-Only T3T 1.0 7.2.1 */
#define RFAL_NFCF_SERVICECODE_RDWR 0x0009U /*!< NDEF Service Code as Read and Write T3T 1.0 7.2.1 */
#define RFAL_NFCF_BLOCKLISTELEM_LEN \
0x80U /*!< Block List Element Length bit (2|3 bytes) T3T 1.0 5.6.1 */
#define RFAL_NFCF_SERVICECODE_RDONLY \
0x000BU /*!< NDEF Service Code as Read-Only T3T 1.0 7.2.1 */
#define RFAL_NFCF_SERVICECODE_RDWR \
0x0009U /*!< NDEF Service Code as Read and Write T3T 1.0 7.2.1 */
/*! NFC-F Felica command set JIS X6319-4 9.1 */
enum
{
RFAL_NFCF_CMD_POLLING = 0x00, /*!< SENSF_REQ (Felica Poll/REQC command to identify a card ) */
RFAL_NFCF_CMD_POLLING_RES = 0x01, /*!< SENSF_RES (Felica Poll/REQC command response ) */
RFAL_NFCF_CMD_REQUEST_SERVICE = 0x02, /*!< verify the existence of Area and Service */
RFAL_NFCF_CMD_REQUEST_RESPONSE = 0x04, /*!< verify the existence of a card */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION = 0x06, /*!< read Block Data from a Service that requires no authentication */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION_RES = 0x07, /*!< read Block Data response from a Service with no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION = 0x08, /*!< write Block Data to a Service that requires no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION_RES = 0x09, /*!< write Block Data response to a Service with no authentication */
RFAL_NFCF_CMD_REQUEST_SYSTEM_CODE = 0x0c, /*!< acquire the System Code registered to a card */
RFAL_NFCF_CMD_AUTHENTICATION1 = 0x10, /*!< authenticate a card */
RFAL_NFCF_CMD_AUTHENTICATION2 = 0x12, /*!< allow a card to authenticate a Reader/Writer */
RFAL_NFCF_CMD_READ = 0x14, /*!< read Block Data from a Service that requires authentication */
RFAL_NFCF_CMD_WRITE = 0x16, /*!< write Block Data to a Service that requires authentication */
enum {
RFAL_NFCF_CMD_POLLING =
0x00, /*!< SENSF_REQ (Felica Poll/REQC command to identify a card ) */
RFAL_NFCF_CMD_POLLING_RES =
0x01, /*!< SENSF_RES (Felica Poll/REQC command response ) */
RFAL_NFCF_CMD_REQUEST_SERVICE =
0x02, /*!< verify the existence of Area and Service */
RFAL_NFCF_CMD_REQUEST_RESPONSE =
0x04, /*!< verify the existence of a card */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION =
0x06, /*!< read Block Data from a Service that requires no authentication */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION_RES =
0x07, /*!< read Block Data response from a Service with no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION =
0x08, /*!< write Block Data to a Service that requires no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION_RES =
0x09, /*!< write Block Data response to a Service with no authentication */
RFAL_NFCF_CMD_REQUEST_SYSTEM_CODE =
0x0c, /*!< acquire the System Code registered to a card */
RFAL_NFCF_CMD_AUTHENTICATION1 =
0x10, /*!< authenticate a card */
RFAL_NFCF_CMD_AUTHENTICATION2 =
0x12, /*!< allow a card to authenticate a Reader/Writer */
RFAL_NFCF_CMD_READ =
0x14, /*!< read Block Data from a Service that requires authentication */
RFAL_NFCF_CMD_WRITE =
0x16, /*!< write Block Data to a Service that requires authentication */
};
/*
@@ -137,9 +160,11 @@ enum
*/
/*! Checks if the given NFC-F device indicates NFC-DEP support */
#define rfalNfcfIsNfcDepSupported( dev ) ( (((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE1_POS] == RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP) && \
(((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE2_POS] == RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP) )
#define rfalNfcfIsNfcDepSupported(dev) \
((((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE1_POS] == \
RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP) && \
(((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE2_POS] == \
RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP))
/*
******************************************************************************
@@ -147,52 +172,44 @@ enum
******************************************************************************
*/
/*! NFC-F SENSF_RES format Digital 1.1 8.6.2 */
typedef struct
{
uint8_t CMD; /*!< Command Code: 01h */
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
typedef struct {
uint8_t CMD; /*!< Command Code: 01h */
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
uint8_t PAD0[RFAL_NFCF_SENSF_RES_PAD0_LEN]; /*!< PAD0 */
uint8_t PAD1[RFAL_NFCF_SENSF_RES_PAD1_LEN]; /*!< PAD1 */
uint8_t MRTIcheck; /*!< MRTIcheck */
uint8_t MRTIupdate; /*!< MRTIupdate */
uint8_t PAD2; /*!< PAD2 */
uint8_t RD[RFAL_NFCF_SENSF_RES_RD_LEN]; /*!< Request Data */
uint8_t MRTIcheck; /*!< MRTIcheck */
uint8_t MRTIupdate; /*!< MRTIupdate */
uint8_t PAD2; /*!< PAD2 */
uint8_t RD[RFAL_NFCF_SENSF_RES_RD_LEN]; /*!< Request Data */
} rfalNfcfSensfRes;
/*! NFC-F poller device (PCD) struct */
typedef struct
{
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
typedef struct {
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
} rfalNfcfPollDevice;
/*! NFC-F listener device (PICC) struct */
typedef struct
{
uint8_t sensfResLen; /*!< SENF_RES length */
rfalNfcfSensfRes sensfRes; /*!< SENF_RES */
typedef struct {
uint8_t sensfResLen; /*!< SENF_RES length */
rfalNfcfSensfRes sensfRes; /*!< SENF_RES */
} rfalNfcfListenDevice;
typedef uint16_t rfalNfcfServ; /*!< NFC-F Service Code */
typedef uint16_t rfalNfcfServ; /*!< NFC-F Service Code */
/*! NFC-F Block List Element (2 or 3 bytes element) T3T 1.0 5.6.1 */
typedef struct
{
uint8_t conf; /*!< Access Mode | Serv Code List Order */
uint16_t blockNum; /*!< Block Number */
}rfalNfcfBlockListElem;
typedef struct {
uint8_t conf; /*!< Access Mode | Serv Code List Order */
uint16_t blockNum; /*!< Block Number */
} rfalNfcfBlockListElem;
/*! Check Update Service list and Block list parameter */
typedef struct
{
uint8_t numServ; /*!< Number of Services */
rfalNfcfServ *servList; /*!< Service Code List */
uint8_t numBlock; /*!< Number of Blocks */
rfalNfcfBlockListElem *blockList; /*!< Block Number List */
}rfalNfcfServBlockListParam;
typedef struct {
uint8_t numServ; /*!< Number of Services */
rfalNfcfServ* servList; /*!< Service Code List */
uint8_t numBlock; /*!< Number of Blocks */
rfalNfcfBlockListElem* blockList; /*!< Block Number List */
} rfalNfcfServBlockListParam;
/*
******************************************************************************
@@ -214,8 +231,7 @@ typedef struct
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerInitialize( rfalBitRate bitRate );
ReturnCode rfalNfcfPollerInitialize(rfalBitRate bitRate);
/*!
*****************************************************************************
@@ -235,8 +251,7 @@ ReturnCode rfalNfcfPollerInitialize( rfalBitRate bitRate );
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerCheckPresence( void );
ReturnCode rfalNfcfPollerCheckPresence(void);
/*!
*****************************************************************************
@@ -265,8 +280,13 @@ ReturnCode rfalNfcfPollerCheckPresence( void );
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerPoll( rfalFeliCaPollSlots slots, uint16_t sysCode, uint8_t reqCode, rfalFeliCaPollRes *cardList, uint8_t *devCnt, uint8_t *collisions );
ReturnCode rfalNfcfPollerPoll(
rfalFeliCaPollSlots slots,
uint16_t sysCode,
uint8_t reqCode,
rfalFeliCaPollRes* cardList,
uint8_t* devCnt,
uint8_t* collisions);
/*!
*****************************************************************************
@@ -285,8 +305,11 @@ ReturnCode rfalNfcfPollerPoll( rfalFeliCaPollSlots slots, uint16_t sysCode, uint
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcfListenDevice *nfcfDevList, uint8_t *devCnt );
ReturnCode rfalNfcfPollerCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcfListenDevice* nfcfDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -310,8 +333,12 @@ ReturnCode rfalNfcfPollerCollisionResolution( rfalComplianceMode compMode, uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerCheck( const uint8_t* nfcid2, const rfalNfcfServBlockListParam *servBlock, uint8_t *rxBuf, uint16_t rxBufLen, uint16_t *rcvdLen );
ReturnCode rfalNfcfPollerCheck(
const uint8_t* nfcid2,
const rfalNfcfServBlockListParam* servBlock,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvdLen);
/*!
*****************************************************************************
@@ -336,7 +363,14 @@ ReturnCode rfalNfcfPollerCheck( const uint8_t* nfcid2, const rfalNfcfServBlockLi
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerUpdate( const uint8_t* nfcid2, const rfalNfcfServBlockListParam *servBlock, uint8_t *txBuf, uint16_t txBufLen, const uint8_t *blockData, uint8_t *rxBuf, uint16_t rxBufLen);
ReturnCode rfalNfcfPollerUpdate(
const uint8_t* nfcid2,
const rfalNfcfServBlockListParam* servBlock,
uint8_t* txBuf,
uint16_t txBufLen,
const uint8_t* blockData,
uint8_t* rxBuf,
uint16_t rxBufLen);
/*!
*****************************************************************************
@@ -356,8 +390,7 @@ ReturnCode rfalNfcfPollerUpdate( const uint8_t* nfcid2, const rfalNfcfServBlockL
*
*****************************************************************************
*/
bool rfalNfcfListenerIsT3TReq( const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid2 );
bool rfalNfcfListenerIsT3TReq(const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid2);
#endif /* RFAL_NFCF_H */