48 #define PKT_FORMAT_BASIC_CODE 0x00 60 #define IS_BASIC_PREAMBLE_LENGTH IS_PREAMBLE_LEN 61 #define IS_BASIC_SYNC_LENGTH IS_SYNC_LEN 62 #define IS_BASIC_PKT_LEN_FIELD_WID IS_PKT_LEN_FIELD_WID 63 #define IS_BASIC_CRC_MODE IS_PKT_CRC_MODE 88 s_assert_param(IS_BASIC_PREAMBLE_LENGTH(pxPktBasicInit->
xPreambleLength));
89 s_assert_param(IS_BASIC_SYNC_LENGTH(pxPktBasicInit->
xSyncLength));
90 s_assert_param(IS_BASIC_CRC_MODE(pxPktBasicInit->
xCrcMode));
92 s_assert_param(IS_SFUNCTIONAL_STATE(pxPktBasicInit->
xFixVarLength));
93 s_assert_param(IS_SFUNCTIONAL_STATE(pxPktBasicInit->
xAddressField));
94 s_assert_param(IS_SFUNCTIONAL_STATE(pxPktBasicInit->
xFec));
95 s_assert_param(IS_SFUNCTIONAL_STATE(pxPktBasicInit->
xDataWhitening));
101 tmpBuffer[0] |= AUTO_PCKT_FLT_REGMASK;
106 tmpBuffer[2] = (((uint8_t)pxPktBasicInit->
xAddressField)<<3);
114 tmpBuffer[3] &= ~(PCKT_FRMT_REGMASK | RX_MODE_REGMASK);
115 tmpBuffer[3] |= PKT_FORMAT_BASIC_CODE;
120 tmpBuffer[4] |= FIX_VAR_LEN_REGMASK;
123 tmpBuffer[4] &= ~FIX_VAR_LEN_REGMASK;
125 tmpBuffer[4] &= ~(MANCHESTER_EN_REGMASK | MBUS_3OF6_EN_REGMASK);
127 tmpBuffer[5] &= ~(CRC_MODE_REGMASK | TXSOURCE_REGMASK);
128 tmpBuffer[5] |= (uint8_t)pxPktBasicInit->
xCrcMode;
131 tmpBuffer[5] |= WHIT_EN_REGMASK;
134 tmpBuffer[5] &= ~WHIT_EN_REGMASK;
137 if(pxPktBasicInit->
xFec == S_ENABLE)
139 tmpBuffer[5] |= FEC_EN_REGMASK;
142 tmpBuffer[5] &= ~FEC_EN_REGMASK;
148 for(uint8_t i=0 ; i<4 ; i++) {
149 tmpBuffer[i] = (uint8_t)(pxPktBasicInit->
lSyncWords>>(8*i));
162 S2LPSpiReadRegisters(
MOD1_ADDR, 1, tmpBuffer);
163 tmpBuffer[0] &= ~G4FSK_CONST_MAP_REGMASK;
164 S2LPSpiWriteRegisters(
MOD1_ADDR, 1, tmpBuffer);
176 uint8_t tmpBuffer[6];
181 pxPktBasicInit->
xSyncLength = ((tmpBuffer[0] & SYNC_LEN_REGMASK)>>2);
184 pxPktBasicInit->
xPreambleLength = (((uint16_t)(tmpBuffer[0] & PREAMBLE_LEN_9_8_REGMASK))<<8) | ((uint16_t)tmpBuffer[1]);
208 for(uint8_t i=0 ; i<4 ; i++) {
209 pxPktBasicInit->
lSyncWords |= ((uint32_t)tmpBuffer[i])<<(8*i);
223 uint8_t tmpBuffer[3];
233 tmpBuffer[0] |= DEST_VS_SOURCE_ADDR_REGMASK;
236 tmpBuffer[0] &= ~DEST_VS_SOURCE_ADDR_REGMASK;
241 tmpBuffer[0] |= DEST_VS_MULTICAST_ADDR_REGMASK;
244 tmpBuffer[0] &= ~DEST_VS_MULTICAST_ADDR_REGMASK;
249 tmpBuffer[0] |= DEST_VS_BROADCAST_ADDR_REGMASK;
252 tmpBuffer[0] &= ~DEST_VS_BROADCAST_ADDR_REGMASK;
258 tmpBuffer[2] = pxPktBasicAddresses->
cMyAddress;
274 uint8_t tmpBuffer[3];
277 pxPktBasicAddresses->
cMyAddress = tmpBuffer[0];
300 tmp &= ~(PCKT_FRMT_REGMASK | RX_MODE_REGMASK);
301 tmp |= PKT_FORMAT_BASIC_CODE;
307 tmp &= ~TXSOURCE_REGMASK;
323 s_assert_param(IS_SFUNCTIONAL_STATE(xAddressField));
326 if(xAddressField==S_ENABLE) {
327 tmp |= ADDRESS_LEN_REGMASK;
330 tmp &= ADDRESS_LEN_REGMASK;
347 if(tmp & ADDRESS_LEN_REGMASK) {
368 uint8_t tmpBuffer[2];
373 tmpBuffer[0] = (uint8_t)(nPayloadLength>>8);
374 tmpBuffer[1] = (uint8_t)nPayloadLength;
390 uint8_t tmpBuffer[2];
391 uint16_t nPayloadLength;
394 nPayloadLength = (((uint16_t)tmpBuffer[0])<<8) | ((uint16_t)tmpBuffer[1]);
399 return nPayloadLength;
409 uint8_t tmpBuffer[2];
410 uint16_t nPayloadLength;
413 nPayloadLength = (((uint16_t)tmpBuffer[0])<<8) | ((uint16_t)tmpBuffer[1]);
418 return nPayloadLength;
SFunctionalState xAddressField
SFunctionalState cExtendedPktLenField
SFunctionalState xDataWhitening
SFunctionalState xFilterOnMyAddress
uint16_t S2LPPktBasicGetReceivedPktLength(void)
Return the packet length field of the received packet.
#define MOD1_ADDR
MOD1 register.
SFunctionalState
S2LP Functional state. Used to enable or disable a specific option.
#define PROTOCOL1_ADDR
PROTOCOL1 register.
void S2LPPktBasicGetAddressesInfo(PktBasicAddressesInit *pxPktBasicAddresses)
Return the S2LP Basic packet addresses structure according to the specified parameters in the registe...
S2LP Basic Packet Init structure definition.
void S2LPPktBasicSetFormat(void)
Configure the Basic packet format as packet used by S2LP.
#define PCKTCTRL6_ADDR
PCKTCTRL6 register.
SFunctionalState xFilterOnBroadcastAddress
#define PCKTCTRL4_ADDR
PCKTCTRL4 register.
uint8_t cMulticastAddress
#define PCKTCTRL2_ADDR
PCKTCTRL2 register.
SFunctionalState xFilterOnMulticastAddress
S2LP Basic packet address structure definition. This structure allows users to specify the node/multi...
#define SYNC3_ADDR
SYNC3 register.
Configuration and management of S2-LP Basic packets.
void S2LPPktBasicGetInfo(PktBasicInit *pxPktBasicInit)
Return the S2LP Basic packet structure according to the specified parameters in the registers.
void S2LPPktBasicAddressField(SFunctionalState xAddressField)
Set the address length for S2LP Basic packets.
Configuration and management of S2-LP WMbus packets.
#define PCKTCTRL1_ADDR
PCKTCTRL1 register.
SFunctionalState xFixVarLength
void S2LPPktBasicAddressesInit(PktBasicAddressesInit *pxPktBasicAddresses)
Initialize the S2LP Basic packet addresses according to the specified parameters in the PktBasicAddre...
#define PCKTLEN1_ADDR
PCKTLEN1 register.
void S2LPPktWMbusSetSubmode(WMbusSubmode xWMbusSubmode)
Set the W-MBus submode.
#define RX_PCKT_LEN1_ADDR
RX_PCKT_LEN1 register.
volatile S2LPStatus g_xStatus
S2LP Status global variable. This global variable of S2LPStatus type is updated on every SPI transact...
#define PCKTCTRL3_ADDR
PCKTCTRL3 register.
#define PCKT_FLT_GOALS3_ADDR
PCKT_FLT_GOALS3 register.
#define PCKT_FLT_GOALS2_ADDR
PCKT_FLT_GOALS2 register.
void S2LPPktBasicInit(PktBasicInit *pxPktBasicInit)
Initialize the S2LP Basic packet according to the specified parameters in the PktBasicInit struct....
#define S2LPPktBasicFilterOnCrc(xNewState)
Enables or Disables the CRC filtering.
#define PCKT_FLT_OPTIONS_ADDR
PCKT_FLT_OPTIONS register.
uint8_t cBroadcastAddress
Header file for low level S2LP SPI driver.
void S2LPPktBasicSetPayloadLength(uint16_t nPayloadLength)
Set the payload length for S2LP Basic packets. Since the packet length depends from the address and t...
SFunctionalState S2LPPktBasicGetAddressField(void)
Specify if the Address field for S2LP Basic packets is enabled or disabled.
uint16_t S2LPPktBasicGetPayloadLength(void)
Return the payload length for S2LP Basic packets. Since the packet length depends from the address an...
PktCrcMode BasicCrcMode
CRC length in bytes enumeration.