wireless/ieee802154: Cleans up some endianness issues
This commit is contained in:
parent
c5ae864624
commit
fc4f1de766
@ -251,7 +251,6 @@ void mac802154_create_datareq(FAR struct ieee802154_privmac_s *priv,
|
|||||||
FAR struct ieee802154_txdesc_s *txdesc)
|
FAR struct ieee802154_txdesc_s *txdesc)
|
||||||
{
|
{
|
||||||
FAR struct iob_s *iob;
|
FAR struct iob_s *iob;
|
||||||
FAR uint16_t *u16;
|
|
||||||
|
|
||||||
/* The only node allowed to use a source address of none is the PAN Coordinator.
|
/* The only node allowed to use a source address of none is the PAN Coordinator.
|
||||||
* PAN coordinators should not be sending data request commans.
|
* PAN coordinators should not be sending data request commans.
|
||||||
@ -269,16 +268,16 @@ void mac802154_create_datareq(FAR struct ieee802154_privmac_s *priv,
|
|||||||
iob->io_offset = 0;
|
iob->io_offset = 0;
|
||||||
iob->io_pktlen = 0;
|
iob->io_pktlen = 0;
|
||||||
|
|
||||||
/* Get a uin16_t reference to the first two bytes. ie frame control field */
|
/* Set the frame control fields */
|
||||||
|
|
||||||
u16 = (FAR uint16_t *)&iob->io_data[iob->io_len];
|
iob->io_data[0] = 0;
|
||||||
|
iob->io_data[1] = 0;
|
||||||
|
IEEE802154_SETACKREQ(iob->io_data, 0);
|
||||||
|
IEEE802154_SETFTYPE(iob->io_data, 0, IEEE802154_FRAME_COMMAND);
|
||||||
|
IEEE802154_SETDADDRMODE(iob->io_data, 0, coordaddr->mode);
|
||||||
|
IEEE802154_SETSADDRMODE(iob->io_data, 0, srcmode);
|
||||||
iob->io_len = 2;
|
iob->io_len = 2;
|
||||||
|
|
||||||
*u16 = (IEEE802154_FRAME_COMMAND << IEEE802154_FRAMECTRL_SHIFT_FTYPE);
|
|
||||||
*u16 |= IEEE802154_FRAMECTRL_ACKREQ;
|
|
||||||
*u16 |= (coordaddr->mode << IEEE802154_FRAMECTRL_SHIFT_DADDR);
|
|
||||||
*u16 |= (srcmode << IEEE802154_FRAMECTRL_SHIFT_SADDR);
|
|
||||||
|
|
||||||
/* Each time a data or a MAC command frame is generated, the MAC sublayer
|
/* Each time a data or a MAC command frame is generated, the MAC sublayer
|
||||||
* shall copy the value of macDSN into the Sequence Number field of the
|
* shall copy the value of macDSN into the Sequence Number field of the
|
||||||
* MHR of the outgoing frame and then increment it by one. [1] pg. 40.
|
* MHR of the outgoing frame and then increment it by one. [1] pg. 40.
|
||||||
@ -304,8 +303,6 @@ void mac802154_create_datareq(FAR struct ieee802154_privmac_s *priv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*u16 |= (coordaddr->mode << IEEE802154_FRAMECTRL_SHIFT_DADDR);
|
|
||||||
|
|
||||||
/* If the Destination Addressing Mode field is set to indicate that
|
/* If the Destination Addressing Mode field is set to indicate that
|
||||||
* destination addressing information is not present, the PAN ID Compression
|
* destination addressing information is not present, the PAN ID Compression
|
||||||
* field shall be set to zero and the source PAN identifier shall contain the
|
* field shall be set to zero and the source PAN identifier shall contain the
|
||||||
@ -318,7 +315,7 @@ void mac802154_create_datareq(FAR struct ieee802154_privmac_s *priv,
|
|||||||
if (coordaddr->mode != IEEE802154_ADDRMODE_NONE &&
|
if (coordaddr->mode != IEEE802154_ADDRMODE_NONE &&
|
||||||
IEEE802154_PANIDCMP(coordaddr->panid, priv->addr.panid))
|
IEEE802154_PANIDCMP(coordaddr->panid, priv->addr.panid))
|
||||||
{
|
{
|
||||||
*u16 |= IEEE802154_FRAMECTRL_PANIDCOMP;
|
IEEE802154_SETPANIDCOMP(iob->io_data, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,6 @@ int mac802154_req_associate(MACHANDLE mac,
|
|||||||
(FAR struct ieee802154_privmac_s *)mac;
|
(FAR struct ieee802154_privmac_s *)mac;
|
||||||
FAR struct ieee802154_txdesc_s *txdesc;
|
FAR struct ieee802154_txdesc_s *txdesc;
|
||||||
FAR struct iob_s *iob;
|
FAR struct iob_s *iob;
|
||||||
FAR uint16_t *u16;
|
|
||||||
bool rxonidle;
|
bool rxonidle;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -177,12 +176,13 @@ int mac802154_req_associate(MACHANDLE mac,
|
|||||||
|
|
||||||
/* Get a uin16_t reference to the first two bytes. ie frame control field */
|
/* Get a uin16_t reference to the first two bytes. ie frame control field */
|
||||||
|
|
||||||
u16 = (FAR uint16_t *)&iob->io_data[0];
|
iob->io_data[0] = 0;
|
||||||
|
iob->io_data[1] = 0;
|
||||||
|
|
||||||
*u16 = (IEEE802154_FRAME_COMMAND << IEEE802154_FRAMECTRL_SHIFT_FTYPE);
|
IEEE802154_SETACKREQ(iob->io_data, 0);
|
||||||
*u16 |= IEEE802154_FRAMECTRL_ACKREQ;
|
IEEE802154_SETFTYPE(iob->io_data, 0, IEEE802154_FRAME_COMMAND);
|
||||||
*u16 |= (priv->coordaddr.mode << IEEE802154_FRAMECTRL_SHIFT_DADDR);
|
IEEE802154_SETDADDRMODE(iob->io_data, 0, priv->coordaddr.mode);
|
||||||
*u16 |= (IEEE802154_ADDRMODE_EXTENDED << IEEE802154_FRAMECTRL_SHIFT_SADDR);
|
IEEE802154_SETSADDRMODE(iob->io_data, 0, IEEE802154_ADDRMODE_EXTENDED);
|
||||||
|
|
||||||
iob->io_len = 2;
|
iob->io_len = 2;
|
||||||
|
|
||||||
@ -281,7 +281,6 @@ int mac802154_resp_associate(MACHANDLE mac,
|
|||||||
(FAR struct ieee802154_privmac_s *)mac;
|
(FAR struct ieee802154_privmac_s *)mac;
|
||||||
FAR struct ieee802154_txdesc_s *txdesc;
|
FAR struct ieee802154_txdesc_s *txdesc;
|
||||||
FAR struct iob_s *iob;
|
FAR struct iob_s *iob;
|
||||||
FAR uint16_t *u16;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Allocate an IOB to put the frame in */
|
/* Allocate an IOB to put the frame in */
|
||||||
@ -294,10 +293,6 @@ int mac802154_resp_associate(MACHANDLE mac,
|
|||||||
iob->io_offset = 0;
|
iob->io_offset = 0;
|
||||||
iob->io_pktlen = 0;
|
iob->io_pktlen = 0;
|
||||||
|
|
||||||
/* Get a uin16_t reference to the first two bytes. ie frame control field */
|
|
||||||
|
|
||||||
u16 = (FAR uint16_t *)&iob->io_data[0];
|
|
||||||
|
|
||||||
/* The Destination Addressing Mode and Source Addressing Mode fields shall
|
/* The Destination Addressing Mode and Source Addressing Mode fields shall
|
||||||
* each be set to indicate extended addressing.
|
* each be set to indicate extended addressing.
|
||||||
*
|
*
|
||||||
@ -307,12 +302,13 @@ int mac802154_resp_associate(MACHANDLE mac,
|
|||||||
* The PAN ID Compression field shall be set to one. [1] pg. 69
|
* The PAN ID Compression field shall be set to one. [1] pg. 69
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*u16 = (IEEE802154_FRAME_COMMAND << IEEE802154_FRAMECTRL_SHIFT_FTYPE);
|
iob->io_data[0] = 0;
|
||||||
*u16 |= IEEE802154_FRAMECTRL_ACKREQ;
|
iob->io_data[1] = 0;
|
||||||
*u16 |= IEEE802154_FRAMECTRL_PANIDCOMP;
|
IEEE802154_SETACKREQ(iob->io_data, 0);
|
||||||
*u16 |= (IEEE802154_ADDRMODE_EXTENDED << IEEE802154_FRAMECTRL_SHIFT_DADDR);
|
IEEE802154_SETPANIDCOMP(iob->io_data, 0);
|
||||||
*u16 |= (IEEE802154_ADDRMODE_EXTENDED << IEEE802154_FRAMECTRL_SHIFT_SADDR);
|
IEEE802154_SETFTYPE(iob->io_data, 0, IEEE802154_FRAME_COMMAND);
|
||||||
|
IEEE802154_SETDADDRMODE(iob->io_data, 0, IEEE802154_ADDRMODE_EXTENDED);
|
||||||
|
IEEE802154_SETSADDRMODE(iob->io_data, 0, IEEE802154_ADDRMODE_EXTENDED);
|
||||||
iob->io_len = 2;
|
iob->io_len = 2;
|
||||||
|
|
||||||
/* Each time a data or a MAC command frame is generated, the MAC sublayer
|
/* Each time a data or a MAC command frame is generated, the MAC sublayer
|
||||||
|
@ -127,16 +127,31 @@
|
|||||||
#define GETNET16(ptr,index) \
|
#define GETNET16(ptr,index) \
|
||||||
((((uint16_t)((ptr)[(index) + 1])) << 8) | ((uint16_t)(((ptr)[index]))))
|
((((uint16_t)((ptr)[(index) + 1])) << 8) | ((uint16_t)(((ptr)[index]))))
|
||||||
|
|
||||||
/* PUT 16-bit data: source in host order, result in newtwork order */
|
/* Set 16-bit data: source in host order, result in network order. */
|
||||||
|
|
||||||
#define PUTHOST16(ptr,index,value) \
|
#define IEEE802154_SETBITS_U16(ptr,index,value) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
(ptr)[index] = ((uint16_t)(value) >> 8) & 0xff; \
|
(ptr)[index] |= (uint16_t)(value) & 0xff; \
|
||||||
(ptr)[index + 1] = (uint16_t)(value) & 0xff; \
|
(ptr)[index + 1] |= ((uint16_t)(value) >> 8) & 0xff; \
|
||||||
} \
|
} \
|
||||||
while(0)
|
while(0)
|
||||||
|
|
||||||
|
#define IEEE802154_SETFTYPE(ptr, index, ftype) \
|
||||||
|
IEEE802154_SETBITS_U16(ptr, index, (ftype << IEEE802154_FRAMECTRL_SHIFT_FTYPE))
|
||||||
|
|
||||||
|
#define IEEE802154_SETACKREQ(ptr, index) \
|
||||||
|
IEEE802154_SETBITS_U16(ptr, index, IEEE802154_FRAMECTRL_ACKREQ)
|
||||||
|
|
||||||
|
#define IEEE802154_SETDADDRMODE(ptr, index, mode) \
|
||||||
|
IEEE802154_SETBITS_U16(ptr, index, (mode << IEEE802154_FRAMECTRL_SHIFT_DADDR))
|
||||||
|
|
||||||
|
#define IEEE802154_SETSADDRMODE(ptr, index, mode) \
|
||||||
|
IEEE802154_SETBITS_U16(ptr, index, (mode << IEEE802154_FRAMECTRL_SHIFT_SADDR))
|
||||||
|
|
||||||
|
#define IEEE802154_SETPANIDCOMP(ptr, index) \
|
||||||
|
IEEE802154_SETBITS_U16(ptr, index, IEEE802154_FRAMECTRL_PANIDCOMP)
|
||||||
|
|
||||||
/* Configuration ************************************************************/
|
/* Configuration ************************************************************/
|
||||||
/* If processing is not done at the interrupt level, then work queue support
|
/* If processing is not done at the interrupt level, then work queue support
|
||||||
* is required.
|
* is required.
|
||||||
|
Loading…
Reference in New Issue
Block a user