Microchip® Advanced Software Framework

mac_internal.h File Reference

Declares MAC internal functions, globals, and macros.

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

#include "pal.h"
#include "tal.h"
#include "ieee_const.h"
#include "mac_data_structures.h"
#include "return_val.h"
#include "mac_msg_types.h"

Data Structures

struct  mac_pib_tag
 

Macros

#define BO_USED_FOR_MAC_PERS_TIME   (0)
 
#define DEV_RX_SLOT_INDEX   (GTS_RX_SLOT)
 
#define DEV_TX_SLOT_INDEX   (GTS_TX_SLOT)
 
#define FINAL_CAP_SLOT_DEFAULT   (0x0F)
 
#define GTS_EXPIRY_BO_0_TO_8   ((1 << ((8 - tal_pib.BeaconOrder) + 1)) + 1)
 
#define GTS_EXPIRY_BO_9_TO_14   (2 + 1)
 
#define GTS_REQ_PAYLOAD_LEN   (2)
 
#define macAckWaitDuration_def   (54)
 Default value for MIB macAckWaitDuration. More...
 
#define macMaxFrameTotalWaitTime_def   (1986)
 
#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...
 
#define MAX_GTS_ON_DEV   (4)
 
#define MAX_GTS_ON_PANC   (7)
 
#define PAN_RX_SLOT_INDEX   ((PANC_SLOT << 1) | GTS_RX_SLOT)
 
#define PAN_TX_SLOT_INDEX   ((PANC_SLOT << 1) | GTS_TX_SLOT)
 
#define PANC_SLOT   (1)
 

Typedefs

typedef void(* handler_t )(uint8_t *)
 
typedef struct mac_pib_tag mac_pib_t
 
typedef enum mac_poll_state_tag mac_poll_state_t
 MAC poll states. More...
 
typedef enum
mac_radio_sleep_state_tag 
mac_radio_sleep_state_t
 MAC sleep state type. More...
 
typedef enum mac_scan_state_tag mac_scan_state_t
 Device or coordinator scan states. More...
 
typedef __PACK__DATA__ enum
mac_state_tag 
mac_state_t
 MAC state type. More...
 
typedef enum
mac_superframe_state_tag 
mac_superframe_state_t
 MAC state type. More...
 
typedef enum mac_sync_state_tag mac_sync_state_t
 Device or coordinator sync states. More...
 

Enumerations

enum  mac_poll_state_tag {
  MAC_POLL_IDLE = 0,
  MAC_AWAIT_ASSOC_RESPONSE,
  MAC_POLL_EXPLICIT,
  MAC_POLL_IMPLICIT
}
 MAC poll states. More...
 
enum  mac_radio_sleep_state_tag {
  RADIO_AWAKE = 0,
  RADIO_SLEEPING
}
 MAC sleep state type. More...
 
enum  mac_scan_state_tag {
  MAC_SCAN_IDLE = 0,
  MAC_SCAN_ED,
  MAC_SCAN_ACTIVE,
  MAC_SCAN_ORPHAN,
  MAC_SCAN_PASSIVE
}
 Device or coordinator scan states. More...
 
enum  mac_state_tag {
  MAC_IDLE = 0,
  MAC_ASSOCIATED = 1,
  MAC_COORDINATOR = 2,
  MAC_PAN_COORD_STARTED = 3
}
 MAC state type. More...
 
enum  mac_superframe_state_tag {
  MAC_ACTIVE_CAP = 0,
  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_DEV_GTS_TX,
  MAC_DEV_GTS_IDLE,
  MAC_DEV_GTS_IDLE1,
  MAC_DEV_GTS_IDLE2,
  MAC_INACTIVE,
  MAC_NOBEACON
}
 MAC state type. More...
 
enum  mac_sync_state_tag {
  MAC_SYNC_NEVER = 0,
  MAC_SYNC_ONCE,
  MAC_SYNC_TRACKING_BEACON,
  MAC_SYNC_BEFORE_ASSOC
}
 Device or coordinator sync states. 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...
 

Variables

bool mac_bc_data_indicated
 Flag stating that the last received beacon frame from the parent indicated pending broadcast data to be received. More...
 
bool mac_busy
 MAC busy state, indicates whether MAC can process any request from NHLE. More...
 
__PACK__RST_DATA__ uint8_t * mac_conf_buf_ptr
 Holds the mlme request buffer pointer, used to give the respective confirmation in scan, poll and association. More...
 
mac_dev_gts_mgmt_t mac_dev_gts_table []
 
uint8_t mac_dev_gts_table_len
 
uint8_t mac_final_cap_slot
 Final Cap Slot of current Superframe. More...
 
uint8_t mac_last_dsn
 
uint64_t mac_last_src_addr
 
mac_pan_gts_mgmt_t mac_pan_gts_table []
 PANC table for GTS maintenance. More...
 
uint8_t mac_pan_gts_table_len
 Length of active GTS in PANC table. More...
 
parse_t mac_parse_data
 Global parse data. More...
 
mac_pib_t mac_pib
 
mac_poll_state_t mac_poll_state
 Current state of MAC poll state machine, e.g. More...
 
mac_radio_sleep_state_t mac_radio_sleep_state
 Radio sleep state. More...
 
bool mac_rx_enabled
 
mac_scan_state_t mac_scan_state
 Current state of scanning process. More...
 
mac_state_t mac_state
 Current state of the MAC state machine. More...
 
mac_superframe_state_t mac_superframe_state
 
mac_sync_state_t mac_sync_state
 Current state of syncronization with parent (either coordinator or PAN coordinator). More...
 
queue_t tal_mac_q
 Queue used by MAC for its internal operation. More...