Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PN512TransportDriver.h Source File

PN512TransportDriver.h

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 #ifndef MBED_PN512_TRANSPORT_DRIVER_H
00018 #define MBED_PN512_TRANSPORT_DRIVER_H
00019 
00020 #include <stdint.h>
00021 #include "stack/platform/nfc_transport.h"
00022 
00023 
00024 namespace mbed {
00025 namespace nfc {
00026 /**
00027  * The PN512 supports multiple transport mechanisms (SPI, I2C, UART): this class provides a unified API across these transports
00028  */
00029 class PN512TransportDriver {
00030 public:
00031     /**
00032      * The PN512TransportDriver delegate
00033      */
00034     struct Delegate {
00035         /**
00036          * Called when the PN512 asserts the interrupt line
00037          */
00038         virtual void on_hw_interrupt() {}
00039 
00040     protected:
00041         ~Delegate() {}
00042     };
00043 
00044     /**
00045      * Create a PN512TransportDriver instance
00046      */
00047     PN512TransportDriver();
00048 
00049     /**
00050     * PN512TransportDriver destructor.
00051     */
00052     virtual ~PN512TransportDriver();
00053 
00054     /**
00055      * Initialize transport driver and perform a chip reset
00056      */
00057     virtual void initialize() = 0;
00058 
00059     /**
00060      * Retrieve the nfc_transport_t struct for the stack to use
00061      *
00062      * @return a pointer to a nfc_transport_t struct
00063      */
00064     virtual nfc_transport_t *get_transport() = 0;
00065 
00066     /**
00067      * Set this instance's delegate
00068      *
00069      * @param[in] delegate the delegate instance to use
00070      */
00071     void set_delegate(Delegate *delegate);
00072 protected:
00073 
00074     /**
00075      * An implementation must call this function (can be called from interrupt context)
00076      * when the PN512 asserts its interrupt line
00077      */
00078     void hw_interrupt();
00079 private:
00080     Delegate *_delegate;
00081 };
00082 
00083 } // namespace nfc
00084 } // namespace mbed
00085 
00086 #endif