Microchip® Advanced Software Framework

mac.h File Reference

Provides MAC API to access MAC Layer functionality.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include <stdint.h>
#include <stdbool.h>
#include "stack_config.h"
#include "tal_generic.h"
#include "return_val.h"
#include "mac_api.h"
#include "qmm.h"
#include "mac_build_config.h"

Macros

#define FCF_ADDR_MASK   (3)
 
#define FCF_GET_DEST_ADDR_MODE(x)   (((x) >> FCF_DEST_ADDR_OFFSET) & FCF_ADDR_MASK)
 
#define FCF_GET_SOURCE_ADDR_MODE(x)   (((x) >> FCF_SOURCE_ADDR_OFFSET) & FCF_ADDR_MASK)
 

Functions

uint8_t mac_extract_mhr_addr_info (uint8_t *frame_ptr)
 
retval_t mac_init (void)
 Initializes the MAC sublayer. More...
 
bool mac_task (void)
 Runs the MAC scheduler. More...
 
void mcps_data_conf (uint8_t *m)
 Wrapper function for messages of type mcps_data_conf_t. More...
 
void mcps_data_ind (uint8_t *m)
 Wrapper function for messages of type mcps_data_ind_t. More...
 
void mcps_data_request (uint8_t *msg)
 Builds the data frame for transmission. More...
 
retval_t mlme_get (uint8_t attribute, pib_value_t *attribute_value)
 
void mlme_gts_conf (uint8_t *m)
 
void mlme_gts_ind (uint8_t *m)
 
void mlme_gts_request (uint8_t *m)
 
void mlme_reset_conf (uint8_t *m)
 Wrapper function for messages of type mlme_reset_conf_t. More...
 
void mlme_reset_request (uint8_t *m)
 Resets the MAC layer. More...
 
retval_t mlme_set (uint8_t attribute, pib_value_t *attribute_value, bool set_trx_to_sleep)
 Setting of MAC PIB attributes via functional access. More...
 
void mlme_set_conf (uint8_t *m)
 Wrapper function for messages of type mlme_set_conf_t. More...
 
void mlme_set_request (uint8_t *m)
 Handles an MLME-SET.request primitive. More...
 
void mlme_sync_loss_ind (uint8_t *m)
 Wrapper function for messages of type mlme_sync_loss_ind_t. More...
 
void mlme_sync_request (uint8_t *m)
 Implements the MLME-SYNC request. More...
 

Variables

queue_t mac_nhle_q
 Queue used by MAC for communication to next higher layer. More...
 
queue_t nhle_mac_q
 NHLE to MAC queue in which NHLE pushes all the requests to the MAC layer. More...
 

#define FCF_ADDR_MASK   (3)
#define FCF_GET_DEST_ADDR_MODE (   x)    (((x) >> FCF_DEST_ADDR_OFFSET) & FCF_ADDR_MASK)
#define FCF_GET_SOURCE_ADDR_MODE (   x)    (((x) >> FCF_SOURCE_ADDR_OFFSET) & FCF_ADDR_MASK)

retval_t mlme_get ( uint8_t  attribute,
pib_value_t attribute_value 
)
void mlme_gts_conf ( uint8_t *  m)
void mlme_gts_ind ( uint8_t *  m)
retval_t mlme_set ( uint8_t  attribute,
pib_value_t attribute_value,
bool  set_trx_to_sleep 
)

Setting of MAC PIB attributes via functional access.

In case the highest stack layer is above MAC (e.g. NWK or even higher), it is not efficient to change PIB attributes using the standard request / confirm primitive concept via the NHLE_MAC queue. In order to allow a more efficient way to change PIB attributes residing in MAC or TAL, this function replaces the standard primitive access via a functional interface.

An additional parameter allows for forcing the transceiver back to sleep after PIB setting. Otherwise the transceiver will stay awake (if it has been woken up before). This enables the higher layer to change several PIB attributes without waking up the transceiver and putting it back to sleep several times.

Parameters
attributePIB attribute to be set
attribute_indexIndex of the PIB attribute to be set
attribute_valueAttribute value to be set
set_trx_to_sleepSet TRX back to sleep after this PIB access if it was before starting this TRX access. Otherwise the transceiver state will remain as it is, i.e. in case the transceiver was woken up, it will stay awake. The default value for just changing one variable is true, i.e. the transceiver will be put back to sleep if it has been woken up.
Returns
Status of the attempt to set the TAL PIB attribute: MAC_UNSUPPORTED_ATTRIBUTE if the PIB attribute was not found MAC_SUCCESS if the attempt to set the PIB attribute was successful TAL_BUSY if the TAL is not in an idle state to change PIB attributes

References aMaxBeaconPayloadLength, DEEP_SLEEP_MODE, mac_pib_tag::mac_AutoRequest, mac_pib_tag::mac_BattLifeExtPeriods, mac_pib_tag::mac_CoordExtendedAddress, mac_pib_tag::mac_CoordShortAddress, mac_pib_tag::mac_DSN, mac_pib_tag::mac_GTSPermit, MAC_INVALID_INDEX, MAC_INVALID_PARAMETER, mac_pib_tag::mac_MaxFrameTotalWaitTime, mac_pib, mac_pib_tag::mac_ResponseWaitTime, mac_pib_tag::mac_RxOnWhenIdle, mac_pib_tag::mac_SecurityEnabled, mac_sleep_trans(), MAC_SUCCESS, mac_trx_wakeup(), MAC_UNSUPPORTED_ATTRIBUTE, macAckWaitDuration, macAssociatedPANCoord, macAssociationPermit, macAutoRequest, macBattLifeExt, macBattLifeExtPeriods, macBeaconOrder, macBeaconPayload, macBeaconPayloadLength, macBSN, macCoordExtendedAddress, macCoordShortAddress, macDSN, macGTSPermit, macIeeeAddress, macMaxBE, macMaxCSMABackoffs, macMaxFrameRetries, macMaxFrameTotalWaitTime, macMinBE, macPANCoordExtendedAddress, macPANCoordShortAddress, macPANId, macPrivateCCAFailure, macPrivateDisableACK, macPrivateIllegalFrameType, macPrivateNoDataAfterAssocReq, macPrivateVirtualPANs, macPromiscuousMode, macResponseWaitTime, macRxOnWhenIdle, macSecurityEnabled, macShortAddress, macSuperframeOrder, macTransactionPersistenceTime, PHY_RX_ON, phyCCAMode, phyCurrentChannel, phyCurrentPage, phyTransmitPower, pib_value_t::pib_value_16bit, pib_value_t::pib_value_32bit, pib_value_t::pib_value_64bit, pib_value_t::pib_value_8bit, mac_pib_tag::privateIllegalFrameType, mac_pib_tag::privateNoDataAfterAssocReq, mac_pib_tag::privateVirtualPANs, recalc_macMaxFrameTotalWaitTime(), SLEEP_MODE_1, status, tal_pib_set(), tal_rx_enable(), TAL_TRX_ASLEEP, tal_trx_sleep(), and tal_trx_wakeup().

Referenced by mlme_set_request().

queue_t nhle_mac_q

NHLE to MAC queue in which NHLE pushes all the requests to the MAC layer.

Referenced by flush_queues(), mac_init(), mac_ready_to_sleep(), mac_task(), wpan_mcps_data_req(), wpan_mlme_reset_req(), and wpan_mlme_set_req().