Diego Ostuni / ST25R3911
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers st25r3911_interrupt.h Source File

st25r3911_interrupt.h

Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003   * @attention
00004   *
00005   * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
00006   *
00007   * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
00008   * You may not use this file except in compliance with the License.
00009   * You may obtain a copy of the License at:
00010   *
00011   *        http://www.st.com/myliberty
00012   *
00013   * Unless required by applicable law or agreed to in writing, software
00014   * distributed under the License is distributed on an "AS IS" BASIS,
00015   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
00016   * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
00017   * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
00018   * See the License for the specific language governing permissions and
00019   * limitations under the License.
00020   *
00021 ******************************************************************************/
00022 
00023 
00024 /*
00025  *      PROJECT:   ST25R3911 firmware
00026  *      $Revision: $
00027  *      LANGUAGE:  ISO C99
00028  */
00029 
00030 /*! \file
00031  *
00032  *  \author Ulrich Herrmann
00033  *
00034  *  \brief ST25R3911 Interrupt header file
00035  *
00036  *
00037  * @addtogroup RFAL
00038  * @{
00039  *
00040  * @addtogroup RFAL-HAL
00041  * @brief RFAL Hardware Abstraction Layer
00042  * @{
00043  *
00044  * @addtogroup ST25R3911
00045  * @brief RFAL ST25R3911 Driver
00046  * @{
00047  *
00048  * @addtogroup ST25R3911_Interrupt
00049  * @brief RFAL ST25R3911 Interrupt
00050  * @{
00051  *
00052  */
00053 
00054 #ifndef ST25R3911_INTERRUPT_H
00055 #define ST25R3911_INTERRUPT_H
00056 
00057 /*
00058 ******************************************************************************
00059 * INCLUDES
00060 ******************************************************************************
00061 */
00062 #include "platform1.h"
00063 #include "ST25R3911.h"
00064 
00065 
00066 /*
00067 ******************************************************************************
00068 * GLOBAL DEFINES
00069 ******************************************************************************
00070 */
00071 
00072 /* Main interrupt register. */
00073 #define ST25R3911_IRQ_MASK_ALL             (uint32_t)(0xFFFFFF) /*!< All ST25R3911 interrupt sources. */
00074 #define ST25R3911_IRQ_MASK_NONE            (uint32_t)(0)        /*!< No ST25R3911 interrupt source. */
00075 #define ST25R3911_IRQ_MASK_OSC             (uint32_t)(0x80)     /*!< ST25R3911 oscillator stable interrupt. */
00076 #define ST25R3911_IRQ_MASK_FWL             (uint32_t)(0x40)     /*!< ST25R3911 FIFO water level interrupt. */
00077 #define ST25R3911_IRQ_MASK_RXS             (uint32_t)(0x20)     /*!< ST25R3911 start of receive interrupt. */
00078 #define ST25R3911_IRQ_MASK_RXE             (uint32_t)(0x10)     /*!< ST25R3911 end of receive interrupt. */
00079 #define ST25R3911_IRQ_MASK_TXE             (uint32_t)(0x08)     /*!< ST25R3911 end of transmission interrupt. */
00080 #define ST25R3911_IRQ_MASK_COL             (uint32_t)(0x04)     /*!< ST25R3911 bit collision interrupt. */
00081 
00082 /* Timer and NFC interrupt register. */
00083 #define ST25R3911_IRQ_MASK_DCT             (uint32_t)(0x8000)   /*!< ST25R3911 termination of direct command interrupt. */
00084 #define ST25R3911_IRQ_MASK_NRE             (uint32_t)(0x4000)   /*!< ST25R3911 no-response timer expired interrupt. */
00085 #define ST25R3911_IRQ_MASK_GPE             (uint32_t)(0x2000)   /*!< ST25R3911 general purpose timer expired interrupt. */
00086 #define ST25R3911_IRQ_MASK_EON             (uint32_t)(0x1000)   /*!< ST25R3911 external field on interrupt. */
00087 #define ST25R3911_IRQ_MASK_EOF             (uint32_t)(0x0800)   /*!< ST25R3911 external field off interrupt. */
00088 #define ST25R3911_IRQ_MASK_CAC             (uint32_t)(0x0400)   /*!< ST25R3911 collision during RF collision avoidance interrupt. */
00089 #define ST25R3911_IRQ_MASK_CAT             (uint32_t)(0x0200)   /*!< ST25R3911 minimum guard time expired interrupt. */
00090 #define ST25R3911_IRQ_MASK_NFCT            (uint32_t)(0x0100)   /*!< ST25R3911 initiator bit rate recognized interrupt. */
00091 
00092 /* Error and wake-up interrupt register. */
00093 #define ST25R3911_IRQ_MASK_CRC             (uint32_t)(0x800000) /*!< ST25R3911 CRC error interrupt. */
00094 #define ST25R3911_IRQ_MASK_PAR             (uint32_t)(0x400000) /*!< ST25R3911 parity error interrupt. */
00095 #define ST25R3911_IRQ_MASK_ERR2            (uint32_t)(0x200000) /*!< ST25R3911 soft framing error interrupt. */
00096 #define ST25R3911_IRQ_MASK_ERR1            (uint32_t)(0x100000) /*!< ST25R3911 hard framing error interrupt. */
00097 #define ST25R3911_IRQ_MASK_WT              (uint32_t)(0x080000) /*!< ST25R3911 wake-up interrupt. */
00098 #define ST25R3911_IRQ_MASK_WAM             (uint32_t)(0x040000) /*!< ST25R3911 wake-up due to amplitude interrupt. */
00099 #define ST25R3911_IRQ_MASK_WPH             (uint32_t)(0x020000) /*!< ST25R3911 wake-up due to phase interrupt. */
00100 #define ST25R3911_IRQ_MASK_WCAP            (uint32_t)(0x010000) /*!< ST25R3911 wake-up due to capacitance measurement. */
00101 
00102 
00103 #define ST25R3911_IRQ_MASK_TIM             (0x02)               /*!< additional interrupts in ST25R3911_REG_IRQ_TIMER_NFC */
00104 #define ST25R3911_IRQ_MASK_ERR             (0x01)               /*!< additional interrupts in ST25R3911_REG_IRQ_ERROR_WUP */
00105 
00106 
00107 /*
00108 ******************************************************************************
00109 * GLOBAL FUNCTION PROTOTYPES
00110 ******************************************************************************
00111 */
00112 
00113 
00114 /*!
00115  *****************************************************************************
00116  *  \brief  Wait until an ST25R3911 interrupt occurs
00117  *
00118  *  This function is used to access the ST25R3911 interrupt flags. Use this
00119  *  to wait for max. \a tmo milliseconds for the \b first interrupt indicated
00120  *  with mask \a mask to occur.
00121  *
00122  *  \param[in] mask : mask indicating the interrupts to wait for.
00123  *  \param[in] tmo : time in milliseconds until timeout occurs. If set to 0
00124  *                   the functions waits forever.
00125  *
00126  *  \return : 0 if timeout occured otherwise a mask indicating the cleared
00127  *              interrupts.
00128  *
00129  *****************************************************************************
00130  */
00131 extern uint32_t st25r3911WaitForInterruptsTimed(uint32_t mask, uint16_t tmo, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00132 
00133 /*!
00134  *****************************************************************************
00135  *  \brief  Get status for the given interrupt
00136  *
00137  *  This function is used to check whether the interrupt given by \a mask
00138  *  has occured. If yes the interrupt gets cleared. This function returns
00139  *  only status bits which are inside \a mask.
00140  *
00141  *  \param[in] mask : mask indicating the interrupt to check for.
00142  *
00143  *  \return the mask of the interrupts occurred
00144  *
00145  *****************************************************************************
00146  */
00147 extern uint32_t st25r3911GetInterrupt(uint32_t mask, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00148 
00149 
00150 /*!
00151  *****************************************************************************
00152  *  \brief  Checks if there is an interrupt
00153  *
00154  *  This function is used to check whether the interrupt given by \a mask
00155  *  has occured.
00156  *
00157  *****************************************************************************
00158  */
00159 //extern void st25r3911CheckForReceivedInterrupts( SPI* mspiChannel );
00160 
00161 
00162 /*!
00163  *****************************************************************************
00164  *  \brief  Init the 3911 interrupt
00165  *
00166  *  This function is used to check whether the interrupt given by \a mask
00167  *  has occured.
00168  *
00169  *****************************************************************************
00170  */
00171 extern void st25r3911InitInterrupts( DigitalOut* fieldLED_06 );
00172 
00173 
00174 /*!
00175  *****************************************************************************
00176  *  \brief  Modifies the Interrupt
00177  *
00178  *  This function modifies the interrupt
00179  *
00180  *  \param[in] clr_mask : bit mask to be cleared on the interrupt mask
00181  *  \param[in] set_mask : bit mask to be set on the interrupt mask
00182  *****************************************************************************
00183  */
00184 extern void st25r3911ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask,SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00185 
00186 
00187 /*!
00188  *****************************************************************************
00189  *  \brief Checks received interrupts
00190  *
00191  *  Checks received interrupts and saves the result into global params
00192  *****************************************************************************
00193  */
00194 extern void st25r3911CheckForReceivedInterrupts( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00195 
00196 
00197 /*!
00198  *****************************************************************************
00199  *  \brief  ISR Service routine
00200  *
00201  *  This function modifies the interrupt
00202  *****************************************************************************
00203  */
00204 extern void  st25r3911Isr( SPI * mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00205 
00206 /*!
00207  *****************************************************************************
00208  *  \brief  Enable a given ST25R3911 Interrupt source
00209  *
00210  *  This function enables all interrupts given by \a mask,
00211  *  ST25R3911_IRQ_MASK_ALL enables all interrupts.
00212  *
00213  *  \param[in] mask: mask indicating the interrupts to be enabled
00214  *
00215  *****************************************************************************
00216  */
00217 extern void st25r3911EnableInterrupts(uint32_t mask, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00218 
00219 /*!
00220  *****************************************************************************
00221  *  \brief  Disable one or more a given ST25R3911 Interrupt sources
00222  *
00223  *  This function disables all interrupts given by \a mask. 0xff disables all.
00224  *
00225  *  \param[in] mask: mask indicating the interrupts to be disabled.
00226  *
00227  *****************************************************************************
00228  */
00229 extern void st25r3911DisableInterrupts( uint32_t mask,SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00230 
00231 /*!
00232  *****************************************************************************
00233  *  \brief  Clear all st25r3911 irq flags
00234  *
00235  *****************************************************************************
00236  */
00237 extern void st25r3911ClearInterrupts( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00238 
00239 /*!
00240  *****************************************************************************
00241  *  \brief  Sets IRQ callback for the ST25R3911 interrupt
00242  *
00243  *****************************************************************************
00244  */
00245 extern void st25r3911IRQCallbackSet(void (*cb)());
00246 
00247 /*!
00248  *****************************************************************************
00249  *  \brief  Sets IRQ callback for the ST25R3911 interrupt
00250  *
00251  *****************************************************************************
00252  */
00253 extern void st25r3911IRQCallbackRestore(void);
00254 
00255 extern uint8_t st25r3911ChipHasWoke( void );
00256 
00257 #endif /* ST25R3911_ISR_H */
00258 
00259 /**
00260   * @}
00261   *
00262   * @}
00263   *
00264   * @}
00265   *
00266   * @}
00267   */