Microchip® Advanced Software Framework

serial_if_mac.c File Reference

PRIME Serial Interface for MAC.

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

#include <string.h>
#include "compiler.h"
#include "serial_if_mac.h"
#include <mngl.h>
#include <prime.h>
#include <usi.h>

Macros

#define NOTVALID   0
 
#define VALID   1
 

Functions

static int8_t _serial_if_mac_pack_data_conf (uint16_t us_con_handle, const uint8_t *puc_data, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Data.Confirm. More...
 
static int8_t _serial_if_mac_pack_data_ind (uint16_t us_con_handle, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Data.Indication. More...
 
static int8_t _serial_if_mac_pack_establish_conf (uint16_t us_con_handle, uint8_t uc_reason, const uint8_t *puc_eui48_addr, uint8_t uc_type, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_error_type)
 This function packs the MAC callback primitive Establish.Confirm. More...
 
static int8_t _serial_if_mac_pack_establish_ind (uint16_t us_con_handle, const uint8_t *puc_eui48_addr, uint8_t uc_type, const uint8_t *puc_data, uint16_t us_data_len, uint16_t us_cf_bytes, uint8_t uc_error_type)
 This function packs the MAC callback primitive Establish.Indication. More...
 
static int8_t _serial_if_mac_pack_join_conf (uint16_t us_con_handle, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Join.Confirm. More...
 
static int8_t _serial_if_mac_pack_join_ind_base (uint16_t us_con_handle, const uint8_t *puc_eui48_addr, uint8_t uc_type, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_error_type)
 This function packs the MAC callback primitive Join.Indication.Base. More...
 
static int8_t _serial_if_mac_pack_join_ind_service (uint16_t us_con_handle, const uint8_t *puc_data, uint16_t us_data_len, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Join.Indication.Service. More...
 
static int8_t _serial_if_mac_pack_leave_conf (uint16_t us_con_handle, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Leave.Confirm. More...
 
static int8_t _serial_if_mac_pack_leave_ind_base (uint16_t us_con_handle, const uint8_t *puc_eui48_addr, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Leave.Indication.Base. More...
 
static int8_t _serial_if_mac_pack_leave_ind_service (uint16_t us_con_handle, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Leave.Indication.Service. More...
 
static int8_t _serial_if_mac_pack_release_conf (uint16_t us_con_handle, uint8_t uc_result, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Release.Confirm. More...
 
static int8_t _serial_if_mac_pack_release_ind (uint16_t us_con_handle, uint8_t uc_reason, uint8_t uc_type, uint8_t uc_error_type)
 This function packs the MAC callback primitive Release.Indication. More...
 
static int _serial_if_mac_unpack_data_req (void)
 This function extracts the MAC SAP Data.Request. More...
 
static int _serial_if_mac_unpack_establish_req (void)
 This function extracts the MAC SAP Establish.Request. More...
 
static int _serial_if_mac_unpack_establish_resp (void)
 This function extracts the MAC SAP Establish.Response. More...
 
static int _serial_if_mac_unpack_join_req_base (void)
 This function extracts the MAC SAP Join.Request.Base. More...
 
static int _serial_if_mac_unpack_join_req_service (void)
 This function extracts the MAC SAP Join.Request.Service. More...
 
static int _serial_if_mac_unpack_join_resp_base (void)
 This function extracts the MAC SAP Join.Response.Base. More...
 
static int _serial_if_mac_unpack_join_resp_service (void)
 This function extracts the MAC SAP Join.Response.Service. More...
 
static int _serial_if_mac_unpack_leave_req_base (void)
 This function extracts the MAC SAP Leave.Request.Base. More...
 
static int _serial_if_mac_unpack_leave_req_service (void)
 This function extracts the MAC SAP Leave.Request.Service. More...
 
static int _serial_if_mac_unpack_redirect_resp (void)
 This function extracts the MAC SAP Redirect.Response. More...
 
static int _serial_if_mac_unpack_release_req (void)
 This function extracts the MAC SAP Release.Request. More...
 
static int _serial_if_mac_unpack_release_resp (void)
 This function extracts the MAC SAP Release.Response. More...
 
uint8_t serial_if_mac_api_parser (uint8_t *puc_rx_msg, uint16_t us_len)
 Received message. More...
 
int8_t serial_if_mac_process (void)
 Function to encapsulate MAC Tx Control Process. More...
 

Variables

static MacSapCallBack cmd
 
static uint8_t commandMacToPack [PRIME_MACSAP_DATA_SIZE]
 
static MacSapCallBacknewMacCallBackCmd = &cmd
 
static uint8_t * puc_rx
 
static uint16_t us_rx_len
 
static uint16_t us_tx_len