summaryrefslogtreecommitdiff
path: root/halimpl/configs/NxpNfcCapability.cpp
blob: 3069a1672342532387af4d82ebcfe58059e68131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/******************************************************************************
 *
 *  Copyright (C) 2015 NXP Semiconductors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/
#include "NxpNfcCapability.h"
#include <phNxpLog.h>

capability* capability::instance = NULL;
tNFC_chipType capability::chipType = pn80T;

capability::capability(){}

capability* capability::getInstance() {
    if (NULL == instance) {
        instance = new capability();
    }
    return instance;
}

tNFC_chipType capability::getChipType(uint8_t* msg, uint16_t msg_len) {
    if((msg != NULL) && (msg_len != 0)) {
        uint16_t offsetHwVersion = 0;
        uint16_t offsetFwVersion = 0;
        if(msg[0] == 0x60 && msg[1] == 00) {
            /* CORE_RST_NTF*/
            offsetHwVersion = offsetRstHwVersion;
            offsetFwVersion = offsetRstFwVersion;
        } else if (msg[0] == 0x40 && msg[1] == 0x01) {
            /*CORE_INIT_RSP*/
            offsetHwVersion = offsetInitHwVersion;
            offsetFwVersion = offsetInitFwVersion;
        } else if (msg[0] == 0x00 && msg[1] == 0x0A) {
            /*Propreitary Response*/
            offsetHwVersion = offsetPropHwVersion;
            offsetFwVersion = offsetPropFwVersion;
        }
        if ((offsetHwVersion > 0) && (offsetHwVersion < msg_len)) {
            ALOGD ("%s HwVersion : 0x%02x", __func__,msg[offsetHwVersion]);
            switch(msg[offsetHwVersion]){

            case 0x40 : //A0
            case 0x41 : //B0
                        //NQ310
                if (msg[offsetFwVersion] == 0x12) {
                    chipType = pn557;
                } else {
                    chipType = pn553;
                }
                break;

            case 0x50 : //A0 + ESE
            case 0x51 : //B0 + ESE , NQ440
                        //NQ330
                if (msg[offsetFwVersion] == 0x12) {
                    chipType = pn81T;
                } else {
                    chipType = pn80T;
                }
                break;
            case 0x61:
                if(msg[offsetFwVersion] == 0x11) {
                    chipType = pn553;
                }
                break;
            case 0x98 :
                chipType = pn551;
                break;

            case 0xA8 :
            case 0x08 :
                chipType = pn67T;
                break;

            case 0x28 :
            case 0x48 : //NQ210
                chipType = pn548C2;
                break;

            case 0x18 :
            case 0x58 : //NQ220
                chipType = pn66T;
                break;

            default :
                chipType = pn80T;
            }
        }
        else {
            ALOGD ("%s Wrong msg_len. Setting Default ChiptType pn81T",__func__);
            chipType = pn81T;
        }
    }
    ALOGD ("%s NxpNci > Product : %s",__func__,product[chipType]);
    return chipType;
}

extern tNFC_chipType configChipType(uint8_t* msg, uint16_t msg_len) {
    return pConfigFL->getChipType(msg,msg_len);
}

extern tNFC_chipType getChipType() {
    ALOGD ("%s", __FUNCTION__);
    return capability::chipType;
}