Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nfc_transport.h Source File

nfc_transport.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2013-2018, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00006  * 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, WITHOUT
00013  * 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 nfc_transport.h
00019  * \copyright Copyright (c) ARM Ltd 2013-2018
00020  * \author Donatien Garnier
00021  */
00022 
00023 /** \addtogroup Implementation
00024  *  @{
00025  *  \name Transport
00026  *  @{
00027  */
00028 
00029 #ifndef NFC_TRANSPORT_H_
00030 #define NFC_TRANSPORT_H_
00031 
00032 #include "stack/nfc_common.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 
00039 /** Function called to write a register's value
00040  * \param address address of the register to write to
00041  * \param outBuf buffer to write
00042  * \param outLen buffer's length
00043  * \param pUser parameter passed to the nfc_transport_init function
00044  */
00045 typedef void (*nfc_transport_write_fn_t)(uint8_t address, const uint8_t *outBuf, size_t outLen, void *pUser);
00046 
00047 /** Function called to read a register's value
00048  * \param address address to read packet from
00049  * \param outBuf buffer to read
00050  * \param outLen buffer's length
00051  * \param pUser parameter passed to the nfc_transport_init function
00052  */
00053 typedef void (*nfc_transport_read_fn_t)(uint8_t address, uint8_t *inBuf, size_t inLen, void *pUser);
00054 
00055 typedef struct __transport {
00056     nfc_transport_write_fn_t write;
00057     nfc_transport_read_fn_t read;
00058     void *pUser;
00059 } nfc_transport_t;
00060 
00061 void nfc_transport_init(nfc_transport_t *pTransport, nfc_transport_write_fn_t write, nfc_transport_read_fn_t read, void *pUser);
00062 
00063 static inline void nfc_transport_write(nfc_transport_t *pTransport, uint8_t address, const uint8_t *outBuf, size_t outLen)
00064 {
00065     pTransport->write(address, outBuf, outLen, pTransport->pUser);
00066 }
00067 
00068 static inline void nfc_transport_read(nfc_transport_t *pTransport, uint8_t address, uint8_t *inBuf, size_t inLen)
00069 {
00070     pTransport->read(address, inBuf, inLen, pTransport->pUser);
00071 }
00072 
00073 #ifdef __cplusplus
00074 }
00075 #endif
00076 
00077 #endif /* NFC_TRANSPORT_H_ */
00078 
00079 
00080 /**
00081  * @}
00082  * @}
00083  * */
00084