68 #define IS_DIRECT_TX(MODE) (((MODE) == NORMAL_TX_MODE) || \ 69 ((MODE) == DIRECT_TX_FIFO_MODE) || \ 70 ((MODE) == DIRECT_TX_GPIO_MODE) || \ 71 ((MODE) == PN9_TX_MODE)) 73 #define IS_DIRECT_RX(MODE) (((MODE) == NORMAL_RX_MODE) || \ 74 ((MODE) == DIRECT_RX_FIFO_MODE) || \ 75 ((MODE) == DIRECT_RX_GPIO_MODE)) 78 #define IS_PKT_SEQ_NUMBER_RELOAD(SEQN) (SEQN<=3) 124 tmp &= PCKT_FRMT_REGMASK;
144 uint8_t tmpBuffer[2];
146 s_assert_param(IS_PREAMBLE_LEN(cPreambleLength));
151 tmpBuffer[0] &= ~PREAMBLE_LEN_9_8_REGMASK;
152 tmpBuffer[0] |= (cPreambleLength>>8) & PREAMBLE_LEN_9_8_REGMASK;
153 tmpBuffer[1] = cPreambleLength & PREAMBLE_LEN_7_0_REGMASK;
167 uint8_t tmpBuffer[2];
173 return ( ((((uint16_t)tmpBuffer[0])&PREAMBLE_LEN_9_8_REGMASK)<<8) | (((uint16_t)tmpBuffer[1]) + 1));
187 s_assert_param(IS_SYNC_LEN(cSyncLength));
191 tmp &= ~SYNC_LEN_REGMASK;
192 tmp |= (cSyncLength<<2);
208 return (((tmp & SYNC_LEN_REGMASK)>>2) );
222 s_assert_param(IS_SFUNCTIONAL_STATE(xNewState));
225 if(xNewState == S_ENABLE) {
226 tmp |= WHIT_EN_REGMASK;
229 tmp &= ~WHIT_EN_REGMASK;
246 if(xNewState == S_ENABLE) {
247 tmp |= FEC_EN_REGMASK;
250 tmp &= ~FEC_EN_REGMASK;
268 tmp &= ~MANCHESTER_EN_REGMASK;
269 tmp |= (((uint8_t)xNewState)<<1);
287 tmp &= ~MBUS_3OF6_EN_REGMASK;
288 tmp |= (((uint8_t)xNewState)<<2);
303 uint8_t tmpBuffer[4], tmp;
306 for(uint8_t i=0 ; i<4 ; i++) {
307 tmpBuffer[i]=(uint8_t)(lSyncWords>>(8*i));
312 tmp &= ~SYNC_LEN_REGMASK;
313 tmp |= (cSyncLength<<2);
331 uint8_t tmpBuffer[4], tmp;
336 tmp &= SYNC_LEN_REGMASK;
341 *lSyncWords = ((uint32_t)tmpBuffer[0]<<24) | ((uint32_t)tmpBuffer[1]<<16) | ((uint32_t)tmpBuffer[2]<<8) | ((uint32_t)tmpBuffer[3]);
355 s_assert_param(IS_SFUNCTIONAL_STATE(xNewState));
358 if(xNewState == S_ENABLE) {
359 tmp |= CRC_FLT_REGMASK;
362 tmp &= ~CRC_FLT_REGMASK;
529 s_assert_param(IS_DIRECT_RX(xDirectRx));
532 tmp &= ~RX_MODE_REGMASK;
533 tmp |= (uint8_t)xDirectRx;
548 return (
DirectRx)(tmp & RX_MODE_REGMASK);
562 s_assert_param(IS_DIRECT_TX(xDirectTx));
565 tmp &= ~TXSOURCE_REGMASK;
566 tmp |= (uint8_t)xDirectTx;
580 return (
DirectTx)(tmp & TXSOURCE_REGMASK);
590 uint8_t tempRegValue;
596 return (tempRegValue >> 4) & 0x07;
608 s_assert_param(IS_SFUNCTIONAL_STATE(xExtendedLenField));
611 if(xExtendedLenField == S_ENABLE) {
612 tmp |= LEN_WID_REGMASK;
615 tmp &= ~LEN_WID_REGMASK;
629 s_assert_param(IS_SFUNCTIONAL_STATE(xSwapSymbol));
632 if(xSwapSymbol == S_ENABLE) {
633 tmp |= FSK4_SYM_SWAP_REGMASK;
636 tmp &= ~FSK4_SYM_SWAP_REGMASK;
650 s_assert_param(IS_SFUNCTIONAL_STATE(xEnableSwap));
653 if(xEnableSwap == S_ENABLE) {
654 tmp |= BYTE_SWAP_REGMASK;
657 tmp &= ~BYTE_SWAP_REGMASK;
671 s_assert_param(IS_SFUNCTIONAL_STATE(xEnableSwap));
676 if(xEnableSwap == S_DISABLE) {
693 s_assert_param(IS_SFUNCTIONAL_STATE(xVarLen));
696 if(xVarLen == S_ENABLE) {
697 tmp |= FIX_VAR_LEN_REGMASK;
700 tmp &= ~FIX_VAR_LEN_REGMASK;
714 s_assert_param(IS_PKT_CRC_MODE(xPktCrcMode));
717 tmp &= ~CRC_MODE_REGMASK;
718 tmp |= (uint8_t)xPktCrcMode;
733 tmp &= ~CRC_MODE_REGMASK;
750 s_assert_param(IS_SFUNCTIONAL_STATE(xSecondarySync));
753 if(xSecondarySync == S_ENABLE) {
754 tmp |= SECOND_SYNC_SEL_REGMASK;
757 tmp &= ~SECOND_SYNC_SEL_REGMASK;
773 s_assert_param(IS_SFUNCTIONAL_STATE(xNewState));
776 if(xNewState == S_ENABLE) {
777 tmp |= AUTO_PCKT_FLT_REGMASK;
780 tmp &= ~AUTO_PCKT_FLT_REGMASK;
795 s_assert_param(IS_SFUNCTIONAL_STATE(xNewState));
798 if(xNewState == S_ENABLE) {
799 tmp |= PERS_RX_REGMASK;
802 tmp &= ~PERS_RX_REGMASK;
816 s_assert_param(IS_SFUNCTIONAL_STATE(xNewState));
819 if(xNewState == S_ENABLE) {
820 tmp |= SOURCE_ADDR_FLT_REGMASK;
823 tmp &= ~SOURCE_ADDR_FLT_REGMASK;
837 uint8_t tmpBuffer[4];
840 for(uint8_t i=0 ; i<4 ; i++) {
841 tmpBuffer[i]=(uint8_t)(lSyncWords>>(8*i));
855 uint8_t tmpBuffer[4];
858 *lSyncWords = ((uint32_t)tmpBuffer[0]<<24) | ((uint32_t)tmpBuffer[1]<<16) | ((uint32_t)tmpBuffer[2]<<8) | ((uint32_t)tmpBuffer[3]);
#define TX_PCKT_INFO_ADDR
TX_PCKT_INFO register.
uint8_t S2LPGetReceivedDestinationAddress(void)
Get the received destination address.
void S2LPPacketHandlerFec(SFunctionalState xNewState)
Enable or Disable the FEC encoding.
void S2LPPacketHandlerSwapFifoEndianess(SFunctionalState xEnableSwap)
Change the FIFO endianness .
void S2LPPacketHandlerManchester(SFunctionalState xNewState)
Enable or Disable the MANCHESTER encoding.
void S2LPSetDualSyncWords(uint32_t lSyncWords)
Set the secondary sync word.
#define PCKT_FLT_GOALS4_ADDR
PCKT_FLT_GOALS4 register.
void S2LPPacketHandlerSetTxMode(DirectTx xDirectTx)
Set the TX mode of S2LP.
void S2LPSetRxSourceMask(uint8_t mask)
Set the SOURCE_MASK .
uint8_t S2LPGetMulticastAddress(void)
Get the MULTICAST_ADDRESS set on the chip.
uint8_t S2LPGetBroadcastAddress(void)
Get the BROADCAST_ADDRESS set on the chip.
SFunctionalState
S2LP Functional state. Used to enable or disable a specific option.
void S2LPPacketHandlerSelectSecondarySync(SFunctionalState xSecondarySync)
Select the secondary sync mode. In TX if enabled: it will send the secondary sync word (from the PCKT...
#define PCKT_FLT_GOALS1_ADDR
PCKT_FLT_GOALS1 register.
uint8_t S2LPGetRxSourceReferenceAddress(void)
Get the SOURCE_REFERENCE set on the chip.
#define PROTOCOL1_ADDR
PROTOCOL1 register.
void S2LPPacketHandler3OutOf6(SFunctionalState xNewState)
Enable or Disable the 3o6 encoding.
#define PCKTCTRL6_ADDR
PCKTCTRL6 register.
uint8_t S2LPGetReceivedSourceAddress(void)
Get the received source address.
#define PCKTCTRL4_ADDR
PCKTCTRL4 register.
void S2LPPacketHandlerSwap4FSKSymbol(SFunctionalState xSwapSymbol)
Swap the 4FSK symbol mapping.
#define PCKT_FLT_GOALS0_ADDR
PCKT_FLT_GOALS0 register.
void S2LPSetMyAddress(uint8_t address)
Set the MY_ADDRESS (source address that will be transmitted).
#define PCKTCTRL2_ADDR
PCKTCTRL2 register.
void S2LPSetRxSourceReferenceAddress(uint8_t address)
Set the SOURCE_REFERENCEK.
void S2LPPacketHandlerSetRxPersistentMode(SFunctionalState xNewState)
Set the RX persistent mode. The device will be ever in RX unles an abort command comes.
#define RX_ADDRE_FIELD0_ADDR
RX_ADDRE_FIELD0 register.
#define SYNC3_ADDR
SYNC3 register.
void S2LPPacketHandlerSetVariableLength(SFunctionalState xVarLen)
Set the variable length mode.
void S2LPSetBroadcastAddress(uint8_t address)
Set the BROADCAST_ADDRESS set on the chip.
void S2LPSetSyncWords(uint32_t lSyncWords, uint8_t cSyncLength)
Set the SYNC_WORD.
Configuration and management of S2-LP WMbus packets.
uint8_t S2LPGetMyAddress(void)
Get the MY_ADDRESS set on the chip.
#define PCKTCTRL1_ADDR
PCKTCTRL1 register.
uint16_t S2LPGetPreambleLength(void)
Return the PREAMBLE field Length mode for S2LP packets.
DirectTx
Direct transmission mode enumeration for SPIRIT.
void S2LPPacketHandlerSetCrcMode(PktCrcMode xPktCrcMode)
Set the CRC mode.
PktCrcMode S2LPPacketHandlerGetCrcMode(void)
Get the CRC mode.
Configuration and management of the common features of S2-LP packets.
void S2LPSetSyncLength(uint8_t cSyncLength)
Set the SYNC field Length for S2LP packets.
void S2LPGetDualSyncWords(uint32_t *lSyncWords)
Get the secondary sync word.
void S2LPGetSyncWords(uint32_t *lSyncWords, uint8_t *cSyncLength)
Get the SYNC_WORD.
#define PROTOCOL0_ADDR
PROTOCOL0 register.
uint8_t S2LPGetSyncLength(void)
Return the SYNC field Length for S2LP packets.
void S2LPPktCommonFilterOnCrc(SFunctionalState xNewState)
Enable or Disable the filtering on CRC.
void S2LPPacketHandlerSetSrcAddrFlt(SFunctionalState xNewState)
Set the source address filtering.
volatile S2LPStatus g_xStatus
S2LP Status global variable. This global variable of S2LPStatus type is updated on every SPI transact...
uint8_t S2LPPacketHandlerGetTransmittedSeqNumber(void)
Returns the sequence number of the transmitted packet.
void S2LPPacketHandlerSetRxMode(DirectRx xDirectRx)
Set the DirectRF RX mode of S2LP.
WMbusSubmode S2LPPktWMbusGetSubmode(void)
Return the WMBUS submode used.
#define PCKTCTRL3_ADDR
PCKTCTRL3 register.
#define PCKT_FLT_GOALS3_ADDR
PCKT_FLT_GOALS3 register.
#define PCKT_FLT_GOALS2_ADDR
PCKT_FLT_GOALS2 register.
PktCrcMode
CRC length in bytes enumeration.
#define PCKT_FLT_OPTIONS_ADDR
PCKT_FLT_OPTIONS register.
void S2LPSetPreambleLength(uint16_t cPreambleLength)
Set the PREAMBLE field Length mode for S2LP packets.
uint8_t S2LPGetRxSourceMask(void)
Get the SOURCE_MASK set on the chip.
void S2LPPacketHandlerWhitening(SFunctionalState xNewState)
Enable or Disable WHITENING for S2LP packets.
Header file for low level S2LP SPI driver.
void S2LPPacketHandlerSetAutoPcktFilter(SFunctionalState xNewState)
Enable or Disable the auto packet filter mechanisms.
void S2LPPacketHandlerSetExtendedLenField(SFunctionalState xExtendedLenField)
Set the extended length field in case of variable length.
DirectRx
Direct receive mode enumeration for SPIRIT.
void S2LPPacketHandlerSwapPreamblePattern(SFunctionalState xEnableSwap)
Swap preamble pattern.
uint8_t S2LPGetPacketFormat(void)
Get the packet format.
void S2LPSetMulticastAddress(uint8_t address)
Set the MULTICAST_ADDRESS set on the chip.
DirectTx S2LPPacketHandlerGetTxMode(void)
Return the DirectRF TX mode of S2LP.
#define RX_ADDRE_FIELD1_ADDR
RX_ADDRE_FIELD1 register.
DirectRx S2LPPacketHandlerGetRxMode(void)
Return the DirectRF RX mode of S2LP.