ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers serial_mac_api.h Source File

serial_mac_api.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2016 ARM Limited. All rights reserved.
00003  *
00004  * SPDX-License-Identifier: LicenseRef-PBL
00005  *
00006  * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * https://www.mbed.com/licenses/PBL-1.0
00010  *
00011  * See the License for the specific language governing permissions and limitations under the License.
00012  *
00013  */
00014 
00015 /** \file serial_mac_api.h
00016  * \brief Serial MAC API.
00017  */
00018 
00019 #ifndef SERIAL_MAC_API_H_
00020 #define SERIAL_MAC_API_H_
00021 
00022 #include <inttypes.h>
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 struct virtual_data_req_s;
00029 
00030 typedef struct serial_mac_api_s serial_mac_api_t;
00031 
00032 extern serial_mac_api_t *serial_mac_create(int8_t serial_driver_id);
00033 
00034 /**
00035  * @brief data_request data request call
00036  * @param api API to handle the request
00037  * @param data Data to be sent
00038  * @param data_length Length of the data
00039  */
00040 typedef int8_t data_request(const serial_mac_api_t* api, const uint8_t *data_ptr, uint16_t data_length);
00041 
00042 
00043 /**
00044  * @brief data_indication Data indication is called when MAC layer has received data
00045  * @param api The API which handled the response
00046  * @param data Data to be sent
00047  * @param data_length Length of the data
00048  */
00049 typedef void data_indication(const serial_mac_api_t *api, const uint8_t *data_ptr, uint16_t data_length);
00050 
00051 /**
00052  * * @brief serial_mac_api_initialize Initialises Serial MAC layer into use
00053  * @param api API to initialize
00054  * @param ind_cb Callback to call when data is received.
00055  * @return 0 if success, -1 if api is invalid
00056  */
00057 typedef int8_t serial_mac_api_initialize(serial_mac_api_t *api, data_indication *ind_cb);
00058 
00059 /**
00060  * @brief serial_mac_virtual_initialize Initialises MAC to use virtual driver
00061  * @param api API to start using virtual driver
00062  * @param driver_id Virtual driver ID. Must be valid.
00063  * @return 0 if success, -1 if api or driver is invalid
00064  */
00065 typedef int8_t serial_mac_virtual_initialize(const serial_mac_api_t *api, int8_t driver_id);
00066 
00067 struct serial_mac_api_s {
00068     serial_mac_api_initialize   *mac_initialize;            //Inititilize data callback
00069     serial_mac_virtual_initialize * virtual_initilize;      //Enable bridge to virtual driver
00070     data_request                *data_request_cb;
00071     data_indication             *data_ind_cb;
00072 };
00073 
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077 
00078 #endif /* SERIAL_MAC_API_H_ */