Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sw_mac.h Source File

sw_mac.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2016-2019, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /** \file sw_mac.h
00019  * \brief Software MAC API.
00020  */
00021 
00022 #ifndef NS_SW_MAC_H
00023 #define NS_SW_MAC_H
00024 
00025 #include "ns_types.h"
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 struct protocol_interface_rf_mac_setup;
00032 struct mac_api_s;
00033 struct mac_description_storage_size_s;
00034 struct fhss_api;
00035 struct mac_statistics_s;
00036 struct phy_rf_statistics_s;
00037 
00038 /**
00039  * @brief Creates 802.15.4 MAC API instance which will use RF driver given
00040  * @param rf_driver_id RF driver id. Must be valid
00041  * @param storage_sizes dynamic mac storage sizes DO NOT set any values to zero !!
00042  * @return New MAC instance if successful, NULL otherwise
00043  */
00044 extern struct mac_api_s *ns_sw_mac_create(int8_t rf_driver_id, struct mac_description_storage_size_s *storage_sizes);
00045 
00046 /**
00047  * @brief ns_sw_mac_virtual_client_register registers virtual driver to be used with 802.15.4 MAC.
00048  * This is always used with serial_mac_api
00049  * @param api API to start using virtual driver
00050  * @param virtual_driver_id
00051  * @return 0 if success, -1 if api or driver is invalid
00052  */
00053 extern int8_t ns_sw_mac_virtual_client_register(struct mac_api_s *api, int8_t virtual_driver_id);
00054 
00055 /**
00056  * @brief ns_sw_mac_virtual_client_unregister Unregisters virtual driver from 802.15.4 MAC
00057  * @param api API from which to unregister virtual driver
00058  * @return 0 if success, -1 if api is invalid
00059  */
00060 extern int8_t ns_sw_mac_virtual_client_unregister(struct mac_api_s *api);
00061 
00062 /**
00063  * @brief Registers created FHSS API instance to given software MAC instance.
00064  * @param mac_api MAC instance.
00065  * @param fhss_api FHSS instance.
00066  * @return 0 on success, -1 on fail.
00067  */
00068 extern int ns_sw_mac_fhss_register(struct mac_api_s *mac_api, struct fhss_api *fhss_api);
00069 
00070 /**
00071  * @brief Request registered FHSS API instance from software MAC instance.
00072  * @param mac_api MAC instance.
00073  * @return FHSS api.
00074  */
00075 extern struct fhss_api *ns_sw_mac_get_fhss_api(struct mac_api_s *mac_api);
00076 
00077 /**
00078  * @brief Start collecting statistics from software MAC.
00079  * @param mac_api MAC instance.
00080  * @param mac_statistics Statistics storage.
00081  * @return 0 on success, -1 on fail.
00082  */
00083 extern int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_s *mac_statistics);
00084 
00085 /**
00086  * @brief Start collecting statistics from PHY driver.
00087  * @param mac_api MAC instance.
00088  * @param phy_statistics Statistics storage.
00089  * @return 0 on success, -1 on fail.
00090  */
00091 extern int ns_sw_mac_phy_statistics_start(struct mac_api_s *mac_api, struct phy_rf_statistics_s *phy_statistics);
00092 
00093 /**
00094  * @brief Read current timestamp.
00095  * @param mac_api MAC instance.
00096  * @return Current timestamp in us
00097  */
00098 extern uint32_t ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api);
00099 
00100 /**
00101  * @brief Enable or disable Frame counter per security key. SW MAC must be create before enable this feature!
00102  * @param mac_api MAC instance.
00103  * @param enable_feature True will allocate frame counter table for devices / key False will clear mode and free counter table.
00104  * @return 0 on success, -1 on fail.
00105  */
00106 extern int8_t ns_sw_mac_enable_frame_counter_per_key(struct mac_api_s *mac_api, bool enable_feature);
00107 
00108 #ifdef __cplusplus
00109 }
00110 #endif
00111 
00112 #endif // NS_SW_MAC_H