Martijn Coenen | cbe590c | 2016-08-30 11:27:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 17 | package android.hardware.nfc@1.0; |
| 18 | |
| 19 | import INfcClientCallback; |
| 20 | |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 21 | interface INfc { |
Andreas Huber | 675ae49 | 2017-03-28 14:40:58 -0700 | [diff] [blame] | 22 | /** |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 23 | * Opens the NFC controller device and performs initialization. |
| 24 | * This may include patch download and other vendor-specific initialization. |
| 25 | * |
| 26 | * If open completes successfully, the controller should be ready to perform |
| 27 | * NCI initialization - ie accept CORE_RESET and subsequent commands through |
| 28 | * the write() call. |
| 29 | * |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 30 | * If open() returns NfcStatus::OK, the NCI stack will wait for a |
| 31 | * NfcEvent.OPEN_CPLT before continuing. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 32 | * |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 33 | * If open() returns NfcStatus::FAILED, the NCI stack will stop. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 34 | * |
| 35 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame] | 36 | @entry |
| 37 | @callflow(next={"write", "coreInitialized", "prediscover", "powerCycle", "controlGranted"}) |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 38 | open(INfcClientCallback clientCallback) generates (NfcStatus status); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 39 | |
Andreas Huber | 675ae49 | 2017-03-28 14:40:58 -0700 | [diff] [blame] | 40 | /** |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 41 | * Performs an NCI write. |
| 42 | * |
| 43 | * This method may queue writes and return immediately. The only |
| 44 | * requirement is that the writes are executed in order. |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 45 | * |
| 46 | * @return number of bytes written to the NFCC |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 47 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame] | 48 | @callflow(next={"write", "prediscover", "coreInitialized", "close", "powerCycle", |
| 49 | "controlGranted"}) |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 50 | write(NfcData data) generates (uint32_t retval); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 51 | |
Andreas Huber | 675ae49 | 2017-03-28 14:40:58 -0700 | [diff] [blame] | 52 | /** |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 53 | * coreInitialized() is called after the CORE_INIT_RSP is received from the |
| 54 | * NFCC. At this time, the HAL can do any chip-specific configuration. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 55 | * |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 56 | * If coreInitialized() returns NfcStatus::OK, the NCI stack will wait for a |
| 57 | * NfcEvent.POST_INIT_CPLT before continuing. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 58 | * |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 59 | * If coreInitialized() returns NfcStatus::FAILED, the NCI stack will |
| 60 | * continue immediately. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 61 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame] | 62 | @callflow(next={"write", "prediscover", "close"}) |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 63 | coreInitialized(NfcData data) generates (NfcStatus status); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 64 | |
Andreas Huber | 675ae49 | 2017-03-28 14:40:58 -0700 | [diff] [blame] | 65 | /** |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 66 | * prediscover is called every time before starting RF discovery. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 67 | * It is a good place to do vendor-specific configuration that must be |
| 68 | * performed every time RF discovery is about to be started. |
| 69 | * |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 70 | * If prediscover() returns NfcStatus::OK, the NCI stack will wait for a |
| 71 | * NfcEvent.PREDISCOVER_CPLT before continuing. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 72 | * |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 73 | * If prediscover() returns NfcStatus::FAILED, the NCI stack will start |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 74 | * RF discovery immediately. |
| 75 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame] | 76 | @callflow(next={"write", "close", "coreInitialized", "powerCycle", "controlGranted"}) |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 77 | prediscover() generates (NfcStatus status); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 78 | |
Andreas Huber | 675ae49 | 2017-03-28 14:40:58 -0700 | [diff] [blame] | 79 | /** |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 80 | * Close the NFC controller. Should free all resources. |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 81 | * |
| 82 | * @return NfcStatus::OK on success and NfcStatus::FAILED on error. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 83 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame] | 84 | @exit |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 85 | close() generates (NfcStatus status); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 86 | |
Andreas Huber | 675ae49 | 2017-03-28 14:40:58 -0700 | [diff] [blame] | 87 | /** |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 88 | * Grant HAL the exclusive control to send NCI commands. |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 89 | * Called in response to NfcEvent.REQUEST_CONTROL. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 90 | * Must only be called when there are no NCI commands pending. |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 91 | * NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control. |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 92 | * |
| 93 | * @return NfcStatus::OK on success and NfcStatus::FAILED on error. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 94 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame] | 95 | @callflow(next={"write", "close", "prediscover", "coreInitialized", "powerCycle"}) |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 96 | controlGranted() generates (NfcStatus status); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 97 | |
Andreas Huber | 675ae49 | 2017-03-28 14:40:58 -0700 | [diff] [blame] | 98 | /** |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 99 | * Restart controller by power cyle; |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 100 | * NfcEvent.OPEN_CPLT will notify when operation is complete. |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 101 | * |
| 102 | * @return NfcStatus::OK on success and NfcStatus::FAILED on error. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 103 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame] | 104 | @callflow(next={"write", "coreInitialized", "prediscover", "controlGranted", "close"}) |
Ruchi Kandoi | 51068e0 | 2016-11-18 14:11:33 -0800 | [diff] [blame] | 105 | powerCycle() generates (NfcStatus status); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 106 | }; |