Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PN512Driver.cpp Source File

PN512Driver.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2018 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include "PN512Driver.h"
00018 
00019 #include "nfc/stack/platform/nfc_debug.h"
00020 
00021 using namespace mbed;
00022 using namespace mbed::nfc;
00023 
00024 PN512Driver::PN512Driver(PN512TransportDriver *transport_driver) : NFCControllerDriver(), _transport_driver(transport_driver)
00025 {
00026     _transport_driver->set_delegate(this);
00027 }
00028 
00029 nfc_transceiver_t *PN512Driver::initialize(nfc_scheduler_timer_t *scheduler_timer)
00030 {
00031     // Initialize transport
00032     _transport_driver->initialize();
00033 
00034     nfc_err_t ret = pn512_init(&_pn512, _transport_driver->get_transport(), scheduler_timer);
00035     if (ret != NFC_OK) {
00036         NFC_ERR("PN512 init error (%d)", ret);
00037         return NULL;
00038     }
00039     NFC_DBG("PN512 Initialized");
00040 
00041     return pn512_get_transceiver(&_pn512);
00042 }
00043 
00044 void PN512Driver::get_supported_nfc_techs(nfc_tech_t *initiator, nfc_tech_t *target) const
00045 {
00046     initiator->nfc_type1 = 0;
00047     initiator->nfc_type2 = 1;
00048     initiator->nfc_type3 = 1;
00049     initiator->nfc_iso_dep_a = 1;
00050     initiator->nfc_iso_dep_b = 0;
00051     initiator->nfc_nfc_dep_a = 1;
00052     initiator->nfc_nfc_dep_f_212 = 1;
00053     initiator->nfc_nfc_dep_f_424 = 1;
00054 
00055     target->nfc_type1 = 0;
00056     target->nfc_type2 = 0;
00057     target->nfc_type3 = 0;
00058     target->nfc_iso_dep_a = 1;
00059     target->nfc_iso_dep_b = 0;
00060     target->nfc_nfc_dep_a = 1;
00061     target->nfc_nfc_dep_f_212 = 1;
00062     target->nfc_nfc_dep_f_424 = 1;
00063 }
00064 
00065 void PN512Driver::on_hw_interrupt()
00066 {
00067     hw_interrupt(); // Propagate interrupt signal
00068 }