Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers isodep_target.h Source File

isodep_target.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2015-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 isodep_target.h
00019  * \copyright Copyright (c) ARM Ltd 2015
00020  * \author Donatien Garnier
00021  */
00022 
00023 #ifndef ISODEP_TARGET_H_
00024 #define ISODEP_TARGET_H_
00025 
00026 #include "stack/nfc_common.h"
00027 #include "transceiver/transceiver.h"
00028 #include "isodep.h"
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 struct nfc_tech_isodep_target;
00035 typedef struct nfc_tech_isodep_target nfc_tech_isodep_target_t;
00036 struct nfc_tech_isodep_target {
00037     nfc_transceiver_t *pTransceiver;
00038 
00039     struct {
00040         ac_ostream_t *pReqStream;
00041         ac_istream_t *pResStream;
00042 
00043         nfc_tech_isodep_cb_t reqCb;
00044         void *pReqUserData;
00045 
00046         nfc_tech_isodep_cb_t resCb;
00047         void *pResUserData;
00048 
00049         ac_buffer_t res;
00050         bool chaining;
00051 
00052         uint8_t blockNumber;
00053 
00054         enum {
00055             ISO_DEP_TARGET_DEP_FRAME_IDLE,
00056             ISO_DEP_TARGET_DEP_FRAME_WTX_RECEIVED,
00057             ISO_DEP_TARGET_DEP_FRAME_WTX_SENT,
00058             ISO_DEP_TARGET_DEP_FRAME_INFORMATION_RECEIVED,
00059             ISO_DEP_TARGET_DEP_FRAME_INFORMATION_SENT,
00060             ISO_DEP_TARGET_DEP_FRAME_NACK_RECEIVED,
00061             ISO_DEP_TARGET_DEP_FRAME_NACK_DIFF_BLOCK_NUMBER_RECEIVED,
00062             ISO_DEP_TARGET_DEP_FRAME_NACK_SENT,
00063             ISO_DEP_TARGET_DEP_FRAME_ACK_RECEIVED,
00064             ISO_DEP_TARGET_DEP_FRAME_ACK_SENT,
00065             ISO_DEP_TARGET_DEP_FRAME_DESELECT_RECEIVED,
00066             ISO_DEP_TARGET_DEP_FRAME_DESELECT_SENT,
00067         } frameState;
00068     } dep;
00069     struct {
00070         enum {
00071             ISO_DEP_TARGET_COMMANDS_DISCONNECTED,
00072 
00073             ISO_DEP_TARGET_COMMANDS_CONNECTING,
00074 
00075             ISO_DEP_TARGET_COMMANDS_ATS_REQ_RECVD,
00076             ISO_DEP_TARGET_COMMANDS_ATS_RES_SENT,
00077 
00078             ISO_DEP_TARGET_COMMANDS_DEP_REQ_RECVD,
00079             ISO_DEP_TARGET_COMMANDS_DEP_RES_SENT,
00080         } state;
00081 
00082         size_t inPayloadSize;
00083 
00084         ac_buffer_builder_t respBldr;
00085         uint8_t respBuf[32];
00086 
00087         ac_buffer_t *pReq;
00088     } commands;
00089 
00090     ac_buffer_t *pHist;
00091 
00092     nfc_tech_isodep_disconnected_cb disconnectedCb;
00093     void *pUserData;
00094 };
00095 
00096 //High-level Target functions
00097 void nfc_tech_isodep_target_init(nfc_tech_isodep_target_t *pIsodepTarget, nfc_transceiver_t *pTransceiver,
00098                                  ac_buffer_t *pHist, nfc_tech_isodep_disconnected_cb disconnectedCb, void *pUserData);
00099 
00100 nfc_err_t nfc_tech_isodep_target_connect(nfc_tech_isodep_target_t *pIsodepTarget);
00101 void nfc_tech_isodep_target_disconnect(nfc_tech_isodep_target_t *pIsodepTarget);
00102 
00103 nfc_err_t nfc_tech_isodep_target_transmit(nfc_tech_isodep_target_t *pIsodepTarget, ac_istream_t *pStream, nfc_tech_isodep_cb_t cb, void *pUserData);
00104 nfc_err_t nfc_tech_isodep_target_receive(nfc_tech_isodep_target_t *pIsodepTarget, ac_ostream_t *pStream, nfc_tech_isodep_cb_t cb, void *pUserData);
00105 
00106 
00107 #ifdef __cplusplus
00108 }
00109 #endif
00110 
00111 #endif /* ISODEP_TARGET_H_ */