Fork of my original MQTTGateway
SPIRIT_Irq.h File Reference
Configuration and management of SPIRIT IRQs. More...
Go to the source code of this file.
Data Structures | |
struct | SpiritIrqs |
IRQ bitfield structure for SPIRIT. More... | |
Enumerations | |
enum | IrqList { RX_DATA_READY = 0x00000001, RX_DATA_DISC = 0x00000002, TX_DATA_SENT = 0x00000004, MAX_RE_TX_REACH = 0x00000008, CRC_ERROR = 0x00000010, TX_FIFO_ERROR = 0x00000020, RX_FIFO_ERROR = 0x00000040, TX_FIFO_ALMOST_FULL = 0x00000080, TX_FIFO_ALMOST_EMPTY = 0x00000100, RX_FIFO_ALMOST_FULL = 0x00000200, RX_FIFO_ALMOST_EMPTY = 0x00000400, MAX_BO_CCA_REACH = 0x00000800, VALID_PREAMBLE = 0x00001000, VALID_SYNC = 0x00002000, RSSI_ABOVE_TH = 0x00004000, WKUP_TOUT_LDC = 0x00008000, READY = 0x00010000, STANDBY_DELAYED = 0x00020000, LOW_BATT_LVL = 0x00040000, POR = 0x00080000, BOR = 0x00100000, LOCK = 0x00200000, PM_COUNT_EXPIRED = 0x00400000, XO_COUNT_EXPIRED = 0x00800000, SYNTH_LOCK_TIMEOUT = 0x01000000, SYNTH_LOCK_STARTUP = 0x02000000, SYNTH_CAL_TIMEOUT = 0x04000000, TX_START_TIME = 0x08000000, RX_START_TIME = 0x10000000, RX_TIMEOUT = 0x20000000, AES_END = 0x40000000, ALL_IRQ = 0x7FFFFFFF } |
IRQ list enumeration for SPIRIT. More... | |
Functions | |
void | SpiritIrqDeInit (SpiritIrqs *pxIrqInit) |
De initializate the SpiritIrqs structure setting all the bitfield to 0. | |
void | SpiritIrqInit (SpiritIrqs *pxIrqInit) |
Enables all the IRQs according to the user defined pxIrqInit structure. | |
void | SpiritIrq (IrqList xIrq, SpiritFunctionalState xNewState) |
Enables or disables a specific IRQ. | |
void | SpiritIrqGetMask (SpiritIrqs *pxIrqMask) |
Fills a pointer to a structure of SpiritIrqs type reading the IRQ_MASK registers. | |
void | SpiritIrqGetStatus (SpiritIrqs *pxIrqStatus) |
Filla a pointer to a structure of SpiritIrqs type reading the IRQ_STATUS registers. | |
void | SpiritIrqClearStatus (void) |
Clear the IRQ status registers. | |
SpiritBool | SpiritIrqCheckFlag (IrqList xFlag) |
Verifies if a specific IRQ has been generated. |
Detailed Description
Configuration and management of SPIRIT IRQs.
- Version:
- 3.2.2
- Date:
- 08-July-2015
On the Spirit side specific IRQs can be enabled by setting a specific bitmask. The Spirit libraries allow the user to do this in two different ways:
-
The first enables the IRQs one by one, i.e. using an SPI transaction for each IRQ to enable.
Example:
SpiritIrqDeInit(NULL); // this call is used to reset the IRQ mask registers SpiritIrq(RX_DATA_READY , S_ENABLE); SpiritIrq(VALID_SYNC , S_ENABLE); SpiritIrq(RX_TIMEOUT , S_ENABLE);
-
The second strategy is to set the IRQ bitfields structure. So, during the initialization the user has to fill the SpiritIrqs structure setting to one the single field related to the IRQ he wants to enable, and to zero the single field related to all the IRQs he wants to disable.
Example:
SpiritIrqs irqMask; ... SpiritIrqDeInit(&irqMask); // this call is used to reset the IRQ mask registers // and to set to 0x00000000 the irq mask in order to disable // all IRQs (disabled by default on startup) irqMask.IRQ_RX_DATA_READY = 1; irqMask.IRQ_VALID_SYNC = 1; irqMask.IRQ_RX_TIMEOUT = 1; ...
The most applications will require a Spirit IRQ notification on an microcontroller EXTI line. Then, the user can check which IRQ has been raised using two different ways.
On the ISR of the EXTI line phisically linked to the Spirit pin configured for IRQ:
-
Check only one Spirit IRQ (because the Spirit IRQ status register automatically blanks itself after an SPI reading) into the ISR.
Example:
if(SpiritIrqCheckFlag(RX_DATA_READY )) { // do something... }
-
Check more than one Spirit IRQ status by storing the entire IRQ status registers into a bitfields SpiritIrqs structure and then check the interested bits.
Example:
SpiritIrqGetStatus(&irqStatus); if(irqStatus.IRQ_RX_DATA_READY) { // do something... } if(irqStatus.IRQ_VALID_SYNC) { // do something... } if(irqStatus.RX_TIMEOUT) { // do something... }
- Attention:
© COPYRIGHT(c) 2015 STMicroelectronics
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file SPIRIT_Irq.h.
Generated on Tue Jul 12 2022 18:06:47 by 1.7.2