The MAC Core Layer (MCL) abstracts and implements IEEE 802.15.4-2006 compliant behavior for non-beacon enabled and beacon-enabled network support.
Macros | |
#define | MAKE_MAC_BUSY() |
This macro sets the MAC to busy. More... | |
#define | MAKE_MAC_NOT_BUSY() |
This macro sets the MAC to not busy. More... | |
Functions | |
void | dispatch_event (uint8_t *event) |
Obtains the message type from the buffer and calls the respective handler. More... | |
void | flush_gts_queues (void) |
void | handle_gts_data_req (mcps_data_req_t *data_req, uint8_t *msg) |
void | handle_gts_data_tx_end (void) |
void | handle_gts_sync_loss (void) |
void | init_gts_queues (void) |
uint8_t | mac_add_gts_info (uint8_t *frame_ptr) |
void | mac_gen_mcps_data_conf (buffer_t *buf_ptr, uint8_t status, uint8_t handle, uint32_t timestamp) |
void | mac_gen_mlme_gts_conf (buffer_t *buf_ptr, uint8_t status, gts_char_t gts_char) |
void | mac_gts_table_update (void) |
void | mac_idle_trans (void) |
Resets the MAC helper variables and transition to idle state. More... | |
void | mac_parse_bcn_gts_info (uint8_t gts_count, uint8_t gts_dir, mac_gts_list_t *gts_list_ptr) |
void | mac_process_data_frame (buffer_t *buf_ptr) |
Processes data frames. More... | |
void | mac_process_gts_request (buffer_t *gts_req) |
void | mac_process_tal_data_ind (uint8_t *msg) |
Depending on received frame the appropriate function is called. More... | |
void | mac_sleep_trans (void) |
Puts the radio to sleep if this is allowed. More... | |
void | mac_t_gts_cb (void *callback_parameter) |
void | mac_trx_init_sleep (void) |
MAC function to put the radio to sleep mode. More... | |
void | mac_trx_wakeup (void) |
MAC function to wake-up the radio from sleep state. More... | |
void | mac_tx_gts_data (queue_t *gts_data) |
void | reset_gts_expiry (mac_pan_gts_mgmt_t *mac_pan_gts_entry) |
void | reset_gts_globals (void) |
retval_t | set_tal_pib_internal (uint8_t attribute, pib_value_t *attribute_value) |
Wakes-up the radio and sets the corresponding TAL PIB attribute. More... | |
#define MAKE_MAC_BUSY | ( | ) |
This macro sets the MAC to busy.
Referenced by mac_process_tal_tx_status(), mac_tx_gts_data(), mcps_data_request(), and mlme_gts_request().
#define MAKE_MAC_NOT_BUSY | ( | ) |
This macro sets the MAC to not busy.
Referenced by tal_tx_frame_done_cb().
void dispatch_event | ( | uint8_t * | event | ) |
Obtains the message type from the buffer and calls the respective handler.
This function decodes all events/messages and calls the appropriate handler.
event | Pointer to the buffer header whose body part holds the message type and message elemnets |
References Assert, CMD_ID_OCTET, event, LAST_MESSAGE, NULL, and PGM_READ_WORD.
Referenced by mac_task(), and wpan_task().
void flush_gts_queues | ( | void | ) |
References dev_tx_gts_q, gts_q, and MAX_GTS_ON_PANC.
Referenced by flush_queues().
void handle_gts_data_req | ( | mcps_data_req_t * | data_req, |
uint8_t * | msg | ||
) |
References ADDR_COPY_DST_SRC_16, frame_info_tag::buffer_header, calc_frame_transmit_duration(), dev_tx_gts_q, DEV_TX_SLOT_INDEX, mcps_data_req_tag::DstAddr, GTS_RX_SLOT, if(), MAC_ACTIVE_CFP_GTS1, MAC_ASSOCIATED, MAC_CHANNEL_ACCESS_FAILURE, mac_pib_tag::mac_CoordShortAddress, mac_dev_gts_table, MAC_DEV_GTS_TX, MAC_FRAME_TOO_LONG, mac_gen_mcps_data_conf(), MAC_INVALID_GTS, MAC_PAN_COORD_STARTED, mac_pan_gts_table_len, mac_pib, mac_state, mac_superframe_state, mac_tx_gts_data(), frame_info_tag::mpdu, mcps_data_req_tag::msduHandle, NULL, QUEUE_FULL, sw_timer_get_residual_time(), T_CAP, TAL_CONVERT_SYMBOLS_TO_US, TAL_GET_SUPERFRAME_DURATION_TIME, tal_pib, and transmit_frame().
Referenced by mcps_data_request().
void handle_gts_data_tx_end | ( | void | ) |
void handle_gts_sync_loss | ( | void | ) |
void init_gts_queues | ( | void | ) |
References dev_tx_gts_q, mac_pan_gts_mgmt_tag::gts_data_q, gts_q, and MAX_GTS_ON_PANC.
Referenced by reset_gts_globals().
uint8_t mac_add_gts_info | ( | uint8_t * | frame_ptr | ) |
References mac_pan_gts_mgmt_tag::DevShortAddr, ENTER_CRITICAL_REGION, GTS_RX_SLOT, mac_pan_gts_mgmt_tag::GtsDesc, mac_gts_spec_tag::GtsDescCount, mac_gts_spec_tag::GtsPermit, LEAVE_CRITICAL_REGION, mac_pib_tag::mac_GTSPermit, mac_pib, MAX_GTS_ON_PANC, mac_pan_gts_mgmt_tag::PersistenceCount, and mac_gts_spec_tag::Reserved.
void mac_gen_mcps_data_conf | ( | buffer_t * | buf_ptr, |
uint8_t | status, | ||
uint8_t | handle, | ||
uint32_t | timestamp | ||
) |
References mcps_data_conf_tag::cmdcode, mac_nhle_q, MCPS_DATA_CONFIRM, mcps_data_conf_tag::msduHandle, mcps_data_conf_tag::status, and mcps_data_conf_tag::Timestamp.
Referenced by handle_gts_data_req(), mac_process_tal_tx_status(), mac_tx_gts_data(), mcps_data_request(), and process_deallocate_data_q().
void mac_gen_mlme_gts_conf | ( | buffer_t * | buf_ptr, |
uint8_t | status, | ||
gts_char_t | gts_char | ||
) |
References mlme_gts_conf_tag::cmdcode, mlme_gts_conf_tag::GtsChar, mac_nhle_q, MLME_GTS_CONFIRM, and mlme_gts_conf_tag::status.
Referenced by handle_gts_sync_loss(), mac_parse_bcn_gts_info(), and mlme_gts_request().
void mac_gts_table_update | ( | void | ) |
References mlme_gts_ind_tag::cmdcode, mlme_gts_ind_tag::DeviceAddr, mac_pan_gts_mgmt_tag::DevShortAddr, GTS_DEALLOCATE, mlme_gts_ind_tag::GtsChar, gts_char_tag::GtsCharType, mac_pan_gts_mgmt_tag::GtsDesc, mac_gts_desc_tag::GtsDirection, gts_char_tag::GtsDirection, mac_gts_desc_tag::GtsLength, gts_char_tag::GtsLength, mac_gts_deallocate(), mac_nhle_q, mac_pan_gts_table_len, MLME_GTS_INDICATION, NULL, and gts_char_tag::Reserved.
void mac_idle_trans | ( | void | ) |
Resets the MAC helper variables and transition to idle state.
This function sets the MAC to idle state and resets MAC helper variables
References Assert, mac_sleep_trans(), mac_soft_reset(), MAC_SUCCESS, mac_trx_wakeup(), macPANId, macPANId_def, macShortAddress, macShortAddress_def, and set_tal_pib_internal().
Referenced by mac_process_tal_data_ind(), mac_process_tal_tx_status(), and process_data_ind_not_transient().
void mac_parse_bcn_gts_info | ( | uint8_t | gts_count, |
uint8_t | gts_dir, | ||
mac_gts_list_t * | gts_list_ptr | ||
) |
References mac_gts_list_tag::dev_addr, dev_tx_gts_q, DEV_TX_SLOT_INDEX, GTS_ALLOCATE, GTS_DEALLOCATE, GTS_STATE_ALLOCATED, GTS_STATE_IDLE, GTS_STATE_REQ_SENT, gts_char_tag::GtsCharType, gts_char_tag::GtsDirection, gts_char_tag::GtsLength, if(), mac_gts_list_tag::length, mac_pib_tag::mac_CoordShortAddress, MAC_DENIED, mac_dev_gts_table, mac_gen_mlme_gts_conf(), mac_pib, mac_send_gts_ind(), MAC_SUCCESS, process_deallocate_data_q(), gts_char_tag::Reserved, mac_gts_list_tag::starting_slot, and tal_pib.
void mac_process_data_frame | ( | buffer_t * | buf_ptr | ) |
Processes data frames.
This function processes the data frames received and sends mcps_data_indication to the NHLE.
buf_ptr | Pointer to receive buffer of the data frame |
References ADDR_COPY_DST_SRC_16, ADDR_COPY_DST_SRC_64, frame_payload_t::data, parse_tag::dest_addr, parse_tag::dest_addr_mode, parse_tag::dest_panid, parse_tag::fcf, FCF_FRAME_PENDING, FCF_LONG_ADDR, FCF_SHORT_ADDR, GTS_TX_SLOT, address_field_t::long_address, mac_last_dsn, mac_last_src_addr, mac_nhle_q, MAC_PAN_COORD_STARTED, mac_pan_gts_table, mac_pan_gts_table_len, mac_parse_data, parse_tag::mac_payload_data, parse_tag::mac_payload_length, mac_sleep_trans(), mac_state, MCPS_DATA_INDICATION, NULL, mac_data_payload_tag::payload, port_pin_toggle_output_level(), parse_tag::ppdu_link_quality, reset_gts_expiry(), parse_tag::sequence_number, address_field_t::short_address, parse_tag::src_addr, parse_tag::src_addr_mode, parse_tag::src_panid, and parse_tag::time_stamp.
Referenced by mac_process_tal_data_ind(), and process_data_ind_not_transient().
void mac_process_gts_request | ( | buffer_t * | gts_req | ) |
References mlme_gts_ind_tag::cmdcode, mlme_gts_ind_tag::DeviceAddr, GTS_ALLOCATE, frame_payload_t::gts_req_data, mlme_gts_ind_tag::GtsChar, mac_gts_allocate(), mac_gts_deallocate(), mac_nhle_q, mac_parse_data, parse_tag::mac_payload_data, MLME_GTS_INDICATION, address_field_t::short_address, and parse_tag::src_addr.
Referenced by process_data_ind_not_transient().
void mac_process_tal_data_ind | ( | uint8_t * | msg | ) |
Depending on received frame the appropriate function is called.
msg | Pointer to the buffer header. |
References Assert, ASSOCIATIONREQUEST, ASSOCIATIONRESPONSE, BEACONREQUEST, COORDINATORREALIGNMENT, DATAREQUEST, DISASSOCIATIONNOTIFICATION, FCF_FRAMETYPE_DATA, FCF_FRAMETYPE_MAC_CMD, parse_tag::frame_type, LQI_LEN, MAC_AWAIT_ASSOC_RESPONSE, mac_busy, parse_tag::mac_command, MAC_COORDINATOR, mac_idle_trans(), mac_parse_data, MAC_POLL_EXPLICIT, MAC_POLL_IDLE, MAC_POLL_IMPLICIT, mac_poll_state, mac_process_data_frame(), MAC_SCAN_IDLE, mac_scan_state, mac_state, frame_info_tag::mpdu, parse_tag::mpdu_length, ORPHANNOTIFICATION, pal_is_timer_running(), pal_timer_stop(), PANIDCONFLICTNOTIFICAION, parse_mpdu(), parse_tag::ppdu_link_quality, process_data_ind_not_transient(), tal_mac_q, and tal_pib.
void mac_sleep_trans | ( | void | ) |
Puts the radio to sleep if this is allowed.
References MAC_INACTIVE, mac_pib, mac_rx_enabled, mac_pib_tag::mac_RxOnWhenIdle, mac_superframe_state, MAC_SYNC_NEVER, mac_sync_state, mac_trx_init_sleep(), NON_BEACON_NWK, pal_is_timer_running(), T_Beacon_Tracking_Period, and tal_pib.
Referenced by mac_coord_realignment_command_tx_success(), mac_idle_trans(), mac_init(), mac_process_data_frame(), mac_process_tal_tx_status(), mac_t_wait_for_bc_time_cb(), mcps_data_request(), mlme_reset_request(), mlme_set(), mlme_start_request(), process_data_ind_not_transient(), and set_tal_pib_internal().
void mac_t_gts_cb | ( | void * | callback_parameter | ) |
References dev_tx_gts_q, DEV_TX_SLOT_INDEX, ENTER_CRITICAL_REGION, FINAL_CAP_SLOT_DEFAULT, FUNC_PTR, mac_pan_gts_mgmt_tag::gts_data_q, mac_pan_gts_mgmt_tag::GtsDesc, mac_gts_desc_tag::GtsLength, LEAVE_CRITICAL_REGION, MAC_ACTIVE_CAP, MAC_ACTIVE_CFP_GTS1, MAC_ACTIVE_CFP_GTS2, MAC_ACTIVE_CFP_GTS3, MAC_ACTIVE_CFP_GTS4, MAC_ACTIVE_CFP_GTS5, MAC_ACTIVE_CFP_GTS6, MAC_ACTIVE_CFP_GTS7, MAC_ASSOCIATED, MAC_DEV_GTS_IDLE, MAC_DEV_GTS_IDLE1, MAC_DEV_GTS_IDLE2, mac_dev_gts_table, MAC_DEV_GTS_TX, mac_final_cap_slot, MAC_PAN_COORD_STARTED, mac_pan_gts_table_len, mac_state, mac_superframe_state, mac_t_gts_cb(), mac_trx_wakeup(), mac_tx_gts_data(), NULL, pal_timer_start(), port_pin_set_output_level(), reset_gts_expiry(), T_CAP, TAL_CONVERT_SYMBOLS_TO_US, TAL_GET_SUPERFRAME_DURATION_TIME, tal_pib, and TIMEOUT_RELATIVE.
Referenced by mac_t_gts_cb(), and process_data_ind_not_transient().
void mac_trx_init_sleep | ( | void | ) |
MAC function to put the radio to sleep mode.
References mac_radio_sleep_state, MAC_SUCCESS, pal_timer_source_select(), RADIO_AWAKE, RADIO_SLEEPING, SLEEP_MODE_1, tal_trx_sleep(), TMR_CLK_SRC_DURING_TRX_AWAKE, and TMR_CLK_SRC_DURING_TRX_SLEEP.
Referenced by mac_sleep_trans().
void mac_trx_wakeup | ( | void | ) |
MAC function to wake-up the radio from sleep state.
References FAILURE, mac_radio_sleep_state, pal_timer_source_select(), RADIO_AWAKE, RADIO_SLEEPING, tal_trx_wakeup(), and TMR_CLK_SRC_DURING_TRX_AWAKE.
Referenced by mac_idle_trans(), mac_t_gts_cb(), mcps_data_request(), mlme_gts_request(), mlme_reset_request(), mlme_set(), mlme_start_request(), process_data_ind_not_transient(), and set_tal_pib_internal().
void mac_tx_gts_data | ( | queue_t * | gts_data | ) |
References Assert, frame_info_tag::buffer_header, FCF_SECURITY_ENABLED, frame_info_tag::gts_queue, MAC_ACTIVE_CFP_GTS1, MAC_CHANNEL_ACCESS_FAILURE, mac_gen_mcps_data_conf(), mac_pan_gts_table_len, MAC_SUCCESS, mac_superframe_state, MAKE_MAC_BUSY, frame_info_tag::mpdu, mcps_data_req_tag::msduHandle, frame_info_tag::msduHandle, NO_CSMA_WITH_IFS, NULL, tal_tx_frame(), and transmit_frame().
Referenced by handle_gts_data_req(), handle_gts_data_tx_end(), and mac_t_gts_cb().
void reset_gts_expiry | ( | mac_pan_gts_mgmt_t * | mac_pan_gts_entry | ) |
References mac_pan_gts_mgmt_tag::ExpiryCount, GTS_EXPIRY_BO_0_TO_8, GTS_EXPIRY_BO_9_TO_14, and tal_pib.
Referenced by mac_process_data_frame(), and mac_t_gts_cb().
void reset_gts_globals | ( | void | ) |
References init_gts_queues(), mac_dev_gts_table, mac_dev_gts_table_len, mac_pan_gts_table_len, MAX_GTS_ON_DEV, and MAX_GTS_ON_PANC.
Referenced by reset_globals().
retval_t set_tal_pib_internal | ( | uint8_t | attribute, |
pib_value_t * | attribute_value | ||
) |
Wakes-up the radio and sets the corresponding TAL PIB attribute.
attribute | PIB attribute to be set |
attribute_value | Attribute value to be set |
References mac_radio_sleep_state, mac_sleep_trans(), mac_trx_wakeup(), RADIO_SLEEPING, and tal_pib_set().
Referenced by mac_coord_realignment_command_tx_success(), mac_idle_trans(), mlme_start_request(), and process_data_ind_not_transient().