mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:5b88d5760320 1 /* mbed Microcontroller Library
kenjiArai 0:5b88d5760320 2 * Copyright (c) 2018 ARM Limited
kenjiArai 0:5b88d5760320 3 *
kenjiArai 0:5b88d5760320 4 * Licensed under the Apache License, Version 2.0 (the "License");
kenjiArai 0:5b88d5760320 5 * you may not use this file except in compliance with the License.
kenjiArai 0:5b88d5760320 6 * You may obtain a copy of the License at
kenjiArai 0:5b88d5760320 7 *
kenjiArai 0:5b88d5760320 8 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 0:5b88d5760320 9 *
kenjiArai 0:5b88d5760320 10 * Unless required by applicable law or agreed to in writing, software
kenjiArai 0:5b88d5760320 11 * distributed under the License is distributed on an "AS IS" BASIS,
kenjiArai 0:5b88d5760320 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 0:5b88d5760320 13 * See the License for the specific language governing permissions and
kenjiArai 0:5b88d5760320 14 * limitations under the License.
kenjiArai 0:5b88d5760320 15 */
kenjiArai 0:5b88d5760320 16
kenjiArai 0:5b88d5760320 17 #include "PN512Driver.h"
kenjiArai 0:5b88d5760320 18
kenjiArai 0:5b88d5760320 19 #include "nfc/stack/platform/nfc_debug.h"
kenjiArai 0:5b88d5760320 20
kenjiArai 0:5b88d5760320 21 using namespace mbed;
kenjiArai 0:5b88d5760320 22 using namespace mbed::nfc;
kenjiArai 0:5b88d5760320 23
kenjiArai 0:5b88d5760320 24 PN512Driver::PN512Driver(PN512TransportDriver *transport_driver) : NFCControllerDriver(), _transport_driver(transport_driver)
kenjiArai 0:5b88d5760320 25 {
kenjiArai 0:5b88d5760320 26 _transport_driver->set_delegate(this);
kenjiArai 0:5b88d5760320 27 }
kenjiArai 0:5b88d5760320 28
kenjiArai 0:5b88d5760320 29 nfc_transceiver_t *PN512Driver::initialize(nfc_scheduler_timer_t *scheduler_timer)
kenjiArai 0:5b88d5760320 30 {
kenjiArai 0:5b88d5760320 31 // Initialize transport
kenjiArai 0:5b88d5760320 32 _transport_driver->initialize();
kenjiArai 0:5b88d5760320 33
kenjiArai 0:5b88d5760320 34 nfc_err_t ret = pn512_init(&_pn512, _transport_driver->get_transport(), scheduler_timer);
kenjiArai 0:5b88d5760320 35 if (ret != NFC_OK) {
kenjiArai 0:5b88d5760320 36 NFC_ERR("PN512 init error (%d)", ret);
kenjiArai 0:5b88d5760320 37 return NULL;
kenjiArai 0:5b88d5760320 38 }
kenjiArai 0:5b88d5760320 39 NFC_DBG("PN512 Initialized");
kenjiArai 0:5b88d5760320 40
kenjiArai 0:5b88d5760320 41 return pn512_get_transceiver(&_pn512);
kenjiArai 0:5b88d5760320 42 }
kenjiArai 0:5b88d5760320 43
kenjiArai 0:5b88d5760320 44 void PN512Driver::get_supported_nfc_techs(nfc_tech_t *initiator, nfc_tech_t *target) const
kenjiArai 0:5b88d5760320 45 {
kenjiArai 0:5b88d5760320 46 initiator->nfc_type1 = 0;
kenjiArai 0:5b88d5760320 47 initiator->nfc_type2 = 1;
kenjiArai 0:5b88d5760320 48 initiator->nfc_type3 = 1;
kenjiArai 0:5b88d5760320 49 initiator->nfc_iso_dep_a = 1;
kenjiArai 0:5b88d5760320 50 initiator->nfc_iso_dep_b = 0;
kenjiArai 0:5b88d5760320 51 initiator->nfc_nfc_dep_a = 1;
kenjiArai 0:5b88d5760320 52 initiator->nfc_nfc_dep_f_212 = 1;
kenjiArai 0:5b88d5760320 53 initiator->nfc_nfc_dep_f_424 = 1;
kenjiArai 0:5b88d5760320 54
kenjiArai 0:5b88d5760320 55 target->nfc_type1 = 0;
kenjiArai 0:5b88d5760320 56 target->nfc_type2 = 0;
kenjiArai 0:5b88d5760320 57 target->nfc_type3 = 0;
kenjiArai 0:5b88d5760320 58 target->nfc_iso_dep_a = 1;
kenjiArai 0:5b88d5760320 59 target->nfc_iso_dep_b = 0;
kenjiArai 0:5b88d5760320 60 target->nfc_nfc_dep_a = 1;
kenjiArai 0:5b88d5760320 61 target->nfc_nfc_dep_f_212 = 1;
kenjiArai 0:5b88d5760320 62 target->nfc_nfc_dep_f_424 = 1;
kenjiArai 0:5b88d5760320 63 }
kenjiArai 0:5b88d5760320 64
kenjiArai 0:5b88d5760320 65 void PN512Driver::on_hw_interrupt()
kenjiArai 0:5b88d5760320 66 {
kenjiArai 0:5b88d5760320 67 hw_interrupt(); // Propagate interrupt signal
kenjiArai 0:5b88d5760320 68 }