Mbed OS Reference
Loading...
Searching...
No Matches
nfc_transport.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2018, ARM Limited, All Rights Reserved
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17/**
18 * \file nfc_transport.h
19 * \copyright Copyright (c) ARM Ltd 2013-2018
20 * \author Donatien Garnier
21 */
22
23/** \addtogroup nfc-transport Transport
24 * \ingroup nfc
25 * @{
26 * \name Transport
27 * @{
28 */
29
30#ifndef NFC_TRANSPORT_H_
31#define NFC_TRANSPORT_H_
32
33#include "stack/nfc_common.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39
40/** Function called to write a register's value
41 * \param address address of the register to write to
42 * \param outBuf buffer to write
43 * \param outLen buffer's length
44 * \param pUser parameter passed to the nfc_transport_init function
45 */
46typedef void (*nfc_transport_write_fn_t)(uint8_t address, const uint8_t *outBuf, size_t outLen, void *pUser);
47
48/** Function called to read a register's value
49 * \param address address to read packet from
50 * \param inBuf buffer to read
51 * \param inLen buffer's length
52 * \param pUser parameter passed to the nfc_transport_init function
53 */
54typedef void (*nfc_transport_read_fn_t)(uint8_t address, uint8_t *inBuf, size_t inLen, void *pUser);
55
56typedef struct __transport {
59 void *pUser;
61
62void nfc_transport_init(nfc_transport_t *pTransport, nfc_transport_write_fn_t write, nfc_transport_read_fn_t read, void *pUser);
63
64static inline void nfc_transport_write(nfc_transport_t *pTransport, uint8_t address, const uint8_t *outBuf, size_t outLen)
65{
66 pTransport->write(address, outBuf, outLen, pTransport->pUser);
67}
68
69static inline void nfc_transport_read(nfc_transport_t *pTransport, uint8_t address, uint8_t *inBuf, size_t inLen)
70{
71 pTransport->read(address, inBuf, inLen, pTransport->pUser);
72}
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* NFC_TRANSPORT_H_ */
79
80
81/**
82 * @}
83 * @}
84 * */
85
void(* nfc_transport_write_fn_t)(uint8_t address, const uint8_t *outBuf, size_t outLen, void *pUser)
Function called to write a register's value.
Definition: nfc_transport.h:46
void(* nfc_transport_read_fn_t)(uint8_t address, uint8_t *inBuf, size_t inLen, void *pUser)
Function called to read a register's value.
Definition: nfc_transport.h:54