blob: 8cbd3b186344cb2ff5ac803974f0b713eea12fd7 [file] [log] [blame]
Andrew Scull17398422017-03-01 14:43:39 +00001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Andrew Sculle416c0e2017-04-16 10:38:33 +010017#include <esecpp/NxpPn80tNqNci.h>
Andrew Scull17398422017-03-01 14:43:39 +000018ESE_INCLUDE_HW(ESE_HW_NXP_PN80T_NQ_NCI);
19
20namespace android {
Andrew Scull17398422017-03-01 14:43:39 +000021
Andrew Sculle416c0e2017-04-16 10:38:33 +010022void NxpPn80tNqNci::init() {
Will Drewrye47ba832017-04-18 17:08:09 -050023 if (mEse == nullptr) {
24 mEse = new ::EseInterface;
25 }
Andrew Scull17398422017-03-01 14:43:39 +000026 ese_init(mEse, ESE_HW_NXP_PN80T_NQ_NCI);
27}
28
Andrew Sculle416c0e2017-04-16 10:38:33 +010029int NxpPn80tNqNci::open() {
30 const int ret = ese_open(mEse, nullptr);
Andrew Scull17398422017-03-01 14:43:39 +000031 mOpen = !(ret < 0);
32 return ret;
33}
34
Andrew Sculle416c0e2017-04-16 10:38:33 +010035void NxpPn80tNqNci::close() {
Andrew Scull17398422017-03-01 14:43:39 +000036 if (mOpen) {
37 ese_close(mEse);
Andrew Scull66872902017-04-18 23:55:26 +010038 mOpen = false;
Andrew Scull17398422017-03-01 14:43:39 +000039 }
40 delete mEse;
Andrew Scull66872902017-04-18 23:55:26 +010041 mEse = nullptr;
Andrew Scull17398422017-03-01 14:43:39 +000042}
43
Andrew Scull17398422017-03-01 14:43:39 +000044} // namespace android