Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NFCControllerDriver.h Source File

NFCControllerDriver.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_NFC_CONTROLLER_DRIVER_H
00018 #define MBED_NFC_CONTROLLER_DRIVER_H
00019 
00020 #include <stdint.h>
00021 #include "events/EventQueue.h"
00022 
00023 #include "stack/nfc_errors.h"
00024 #include "stack/transceiver/transceiver.h"
00025 #include "stack/platform/nfc_scheduler.h"
00026 
00027 namespace mbed {
00028 namespace nfc {
00029 
00030 /**
00031  * @addtogroup nfc
00032  * @{
00033  */
00034 
00035 /**
00036  * The abstraction for a NFC controller driver.
00037  * Implementers need to derive from this class and implement its methods.
00038  */
00039 class NFCControllerDriver {
00040 public:
00041     /**
00042      * Instantiate a NFCControllerDriver
00043      */
00044     NFCControllerDriver();
00045 
00046     /**
00047      * NFCControllerDriver destructor
00048      */
00049     virtual ~NFCControllerDriver();
00050 
00051     /**
00052      * The NFCControllerDriver delegate
00053      */
00054     struct Delegate {
00055         /**
00056          * Called when the controller asserts the interrupt line
00057          */
00058         virtual void on_hw_interrupt() {}
00059 
00060     protected:
00061         ~Delegate() {}
00062     };
00063 
00064     /**
00065      * Initialize the driver and retrieve the interface to the controller.
00066      *
00067      * @param[in] scheduler_timer a timer to initialize the controller's scheduler instance with
00068      * @return an initialized MicroNFC nfc_transceiver_t instance
00069      */
00070     virtual nfc_transceiver_t *initialize(nfc_scheduler_timer_t *scheduler_timer) = 0;
00071 
00072     /**
00073      * Retrieve list of technologies supported by the controller
00074      * @param[out] initiator bitmask of technologies supported when the controller is in initiator mode
00075      * @param[out] target bitmask of technologies supported when the controller is in target mode
00076      */
00077     virtual void get_supported_nfc_techs(nfc_tech_t *initiator, nfc_tech_t *target) const = 0;
00078 
00079     /**
00080      * Set this instance's delegate
00081      *
00082      * @param[in] delegate the delegate instance to use
00083      */
00084     void set_delegate(Delegate *delegate);
00085 
00086 protected:
00087     /**
00088      * An implementation must call this function (can be called from interrupt context)
00089      * when the controller asserts its interrupt line
00090      */
00091     void hw_interrupt();
00092 
00093 private:
00094     Delegate *_delegate;
00095 };
00096 
00097 /**
00098  * @}
00099  */
00100 
00101 } // namespace nfc
00102 } // namespace mbed
00103 
00104 #endif