2020-10-18 22:09:48 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* \attention
|
|
|
|
*
|
|
|
|
* <h2><center>© COPYRIGHT 2020 STMicroelectronics</center></h2>
|
|
|
|
*
|
|
|
|
* Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* www.st.com/myliberty
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
|
|
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PROJECT: ST25R3916 firmware
|
|
|
|
* Revision:
|
|
|
|
* LANGUAGE: ISO C99
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
|
|
|
* \author Gustavo Patricio
|
|
|
|
*
|
|
|
|
* \brief ST25R3916 LEDs handling
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* INCLUDES
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "st25r3916_led.h"
|
|
|
|
#include "st25r3916_irq.h"
|
|
|
|
#include "st25r3916_com.h"
|
|
|
|
#include "st25r3916.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* MACROS
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef PLATFORM_LED_RX_PIN
|
2022-01-05 16:10:18 +00:00
|
|
|
#define st25r3916ledRxOn() \
|
|
|
|
platformLedOn( \
|
|
|
|
PLATFORM_LED_RX_PORT, \
|
|
|
|
PLATFORM_LED_RX_PIN); /*!< LED Rx Pin On from system HAL */
|
|
|
|
#define st25r3916ledRxOff() \
|
|
|
|
platformLedOff( \
|
|
|
|
PLATFORM_LED_RX_PORT, \
|
|
|
|
PLATFORM_LED_RX_PIN); /*!< LED Rx Pin Off from system HAL */
|
2020-10-18 22:09:48 +00:00
|
|
|
#else /* PLATFORM_LED_RX_PIN */
|
2022-01-05 16:10:18 +00:00
|
|
|
#define st25r3916ledRxOn()
|
|
|
|
#define st25r3916ledRxOff()
|
2020-10-18 22:09:48 +00:00
|
|
|
#endif /* PLATFORM_LED_RX_PIN */
|
|
|
|
|
|
|
|
#ifdef PLATFORM_LED_FIELD_PIN
|
2022-01-05 16:10:18 +00:00
|
|
|
#define st25r3916ledFieldOn() \
|
|
|
|
platformLedOn( \
|
|
|
|
PLATFORM_LED_FIELD_PORT, \
|
|
|
|
PLATFORM_LED_FIELD_PIN); /*!< LED Field Pin On from system HAL */
|
|
|
|
#define st25r3916ledFieldOff() \
|
|
|
|
platformLedOff( \
|
|
|
|
PLATFORM_LED_FIELD_PORT, \
|
|
|
|
PLATFORM_LED_FIELD_PIN); /*!< LED Field Pin Off from system HAL */
|
2020-10-18 22:09:48 +00:00
|
|
|
#else /* PLATFORM_LED_FIELD_PIN */
|
2022-01-05 16:10:18 +00:00
|
|
|
#define st25r3916ledFieldOn()
|
|
|
|
#define st25r3916ledFieldOff()
|
2020-10-18 22:09:48 +00:00
|
|
|
#endif /* PLATFORM_LED_FIELD_PIN */
|
|
|
|
|
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2022-01-05 16:10:18 +00:00
|
|
|
void st25r3916ledInit(void) {
|
2020-10-18 22:09:48 +00:00
|
|
|
/* Initialize LEDs if existing and defined */
|
|
|
|
platformLedsInitialize();
|
2022-01-05 16:10:18 +00:00
|
|
|
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledRxOff();
|
|
|
|
st25r3916ledFieldOff();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2022-01-05 16:10:18 +00:00
|
|
|
void st25r3916ledEvtIrq(uint32_t irqs) {
|
|
|
|
if((irqs & (ST25R3916_IRQ_MASK_TXE | ST25R3916_IRQ_MASK_CAT)) != 0U) {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledFieldOn();
|
|
|
|
}
|
2022-01-05 16:10:18 +00:00
|
|
|
|
|
|
|
if((irqs & (ST25R3916_IRQ_MASK_RXS | ST25R3916_IRQ_MASK_NFCT)) != 0U) {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledRxOn();
|
|
|
|
}
|
2022-01-05 16:10:18 +00:00
|
|
|
|
|
|
|
if((irqs & (ST25R3916_IRQ_MASK_RXE | ST25R3916_IRQ_MASK_NRE | ST25R3916_IRQ_MASK_RX_REST |
|
|
|
|
ST25R3916_IRQ_MASK_RXE_PTA | ST25R3916_IRQ_MASK_WU_A | ST25R3916_IRQ_MASK_WU_A_X |
|
|
|
|
ST25R3916_IRQ_MASK_WU_F | ST25R3916_IRQ_MASK_RFU2)) != 0U) {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledRxOff();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2022-01-05 16:10:18 +00:00
|
|
|
void st25r3916ledEvtWrReg(uint8_t reg, uint8_t val) {
|
|
|
|
if(reg == ST25R3916_REG_OP_CONTROL) {
|
|
|
|
if((ST25R3916_REG_OP_CONTROL_tx_en & val) != 0U) {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledFieldOn();
|
2022-01-05 16:10:18 +00:00
|
|
|
} else {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledFieldOff();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2022-01-05 16:10:18 +00:00
|
|
|
void st25r3916ledEvtWrMultiReg(uint8_t reg, const uint8_t* vals, uint8_t len) {
|
2020-10-18 22:09:48 +00:00
|
|
|
uint8_t i;
|
2022-01-05 16:10:18 +00:00
|
|
|
|
|
|
|
for(i = 0; i < (len); i++) {
|
|
|
|
st25r3916ledEvtWrReg((reg + i), vals[i]);
|
2020-10-18 22:09:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2022-01-05 16:10:18 +00:00
|
|
|
void st25r3916ledEvtCmd(uint8_t cmd) {
|
|
|
|
if((cmd >= ST25R3916_CMD_TRANSMIT_WITH_CRC) &&
|
|
|
|
(cmd <= ST25R3916_CMD_RESPONSE_RF_COLLISION_N)) {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledFieldOff();
|
|
|
|
}
|
2022-01-05 16:10:18 +00:00
|
|
|
|
|
|
|
if(cmd == ST25R3916_CMD_UNMASK_RECEIVE_DATA) {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledRxOff();
|
|
|
|
}
|
2022-01-05 16:10:18 +00:00
|
|
|
|
|
|
|
if(cmd == ST25R3916_CMD_SET_DEFAULT) {
|
2020-10-18 22:09:48 +00:00
|
|
|
st25r3916ledFieldOff();
|
|
|
|
st25r3916ledRxOff();
|
|
|
|
}
|
|
|
|
}
|