| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2012, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bscd_priv.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/27 $ |
|---|
| 12 | * $brcm_Date: 3/2/12 11:39a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: This file contains Broadcom smart card Porting |
|---|
| 15 | * Interface private functions. |
|---|
| 16 | * |
|---|
| 17 | * Revision History: |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/scd/7346/bscd_priv.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/27 3/2/12 11:39a qxie |
|---|
| 21 | * SW7231-667:incorrect detection of SCD state |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/26 1/5/12 4:16p qxie |
|---|
| 24 | * SW7346-23: minor fixed to backward compatible with 7346A0 |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/25 12/15/11 10:37a qxie |
|---|
| 27 | * SW7346-23: add support 36.864Mhz clock for B0 |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/24 12/1/11 4:10p qxie |
|---|
| 30 | * SW7346-23: add support to E* direct connect card |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/23 10/25/11 3:28p qxie |
|---|
| 33 | * SW7346-23: add support to 7425 B0 |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/22 9/30/11 11:43a qxie |
|---|
| 36 | * SW7346-23: add support to 7425 A1. Change to atomicUpdate32 for some |
|---|
| 37 | * of the SC_PLL registers |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/21 9/8/11 10:39a qxie |
|---|
| 40 | * SW7346-23: add support to 7425 A1 |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/20 9/7/11 3:17p qxie |
|---|
| 43 | * SW7346-23: add support to 7425 B0 |
|---|
| 44 | * |
|---|
| 45 | * Hydra_Software_Devel/19 8/31/11 11:51a qxie |
|---|
| 46 | * SW7346-23: add support to B0 |
|---|
| 47 | * |
|---|
| 48 | ***************************************************************************/ |
|---|
| 49 | #include "bstd.h" |
|---|
| 50 | #include "bkni.h" |
|---|
| 51 | #include "bkni_multi.h" |
|---|
| 52 | #include "bchp_sca.h" |
|---|
| 53 | #include "bchp_scb.h" |
|---|
| 54 | |
|---|
| 55 | #include "bscd.h" |
|---|
| 56 | #include "bscd_priv.h" |
|---|
| 57 | #include "bscd_emvpriv.h" |
|---|
| 58 | #include "bchp_clkgen.h" |
|---|
| 59 | |
|---|
| 60 | #define BCHP_SCA_SC_CLK_CMD_clk_en_MASK BCHP_SCA_SC_CLK_CMD_1_clk_en_MASK |
|---|
| 61 | #define BCHP_SCA_SC_CLK_CMD_bauddiv_MASK BCHP_SCA_SC_CLK_CMD_1_bauddiv0_MASK |
|---|
| 62 | #if 1 |
|---|
| 63 | #undef BDBG_ENTER |
|---|
| 64 | #undef BDBG_LEAVE |
|---|
| 65 | #define BDBG_ENTER(x) |
|---|
| 66 | #define BDBG_LEAVE(x) |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | #define BSCD_INTERRUPT_DEBUG 1 |
|---|
| 71 | |
|---|
| 72 | BDBG_MODULE(BSCD); |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | /* Population count of 1's in a byte */ |
|---|
| 76 | static const unsigned char BSCD_P_Popcount[] = { |
|---|
| 77 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, |
|---|
| 78 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, |
|---|
| 79 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, |
|---|
| 80 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, |
|---|
| 81 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, |
|---|
| 82 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, |
|---|
| 83 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, |
|---|
| 84 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, |
|---|
| 85 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, |
|---|
| 86 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, |
|---|
| 87 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, |
|---|
| 88 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, |
|---|
| 89 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, |
|---|
| 90 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, |
|---|
| 91 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, |
|---|
| 92 | 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 |
|---|
| 93 | }; |
|---|
| 94 | |
|---|
| 95 | static const BSCD_P_DFSmartCardStruct BSCD_P_DF_EMV[4][10][14] = { |
|---|
| 96 | { |
|---|
| 97 | /*27Mhz*/ |
|---|
| 98 | /* There is an issue with old Integri that we have to go with |
|---|
| 99 | lower frequency |
|---|
| 100 | */ |
|---|
| 101 | /* D = 0 */ |
|---|
| 102 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 103 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 104 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 105 | |
|---|
| 106 | /* D = 1 */ |
|---|
| 107 | {{0x01,0x0B,0x1F,0x08}, {0x02,0x17,0x1F,0x08}, {0x01,0x11,0x1F,0x08}, |
|---|
| 108 | {0x01,0x17,0x1F,0x08}, {0x01,0x23,0x1F,0x08}, {0x01,0x2F,0x1F,0x08}, |
|---|
| 109 | {0x01,0x3B,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 110 | {0x01,0x0F,0x20,0x08}, {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}, |
|---|
| 111 | {0x01,0x2F,0x20,0x08}, {0x01,0x3F,0x20,0x08}}, |
|---|
| 112 | |
|---|
| 113 | /* D = 2 */ |
|---|
| 114 | {{0x01,0x05,0x1F,0x08}, {0x02,0x0B,0x1F,0x08}, {0x01,0x08,0x1F,0x08}, |
|---|
| 115 | {0x01,0x0B,0x1F,0x08}, {0x01,0x11,0x1F,0x08}, {0x01,0x17,0x1F,0x08}, |
|---|
| 116 | {0x01,0x1D,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 117 | {0x01,0x07,0x20,0x08}, {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}, |
|---|
| 118 | {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}}, |
|---|
| 119 | |
|---|
| 120 | /* D = 3 */ |
|---|
| 121 | {{0x01,0x02,0x1F,0x08}, {0x02,0x05,0x1F,0x08}, {0x02,0x08,0x1F,0x08}, |
|---|
| 122 | {0x01,0x05,0x1F,0x08}, {0x01,0x08,0x1F,0x08}, {0x01,0x0B,0x1F,0x08}, |
|---|
| 123 | {0x01,0x0E,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 124 | {0x01,0x03,0x20,0x08}, {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}, |
|---|
| 125 | {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}}, |
|---|
| 126 | |
|---|
| 127 | /* D = 4 */ |
|---|
| 128 | {{0x02,0x02,0x1F,0x08}, {0x02,0x02,0x1F,0x08}, {0x04,0x08,0x1F,0x04}, |
|---|
| 129 | {0x01,0x02,0x1F,0x08}, {0x02,0x08,0x1F,0x08}, {0x01,0x05,0x1F,0x08}, |
|---|
| 130 | {0x02,0x0E,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 131 | {0x01,0x01,0x20,0x08}, {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}, |
|---|
| 132 | {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}}, |
|---|
| 133 | |
|---|
| 134 | /* D = 5 */ |
|---|
| 135 | {{0x04,0x02,0x1F,0x04}, {0x04,0x02,0x1F,0x04}, {0x08,0x08,0x1F,0x02}, |
|---|
| 136 | {0x02,0x02,0x1F,0x08}, {0x04,0x08,0x1F,0x04}, {0x01,0x02,0x1F,0x08}, |
|---|
| 137 | {0x04,0x0E,0x1F,0x04}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 138 | {0x02,0x01,0x20,0x08}, {0x02,0x02,0x20,0x08}, {0x01,0x01,0x20,0x08}, |
|---|
| 139 | {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}}, |
|---|
| 140 | |
|---|
| 141 | /* D = 6 */ |
|---|
| 142 | {{0x08,0x02,0x1F,0x02}, {0x08,0x02,0x1F,0x02}, {0x10,0x08,0x1F,0x01}, |
|---|
| 143 | {0x04,0x02,0x1F,0x04}, {0x08,0x08,0x1F,0x02}, {0x02,0x02,0x1F,0x08}, |
|---|
| 144 | {0x08,0x0E,0x1F,0x02}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 145 | {0x04,0x01,0x20,0x04}, {0x04,0x02,0x20,0x04}, {0x02,0x01,0x20,0x08}, |
|---|
| 146 | {0x02,0x02,0x20,0x08}, {0x01,0x01,0x20,0x08}}, |
|---|
| 147 | |
|---|
| 148 | /* D = 7 */ |
|---|
| 149 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 150 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 151 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 152 | |
|---|
| 153 | /* D = 8 */ |
|---|
| 154 | {{0x02,0x01,0x1F,0x08}, {0x02,0x01,0x1F,0x08}, {0x02,0x02,0x1F,0x08}, |
|---|
| 155 | {0x02,0x03,0x1F,0x08}, {0x02,0x05,0x1F,0x08}, {0x02,0x07,0x1F,0x08}, |
|---|
| 156 | {0x02,0x09,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 157 | {0x03,0x03,0x20,0x08}, {0x02,0x03,0x20,0x08}, {0x03,0x07,0x20,0x08}, |
|---|
| 158 | {0x02,0x07,0x20,0x08}, {0x03,0x0F,0x20,0x08}}, |
|---|
| 159 | |
|---|
| 160 | /* D = 9 */ |
|---|
| 161 | {{0x05,0x02,0x1F,0x04}, {0x05,0x02,0x1F,0x04}, {0x0A,0x08,0x1F,0x02}, |
|---|
| 162 | {0x05,0x05,0x1F,0x04}, {0x05,0x08,0x1F,0x04}, {0x05,0x0B,0x1F,0x04}, |
|---|
| 163 | {0x02,0x05,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 164 | {0x05,0x03,0x20,0x04}, {0x05,0x05,0x20,0x04}, {0x05,0x07,0x20,0x04}, |
|---|
| 165 | {0x05,0x0B,0x20,0x04}, {0x05,0x0F,0x20,0x04}} |
|---|
| 166 | }, |
|---|
| 167 | |
|---|
| 168 | {/*36.864Mhz*/ |
|---|
| 169 | /* There is an issue with old Integri that we have to go with |
|---|
| 170 | lower frequency |
|---|
| 171 | */ |
|---|
| 172 | /* D = 0 */ |
|---|
| 173 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 174 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 175 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 176 | |
|---|
| 177 | /* D = 1 */ |
|---|
| 178 | {{0x02,0x17,0x1F,0x06}, {0x02,0x17,0x1F,0x06}, {0x02,0x23,0x1F,0x06}, |
|---|
| 179 | {0x02,0x2F,0x1F,0x06}, {0x02,0x47,0x1F,0x06}, {0x02,0x5F,0x1F,0x06}, |
|---|
| 180 | {0x02,0x77,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 181 | {0x02,0x1F,0x20,0x06}, {0x02,0x2F,0x20,0x06}, {0x02,0x3F,0x20,0x06}, |
|---|
| 182 | {0x02,0x5F,0x20,0x06}, {0x02,0x7F,0x20,0x06}}, |
|---|
| 183 | |
|---|
| 184 | /* D = 2 */ |
|---|
| 185 | {{0x02,0x0B,0x1F,0x08}, {0x02,0x0B,0x1F,0x08}, {0x02,0x11,0x1F,0x08}, |
|---|
| 186 | {0x02,0x17,0x1F,0x08}, {0x02,0x23,0x1F,0x08}, {0x02,0x2F,0x1F,0x08}, |
|---|
| 187 | {0x02,0x3B,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 188 | {0x02,0x0F,0x20,0x08}, {0x02,0x17,0x20,0x08}, {0x02,0x1F,0x20,0x08}, |
|---|
| 189 | {0x02,0x2F,0x20,0x08}, {0x02,0x3F,0x20,0x08}}, |
|---|
| 190 | |
|---|
| 191 | /* D = 3 */ |
|---|
| 192 | {{0x03,0x08,0x1F,0x06}, {0x03,0x08,0x1F,0x06}, {0x06,0x17,0x1F,0x03}, |
|---|
| 193 | {0x03,0x11,0x1F,0x06}, {0x06,0x35,0x1F,0x03}, {0x03,0x23,0x1F,0x06}, |
|---|
| 194 | {0x06,0x59,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 195 | {0x03,0x0B,0x20,0x06}, {0x03,0x11,0x20,0x06}, {0x03,0x17,0x20,0x06}, |
|---|
| 196 | {0x03,0x23,0x20,0x06}, {0x03,0x2F,0x20,0x06}}, |
|---|
| 197 | |
|---|
| 198 | /* D = 4 */ |
|---|
| 199 | {{0x02,0x02,0x1F,0x06}, {0x02,0x02,0x1F,0x06}, {0x04,0x08,0x1F,0x03}, |
|---|
| 200 | {0x02,0x05,0x1F,0x06}, {0x02,0x08,0x1F,0x06}, {0x02,0x0B,0x1F,0x06}, |
|---|
| 201 | {0x02,0x0E,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 202 | {0x02,0x03,0x20,0x06}, {0x02,0x05,0x20,0x06}, {0x02,0x07,0x20,0x06}, |
|---|
| 203 | {0x02,0x0B,0x20,0x06}, {0x02,0x0F,0x20,0x06}}, |
|---|
| 204 | |
|---|
| 205 | /* D = 5 */ |
|---|
| 206 | {{0x04,0x02,0x1F,0x03}, {0x04,0x02,0x1F,0x03}, {0x08,0x08,0x1F,0x02}, |
|---|
| 207 | {0x02,0x02,0x1F,0x06}, {0x04,0x08,0x1F,0x03}, {0x02,0x05,0x1F,0x06}, |
|---|
| 208 | {0x04,0x0E,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 209 | {0x02,0x01,0x20,0x06}, {0x02,0x02,0x20,0x06}, {0x02,0x03,0x20,0x06}, |
|---|
| 210 | {0x02,0x05,0x20,0x06}, {0x02,0x07,0x20,0x06}}, |
|---|
| 211 | |
|---|
| 212 | /* D = 6 */ |
|---|
| 213 | {{0x08,0x02,0x1F,0x02}, {0x08,0x02,0x1F,0x02}, {0x10,0x08,0x1F,0x01}, |
|---|
| 214 | {0x04,0x02,0x1F,0x03}, {0x08,0x08,0x1F,0x02}, {0x04,0x05,0x1F,0x03}, |
|---|
| 215 | {0x08,0x0E,0x1F,0x02}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 216 | {0x04,0x01,0x20,0x03}, {0x04,0x02,0x20,0x03}, {0x02,0x01,0x20,0x06}, |
|---|
| 217 | {0x02,0x02,0x20,0x06}, {0x02,0x03,0x20,0x06}}, |
|---|
| 218 | |
|---|
| 219 | /* D = 7 */ |
|---|
| 220 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 221 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 222 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 223 | |
|---|
| 224 | /* D = 8 */ |
|---|
| 225 | {{0x02,0x01,0x1F,0x06}, {0x02,0x01,0x1F,0x06}, {0x02,0x02,0x1F,0x06}, |
|---|
| 226 | {0x02,0x03,0x1F,0x06}, {0x02,0x05,0x1F,0x06}, {0x02,0x07,0x1F,0x06}, |
|---|
| 227 | {0x02,0x09,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 228 | {0x03,0x03,0x20,0x04}, {0x02,0x03,0x20,0x06}, {0x03,0x07,0x20,0x04}, |
|---|
| 229 | {0x02,0x07,0x20,0x06}, {0x03,0x0F,0x20,0x04}}, |
|---|
| 230 | |
|---|
| 231 | /* D = 9 */ |
|---|
| 232 | {{0x05,0x02,0x1F,0x04}, {0x05,0x02,0x1F,0x04}, {0x0A,0x08,0x1F,0x02}, |
|---|
| 233 | {0x05,0x05,0x1F,0x04}, {0x05,0x08,0x1F,0x04}, {0x05,0x0B,0x1F,0x04}, |
|---|
| 234 | {0x02,0x05,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 235 | {0x05,0x03,0x20,0x04}, {0x05,0x05,0x20,0x04}, {0x05,0x07,0x20,0x04}, |
|---|
| 236 | {0x05,0x0B,0x20,0x04}, {0x05,0x0F,0x20,0x04}} |
|---|
| 237 | }, |
|---|
| 238 | {/*36M */ |
|---|
| 239 | /* There is an issue with old Integri that we have to go with |
|---|
| 240 | lower frequency |
|---|
| 241 | */ |
|---|
| 242 | /* D = 0 */ |
|---|
| 243 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 244 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 245 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 246 | |
|---|
| 247 | /* D = 1 */ |
|---|
| 248 | {{0x02,0x17,0x1F,0x06}, {0x02,0x17,0x1F,0x06}, {0x02,0x23,0x1F,0x06}, |
|---|
| 249 | {0x02,0x2F,0x1F,0x06}, {0x02,0x47,0x1F,0x06}, {0x02,0x5F,0x1F,0x06}, |
|---|
| 250 | {0x02,0x77,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 251 | {0x02,0x1F,0x20,0x06}, {0x02,0x2F,0x20,0x06}, {0x02,0x3F,0x20,0x06}, |
|---|
| 252 | {0x02,0x5F,0x20,0x06}, {0x02,0x7F,0x20,0x06}}, |
|---|
| 253 | |
|---|
| 254 | /* D = 2 */ |
|---|
| 255 | {{0x02,0x0B,0x1F,0x08}, {0x02,0x0B,0x1F,0x08}, {0x02,0x11,0x1F,0x08}, |
|---|
| 256 | {0x02,0x17,0x1F,0x08}, {0x02,0x23,0x1F,0x08}, {0x02,0x2F,0x1F,0x08}, |
|---|
| 257 | {0x02,0x3B,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 258 | {0x02,0x0F,0x20,0x08}, {0x02,0x17,0x20,0x08}, {0x02,0x1F,0x20,0x08}, |
|---|
| 259 | {0x02,0x2F,0x20,0x08}, {0x02,0x3F,0x20,0x08}}, |
|---|
| 260 | |
|---|
| 261 | /* D = 3 */ |
|---|
| 262 | {{0x03,0x08,0x1F,0x06}, {0x03,0x08,0x1F,0x06}, {0x06,0x17,0x1F,0x03}, |
|---|
| 263 | {0x03,0x11,0x1F,0x06}, {0x06,0x35,0x1F,0x03}, {0x03,0x23,0x1F,0x06}, |
|---|
| 264 | {0x06,0x59,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 265 | {0x03,0x0B,0x20,0x06}, {0x03,0x11,0x20,0x06}, {0x03,0x17,0x20,0x06}, |
|---|
| 266 | {0x03,0x23,0x20,0x06}, {0x03,0x2F,0x20,0x06}}, |
|---|
| 267 | |
|---|
| 268 | /* D = 4 */ |
|---|
| 269 | {{0x02,0x02,0x1F,0x06}, {0x02,0x02,0x1F,0x06}, {0x04,0x08,0x1F,0x03}, |
|---|
| 270 | {0x02,0x05,0x1F,0x06}, {0x02,0x08,0x1F,0x06}, {0x02,0x0B,0x1F,0x06}, |
|---|
| 271 | {0x02,0x0E,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 272 | {0x02,0x03,0x20,0x06}, {0x02,0x05,0x20,0x06}, {0x02,0x07,0x20,0x06}, |
|---|
| 273 | {0x02,0x0B,0x20,0x06}, {0x02,0x0F,0x20,0x06}}, |
|---|
| 274 | |
|---|
| 275 | /* D = 5 */ |
|---|
| 276 | {{0x04,0x02,0x1F,0x03}, {0x04,0x02,0x1F,0x03}, {0x08,0x08,0x1F,0x02}, |
|---|
| 277 | {0x02,0x02,0x1F,0x06}, {0x04,0x08,0x1F,0x03}, {0x02,0x05,0x1F,0x06}, |
|---|
| 278 | {0x04,0x0E,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 279 | {0x02,0x01,0x20,0x06}, {0x02,0x02,0x20,0x06}, {0x02,0x03,0x20,0x06}, |
|---|
| 280 | {0x02,0x05,0x20,0x06}, {0x02,0x07,0x20,0x06}}, |
|---|
| 281 | |
|---|
| 282 | /* D = 6 */ |
|---|
| 283 | {{0x08,0x02,0x1F,0x02}, {0x08,0x02,0x1F,0x02}, {0x10,0x08,0x1F,0x01}, |
|---|
| 284 | {0x04,0x02,0x1F,0x03}, {0x08,0x08,0x1F,0x02}, {0x04,0x05,0x1F,0x03}, |
|---|
| 285 | {0x08,0x0E,0x1F,0x02}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 286 | {0x04,0x01,0x20,0x03}, {0x04,0x02,0x20,0x03}, {0x02,0x01,0x20,0x06}, |
|---|
| 287 | {0x02,0x02,0x20,0x06}, {0x02,0x03,0x20,0x06}}, |
|---|
| 288 | |
|---|
| 289 | /* D = 7 */ |
|---|
| 290 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 291 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 292 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 293 | |
|---|
| 294 | /* D = 8 */ |
|---|
| 295 | {{0x02,0x01,0x1F,0x06}, {0x02,0x01,0x1F,0x06}, {0x02,0x02,0x1F,0x06}, |
|---|
| 296 | {0x02,0x03,0x1F,0x06}, {0x02,0x05,0x1F,0x06}, {0x02,0x07,0x1F,0x06}, |
|---|
| 297 | {0x02,0x09,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 298 | {0x03,0x03,0x20,0x04}, {0x02,0x03,0x20,0x06}, {0x03,0x07,0x20,0x04}, |
|---|
| 299 | {0x02,0x07,0x20,0x06}, {0x03,0x0F,0x20,0x04}}, |
|---|
| 300 | |
|---|
| 301 | /* D = 9 */ |
|---|
| 302 | {{0x05,0x02,0x1F,0x04}, {0x05,0x02,0x1F,0x04}, {0x0A,0x08,0x1F,0x02}, |
|---|
| 303 | {0x05,0x05,0x1F,0x04}, {0x05,0x08,0x1F,0x04}, {0x05,0x0B,0x1F,0x04}, |
|---|
| 304 | {0x02,0x05,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 305 | {0x05,0x03,0x20,0x04}, {0x05,0x05,0x20,0x04}, {0x05,0x07,0x20,0x04}, |
|---|
| 306 | {0x05,0x0B,0x20,0x04}, {0x05,0x0F,0x20,0x04}} |
|---|
| 307 | }, |
|---|
| 308 | { /* 24M */ |
|---|
| 309 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 310 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 311 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 312 | |
|---|
| 313 | /* D = 1 */ |
|---|
| 314 | {{0x01,0x0B,0x1F,0x08}, {0x02,0x17,0x1F,0x08}, {0x01,0x11,0x1F,0x08}, |
|---|
| 315 | {0x01,0x17,0x1F,0x08}, {0x01,0x23,0x1F,0x08}, {0x01,0x2F,0x1F,0x08}, |
|---|
| 316 | {0x01,0x3B,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 317 | {0x01,0x0F,0x20,0x08}, {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}, |
|---|
| 318 | {0x01,0x2F,0x20,0x08}, {0x01,0x3F,0x20,0x08}}, |
|---|
| 319 | |
|---|
| 320 | /* D = 2 */ |
|---|
| 321 | {{0x01,0x05,0x1F,0x08}, {0x02,0x0B,0x1F,0x08}, {0x01,0x08,0x1F,0x08}, |
|---|
| 322 | {0x01,0x0B,0x1F,0x08}, {0x01,0x11,0x1F,0x08}, {0x01,0x17,0x1F,0x08}, |
|---|
| 323 | {0x01,0x1D,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 324 | {0x01,0x07,0x20,0x08}, {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}, |
|---|
| 325 | {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}}, |
|---|
| 326 | |
|---|
| 327 | /* D = 3 */ |
|---|
| 328 | {{0x01,0x02,0x1F,0x08}, {0x02,0x05,0x1F,0x08}, {0x02,0x08,0x1F,0x08}, |
|---|
| 329 | {0x01,0x05,0x1F,0x08}, {0x01,0x08,0x1F,0x08}, {0x01,0x0B,0x1F,0x08}, |
|---|
| 330 | {0x01,0x0E,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 331 | {0x01,0x03,0x20,0x08}, {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}, |
|---|
| 332 | {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}}, |
|---|
| 333 | |
|---|
| 334 | /* D = 4 */ |
|---|
| 335 | {{0x02,0x02,0x1F,0x08}, {0x02,0x02,0x1F,0x08}, {0x04,0x08,0x1F,0x04}, |
|---|
| 336 | {0x01,0x02,0x1F,0x08}, {0x02,0x08,0x1F,0x08}, {0x01,0x05,0x1F,0x08}, |
|---|
| 337 | {0x02,0x0E,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 338 | {0x01,0x01,0x20,0x08}, {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}, |
|---|
| 339 | {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}}, |
|---|
| 340 | |
|---|
| 341 | /* D = 5 */ |
|---|
| 342 | {{0x04,0x02,0x1F,0x04}, {0x04,0x02,0x1F,0x04}, {0x08,0x08,0x1F,0x02}, |
|---|
| 343 | {0x02,0x02,0x1F,0x08}, {0x04,0x08,0x1F,0x04}, {0x01,0x02,0x1F,0x08}, |
|---|
| 344 | {0x04,0x0E,0x1F,0x04}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 345 | {0x02,0x01,0x20,0x08}, {0x02,0x02,0x20,0x08}, {0x01,0x01,0x20,0x08}, |
|---|
| 346 | {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}}, |
|---|
| 347 | |
|---|
| 348 | /* D = 6 */ |
|---|
| 349 | {{0x08,0x02,0x1F,0x02}, {0x08,0x02,0x1F,0x02}, {0x10,0x08,0x1F,0x01}, |
|---|
| 350 | {0x04,0x02,0x1F,0x04}, {0x08,0x08,0x1F,0x02}, {0x02,0x02,0x1F,0x08}, |
|---|
| 351 | {0x08,0x0E,0x1F,0x02}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 352 | {0x04,0x01,0x20,0x04}, {0x04,0x02,0x20,0x04}, {0x02,0x01,0x20,0x08}, |
|---|
| 353 | {0x02,0x02,0x20,0x08}, {0x01,0x01,0x20,0x08}}, |
|---|
| 354 | |
|---|
| 355 | /* D = 7 */ |
|---|
| 356 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 357 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 358 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 359 | |
|---|
| 360 | /* D = 8 */ |
|---|
| 361 | {{0x02,0x01,0x1F,0x08}, {0x02,0x01,0x1F,0x08}, {0x02,0x02,0x1F,0x08}, |
|---|
| 362 | {0x02,0x03,0x1F,0x08}, {0x02,0x05,0x1F,0x08}, {0x02,0x07,0x1F,0x08}, |
|---|
| 363 | {0x02,0x09,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 364 | {0x03,0x03,0x20,0x08}, {0x02,0x03,0x20,0x08}, {0x03,0x07,0x20,0x08}, |
|---|
| 365 | {0x02,0x07,0x20,0x08}, {0x03,0x0F,0x20,0x08}}, |
|---|
| 366 | |
|---|
| 367 | /* D = 9 */ |
|---|
| 368 | {{0x05,0x02,0x1F,0x04}, {0x05,0x02,0x1F,0x04}, {0x0A,0x08,0x1F,0x02}, |
|---|
| 369 | {0x05,0x05,0x1F,0x04}, {0x05,0x08,0x1F,0x04}, {0x05,0x0B,0x1F,0x04}, |
|---|
| 370 | {0x02,0x05,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 371 | {0x05,0x03,0x20,0x04}, {0x05,0x05,0x20,0x04}, {0x05,0x07,0x20,0x04}, |
|---|
| 372 | {0x05,0x0B,0x20,0x04}, {0x05,0x0F,0x20,0x04}} |
|---|
| 373 | } |
|---|
| 374 | |
|---|
| 375 | }; |
|---|
| 376 | |
|---|
| 377 | static const BSCD_P_DFSmartCardStruct BSCD_P_DF[5][10][14] = { |
|---|
| 378 | /*27Mhz */ |
|---|
| 379 | { |
|---|
| 380 | |
|---|
| 381 | /* D = 0 */ |
|---|
| 382 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 383 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 384 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 385 | |
|---|
| 386 | /* D = 1 */ |
|---|
| 387 | {{0x01,0x0B,0x1F,0x06}, {0x01,0x0B,0x1F,0x06}, {0x01,0x11,0x1F,0x06}, |
|---|
| 388 | {0x01,0x17,0x1F,0x06}, {0x01,0x23,0x1F,0x06}, {0x01,0x2F,0x1F,0x06}, |
|---|
| 389 | {0x01,0x3B,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 390 | {0x01,0x0F,0x20,0x06}, {0x01,0x17,0x20,0x06}, {0x01,0x1F,0x20,0x06}, |
|---|
| 391 | {0x01,0x2F,0x20,0x06}, {0x01,0x3F,0x20,0x06}}, |
|---|
| 392 | |
|---|
| 393 | /* D = 2 */ |
|---|
| 394 | {{0x01,0x05,0x1F,0x06}, {0x01,0x05,0x1F,0x06}, {0x01,0x08,0x1F,0x06}, |
|---|
| 395 | {0x01,0x0B,0x1F,0x04}, {0x01,0x11,0x1F,0x06}, {0x01,0x17,0x1F,0x02}, |
|---|
| 396 | {0x01,0x1D,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 397 | {0x01,0x07,0x20,0x06}, {0x01,0x0B,0x20,0x06}, {0x01,0x0F,0x20,0x06}, |
|---|
| 398 | {0x01,0x17,0x20,0x06}, {0x01,0x1F,0x20,0x06}}, |
|---|
| 399 | |
|---|
| 400 | /* D = 3 */ |
|---|
| 401 | {{0x01,0x02,0x1F,0x06}, {0x01,0x02,0x1F,0x06}, {0x02,0x08,0x1F,0x03}, |
|---|
| 402 | {0x01,0x05,0x1F,0x06}, {0x01,0x08,0x1F,0x06}, {0x01,0x0B,0x1F,0x06}, |
|---|
| 403 | {0x01,0x0E,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 404 | {0x01,0x03,0x20,0x06}, {0x01,0x05,0x20,0x06}, {0x01,0x07,0x20,0x06}, |
|---|
| 405 | {0x01,0x0B,0x20,0x06}, {0x01,0x0F,0x20,0x06}}, |
|---|
| 406 | |
|---|
| 407 | /* D = 4 */ |
|---|
| 408 | {{0x02,0x02,0x1F,0x03}, {0x02,0x02,0x1F,0x03}, {0x04,0x08,0x1F,0x02}, |
|---|
| 409 | {0x01,0x02,0x1F,0x06}, {0x02,0x08,0x1F,0x03}, {0x01,0x05,0x1F,0x06}, |
|---|
| 410 | {0x02,0x0E,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 411 | {0x01,0x01,0x20,0x06}, {0x01,0x02,0x20,0x06}, {0x01,0x03,0x20,0x06}, |
|---|
| 412 | {0x01,0x05,0x20,0x06}, {0x01,0x07,0x20,0x06}}, |
|---|
| 413 | |
|---|
| 414 | /* D = 5 */ |
|---|
| 415 | {{0x04,0x02,0x1F,0x02}, {0x04,0x02,0x1F,0x02}, {0x08,0x08,0x1F,0x01}, |
|---|
| 416 | {0x02,0x02,0x1F,0x03}, {0x04,0x08,0x1F,0x02}, {0x01,0x02,0x1F,0x06}, |
|---|
| 417 | {0x04,0x0E,0x1F,0x02}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 418 | {0x02,0x01,0x20,0x03}, {0x02,0x02,0x20,0x03}, {0x01,0x01,0x20,0x06}, |
|---|
| 419 | {0x01,0x02,0x20,0x06}, {0x01,0x03,0x20,0x06}}, |
|---|
| 420 | |
|---|
| 421 | /* D = 6 */ |
|---|
| 422 | {{0x08,0x02,0x1F,0x01}, {0x08,0x02,0x1F,0x01}, {0x10,0x08,0x1F,0x01}, |
|---|
| 423 | {0x04,0x02,0x1F,0x01}, {0x08,0x08,0x1F,0x01}, {0x02,0x02,0x1F,0x03}, |
|---|
| 424 | {0x08,0x0E,0x1F,0x01}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 425 | {0x04,0x01,0x20,0x02}, {0x04,0x02,0x20,0x02}, {0x02,0x01,0x20,0x03}, |
|---|
| 426 | {0x02,0x02,0x20,0x03}, {0x01,0x01,0x20,0x06}}, |
|---|
| 427 | |
|---|
| 428 | /* D = 7 */ |
|---|
| 429 | {{0x10,0x02,0x1F,0x01}, {0x10,0x02,0x1F,0x01}, {0x00,0x00,0x00,0x00}, |
|---|
| 430 | {0x08,0x02,0x1F,0x01}, {0x10,0x08,0x1F,0x01}, {0x04,0x02,0x1F,0x02}, |
|---|
| 431 | {0x10,0x0E,0x1F,0x01}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 432 | {0x08,0x01,0x20,0x01}, {0x08,0x02,0x20,0x01}, {0x04,0x01,0x20,0x02}, |
|---|
| 433 | {0x04,0x02,0x20,0x02}, {0x02,0x01,0x20,0x04}}, |
|---|
| 434 | |
|---|
| 435 | /* D = 8 */ |
|---|
| 436 | {{0x02,0x01,0x1F,0x03}, {0x02,0x01,0x1F,0x03}, {0x02,0x02,0x1F,0x03}, |
|---|
| 437 | {0x02,0x03,0x1F,0x03}, {0x02,0x05,0x1F,0x03}, {0x02,0x07,0x1F,0x03}, |
|---|
| 438 | {0x02,0x09,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 439 | {0x03,0x03,0x20,0x02}, {0x02,0x03,0x20,0x03}, {0x03,0x07,0x20,0x02}, |
|---|
| 440 | {0x02,0x07,0x20,0x03}, {0x03,0x0F,0x20,0x02}}, |
|---|
| 441 | |
|---|
| 442 | /* D = 9 */ |
|---|
| 443 | {{0x05,0x02,0x1F,0x02}, {0x05,0x02,0x1F,0x02}, {0x0A,0x08,0x1F,0x01}, |
|---|
| 444 | {0x05,0x05,0x1F,0x02}, {0x05,0x08,0x1F,0x02}, {0x05,0x0B,0x1F,0x02}, |
|---|
| 445 | {0x02,0x05,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 446 | {0x05,0x03,0x20,0x02}, {0x05,0x05,0x20,0x02}, {0x05,0x07,0x20,0x02}, |
|---|
| 447 | }, |
|---|
| 448 | }, |
|---|
| 449 | /* 36.864 */ |
|---|
| 450 | { |
|---|
| 451 | /* D = 0 */ |
|---|
| 452 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 453 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 454 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 455 | |
|---|
| 456 | /* D = 1 */ |
|---|
| 457 | {{0x01,0x0B,0x1F,0x08}, {0x01,0x0B,0x1F,0x08}, {0x01,0x11,0x1F,0x08}, |
|---|
| 458 | {0x01,0x17,0x1F,0x04}, {0x01,0x23,0x1F,0x08}, {0x01,0x2F,0x1F,0x02}, |
|---|
| 459 | {0x01,0x3B,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 460 | {0x01,0x0F,0x20,0x08}, {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}, |
|---|
| 461 | {0x01,0x2F,0x20,0x08}, {0x01,0x3F,0x20,0x08}}, |
|---|
| 462 | |
|---|
| 463 | /* D = 2 */ |
|---|
| 464 | {{0x01,0x05,0x1F,0x08}, {0x01,0x05,0x1F,0x08}, {0x01,0x08,0x1F,0x08}, |
|---|
| 465 | {0x01,0x0B,0x1F,0x04}, {0x01,0x11,0x1F,0x08}, {0x01,0x17,0x1F,0x02}, |
|---|
| 466 | {0x01,0x1D,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 467 | {0x01,0x07,0x20,0x08}, {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}, |
|---|
| 468 | {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}}, |
|---|
| 469 | |
|---|
| 470 | /* D = 3 */ |
|---|
| 471 | {{0x01,0x02,0x1F,0x08}, {0x01,0x02,0x1F,0x08}, {0x02,0x08,0x1F,0x08}, |
|---|
| 472 | {0x01,0x05,0x1F,0x04}, {0x01,0x08,0x1F,0x08}, {0x01,0x0B,0x1F,0x02}, |
|---|
| 473 | {0x01,0x0E,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 474 | {0x01,0x03,0x20,0x08}, {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}, |
|---|
| 475 | {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}}, |
|---|
| 476 | |
|---|
| 477 | /* D = 4 */ |
|---|
| 478 | {{0x02,0x02,0x1F,0x04}, {0x02,0x02,0x1F,0x04}, {0x04,0x08,0x1F,0x04}, |
|---|
| 479 | {0x01,0x02,0x1F,0x04}, {0x02,0x08,0x1F,0x08}, {0x01,0x05,0x1F,0x02}, |
|---|
| 480 | {0x02,0x0E,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 481 | {0x01,0x01,0x20,0x08}, {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}, |
|---|
| 482 | {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}}, |
|---|
| 483 | |
|---|
| 484 | /* D = 5 */ |
|---|
| 485 | {{0x04,0x02,0x1F,0x02}, {0x04,0x02,0x1F,0x02}, {0x08,0x08,0x1F,0x02}, |
|---|
| 486 | {0x02,0x02,0x1F,0x02}, {0x04,0x08,0x1F,0x04}, {0x01,0x02,0x1F,0x02}, |
|---|
| 487 | {0x04,0x0E,0x1F,0x04}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 488 | {0x02,0x01,0x20,0x08}, {0x02,0x02,0x20,0x08}, {0x01,0x01,0x20,0x08}, |
|---|
| 489 | {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}}, |
|---|
| 490 | |
|---|
| 491 | /* D = 6 */ |
|---|
| 492 | {{0x08,0x02,0x1F,0x02}, {0x08,0x02,0x1F,0x02}, {0x10,0x08,0x1F,0x01}, |
|---|
| 493 | {0x04,0x02,0x1F,0x04}, {0x08,0x08,0x1F,0x02}, {0x02,0x02,0x1F,0x08}, |
|---|
| 494 | {0x08,0x0E,0x1F,0x02}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 495 | {0x04,0x01,0x20,0x04}, {0x04,0x02,0x20,0x04}, {0x02,0x01,0x20,0x08}, |
|---|
| 496 | {0x02,0x02,0x20,0x08}, {0x01,0x01,0x20,0x08}}, |
|---|
| 497 | |
|---|
| 498 | /* D = 7 */ |
|---|
| 499 | #if(BCHP_CHIP==7420)|| (BCHP_CHIP==7340) || (BCHP_CHIP==7342)|| (BCHP_CHIP==7125) |
|---|
| 500 | {{0x10,0x02,0x1F,0x01}, {0x10,0x02,0x1F,0x01}, {0x00,0x00,0x00,0x00}, |
|---|
| 501 | {0x08,0x02,0x1F,0x01}, {0x10,0x08,0x1F,0x01}, {0x04,0x02,0x1F,0x02}, |
|---|
| 502 | {0x10,0x0E,0x1F,0x01}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 503 | {0x08,0x01,0x20,0x01}, {0x08,0x02,0x20,0x01}, {0x04,0x01,0x20,0x02}, |
|---|
| 504 | {0x04,0x02,0x20,0x02}, {0x02,0x01,0x20,0x04}}, |
|---|
| 505 | #else |
|---|
| 506 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 507 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 508 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 509 | #endif |
|---|
| 510 | |
|---|
| 511 | /* D = 8 */ |
|---|
| 512 | {{0x02,0x01,0x1F,0x08}, {0x02,0x01,0x1F,0x08}, {0x02,0x02,0x1F,0x08}, |
|---|
| 513 | {0x02,0x03,0x1F,0x08}, {0x02,0x05,0x1F,0x08}, {0x02,0x07,0x1F,0x08}, |
|---|
| 514 | {0x02,0x09,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 515 | {0x03,0x03,0x20,0x08}, {0x02,0x03,0x20,0x08}, {0x03,0x07,0x20,0x08}, |
|---|
| 516 | {0x02,0x07,0x20,0x08}, {0x03,0x0F,0x20,0x08}}, |
|---|
| 517 | |
|---|
| 518 | /* D = 9 */ |
|---|
| 519 | {{0x05,0x02,0x1F,0x04}, {0x05,0x02,0x1F,0x04}, {0x0A,0x08,0x1F,0x02}, |
|---|
| 520 | {0x05,0x05,0x1F,0x04}, {0x05,0x08,0x1F,0x04}, {0x05,0x0B,0x1F,0x04}, |
|---|
| 521 | {0x02,0x05,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 522 | {0x05,0x03,0x20,0x04}, {0x05,0x05,0x20,0x04}, {0x05,0x07,0x20,0x04}, |
|---|
| 523 | {0x05,0x0B,0x20,0x04}, {0x05,0x0F,0x20,0x04}} |
|---|
| 524 | }, |
|---|
| 525 | { |
|---|
| 526 | /* Note: QX: only Test (D, F) = (5, 9)(6, 9)(6, A) */ |
|---|
| 527 | /*36M */ |
|---|
| 528 | /* D = 0 */ |
|---|
| 529 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 530 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 531 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 532 | |
|---|
| 533 | /* D = 1 */ |
|---|
| 534 | {{0x01,0x0B,0x1F,0x08}, {0x01,0x0B,0x1F,0x08}, {0x01,0x11,0x1F,0x08}, |
|---|
| 535 | {0x01,0x17,0x1F,0x08}, {0x01,0x23,0x1F,0x08}, {0x01,0x2F,0x1F,0x08}, |
|---|
| 536 | {0x01,0x3B,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 537 | {0x01,0x0F,0x20,0x08}, {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}, |
|---|
| 538 | {0x01,0x2F,0x20,0x08}, {0x01,0x3F,0x20,0x08}}, |
|---|
| 539 | |
|---|
| 540 | /* D = 2 */ |
|---|
| 541 | {{0x01,0x05,0x1F,0x08}, {0x01,0x05,0x1F,0x08}, {0x01,0x08,0x1F,0x08}, |
|---|
| 542 | {0x01,0x0B,0x1F,0x04}, {0x01,0x11,0x1F,0x08}, {0x01,0x17,0x1F,0x08}, |
|---|
| 543 | {0x01,0x1D,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 544 | {0x01,0x07,0x20,0x08}, {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}, |
|---|
| 545 | {0x01,0x17,0x20,0x08}, {0x01,0x1F,0x20,0x08}}, |
|---|
| 546 | |
|---|
| 547 | /* D = 3 */ |
|---|
| 548 | {{0x01,0x02,0x1F,0x08}, {0x01,0x02,0x1F,0x08}, {0x02,0x08,0x1F,0x04}, |
|---|
| 549 | {0x01,0x05,0x1F,0x08}, {0x01,0x08,0x1F,0x08}, {0x01,0x0B,0x1F,0x08}, |
|---|
| 550 | {0x01,0x0E,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 551 | {0x01,0x03,0x20,0x08}, {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}, |
|---|
| 552 | {0x01,0x0B,0x20,0x08}, {0x01,0x0F,0x20,0x08}}, |
|---|
| 553 | |
|---|
| 554 | /* D = 4 */ |
|---|
| 555 | {{0x02,0x02,0x1F,0x04}, {0x02,0x02,0x1F,0x04}, {0x04,0x08,0x1F,0x02}, |
|---|
| 556 | {0x01,0x02,0x1F,0x08}, {0x02,0x08,0x1F,0x04}, {0x01,0x05,0x1F,0x08}, |
|---|
| 557 | {0x02,0x0E,0x1F,0x04}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 558 | {0x01,0x01,0x20,0x08}, {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}, |
|---|
| 559 | {0x01,0x05,0x20,0x08}, {0x01,0x07,0x20,0x08}}, |
|---|
| 560 | |
|---|
| 561 | /* D = 5 */ |
|---|
| 562 | {{0x04,0x02,0x1F,0x02}, {0x04,0x02,0x1F,0x02}, {0x08,0x08,0x1F,0x01}, |
|---|
| 563 | {0x02,0x02,0x1F,0x04}, {0x04,0x08,0x1F,0x02}, {0x01,0x02,0x1F,0x08}, |
|---|
| 564 | {0x04,0x0E,0x1F,0x02}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 565 | {0x02,0x01,0x20,0x04}, {0x02,0x02,0x20,0x04}, {0x01,0x01,0x20,0x08}, |
|---|
| 566 | {0x01,0x02,0x20,0x08}, {0x01,0x03,0x20,0x08}}, |
|---|
| 567 | |
|---|
| 568 | /* D = 6 */ |
|---|
| 569 | {{0x08,0x02,0x1F,0x01}, {0x08,0x02,0x1F,0x01}, {0x10,0x08,0x1F,0x01}, |
|---|
| 570 | {0x04,0x02,0x1F,0x02}, {0x08,0x08,0x1F,0x01}, {0x04,0x05,0x1F,0x02}, |
|---|
| 571 | {0x08,0x0E,0x1F,0x01}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 572 | {0x04,0x01,0x20,0x02}, {0x04,0x02,0x20,0x02}, {0x02,0x01,0x20,0x04}, |
|---|
| 573 | {0x02,0x02,0x20,0x04}, {0x01,0x01,0x20,0x08}}, |
|---|
| 574 | |
|---|
| 575 | /* D = 7 */ |
|---|
| 576 | #if(BCHP_CHIP==7420) || (BCHP_CHIP==7340) || (BCHP_CHIP==7342)|| (BCHP_CHIP==7125) |
|---|
| 577 | {{0x10,0x02,0x1F,0x01}, {0x10,0x02,0x1F,0x01}, {0x00,0x00,0x00,0x00}, |
|---|
| 578 | {0x08,0x02,0x1F,0x01}, {0x10,0x08,0x1F,0x01}, {0x04,0x02,0x1F,0x02}, |
|---|
| 579 | {0x10,0x0E,0x1F,0x01}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 580 | {0x08,0x01,0x20,0x01}, {0x08,0x02,0x20,0x01}, {0x04,0x01,0x20,0x02}, |
|---|
| 581 | {0x04,0x02,0x20,0x02}, {0x02,0x01,0x20,0x04}}, |
|---|
| 582 | #else |
|---|
| 583 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 584 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 585 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 586 | #endif |
|---|
| 587 | /* D = 8 */ |
|---|
| 588 | {{0x02,0x01,0x1F,0x04}, {0x02,0x01,0x1F,0x04}, {0x02,0x02,0x1F,0x04}, |
|---|
| 589 | {0x02,0x03,0x1F,0x04}, {0x02,0x05,0x1F,0x04}, {0x02,0x07,0x1F,0x04}, |
|---|
| 590 | {0x02,0x09,0x1F,0x04}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 591 | {0x03,0x03,0x20,0x03}, {0x02,0x03,0x20,0x04}, {0x03,0x07,0x20,0x03}, |
|---|
| 592 | {0x02,0x07,0x20,0x04}, {0x03,0x0F,0x20,0x03}}, |
|---|
| 593 | |
|---|
| 594 | /* D = 9 */ |
|---|
| 595 | {{0x05,0x02,0x1F,0x02}, {0x05,0x02,0x1F,0x02}, {0x0A,0x08,0x1F,0x01}, |
|---|
| 596 | {0x05,0x05,0x1F,0x02}, {0x05,0x08,0x1F,0x02}, {0x05,0x0B,0x1F,0x02}, |
|---|
| 597 | {0x02,0x05,0x1F,0x04}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 598 | {0x05,0x03,0x20,0x02}, {0x05,0x05,0x20,0x02}, {0x05,0x07,0x20,0x02}, |
|---|
| 599 | {0x05,0x0B,0x20,0x02}, {0x05,0x0F,0x20,0x02}} |
|---|
| 600 | }, |
|---|
| 601 | |
|---|
| 602 | /*24Mhz */ |
|---|
| 603 | { /* D = 0 */ |
|---|
| 604 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 605 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 606 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 607 | /* D = 1 */ |
|---|
| 608 | {{0,0,0,0}, {0x01,0x0B,0x1F,0x06}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 609 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 610 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 611 | /* D = 2 */ |
|---|
| 612 | {{0,0,0,0}, {0x01,0x05,0x1F,0x06}, {0,0,0,0}, {0x01,0x0B,0x1F,0x06}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 613 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 614 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 615 | /* D = 3 */ |
|---|
| 616 | {{0,0,0,0}, {0x01,0x02,0x1F,0x03}, {0,0,0,0}, {0x01,0x05,0x1F,0x03}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 617 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 618 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 619 | /* D = 4 */ |
|---|
| 620 | {{0,0,0,0}, {0x02,0x02,0x1F,0x03}, {0,0,0,0}, {0x01,0x02,0x1F,0x06}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 621 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 622 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 623 | /* D = 5 */ |
|---|
| 624 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 625 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 626 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 627 | /* D = 6 */ |
|---|
| 628 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 629 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 630 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 631 | /* D = 7 */ |
|---|
| 632 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 633 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 634 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 635 | /* D = 8 */ |
|---|
| 636 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 637 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 638 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 639 | /* D = 9 */ |
|---|
| 640 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 641 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 642 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 643 | }, |
|---|
| 644 | /*108M */ |
|---|
| 645 | /* D = 0 */ |
|---|
| 646 | { |
|---|
| 647 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 648 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 649 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 650 | |
|---|
| 651 | /* D = 1 */ |
|---|
| 652 | {{0x03,0x23,0x1F,0x08}, {0x03,0x23,0x1F,0x08}, {0x03,0x35,0x1F,0x08}, |
|---|
| 653 | {0x03,0x47,0x1F,0x08}, {0x01,0x6B,0x1F,0x08}, {0x03,0x8F,0x1F,0x08}, |
|---|
| 654 | {0x03,0xB3,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 655 | {0x03,0x2F,0x20,0x08}, {0x03,0x47,0x20,0x08}, {0x03,0x5F,0x20,0x08}, |
|---|
| 656 | {0x03,0x8F,0x20,0x08}, {0x03,0xBF,0x20,0x08}}, |
|---|
| 657 | |
|---|
| 658 | /* D = 2 */ |
|---|
| 659 | {{0x03,0x011,0x1F,0x08}, {0x03,0x11,0x1F,0x08}, {0x03,0x1A,0x1F,0x08}, |
|---|
| 660 | {0x02,0x17,0x1F,0x08}, {0x03,0x35,0x1F,0x08}, {0x01,0x17,0x1F,0x08}, |
|---|
| 661 | {0x03,0x59,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 662 | {0x03,0x17,0x20,0x08}, {0x03,0x23,0x20,0x08}, {0x03,0x2F,0x20,0x08}, |
|---|
| 663 | {0x03,0x47,0x20,0x08}, {0x03,0x5F,0x20,0x08}}, |
|---|
| 664 | |
|---|
| 665 | /* D = 3 */ |
|---|
| 666 | {{0x03,0x08,0x1F,0x08}, {0x03,0x08,0x1F,0x08}, {0x06,0x1A,0x1F,0x04}, |
|---|
| 667 | {0x03,0x11,0x1F,0x08}, {0x03,0x1A,0x1F,0x08}, {0x03,0x23,0x1F,0x08}, |
|---|
| 668 | {0x03,0x2C,0x1F,0x08}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 669 | {0x03,0x0B,0x20,0x08}, {0x03,0x11,0x20,0x08}, {0x03,0x17,0x20,0x08}, |
|---|
| 670 | {0x03,0x23,0x20,0x08}, {0x03,0x2f,0x20,0x08}}, |
|---|
| 671 | |
|---|
| 672 | /* D = 4 */ |
|---|
| 673 | {{0x04,0x05,0x1F,0x06}, {0x04,0x05,0x1F,0x06}, {0x04,0x08,0x1F,0x06}, |
|---|
| 674 | {0x03,0x08,0x1F,0x08}, {0x04,0x11,0x1F,0x06}, {0x03,0x11,0x1F,0x08}, |
|---|
| 675 | {0x04,0x1d,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 676 | {0x03,0x05,0x20,0x08}, {0x03,0x08,0x20,0x08}, {0x03,0x0b,0x20,0x08}, |
|---|
| 677 | {0x03,0x11,0x20,0x08}, {0x03,0x17,0x20,0x08}}, |
|---|
| 678 | |
|---|
| 679 | /* D = 5 */ |
|---|
| 680 | {{0x04,0x02,0x1F,0x06}, {0x04,0x02,0x1F,0x06}, {0x08,0x08,0x1F,0x03}, |
|---|
| 681 | {0x04,0x05,0x1F,0x06}, {0x04,0x08,0x1F,0x06}, {0x03,0x08,0x1F,0x08}, |
|---|
| 682 | {0x04,0x0E,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 683 | {0x04,0x03,0x20,0x06}, {0x04,0x05,0x20,0x06}, {0x03,0x05,0x20,0x08}, |
|---|
| 684 | {0x03,0x08,0x20,0x08}, {0x03,0x0b,0x20,0x08}}, |
|---|
| 685 | |
|---|
| 686 | /* D = 6 */ |
|---|
| 687 | {{0x08,0x02,0x1F,0x03}, {0x08,0x02,0x1F,0x03}, {0x10,0x08,0x1F,0x01}, |
|---|
| 688 | {0x04,0x02,0x1F,0x06}, {0x08,0x08,0x1F,0x03}, {0x04,0x05,0x1F,0x06}, |
|---|
| 689 | {0x08,0x0E,0x1F,0x03}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 690 | {0x04,0x01,0x20,0x06}, {0x04,0x02,0x20,0x06}, {0x04,0x03,0x20,0x06}, |
|---|
| 691 | {0x04,0x05,0x20,0x06}, {0x03,0x05,0x20,0x08}}, |
|---|
| 692 | |
|---|
| 693 | /* D = 7 */ |
|---|
| 694 | #if(BCHP_CHIP==7420) || (BCHP_CHIP==7340) || (BCHP_CHIP==7342)|| (BCHP_CHIP==7125) |
|---|
| 695 | {{0x10,0x02,0x1F,0x01}, {0x10,0x02,0x1F,0x01}, {0x00,0x00,0x00,0x00}, |
|---|
| 696 | {0x08,0x02,0x1F,0x03}, {0x10,0x08,0x1F,0x01}, {0x04,0x02,0x1F,0x06}, |
|---|
| 697 | {0x10,0x0E,0x1F,0x01}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 698 | {0x08,0x01,0x20,0x03}, {0x08,0x02,0x20,0x03}, {0x04,0x01,0x20,0x06}, |
|---|
| 699 | {0x04,0x02,0x20,0x06}, {0x04,0x03,0x20,0x06}}, |
|---|
| 700 | #else |
|---|
| 701 | {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 702 | {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, |
|---|
| 703 | {0,0,0,0}, {0,0,0,0}}, |
|---|
| 704 | #endif |
|---|
| 705 | /* D = 8 */ |
|---|
| 706 | {{0x04,0x03,0x1F,0x06}, {0x04,0x03,0x1F,0x06}, {0x04,0x05,0x1F,0x06}, |
|---|
| 707 | {0x04,0x07,0x1F,0x06}, {0x04,0x0b,0x1F,0x06}, {0x04,0x0f,0x1F,0x06}, |
|---|
| 708 | {0x04,0x13,0x1F,0x06}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 709 | {0x03,0x03,0x20,0x08}, {0x04,0x07,0x20,0x06}, {0x03,0x07,0x20,0x08}, |
|---|
| 710 | {0x04,0x0f,0x20,0x06}, {0x03,0x0F,0x20,0x08}}, |
|---|
| 711 | |
|---|
| 712 | /* D = 9 */ |
|---|
| 713 | {{0x05,0x02,0x1F,0x02}, {0x05,0x02,0x1F,0x02}, {0x0A,0x08,0x1F,0x01}, |
|---|
| 714 | {0x05,0x05,0x1F,0x02}, {0x05,0x08,0x1F,0x02}, {0x05,0x0B,0x1F,0x02}, |
|---|
| 715 | {0x02,0x05,0x1F,0x04}, {0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00}, |
|---|
| 716 | {0x05,0x03,0x20,0x02}, {0x05,0x05,0x20,0x02}, {0x05,0x07,0x20,0x02}, |
|---|
| 717 | {0x05,0x0B,0x20,0x02}, {0x05,0x0F,0x20,0x02}} |
|---|
| 718 | } |
|---|
| 719 | |
|---|
| 720 | }; |
|---|
| 721 | |
|---|
| 722 | |
|---|
| 723 | |
|---|
| 724 | |
|---|
| 725 | static unsigned int BSCD_P_aunFFactor[14] = {372, 372, 558, 744, 1116, 1488, 1860, |
|---|
| 726 | -1, -1, 512, 768, 1024, 1536, 2048}; |
|---|
| 727 | |
|---|
| 728 | |
|---|
| 729 | static unsigned char BSCD_P_aucDFactor[10] = {-1, 1, 2, 4, 8, 16, 32, -1, 12, 20}; |
|---|
| 730 | |
|---|
| 731 | static unsigned char BSCD_P_aucSCClkDiv[16] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x00, 0x00, 0x50, |
|---|
| 732 | 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70}; |
|---|
| 733 | |
|---|
| 734 | |
|---|
| 735 | unsigned char BSCD_P_GetClkDiv( |
|---|
| 736 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 737 | unsigned char in_ucDFactor, |
|---|
| 738 | unsigned char in_ucFFactor |
|---|
| 739 | ) |
|---|
| 740 | { |
|---|
| 741 | if ((in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV1996) && |
|---|
| 742 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) ) |
|---|
| 743 | { |
|---|
| 744 | |
|---|
| 745 | if (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto) |
|---|
| 746 | return BSCD_P_DF[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_clkdiv; |
|---|
| 747 | else return 4; |
|---|
| 748 | }else{ |
|---|
| 749 | |
|---|
| 750 | return BSCD_P_DF_EMV[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_clkdiv; |
|---|
| 751 | } |
|---|
| 752 | |
|---|
| 753 | } |
|---|
| 754 | |
|---|
| 755 | |
|---|
| 756 | unsigned char BSCD_P_GetETUClkDiv( |
|---|
| 757 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 758 | unsigned char in_ucDFactor, |
|---|
| 759 | unsigned char in_ucFFactor |
|---|
| 760 | ) |
|---|
| 761 | { |
|---|
| 762 | if ((in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV1996) && |
|---|
| 763 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) ) |
|---|
| 764 | { |
|---|
| 765 | if (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto) |
|---|
| 766 | return BSCD_P_DF[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_etuclkdiv; |
|---|
| 767 | else return 1; |
|---|
| 768 | }else |
|---|
| 769 | return BSCD_P_DF_EMV[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_etuclkdiv; |
|---|
| 770 | |
|---|
| 771 | } |
|---|
| 772 | |
|---|
| 773 | unsigned char BSCD_P_GetISOBaudRateAdjustor( |
|---|
| 774 | unsigned char in_ucDFactor |
|---|
| 775 | ) |
|---|
| 776 | { |
|---|
| 777 | return BSCD_P_aucDFactor[in_ucDFactor]; |
|---|
| 778 | } |
|---|
| 779 | |
|---|
| 780 | unsigned int BSCD_P_GetISOClockRateConversionFactor( |
|---|
| 781 | unsigned char in_ucFFactor |
|---|
| 782 | ) |
|---|
| 783 | { |
|---|
| 784 | return BSCD_P_aunFFactor[in_ucFFactor]; |
|---|
| 785 | } |
|---|
| 786 | |
|---|
| 787 | unsigned char BSCD_P_MapScClkDivToMaskValue( |
|---|
| 788 | unsigned char in_ucClkDiv |
|---|
| 789 | ) |
|---|
| 790 | { |
|---|
| 791 | return BSCD_P_aucSCClkDiv[in_ucClkDiv-1]; |
|---|
| 792 | } |
|---|
| 793 | |
|---|
| 794 | unsigned char BSCD_P_GetPrescale( |
|---|
| 795 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 796 | unsigned char in_ucDFactor, |
|---|
| 797 | unsigned char in_ucFFactor |
|---|
| 798 | ) |
|---|
| 799 | { |
|---|
| 800 | |
|---|
| 801 | if ((in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV1996) && |
|---|
| 802 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) ) |
|---|
| 803 | { |
|---|
| 804 | if (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto) |
|---|
| 805 | return BSCD_P_DF[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_prescale; |
|---|
| 806 | else return 0x4A; |
|---|
| 807 | }else |
|---|
| 808 | return BSCD_P_DF_EMV[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_prescale; |
|---|
| 809 | } |
|---|
| 810 | |
|---|
| 811 | unsigned char BSCD_P_GetBaudDiv( |
|---|
| 812 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 813 | unsigned char in_ucDFactor, |
|---|
| 814 | unsigned char in_ucFFactor |
|---|
| 815 | ) |
|---|
| 816 | { |
|---|
| 817 | if ((in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV1996) && |
|---|
| 818 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) ) |
|---|
| 819 | { |
|---|
| 820 | if (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto) |
|---|
| 821 | return BSCD_P_DF[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_bauddiv; |
|---|
| 822 | else return 32; |
|---|
| 823 | }else |
|---|
| 824 | return BSCD_P_DF_EMV[in_channelHandle->currentChannelSettings.eSrcClkFreq][in_ucDFactor][in_ucFFactor].sc_bauddiv; |
|---|
| 825 | } |
|---|
| 826 | |
|---|
| 827 | |
|---|
| 828 | /* BSYT???: Change this function name to Adjust WWT */ |
|---|
| 829 | BERR_Code BSCD_P_AdjustWWT( |
|---|
| 830 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 831 | unsigned char in_ucFFactor, |
|---|
| 832 | unsigned char in_ucDFactor, |
|---|
| 833 | unsigned char in_ucWorkWaitTImeInteger |
|---|
| 834 | ) |
|---|
| 835 | { |
|---|
| 836 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 837 | unsigned char ucBaudRateAdjustor; |
|---|
| 838 | |
|---|
| 839 | BDBG_ENTER(BSCD_P_AdjustWWT); |
|---|
| 840 | |
|---|
| 841 | BDBG_MSG(("in_ucDFactor = %d\n", in_ucDFactor)); |
|---|
| 842 | BDBG_MSG(("in_ucFFactor = %d\n", in_ucFFactor)); |
|---|
| 843 | |
|---|
| 844 | BDBG_MSG(("baudrate = %lu\n", in_channelHandle->currentChannelSettings.currentBaudRate)); |
|---|
| 845 | |
|---|
| 846 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 847 | (in_channelHandle->currentChannelSettings.currentBaudRate == 0) ); |
|---|
| 848 | |
|---|
| 849 | BDBG_MSG (("etu in us= %d\n", |
|---|
| 850 | 1000000/in_channelHandle->currentChannelSettings.currentBaudRate)); |
|---|
| 851 | |
|---|
| 852 | ucBaudRateAdjustor = BSCD_P_GetISOBaudRateAdjustor(in_ucDFactor); |
|---|
| 853 | |
|---|
| 854 | /*EMV2000*/ |
|---|
| 855 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) |
|---|
| 856 | in_channelHandle->currentChannelSettings.workWaitTime.ulValue = |
|---|
| 857 | BSCD_ISO_WORK_WAIT_TIME_DEFAULT_FACTOR * ucBaudRateAdjustor * |
|---|
| 858 | in_ucWorkWaitTImeInteger + ucBaudRateAdjustor * |
|---|
| 859 | BSCD_DEFAULT_EXTRA_WORK_WAITING_TIME_EMV2000 + |
|---|
| 860 | BSCD_EMV2000_WORK_WAIT_TIME_DELTA; |
|---|
| 861 | else |
|---|
| 862 | in_channelHandle->currentChannelSettings.workWaitTime.ulValue = |
|---|
| 863 | BSCD_ISO_WORK_WAIT_TIME_DEFAULT_FACTOR * ucBaudRateAdjustor * |
|---|
| 864 | in_ucWorkWaitTImeInteger; |
|---|
| 865 | |
|---|
| 866 | in_channelHandle->currentChannelSettings.workWaitTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 867 | |
|---|
| 868 | BSTD_UNUSED(in_ucFFactor); |
|---|
| 869 | |
|---|
| 870 | BSCD_P_DONE_LABEL: |
|---|
| 871 | |
|---|
| 872 | BDBG_LEAVE(BSCD_P_AdjustWWT); |
|---|
| 873 | return( errCode ); |
|---|
| 874 | } |
|---|
| 875 | |
|---|
| 876 | |
|---|
| 877 | /* This modify registers */ |
|---|
| 878 | BERR_Code BSCD_P_FDAdjust( |
|---|
| 879 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 880 | unsigned char in_ucFFactor, |
|---|
| 881 | unsigned char in_ucDFactor |
|---|
| 882 | ) |
|---|
| 883 | { |
|---|
| 884 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 885 | uint32_t ulClkCmd=0; |
|---|
| 886 | |
|---|
| 887 | BDBG_ENTER(BSCD_P_FDAdjust); |
|---|
| 888 | |
|---|
| 889 | /* Set BCM to adjust the clock and bit rate */ |
|---|
| 890 | in_channelHandle->currentChannelSettings.unPrescale = |
|---|
| 891 | BSCD_P_GetPrescale(in_channelHandle, in_ucDFactor, in_ucFFactor) * |
|---|
| 892 | in_channelHandle->currentChannelSettings.ucExternalClockDivisor + |
|---|
| 893 | (in_channelHandle->currentChannelSettings.ucExternalClockDivisor - 1); |
|---|
| 894 | |
|---|
| 895 | BREG_Write32( |
|---|
| 896 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 897 | (in_channelHandle->ulRegStartAddr + BSCD_P_PRESCALE), |
|---|
| 898 | in_channelHandle->currentChannelSettings.unPrescale); |
|---|
| 899 | BDBG_MSG(("SC_Prescale = 0x%x\n", in_channelHandle->currentChannelSettings.unPrescale)); |
|---|
| 900 | |
|---|
| 901 | in_channelHandle->currentChannelSettings.ucBaudDiv = |
|---|
| 902 | BSCD_P_GetBaudDiv(in_channelHandle, in_ucDFactor, in_ucFFactor); |
|---|
| 903 | |
|---|
| 904 | |
|---|
| 905 | BDBG_MSG(("sc_bauddiv = 0x%2x\n", in_channelHandle->currentChannelSettings.ucBaudDiv)); |
|---|
| 906 | |
|---|
| 907 | BDBG_MSG(("orig ucClkCmd = 0x%x\n", BREG_Read32( |
|---|
| 908 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 909 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD)) )); |
|---|
| 910 | |
|---|
| 911 | in_channelHandle->currentChannelSettings.ucScClkDiv = |
|---|
| 912 | BSCD_P_GetClkDiv(in_channelHandle, in_ucDFactor, in_ucFFactor) ; |
|---|
| 913 | |
|---|
| 914 | if (in_channelHandle->currentChannelSettings.ucBaudDiv == BSCD_DEFAULT_BAUD_DIV) { |
|---|
| 915 | if(in_channelHandle->currentChannelSettings.ucScClkDiv<16) |
|---|
| 916 | ulClkCmd = BCHP_SCA_SC_CLK_CMD_clk_en_MASK | |
|---|
| 917 | BSCD_P_MapScClkDivToMaskValue(in_channelHandle->currentChannelSettings.ucScClkDiv ) | |
|---|
| 918 | ((in_channelHandle->currentChannelSettings.ucEtuClkDiv - 1) << 1) ; |
|---|
| 919 | else{ |
|---|
| 920 | #if(BCHP_CHIP==7420) || (BCHP_CHIP==7340) || (BCHP_CHIP==7342)|| (BCHP_CHIP==7125) |
|---|
| 921 | ulClkCmd = BCHP_SCA_SC_CLK_CMD_clk_en_MASK | |
|---|
| 922 | BSCD_P_MapScClkDivToMaskValue(1 ) | |
|---|
| 923 | ((in_channelHandle->currentChannelSettings.ucEtuClkDiv - 1) << 1) ; |
|---|
| 924 | BREG_Write32( |
|---|
| 925 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 926 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD_2), |
|---|
| 927 | 1); |
|---|
| 928 | #else |
|---|
| 929 | BDBG_ERR(("Clock divider %d not supported", in_channelHandle->currentChannelSettings.ucScClkDiv)); |
|---|
| 930 | #endif |
|---|
| 931 | } |
|---|
| 932 | } |
|---|
| 933 | else { |
|---|
| 934 | if(in_channelHandle->currentChannelSettings.ucScClkDiv<16) |
|---|
| 935 | ulClkCmd = BCHP_SCA_SC_CLK_CMD_clk_en_MASK | |
|---|
| 936 | BSCD_P_MapScClkDivToMaskValue(in_channelHandle->currentChannelSettings.ucScClkDiv ) | |
|---|
| 937 | ((in_channelHandle->currentChannelSettings.ucEtuClkDiv - 1) << 1) | |
|---|
| 938 | BCHP_SCA_SC_CLK_CMD_bauddiv_MASK; |
|---|
| 939 | else{ |
|---|
| 940 | #if(BCHP_CHIP==7420) || (BCHP_CHIP==7340) || (BCHP_CHIP==7342)|| (BCHP_CHIP==7125) |
|---|
| 941 | ulClkCmd = BCHP_SCA_SC_CLK_CMD_clk_en_MASK | |
|---|
| 942 | BSCD_P_MapScClkDivToMaskValue(1 ) | |
|---|
| 943 | ((in_channelHandle->currentChannelSettings.ucEtuClkDiv - 1) << 1) | |
|---|
| 944 | BCHP_SCA_SC_CLK_CMD_bauddiv_MASK; |
|---|
| 945 | BREG_Write32( |
|---|
| 946 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 947 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD_2), |
|---|
| 948 | 1); |
|---|
| 949 | #else |
|---|
| 950 | BDBG_ERR(("Clock divider %d not supported", in_channelHandle->currentChannelSettings.ucScClkDiv)); |
|---|
| 951 | #endif |
|---|
| 952 | } |
|---|
| 953 | } |
|---|
| 954 | |
|---|
| 955 | BREG_Write32( |
|---|
| 956 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 957 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD), |
|---|
| 958 | ulClkCmd); |
|---|
| 959 | BDBG_MSG(("New SC_CLK_CMD = 0x%x\n", ulClkCmd)); |
|---|
| 960 | |
|---|
| 961 | BDBG_LEAVE(BSCD_P_FDAdjust); |
|---|
| 962 | return( errCode ); |
|---|
| 963 | |
|---|
| 964 | } |
|---|
| 965 | |
|---|
| 966 | |
|---|
| 967 | /* Default ISR Callback Functions */ |
|---|
| 968 | void BSCD_Channel_P_CardInsertCB_isr( |
|---|
| 969 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 970 | void *inp_data |
|---|
| 971 | ) |
|---|
| 972 | { |
|---|
| 973 | BDBG_MSG(("default BSCD_Channel_P_CardInsertCB_isr \n")); |
|---|
| 974 | BSTD_UNUSED(inp_data); |
|---|
| 975 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 976 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.cardWait); |
|---|
| 977 | } |
|---|
| 978 | } |
|---|
| 979 | |
|---|
| 980 | void BSCD_Channel_P_CardRemoveCB_isr( |
|---|
| 981 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 982 | void *inp_data |
|---|
| 983 | ) |
|---|
| 984 | { |
|---|
| 985 | BDBG_MSG(("default BSCD_Channel_P_CardRemoveCB_isr \n")); |
|---|
| 986 | BSTD_UNUSED(inp_data); |
|---|
| 987 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 988 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.cardWait); |
|---|
| 989 | /* 09/20/05, Allen.C, set rcv event and let BKNI_WaitForEvent() exit after card is removed*/ |
|---|
| 990 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 991 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.tdoneWait); |
|---|
| 992 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.timerWait); |
|---|
| 993 | } |
|---|
| 994 | } |
|---|
| 995 | |
|---|
| 996 | |
|---|
| 997 | void BSCD_Channel_P_RcvCB_isr( |
|---|
| 998 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 999 | void *inp_data |
|---|
| 1000 | ) |
|---|
| 1001 | { |
|---|
| 1002 | BSTD_UNUSED(inp_data); |
|---|
| 1003 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1004 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1005 | } |
|---|
| 1006 | } |
|---|
| 1007 | |
|---|
| 1008 | void BSCD_Channel_P_ATRCB_isr( |
|---|
| 1009 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1010 | void *inp_data |
|---|
| 1011 | ) |
|---|
| 1012 | { |
|---|
| 1013 | BSTD_UNUSED(inp_data); |
|---|
| 1014 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1015 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.atrStart); |
|---|
| 1016 | } |
|---|
| 1017 | } |
|---|
| 1018 | |
|---|
| 1019 | void BSCD_Channel_P_WaitCB_isr( |
|---|
| 1020 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1021 | void *inp_data |
|---|
| 1022 | ) |
|---|
| 1023 | { |
|---|
| 1024 | BSTD_UNUSED(inp_data); |
|---|
| 1025 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1026 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1027 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.tdoneWait); |
|---|
| 1028 | } |
|---|
| 1029 | |
|---|
| 1030 | } |
|---|
| 1031 | |
|---|
| 1032 | void BSCD_Channel_P_RetryCB_isr( |
|---|
| 1033 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1034 | void *inp_data |
|---|
| 1035 | ) |
|---|
| 1036 | { |
|---|
| 1037 | BSTD_UNUSED(inp_data); |
|---|
| 1038 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1039 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.tdoneWait); |
|---|
| 1040 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1041 | } |
|---|
| 1042 | } |
|---|
| 1043 | |
|---|
| 1044 | void BSCD_Channel_P_TimerCB_isr( |
|---|
| 1045 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1046 | void *inp_data |
|---|
| 1047 | ) |
|---|
| 1048 | { |
|---|
| 1049 | BDBG_ENTER(BSCD_Channel_P_TimerCB_isr); |
|---|
| 1050 | BSTD_UNUSED(inp_data); |
|---|
| 1051 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1052 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.atrStart); |
|---|
| 1053 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1054 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.timerWait); |
|---|
| 1055 | } |
|---|
| 1056 | BDBG_LEAVE(BSCD_Channel_P_TimerCB_isr); |
|---|
| 1057 | } |
|---|
| 1058 | |
|---|
| 1059 | void BSCD_Channel_P_RParityCB_isr( |
|---|
| 1060 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1061 | void *inp_data |
|---|
| 1062 | ) |
|---|
| 1063 | { |
|---|
| 1064 | BSTD_UNUSED(inp_data); |
|---|
| 1065 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1066 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1067 | } |
|---|
| 1068 | } |
|---|
| 1069 | |
|---|
| 1070 | void BSCD_Channel_P_TParityCB_isr( |
|---|
| 1071 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1072 | void *inp_data |
|---|
| 1073 | ) |
|---|
| 1074 | { |
|---|
| 1075 | BSTD_UNUSED(inp_data); |
|---|
| 1076 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1077 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.tdoneWait); |
|---|
| 1078 | } |
|---|
| 1079 | } |
|---|
| 1080 | |
|---|
| 1081 | void BSCD_Channel_P_CWTCB_isr( |
|---|
| 1082 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1083 | void *inp_data |
|---|
| 1084 | ) |
|---|
| 1085 | { |
|---|
| 1086 | BSTD_UNUSED(inp_data); |
|---|
| 1087 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1088 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1089 | } |
|---|
| 1090 | } |
|---|
| 1091 | |
|---|
| 1092 | void BSCD_Channel_P_BGTCB_isr( |
|---|
| 1093 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1094 | void *inp_data |
|---|
| 1095 | ) |
|---|
| 1096 | { |
|---|
| 1097 | BSTD_UNUSED(inp_data); |
|---|
| 1098 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1099 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.tdoneWait); |
|---|
| 1100 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1101 | } |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | void BSCD_Channel_P_RLenCB_isr( |
|---|
| 1105 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1106 | void *inp_data |
|---|
| 1107 | ) |
|---|
| 1108 | { |
|---|
| 1109 | BSTD_UNUSED(inp_data); |
|---|
| 1110 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1111 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1112 | } |
|---|
| 1113 | } |
|---|
| 1114 | |
|---|
| 1115 | void BSCD_Channel_P_RReadyCB_isr( |
|---|
| 1116 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1117 | void *inp_data |
|---|
| 1118 | ) |
|---|
| 1119 | { |
|---|
| 1120 | BSTD_UNUSED(inp_data); |
|---|
| 1121 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1122 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1123 | } |
|---|
| 1124 | } |
|---|
| 1125 | |
|---|
| 1126 | void BSCD_Channel_P_TDoneCB_isr( |
|---|
| 1127 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1128 | void *inp_data |
|---|
| 1129 | ) |
|---|
| 1130 | { |
|---|
| 1131 | BSTD_UNUSED(inp_data); |
|---|
| 1132 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1133 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.tdoneWait); |
|---|
| 1134 | } |
|---|
| 1135 | } |
|---|
| 1136 | |
|---|
| 1137 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 1138 | void BSCD_Channel_P_Event1CB_isr( |
|---|
| 1139 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1140 | void *inp_data |
|---|
| 1141 | ) |
|---|
| 1142 | { |
|---|
| 1143 | BSTD_UNUSED(inp_data); |
|---|
| 1144 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1145 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1146 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.event1Wait); |
|---|
| 1147 | } |
|---|
| 1148 | } |
|---|
| 1149 | #endif |
|---|
| 1150 | |
|---|
| 1151 | void BSCD_Channel_P_Event2CB_isr( |
|---|
| 1152 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1153 | void *inp_data |
|---|
| 1154 | ) |
|---|
| 1155 | { |
|---|
| 1156 | BSTD_UNUSED(inp_data); |
|---|
| 1157 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 1158 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.event2Wait); |
|---|
| 1159 | BKNI_SetEvent( in_channelHandle->channelWaitEvent.rcvWait); |
|---|
| 1160 | } |
|---|
| 1161 | } |
|---|
| 1162 | |
|---|
| 1163 | |
|---|
| 1164 | |
|---|
| 1165 | BERR_Code BSCD_Channel_P_WaitForCardInsertion( |
|---|
| 1166 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1167 | ) |
|---|
| 1168 | { |
|---|
| 1169 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1170 | uint32_t ulStatus1; |
|---|
| 1171 | |
|---|
| 1172 | BDBG_ENTER(BSCD_Channel_P_WaitForCardInsertion); |
|---|
| 1173 | |
|---|
| 1174 | BDBG_MSG(("Ready to receive card insertion pres_intr interrupt")); |
|---|
| 1175 | |
|---|
| 1176 | |
|---|
| 1177 | BKNI_EnterCriticalSection(); |
|---|
| 1178 | ulStatus1 = in_channelHandle->ulStatus1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK; |
|---|
| 1179 | BKNI_LeaveCriticalSection(); |
|---|
| 1180 | |
|---|
| 1181 | do { |
|---|
| 1182 | |
|---|
| 1183 | if ( ulStatus1 != BCHP_SCA_SC_STATUS_1_card_pres_MASK) { |
|---|
| 1184 | |
|---|
| 1185 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1186 | BKNI_WaitForEvent( in_channelHandle->channelWaitEvent.cardWait, BKNI_INFINITE)); |
|---|
| 1187 | |
|---|
| 1188 | } |
|---|
| 1189 | |
|---|
| 1190 | BKNI_EnterCriticalSection(); |
|---|
| 1191 | ulStatus1 = in_channelHandle->ulStatus1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK; |
|---|
| 1192 | BKNI_LeaveCriticalSection(); |
|---|
| 1193 | |
|---|
| 1194 | } while (ulStatus1 != BCHP_SCA_SC_STATUS_1_card_pres_MASK); |
|---|
| 1195 | |
|---|
| 1196 | BDBG_MSG(("Received card insertion pres_intr interrupt")); |
|---|
| 1197 | |
|---|
| 1198 | if ( ulStatus1 == BCHP_SCA_SC_STATUS_1_card_pres_MASK) { |
|---|
| 1199 | in_channelHandle->channelStatus.bCardPresent = true; |
|---|
| 1200 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK; |
|---|
| 1201 | BDBG_MSG(("Smart Card Inserted")); |
|---|
| 1202 | } |
|---|
| 1203 | |
|---|
| 1204 | BSCD_P_DONE_LABEL: |
|---|
| 1205 | |
|---|
| 1206 | BDBG_LEAVE(BSCD_Channel_P_WaitForCardInsertion); |
|---|
| 1207 | return errCode; |
|---|
| 1208 | } |
|---|
| 1209 | |
|---|
| 1210 | BERR_Code BSCD_Channel_P_WaitForCardRemove( |
|---|
| 1211 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1212 | ) |
|---|
| 1213 | { |
|---|
| 1214 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1215 | uint32_t ulStatus1; |
|---|
| 1216 | |
|---|
| 1217 | BDBG_ENTER(BSCD_Channel_P_WaitForCardRemove); |
|---|
| 1218 | |
|---|
| 1219 | BDBG_MSG(("Ready to receive card removal pres_intr interrupt")); |
|---|
| 1220 | |
|---|
| 1221 | |
|---|
| 1222 | BKNI_EnterCriticalSection(); |
|---|
| 1223 | ulStatus1 = in_channelHandle->ulStatus1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK; |
|---|
| 1224 | BKNI_LeaveCriticalSection(); |
|---|
| 1225 | |
|---|
| 1226 | do { |
|---|
| 1227 | |
|---|
| 1228 | if ( ulStatus1 == BCHP_SCA_SC_STATUS_1_card_pres_MASK) { |
|---|
| 1229 | |
|---|
| 1230 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1231 | BKNI_WaitForEvent( in_channelHandle->channelWaitEvent.cardWait, BKNI_INFINITE)); |
|---|
| 1232 | |
|---|
| 1233 | } |
|---|
| 1234 | |
|---|
| 1235 | BKNI_EnterCriticalSection(); |
|---|
| 1236 | ulStatus1 = in_channelHandle->ulStatus1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK; |
|---|
| 1237 | BKNI_LeaveCriticalSection(); |
|---|
| 1238 | |
|---|
| 1239 | } while (ulStatus1 == BCHP_SCA_SC_STATUS_1_card_pres_MASK); |
|---|
| 1240 | |
|---|
| 1241 | BDBG_MSG(("Received card removal pres_intr interrupt")); |
|---|
| 1242 | |
|---|
| 1243 | if ( ulStatus1 != BCHP_SCA_SC_STATUS_1_card_pres_MASK) { |
|---|
| 1244 | in_channelHandle->channelStatus.bCardPresent = false; |
|---|
| 1245 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK; |
|---|
| 1246 | BDBG_MSG(("Smart Card Removed")); |
|---|
| 1247 | } |
|---|
| 1248 | |
|---|
| 1249 | BSCD_P_DONE_LABEL: |
|---|
| 1250 | |
|---|
| 1251 | BDBG_LEAVE(BSCD_Channel_P_WaitForCardRemove); |
|---|
| 1252 | return errCode; |
|---|
| 1253 | } |
|---|
| 1254 | |
|---|
| 1255 | |
|---|
| 1256 | BERR_Code BSCD_Channel_P_WaitForTimerEvent( |
|---|
| 1257 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1258 | ) |
|---|
| 1259 | { |
|---|
| 1260 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1261 | uint32_t ulIntrStatus1; |
|---|
| 1262 | |
|---|
| 1263 | BDBG_ENTER(BSCD_Channel_P_WaitForTimerEvent); |
|---|
| 1264 | |
|---|
| 1265 | BDBG_MSG(("Ready to receive scard_timer_wait interrupt\n")); |
|---|
| 1266 | |
|---|
| 1267 | |
|---|
| 1268 | |
|---|
| 1269 | do { |
|---|
| 1270 | BKNI_EnterCriticalSection(); |
|---|
| 1271 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1; |
|---|
| 1272 | BKNI_LeaveCriticalSection(); |
|---|
| 1273 | |
|---|
| 1274 | BDBG_MSG(("ulIntrStatus1 = 0x%x\n", ulIntrStatus1)); |
|---|
| 1275 | BDBG_MSG(("in_channelHandle->ulIntrStatus1 = 0x%x\n", in_channelHandle->ulIntrStatus1)); |
|---|
| 1276 | /*09/20/05,Allen.C, check if the Card is removed */ |
|---|
| 1277 | if ( (in_channelHandle-> bIsCardRemoved == true) && |
|---|
| 1278 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK ) == BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK)) { |
|---|
| 1279 | BKNI_EnterCriticalSection(); |
|---|
| 1280 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK; |
|---|
| 1281 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RESET_CHANNEL_REQUIRED; |
|---|
| 1282 | in_channelHandle-> bIsCardRemoved = false ; |
|---|
| 1283 | BKNI_LeaveCriticalSection(); |
|---|
| 1284 | BDBG_ERR(("ScardDeviceTimerEvent: SC_CARD_REMOVED error \n")); |
|---|
| 1285 | errCode = BSCD_STATUS_FAILED ; |
|---|
| 1286 | goto BSCD_P_DONE_LABEL; |
|---|
| 1287 | } |
|---|
| 1288 | else if (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) != BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) { |
|---|
| 1289 | |
|---|
| 1290 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1291 | BKNI_WaitForEvent( in_channelHandle->channelWaitEvent.timerWait, |
|---|
| 1292 | in_channelHandle->currentChannelSettings.timeOut.ulValue)); |
|---|
| 1293 | |
|---|
| 1294 | } |
|---|
| 1295 | |
|---|
| 1296 | |
|---|
| 1297 | |
|---|
| 1298 | } while ((ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK )!= |
|---|
| 1299 | BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK); |
|---|
| 1300 | |
|---|
| 1301 | BKNI_EnterCriticalSection(); |
|---|
| 1302 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK; |
|---|
| 1303 | BKNI_LeaveCriticalSection(); |
|---|
| 1304 | BDBG_MSG(("scard_timer_wait interrupt received\n")); |
|---|
| 1305 | |
|---|
| 1306 | BSCD_P_DONE_LABEL: |
|---|
| 1307 | |
|---|
| 1308 | BDBG_LEAVE(BSCD_Channel_P_WaitForTimerEvent); |
|---|
| 1309 | return errCode; |
|---|
| 1310 | } |
|---|
| 1311 | |
|---|
| 1312 | BERR_Code BSCD_Channel_P_WaitForATRStart( |
|---|
| 1313 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1314 | ) |
|---|
| 1315 | { |
|---|
| 1316 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1317 | uint32_t ulIntrStatus1, ulIntrStatus2; |
|---|
| 1318 | |
|---|
| 1319 | BDBG_ENTER(BSCD_Channel_P_WaitForATRStart); |
|---|
| 1320 | |
|---|
| 1321 | BDBG_MSG(("Ready to receive scard_atrStart interrupt, ucSlot = %d\n", in_channelHandle->ucChannelNumber)); |
|---|
| 1322 | |
|---|
| 1323 | BKNI_EnterCriticalSection(); |
|---|
| 1324 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1; |
|---|
| 1325 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_atrs_intr_MASK; |
|---|
| 1326 | BKNI_LeaveCriticalSection(); |
|---|
| 1327 | |
|---|
| 1328 | BDBG_MSG(("ulIntrStatus1 = 0x%x, ulIntrStatus2 = 0x%xn", ulIntrStatus1, ulIntrStatus2)); |
|---|
| 1329 | BDBG_MSG(("in_channelHandle->ulIntrStatus1 = 0x%x\n", in_channelHandle->ulIntrStatus1)); |
|---|
| 1330 | |
|---|
| 1331 | |
|---|
| 1332 | do { |
|---|
| 1333 | |
|---|
| 1334 | if ( (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) && |
|---|
| 1335 | (ulIntrStatus2 == BCHP_SCA_SC_INTR_STAT_2_atrs_intr_MASK) ) { |
|---|
| 1336 | goto BSCD_P_SUCCESS_LABEL; |
|---|
| 1337 | } |
|---|
| 1338 | else if (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) { |
|---|
| 1339 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK; |
|---|
| 1340 | BDBG_ERR(("ScardDeviceWaitForATRStart: SC_TIMER_INTR error \n")); |
|---|
| 1341 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1342 | goto BSCD_P_DONE_LABEL; |
|---|
| 1343 | |
|---|
| 1344 | } |
|---|
| 1345 | /*04/11/06,Allen.C, check if the Card is removed */ |
|---|
| 1346 | else if ( (in_channelHandle-> bIsCardRemoved == true) && |
|---|
| 1347 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK ) == BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK)) { |
|---|
| 1348 | BKNI_EnterCriticalSection(); |
|---|
| 1349 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK; |
|---|
| 1350 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RESET_CHANNEL_REQUIRED; |
|---|
| 1351 | in_channelHandle-> bIsCardRemoved = false ; |
|---|
| 1352 | BKNI_LeaveCriticalSection(); |
|---|
| 1353 | BDBG_ERR(("ScardDeviceWaitForTDone: SC_CARD_REMOVED error \n")); |
|---|
| 1354 | errCode = BSCD_STATUS_FAILED ; |
|---|
| 1355 | goto BSCD_P_DONE_LABEL; |
|---|
| 1356 | } |
|---|
| 1357 | else if (ulIntrStatus2 != BCHP_SCA_SC_INTR_STAT_2_atrs_intr_MASK) { |
|---|
| 1358 | |
|---|
| 1359 | |
|---|
| 1360 | if ( (errCode = BERR_TRACE(BKNI_WaitForEvent( in_channelHandle->channelWaitEvent.atrStart, |
|---|
| 1361 | in_channelHandle->currentChannelSettings.timeOut.ulValue))) != BERR_SUCCESS ) { |
|---|
| 1362 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1363 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1364 | goto BSCD_P_DONE_LABEL; |
|---|
| 1365 | } |
|---|
| 1366 | |
|---|
| 1367 | } |
|---|
| 1368 | |
|---|
| 1369 | BKNI_EnterCriticalSection(); |
|---|
| 1370 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1; |
|---|
| 1371 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_atrs_intr_MASK; |
|---|
| 1372 | BKNI_LeaveCriticalSection(); |
|---|
| 1373 | |
|---|
| 1374 | }while (ulIntrStatus2 != BCHP_SCA_SC_INTR_STAT_2_atrs_intr_MASK); |
|---|
| 1375 | |
|---|
| 1376 | |
|---|
| 1377 | BSCD_P_SUCCESS_LABEL: |
|---|
| 1378 | |
|---|
| 1379 | BKNI_EnterCriticalSection(); |
|---|
| 1380 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_atrs_intr_MASK; |
|---|
| 1381 | BKNI_LeaveCriticalSection(); |
|---|
| 1382 | BDBG_MSG(("scard_atrStart interrupt received\n")); |
|---|
| 1383 | |
|---|
| 1384 | BSCD_P_DONE_LABEL: |
|---|
| 1385 | |
|---|
| 1386 | BDBG_LEAVE(BSCD_Channel_P_WaitForATRStart); |
|---|
| 1387 | return errCode; |
|---|
| 1388 | } |
|---|
| 1389 | |
|---|
| 1390 | |
|---|
| 1391 | BERR_Code BSCD_Channel_P_WaitForTDone( |
|---|
| 1392 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1393 | ) |
|---|
| 1394 | { |
|---|
| 1395 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1396 | uint32_t ulIntrStatus1, ulIntrStatus2; |
|---|
| 1397 | |
|---|
| 1398 | BDBG_ENTER(BSCD_Channel_P_WaitForTDone); |
|---|
| 1399 | |
|---|
| 1400 | BDBG_MSG(("Ready to receive scard_tDone interrupt, ucSlot = %d\n", in_channelHandle->ucChannelNumber)); |
|---|
| 1401 | |
|---|
| 1402 | BKNI_EnterCriticalSection(); |
|---|
| 1403 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1 ; |
|---|
| 1404 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2; |
|---|
| 1405 | BKNI_LeaveCriticalSection(); |
|---|
| 1406 | |
|---|
| 1407 | do { |
|---|
| 1408 | if ( (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1) && |
|---|
| 1409 | ((ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK) == |
|---|
| 1410 | BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK) ) { |
|---|
| 1411 | BKNI_EnterCriticalSection(); |
|---|
| 1412 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK; |
|---|
| 1413 | BKNI_LeaveCriticalSection(); |
|---|
| 1414 | BDBG_ERR(("ScardDeviceWaitForTDone: SC_BGT_INTR error \n")); |
|---|
| 1415 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1416 | goto BSCD_P_DONE_LABEL; |
|---|
| 1417 | } |
|---|
| 1418 | |
|---|
| 1419 | else if ( (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e0) && |
|---|
| 1420 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK) == |
|---|
| 1421 | BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK) ) { |
|---|
| 1422 | |
|---|
| 1423 | BKNI_EnterCriticalSection(); |
|---|
| 1424 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK; |
|---|
| 1425 | BKNI_LeaveCriticalSection(); |
|---|
| 1426 | BDBG_ERR(("ScardDeviceWaitForTDone: RETRY_INTR error \n")); |
|---|
| 1427 | |
|---|
| 1428 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_TX_PARITY; |
|---|
| 1429 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1430 | goto BSCD_P_DONE_LABEL; |
|---|
| 1431 | } |
|---|
| 1432 | else if (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK) { |
|---|
| 1433 | BKNI_EnterCriticalSection(); |
|---|
| 1434 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK; |
|---|
| 1435 | BKNI_LeaveCriticalSection(); |
|---|
| 1436 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_TX_TIMEOUT; |
|---|
| 1437 | BDBG_ERR(("ScardDeviceWaitForTDone: SC_WAIT_INTR error \n")); |
|---|
| 1438 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1439 | goto BSCD_P_DONE_LABEL; |
|---|
| 1440 | } |
|---|
| 1441 | /*09/20/05,Allen.C, check if the Card is removed */ |
|---|
| 1442 | else if ( (in_channelHandle-> bIsCardRemoved == true) && |
|---|
| 1443 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK ) == BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK)) { |
|---|
| 1444 | BKNI_EnterCriticalSection(); |
|---|
| 1445 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK; |
|---|
| 1446 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RESET_CHANNEL_REQUIRED; |
|---|
| 1447 | in_channelHandle-> bIsCardRemoved = false ; |
|---|
| 1448 | BKNI_LeaveCriticalSection(); |
|---|
| 1449 | BDBG_ERR(("ScardDeviceWaitForTDone: SC_CARD_REMOVED error \n")); |
|---|
| 1450 | errCode = BSCD_STATUS_FAILED ; |
|---|
| 1451 | goto BSCD_P_DONE_LABEL; |
|---|
| 1452 | } |
|---|
| 1453 | else if (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK) != BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK) { |
|---|
| 1454 | if ( (errCode = BERR_TRACE(BKNI_WaitForEvent( in_channelHandle->channelWaitEvent.tdoneWait, |
|---|
| 1455 | in_channelHandle->currentChannelSettings.timeOut.ulValue))) != BERR_SUCCESS ) { |
|---|
| 1456 | BKNI_EnterCriticalSection(); |
|---|
| 1457 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_TX_TIMEOUT; |
|---|
| 1458 | BKNI_LeaveCriticalSection(); |
|---|
| 1459 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1460 | goto BSCD_P_DONE_LABEL; |
|---|
| 1461 | } |
|---|
| 1462 | } |
|---|
| 1463 | |
|---|
| 1464 | BKNI_EnterCriticalSection(); |
|---|
| 1465 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1; |
|---|
| 1466 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2; |
|---|
| 1467 | BKNI_LeaveCriticalSection(); |
|---|
| 1468 | |
|---|
| 1469 | }while ((ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK )!= |
|---|
| 1470 | BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK); |
|---|
| 1471 | |
|---|
| 1472 | BKNI_EnterCriticalSection(); |
|---|
| 1473 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK; |
|---|
| 1474 | in_channelHandle->ulStatus1 &= ~BCHP_SCA_SC_STATUS_1_tdone_MASK; |
|---|
| 1475 | BKNI_LeaveCriticalSection(); |
|---|
| 1476 | BDBG_MSG(("tdone_intr interrupt received\n")); |
|---|
| 1477 | |
|---|
| 1478 | |
|---|
| 1479 | BSCD_P_DONE_LABEL: |
|---|
| 1480 | |
|---|
| 1481 | BDBG_LEAVE(BSCD_Channel_P_WaitForTDone); |
|---|
| 1482 | return errCode; |
|---|
| 1483 | } |
|---|
| 1484 | |
|---|
| 1485 | |
|---|
| 1486 | BERR_Code BSCD_Channel_P_WaitForRcv( |
|---|
| 1487 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1488 | ) |
|---|
| 1489 | { |
|---|
| 1490 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1491 | uint32_t ulIntrStatus1, ulIntrStatus2, ulStatus2; |
|---|
| 1492 | |
|---|
| 1493 | BDBG_ENTER(BSCD_Channel_P_WaitForRcv); |
|---|
| 1494 | |
|---|
| 1495 | /* BDBG_MSG(("Ready to receive rcv interrupt\n")); */ |
|---|
| 1496 | |
|---|
| 1497 | BKNI_EnterCriticalSection(); |
|---|
| 1498 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1 ; |
|---|
| 1499 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2; |
|---|
| 1500 | ulStatus2 = in_channelHandle->ulStatus2; |
|---|
| 1501 | BKNI_LeaveCriticalSection(); |
|---|
| 1502 | |
|---|
| 1503 | do { |
|---|
| 1504 | |
|---|
| 1505 | |
|---|
| 1506 | if ((ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK ) { |
|---|
| 1507 | BKNI_EnterCriticalSection(); |
|---|
| 1508 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1509 | BKNI_LeaveCriticalSection(); |
|---|
| 1510 | /* This could be a good error if the caller specify a length larger than that of the actual one. */ |
|---|
| 1511 | BDBG_MSG(("ScardDeviceWaitForRcv: SC_TIMER_INTR error \n")); |
|---|
| 1512 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1513 | goto BSCD_P_DONE_LABEL; |
|---|
| 1514 | } |
|---|
| 1515 | |
|---|
| 1516 | /* BSYT???: Obsolete ??? */ |
|---|
| 1517 | else if ( (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1) && |
|---|
| 1518 | ((ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK) ) { |
|---|
| 1519 | BKNI_EnterCriticalSection(); |
|---|
| 1520 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK; |
|---|
| 1521 | BKNI_LeaveCriticalSection(); |
|---|
| 1522 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_BGT_INTR error \n")); |
|---|
| 1523 | errCode = BSCD_STATUS_READ_FAILED; |
|---|
| 1524 | goto BSCD_P_DONE_LABEL; |
|---|
| 1525 | } |
|---|
| 1526 | else if ( ( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_event2_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_event2_intr_MASK) { |
|---|
| 1527 | |
|---|
| 1528 | BKNI_EnterCriticalSection(); |
|---|
| 1529 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_event2_intr_MASK; |
|---|
| 1530 | in_channelHandle->channelStatus.ulStatus2 |= BSCD_RX_TIMEOUT; |
|---|
| 1531 | BKNI_LeaveCriticalSection(); |
|---|
| 1532 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_EVENT2_INTR error \n")); |
|---|
| 1533 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1534 | goto BSCD_P_DONE_LABEL; |
|---|
| 1535 | } |
|---|
| 1536 | else if ((in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e0 ) && |
|---|
| 1537 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto) && |
|---|
| 1538 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK)) { |
|---|
| 1539 | BKNI_EnterCriticalSection(); |
|---|
| 1540 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK; |
|---|
| 1541 | BKNI_LeaveCriticalSection(); |
|---|
| 1542 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_RETRY_INTR error \n")); |
|---|
| 1543 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_PARITY; |
|---|
| 1544 | errCode = BSCD_STATUS_PARITY_EDC_ERR; |
|---|
| 1545 | goto BSCD_P_DONE_LABEL; |
|---|
| 1546 | } |
|---|
| 1547 | |
|---|
| 1548 | else if ( (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1) && |
|---|
| 1549 | ((ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK) ) { |
|---|
| 1550 | BKNI_EnterCriticalSection(); |
|---|
| 1551 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK; |
|---|
| 1552 | BKNI_LeaveCriticalSection(); |
|---|
| 1553 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_RLEN_INTR error \n")); |
|---|
| 1554 | errCode = BSCD_STATUS_READ_FAILED; |
|---|
| 1555 | goto BSCD_P_DONE_LABEL; |
|---|
| 1556 | } |
|---|
| 1557 | else if (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK) { |
|---|
| 1558 | BKNI_EnterCriticalSection(); |
|---|
| 1559 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK; |
|---|
| 1560 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1561 | BKNI_LeaveCriticalSection(); |
|---|
| 1562 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_WAIT_INTR error \n")); |
|---|
| 1563 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1564 | goto BSCD_P_DONE_LABEL; |
|---|
| 1565 | } |
|---|
| 1566 | else if (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK) { |
|---|
| 1567 | BKNI_EnterCriticalSection(); |
|---|
| 1568 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK; |
|---|
| 1569 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1570 | BKNI_LeaveCriticalSection(); |
|---|
| 1571 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_CWT_INTR error \n")); |
|---|
| 1572 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1573 | goto BSCD_P_DONE_LABEL; |
|---|
| 1574 | } |
|---|
| 1575 | else if (( ulStatus2 & BCHP_SCA_SC_STATUS_2_roverflow_MASK) == BCHP_SCA_SC_STATUS_2_roverflow_MASK) { |
|---|
| 1576 | BKNI_EnterCriticalSection(); |
|---|
| 1577 | in_channelHandle->ulStatus2 &= ~BCHP_SCA_SC_STATUS_2_roverflow_MASK; |
|---|
| 1578 | BKNI_LeaveCriticalSection(); |
|---|
| 1579 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_ROVERFLOW error \n")); |
|---|
| 1580 | errCode = BSCD_STATUS_READ_FAILED; |
|---|
| 1581 | goto BSCD_P_DONE_LABEL; |
|---|
| 1582 | } |
|---|
| 1583 | /*09/20/05,Allen.C, check if the Card is removed */ |
|---|
| 1584 | else if ( (in_channelHandle-> bIsCardRemoved == true) && |
|---|
| 1585 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK ) == BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK)) { |
|---|
| 1586 | BKNI_EnterCriticalSection(); |
|---|
| 1587 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK; |
|---|
| 1588 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RESET_CHANNEL_REQUIRED; |
|---|
| 1589 | in_channelHandle-> bIsCardRemoved = false ; |
|---|
| 1590 | BKNI_LeaveCriticalSection(); |
|---|
| 1591 | BDBG_ERR(("ScardDeviceWaitForRcv: SC_CARD_REMOVED error \n")); |
|---|
| 1592 | errCode = BSCD_STATUS_FAILED ; |
|---|
| 1593 | goto BSCD_P_DONE_LABEL; |
|---|
| 1594 | } |
|---|
| 1595 | else if (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK) != BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK) { |
|---|
| 1596 | if ( (errCode = BERR_TRACE(BKNI_WaitForEvent( in_channelHandle->channelWaitEvent.rcvWait, |
|---|
| 1597 | in_channelHandle->currentChannelSettings.timeOut.ulValue))) != BERR_SUCCESS ) { |
|---|
| 1598 | BKNI_EnterCriticalSection(); |
|---|
| 1599 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1600 | BKNI_LeaveCriticalSection(); |
|---|
| 1601 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1602 | goto BSCD_P_DONE_LABEL; |
|---|
| 1603 | } |
|---|
| 1604 | } |
|---|
| 1605 | |
|---|
| 1606 | BKNI_EnterCriticalSection(); |
|---|
| 1607 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1; |
|---|
| 1608 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2; |
|---|
| 1609 | ulStatus2 = in_channelHandle->ulStatus2; |
|---|
| 1610 | BKNI_LeaveCriticalSection(); |
|---|
| 1611 | |
|---|
| 1612 | }while ((ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK ) != |
|---|
| 1613 | BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK); |
|---|
| 1614 | |
|---|
| 1615 | |
|---|
| 1616 | BKNI_EnterCriticalSection(); |
|---|
| 1617 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK; |
|---|
| 1618 | in_channelHandle->ulStatus2 |= BCHP_SCA_SC_STATUS_2_rempty_MASK; |
|---|
| 1619 | BKNI_LeaveCriticalSection(); |
|---|
| 1620 | /* BDBG_MSG(("rcv interrupt received\n")); */ |
|---|
| 1621 | |
|---|
| 1622 | BSCD_P_DONE_LABEL: |
|---|
| 1623 | |
|---|
| 1624 | BDBG_LEAVE(BSCD_Channel_P_WaitForRcv); |
|---|
| 1625 | /* BDBG_MSG(("LeaveWaitForRcv errCode = 0x%x \n", errCode)); */ |
|---|
| 1626 | return errCode; |
|---|
| 1627 | } |
|---|
| 1628 | |
|---|
| 1629 | BERR_Code BSCD_Channel_P_WaitForRReady( |
|---|
| 1630 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1631 | ) |
|---|
| 1632 | { |
|---|
| 1633 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1634 | uint32_t ulIntrStatus1, ulIntrStatus2, ulStatus2; |
|---|
| 1635 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 1636 | uint32_t ulVal; |
|---|
| 1637 | #endif |
|---|
| 1638 | |
|---|
| 1639 | |
|---|
| 1640 | BDBG_ENTER(BSCD_Channel_P_WaitForRReady); |
|---|
| 1641 | |
|---|
| 1642 | BDBG_MSG(("Ready to receive rready interrupt\n")); |
|---|
| 1643 | |
|---|
| 1644 | BKNI_EnterCriticalSection(); |
|---|
| 1645 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1 ; |
|---|
| 1646 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2; |
|---|
| 1647 | ulStatus2 = in_channelHandle->ulStatus2; |
|---|
| 1648 | BKNI_LeaveCriticalSection(); |
|---|
| 1649 | |
|---|
| 1650 | |
|---|
| 1651 | |
|---|
| 1652 | do { |
|---|
| 1653 | |
|---|
| 1654 | |
|---|
| 1655 | BDBG_MSG(("ulIntrStatus1 = 0x%x, ulIntrStatus2 = 0x%x, ulStatus2 = 0x%x \n", |
|---|
| 1656 | ulIntrStatus1, ulIntrStatus2, ulStatus2)); |
|---|
| 1657 | |
|---|
| 1658 | if ((ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK) { |
|---|
| 1659 | BKNI_EnterCriticalSection(); |
|---|
| 1660 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK; |
|---|
| 1661 | BKNI_LeaveCriticalSection(); |
|---|
| 1662 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_BGT_INTR error \n")); |
|---|
| 1663 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1664 | goto BSCD_P_DONE_LABEL; |
|---|
| 1665 | } |
|---|
| 1666 | |
|---|
| 1667 | |
|---|
| 1668 | #if 0 /* Do not need this since T=1 parity and rlen check will be perform when we read in each byte */ |
|---|
| 1669 | else if ( (in_channelHandle->currentChannelSettings.eProtocolType != BSCD_AsyncProtocolType_e1) && |
|---|
| 1670 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK) ) { |
|---|
| 1671 | BKNI_EnterCriticalSection(); |
|---|
| 1672 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK; |
|---|
| 1673 | BKNI_LeaveCriticalSection(); |
|---|
| 1674 | /* For T = 1, retry interrupt is not required while reading a block from the ICC */ |
|---|
| 1675 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_RETRY_INTR error \n")); |
|---|
| 1676 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_PARITY; |
|---|
| 1677 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1678 | goto BSCD_P_DONE_LABEL; |
|---|
| 1679 | } |
|---|
| 1680 | else if ( (in_channelHandle->currentChannelSettings.eProtocolType != BSCD_AsyncProtocolType_e1) && |
|---|
| 1681 | ((ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK) ) { |
|---|
| 1682 | /* For T = 1, parity interrupt is not required while reading a block from the ICC */ |
|---|
| 1683 | BKNI_EnterCriticalSection(); |
|---|
| 1684 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK; |
|---|
| 1685 | BKNI_LeaveCriticalSection(); |
|---|
| 1686 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_RPAR_INTR error \n")); |
|---|
| 1687 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1688 | goto BSCD_P_DONE_LABEL; |
|---|
| 1689 | } |
|---|
| 1690 | |
|---|
| 1691 | else if ( (in_channelHandle->currentChannelSettings.eProtocolType != BSCD_AsyncProtocolType_e1) && |
|---|
| 1692 | ((ulStatus2 & BCHP_SCA_SC_STATUS_2_edc_err_MASK) == BCHP_SCA_SC_STATUS_2_edc_err_MASK) ) { |
|---|
| 1693 | /* For T = 1, EDC interrupt is not required while reading a block from the ICC */ |
|---|
| 1694 | BKNI_EnterCriticalSection(); |
|---|
| 1695 | in_channelHandle->ulStatus2&= ~BCHP_SCA_SC_STATUS_2_edc_err_MASK; |
|---|
| 1696 | BKNI_LeaveCriticalSection(); |
|---|
| 1697 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_EDC_ERR error \n")); |
|---|
| 1698 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1699 | goto BSCD_P_DONE_LABEL; |
|---|
| 1700 | } |
|---|
| 1701 | |
|---|
| 1702 | #endif |
|---|
| 1703 | |
|---|
| 1704 | |
|---|
| 1705 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 1706 | else if ( (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK) && |
|---|
| 1707 | (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) != BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) && |
|---|
| 1708 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000)) { |
|---|
| 1709 | BKNI_EnterCriticalSection(); |
|---|
| 1710 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK; |
|---|
| 1711 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1712 | BKNI_LeaveCriticalSection(); |
|---|
| 1713 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_CWT_INTR error \n")); |
|---|
| 1714 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1715 | goto BSCD_P_DONE_LABEL; |
|---|
| 1716 | } |
|---|
| 1717 | #elif defined(BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR) |
|---|
| 1718 | else if ( (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_event1_intr_MASK) == BCHP_SCA_SC_INTR_STAT_1_event1_intr_MASK) && |
|---|
| 1719 | (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) != BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) ) { |
|---|
| 1720 | |
|---|
| 1721 | BKNI_EnterCriticalSection(); |
|---|
| 1722 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_event1_intr_MASK; |
|---|
| 1723 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1724 | BKNI_LeaveCriticalSection(); |
|---|
| 1725 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_EVENT1_INTR error \n")); |
|---|
| 1726 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1727 | goto BSCD_P_DONE_LABEL; |
|---|
| 1728 | } |
|---|
| 1729 | #else |
|---|
| 1730 | else if ( (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK) && |
|---|
| 1731 | (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) != BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) ) { |
|---|
| 1732 | BKNI_EnterCriticalSection(); |
|---|
| 1733 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK; |
|---|
| 1734 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1735 | BKNI_LeaveCriticalSection(); |
|---|
| 1736 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_CWT_INTR error \n")); |
|---|
| 1737 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1738 | goto BSCD_P_DONE_LABEL; |
|---|
| 1739 | } |
|---|
| 1740 | #endif |
|---|
| 1741 | |
|---|
| 1742 | else if ( (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1) && |
|---|
| 1743 | ((ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK) ) { |
|---|
| 1744 | BKNI_EnterCriticalSection(); |
|---|
| 1745 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK; |
|---|
| 1746 | BKNI_LeaveCriticalSection(); |
|---|
| 1747 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_RLEN_INTR error \n")); |
|---|
| 1748 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1749 | goto BSCD_P_DONE_LABEL; |
|---|
| 1750 | } |
|---|
| 1751 | |
|---|
| 1752 | else if (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK) == BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK) { |
|---|
| 1753 | BKNI_EnterCriticalSection(); |
|---|
| 1754 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK; |
|---|
| 1755 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1756 | BKNI_LeaveCriticalSection(); |
|---|
| 1757 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_WAIT_INTR error \n")); |
|---|
| 1758 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1759 | goto BSCD_P_DONE_LABEL; |
|---|
| 1760 | } |
|---|
| 1761 | |
|---|
| 1762 | else if (( ulStatus2 & BCHP_SCA_SC_STATUS_2_roverflow_MASK) == BCHP_SCA_SC_STATUS_2_roverflow_MASK) { |
|---|
| 1763 | BKNI_EnterCriticalSection(); |
|---|
| 1764 | in_channelHandle->ulStatus2 &= ~BCHP_SCA_SC_STATUS_2_roverflow_MASK; |
|---|
| 1765 | BKNI_LeaveCriticalSection(); |
|---|
| 1766 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_ROVERFLOW error \n")); |
|---|
| 1767 | errCode = BSCD_STATUS_FAILED; |
|---|
| 1768 | goto BSCD_P_DONE_LABEL; |
|---|
| 1769 | } |
|---|
| 1770 | /*09/20/05,Allen.C, check if the Card is removed */ |
|---|
| 1771 | else if ( (in_channelHandle-> bIsCardRemoved == true) && |
|---|
| 1772 | (( ulIntrStatus1 & BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK ) == BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK)) { |
|---|
| 1773 | BKNI_EnterCriticalSection(); |
|---|
| 1774 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK; |
|---|
| 1775 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RESET_CHANNEL_REQUIRED; |
|---|
| 1776 | in_channelHandle-> bIsCardRemoved = false ; |
|---|
| 1777 | BKNI_LeaveCriticalSection(); |
|---|
| 1778 | BDBG_ERR(("ScardDeviceWaitForRReady: SC_CARD_REMOVED error \n")); |
|---|
| 1779 | errCode = BSCD_STATUS_FAILED ; |
|---|
| 1780 | goto BSCD_P_DONE_LABEL; |
|---|
| 1781 | } |
|---|
| 1782 | |
|---|
| 1783 | else if (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) != BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) { |
|---|
| 1784 | if ( (errCode = BERR_TRACE(BKNI_WaitForEvent( in_channelHandle->channelWaitEvent.rcvWait, |
|---|
| 1785 | in_channelHandle->currentChannelSettings.timeOut.ulValue))) != BERR_SUCCESS ) { |
|---|
| 1786 | |
|---|
| 1787 | BKNI_EnterCriticalSection(); |
|---|
| 1788 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_TIMEOUT; |
|---|
| 1789 | BKNI_LeaveCriticalSection(); |
|---|
| 1790 | BDBG_ERR(("ScardDeviceWaitForRReady: BKNI_WaitForEvent timeout error %d\n", in_channelHandle->currentChannelSettings.timeOut.ulValue)); |
|---|
| 1791 | errCode = BSCD_STATUS_TIME_OUT; |
|---|
| 1792 | goto BSCD_P_DONE_LABEL; |
|---|
| 1793 | } |
|---|
| 1794 | } |
|---|
| 1795 | |
|---|
| 1796 | BKNI_EnterCriticalSection(); |
|---|
| 1797 | ulIntrStatus1 = in_channelHandle->ulIntrStatus1; |
|---|
| 1798 | ulIntrStatus2 = in_channelHandle->ulIntrStatus2; |
|---|
| 1799 | ulStatus2 = in_channelHandle->ulStatus2; |
|---|
| 1800 | BKNI_LeaveCriticalSection(); |
|---|
| 1801 | |
|---|
| 1802 | }while (( ulIntrStatus2 & BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) != |
|---|
| 1803 | BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK); |
|---|
| 1804 | |
|---|
| 1805 | BKNI_EnterCriticalSection(); |
|---|
| 1806 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK; |
|---|
| 1807 | in_channelHandle->ulStatus2 &= ~BCHP_SCA_SC_STATUS_2_rready_MASK; |
|---|
| 1808 | BKNI_LeaveCriticalSection(); |
|---|
| 1809 | BDBG_MSG(("rready interrupt received\n")); |
|---|
| 1810 | |
|---|
| 1811 | |
|---|
| 1812 | BSCD_P_DONE_LABEL: |
|---|
| 1813 | |
|---|
| 1814 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 1815 | /* Disable event1 */ |
|---|
| 1816 | ulVal = BREG_Read32( |
|---|
| 1817 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1818 | (in_channelHandle->ulRegStartAddr + BSCD_P_EVENT1_CMD_4)); |
|---|
| 1819 | ulVal &= ~(BCHP_SCA_SC_EVENT1_CMD_4_event_en_MASK); |
|---|
| 1820 | BREG_Write32( |
|---|
| 1821 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1822 | (in_channelHandle->ulRegStartAddr + BSCD_P_EVENT1_CMD_4), |
|---|
| 1823 | ulVal); |
|---|
| 1824 | #endif |
|---|
| 1825 | |
|---|
| 1826 | BDBG_LEAVE(BSCD_Channel_P_WaitForRReady); |
|---|
| 1827 | BDBG_MSG(("BSCD_Channel_P_WaitForRReady errCode = 0x%x\n", errCode)); |
|---|
| 1828 | |
|---|
| 1829 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 1830 | in_channelHandle->bIsReceive = false; |
|---|
| 1831 | #endif |
|---|
| 1832 | |
|---|
| 1833 | return errCode; |
|---|
| 1834 | } |
|---|
| 1835 | |
|---|
| 1836 | BERR_Code BSCD_Channel_P_Activating( |
|---|
| 1837 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1838 | ) |
|---|
| 1839 | { |
|---|
| 1840 | |
|---|
| 1841 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 1842 | uint32_t ulIFCmdVal, ulVal; |
|---|
| 1843 | BSCD_Timer timer = {BSCD_TimerType_eGPTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 1844 | BSCD_TimerValue timeValue= {BSCD_MAX_RESET_IN_CLK_CYCLES, BSCD_TimerUnit_eCLK}; |
|---|
| 1845 | |
|---|
| 1846 | BSCD_Timer wwtTimer = {BSCD_TimerType_eWaitTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 1847 | BSCD_TimerValue wwtTimeValue= {BSCD_MAX_ETU_PER_ATR_BYTE_EMV2000, BSCD_TimerUnit_eETU}; |
|---|
| 1848 | |
|---|
| 1849 | |
|---|
| 1850 | unsigned char i; |
|---|
| 1851 | uint32_t ulTimerCntVal1, ulTimerCntVal2; |
|---|
| 1852 | uint32_t ulTimerCntVal; |
|---|
| 1853 | uint32_t ulPrevTimerCntVal = 0; |
|---|
| 1854 | |
|---|
| 1855 | BDBG_ENTER(BSCD_Channel_P_Activating); |
|---|
| 1856 | BDBG_ASSERT( in_channelHandle ); |
|---|
| 1857 | |
|---|
| 1858 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 1859 | (in_channelHandle == NULL ) ); |
|---|
| 1860 | |
|---|
| 1861 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 1862 | (in_channelHandle->ulMagicNumber != BSCD_P_CHANNEL_HANDLE_MAGIC_NUMBER ) ); |
|---|
| 1863 | |
|---|
| 1864 | /* Set SC_VCC low = CMDVCC low which in turn starts the |
|---|
| 1865 | VCC signal rising in the Phillips chip */ |
|---|
| 1866 | ulIFCmdVal = BREG_Read32( |
|---|
| 1867 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1868 | (in_channelHandle->ulRegStartAddr + BSCD_P_IF_CMD_1)) ; |
|---|
| 1869 | |
|---|
| 1870 | /* Use Auto Deactivation instead of TDA8004 */ |
|---|
| 1871 | if(in_channelHandle->currentChannelSettings.bConnectDirectly == true){ |
|---|
| 1872 | #ifdef BSCD_DIRECT_VCC_INVERTED |
|---|
| 1873 | ulIFCmdVal &= ~(BCHP_SCA_SC_IF_CMD_1_vcc_MASK); |
|---|
| 1874 | #else |
|---|
| 1875 | ulIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_vcc_MASK; |
|---|
| 1876 | #endif |
|---|
| 1877 | } |
|---|
| 1878 | else { |
|---|
| 1879 | ulIFCmdVal &= ~(BCHP_SCA_SC_IF_CMD_1_vcc_MASK); |
|---|
| 1880 | } |
|---|
| 1881 | if (in_channelHandle->currentChannelSettings.bAutoDeactiveReq == true) { |
|---|
| 1882 | ulIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_auto_vcc_MASK; |
|---|
| 1883 | } |
|---|
| 1884 | |
|---|
| 1885 | BREG_Write32( |
|---|
| 1886 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1887 | (in_channelHandle->ulRegStartAddr + BSCD_P_IF_CMD_1), |
|---|
| 1888 | ulIFCmdVal); |
|---|
| 1889 | |
|---|
| 1890 | if(in_channelHandle->currentChannelSettings.bConnectDirectly == true){ |
|---|
| 1891 | #ifdef BSCD_DIRECT_RST_INVERTED |
|---|
| 1892 | ulIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_rst_MASK; |
|---|
| 1893 | #else |
|---|
| 1894 | /* Set SC_RST low = RSTIN low */ |
|---|
| 1895 | ulIFCmdVal &= ~BCHP_SCA_SC_IF_CMD_1_rst_MASK; |
|---|
| 1896 | #endif |
|---|
| 1897 | |
|---|
| 1898 | } |
|---|
| 1899 | else{ |
|---|
| 1900 | |
|---|
| 1901 | /* Set SC_RST low = RSTIN low */ |
|---|
| 1902 | ulIFCmdVal &= ~BCHP_SCA_SC_IF_CMD_1_rst_MASK; |
|---|
| 1903 | } |
|---|
| 1904 | ulIFCmdVal &= ~BCHP_SCA_SC_IF_CMD_1_auto_rst_MASK; |
|---|
| 1905 | BREG_Write32( |
|---|
| 1906 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1907 | (in_channelHandle->ulRegStartAddr + BSCD_P_IF_CMD_1), |
|---|
| 1908 | ulIFCmdVal); |
|---|
| 1909 | |
|---|
| 1910 | BDBG_MSG(("Activating: SC_RST low \n")); |
|---|
| 1911 | |
|---|
| 1912 | /* wait for 42,000 clk cycles. */ |
|---|
| 1913 | for (i=0; i<in_channelHandle->currentChannelSettings.ucExternalClockDivisor; i++) { |
|---|
| 1914 | |
|---|
| 1915 | timer.bIsTimerInterruptEnable = true; |
|---|
| 1916 | timer.bIsTimerEnable = true; |
|---|
| 1917 | timeValue.ulValue = in_channelHandle->currentChannelSettings.eResetCycles; |
|---|
| 1918 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1919 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 1920 | |
|---|
| 1921 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1922 | BSCD_Channel_P_WaitForTimerEvent(in_channelHandle)); |
|---|
| 1923 | |
|---|
| 1924 | /* Disable timer */ |
|---|
| 1925 | timer.bIsTimerInterruptEnable = false; |
|---|
| 1926 | timer.bIsTimerEnable = false; |
|---|
| 1927 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1928 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 1929 | |
|---|
| 1930 | } |
|---|
| 1931 | |
|---|
| 1932 | /***************************************************** |
|---|
| 1933 | ** |
|---|
| 1934 | ** Set all required registers before we receive ATR |
|---|
| 1935 | ** |
|---|
| 1936 | ******************************************************/ |
|---|
| 1937 | /* Set this to 0 temporarily during ATR session. For EMV, |
|---|
| 1938 | we will set it back in BSCD_Channel_P_EMVATRReceiveAndDecode. |
|---|
| 1939 | For the rest, the application should set it back */ |
|---|
| 1940 | BREG_Write32( |
|---|
| 1941 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1942 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_2), |
|---|
| 1943 | 0); |
|---|
| 1944 | |
|---|
| 1945 | /* Enable 2 interrupts with callback */ |
|---|
| 1946 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1947 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 1948 | in_channelHandle, BSCD_IntType_eATRInt, |
|---|
| 1949 | BSCD_Channel_P_ATRCB_isr)); |
|---|
| 1950 | |
|---|
| 1951 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1952 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 1953 | in_channelHandle, BSCD_IntType_eRcvInt, |
|---|
| 1954 | BSCD_Channel_P_RcvCB_isr)); |
|---|
| 1955 | |
|---|
| 1956 | /* Enable WWT to ensure the max interval between 2 consecutive ATR chars of 10080 ETU */ |
|---|
| 1957 | BDBG_MSG(("Activating: Set WWT timer \n")); |
|---|
| 1958 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) |
|---|
| 1959 | wwtTimeValue.ulValue = BSCD_MAX_ETU_PER_ATR_BYTE_EMV2000; |
|---|
| 1960 | else /* EMV 96 or the rest */ |
|---|
| 1961 | wwtTimeValue.ulValue = BSCD_MAX_ETU_PER_ATR_BYTE; |
|---|
| 1962 | wwtTimer.timerMode.eWaitTimerMode = BSCD_WaitTimerMode_eWorkWaitTime; |
|---|
| 1963 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 1964 | BSCD_Channel_ConfigTimer(in_channelHandle, &wwtTimer, &wwtTimeValue)); |
|---|
| 1965 | |
|---|
| 1966 | |
|---|
| 1967 | /* Set BCM to get ATR packet. */ |
|---|
| 1968 | ulVal = BREG_Read32( |
|---|
| 1969 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1970 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)) ; |
|---|
| 1971 | |
|---|
| 1972 | ulVal |= (BCHP_SCA_SC_UART_CMD_1_get_atr_MASK | BCHP_SCA_SC_UART_CMD_1_io_en_MASK); |
|---|
| 1973 | |
|---|
| 1974 | BREG_Write32( |
|---|
| 1975 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1976 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 1977 | ulVal); |
|---|
| 1978 | |
|---|
| 1979 | /* Set RST */ |
|---|
| 1980 | if(in_channelHandle->currentChannelSettings.bConnectDirectly == true){ |
|---|
| 1981 | #ifdef BSCD_DIRECT_RST_INVERTED |
|---|
| 1982 | ulIFCmdVal &= ~BCHP_SCA_SC_IF_CMD_1_rst_MASK; |
|---|
| 1983 | #else |
|---|
| 1984 | ulIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_rst_MASK; |
|---|
| 1985 | #endif |
|---|
| 1986 | } |
|---|
| 1987 | else { |
|---|
| 1988 | ulIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_rst_MASK; |
|---|
| 1989 | } |
|---|
| 1990 | if(in_channelHandle->currentChannelSettings.bAutoDeactiveReq == true){ |
|---|
| 1991 | ulIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_auto_rst_MASK; |
|---|
| 1992 | } |
|---|
| 1993 | BREG_Write32( |
|---|
| 1994 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 1995 | (in_channelHandle->ulRegStartAddr + BSCD_P_IF_CMD_1), |
|---|
| 1996 | ulIFCmdVal); |
|---|
| 1997 | |
|---|
| 1998 | /* wait for 40,000 clk cycles for EMV96 and 42000 for EMV2000 */ |
|---|
| 1999 | for (i=0; i<in_channelHandle->currentChannelSettings.ucExternalClockDivisor ; i++) { |
|---|
| 2000 | |
|---|
| 2001 | /* Set Timer */ |
|---|
| 2002 | timer.bIsTimerInterruptEnable = true; |
|---|
| 2003 | timer.bIsTimerEnable = true; |
|---|
| 2004 | timer.eTimerType = BSCD_TimerType_eGPTimer; |
|---|
| 2005 | timer.timerMode.eGPTimerMode = BSCD_GPTimerMode_eIMMEDIATE; |
|---|
| 2006 | |
|---|
| 2007 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000){ |
|---|
| 2008 | timeValue.ulValue = BSCD_EMV2000_MAX_ATR_START_IN_CLK_CYCLES + BSCD_ATR_START_BIT_DELAY_IN_CLK_CYCLES; |
|---|
| 2009 | timeValue.unit = BSCD_TimerUnit_eCLK; |
|---|
| 2010 | } |
|---|
| 2011 | else{ |
|---|
| 2012 | if(in_channelHandle->currentChannelSettings.ATRRecvTimeInteger.unit == BSCD_TimerUnit_eMilliSec){ |
|---|
| 2013 | timeValue.unit = BSCD_TimerUnit_eETU; |
|---|
| 2014 | timeValue.ulValue = in_channelHandle->currentChannelSettings.ATRRecvTimeInteger.ulValue*1000/372+ |
|---|
| 2015 | BSCD_ATR_START_BIT_DELAY_IN_CLK_CYCLES/372; |
|---|
| 2016 | }else{ |
|---|
| 2017 | timeValue.unit = in_channelHandle->currentChannelSettings.ATRRecvTimeInteger.unit; |
|---|
| 2018 | |
|---|
| 2019 | timeValue.ulValue = in_channelHandle->currentChannelSettings.ATRRecvTimeInteger.ulValue + |
|---|
| 2020 | BSCD_ATR_START_BIT_DELAY_IN_CLK_CYCLES/((timeValue.unit ==BSCD_TimerUnit_eCLK)? 1:372 ); |
|---|
| 2021 | } |
|---|
| 2022 | |
|---|
| 2023 | } |
|---|
| 2024 | |
|---|
| 2025 | BDBG_MSG(("Activating: Set GP timer \n")); |
|---|
| 2026 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 2027 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 2028 | |
|---|
| 2029 | if ((errCode = BSCD_Channel_P_WaitForATRStart(in_channelHandle)) != BERR_SUCCESS) { |
|---|
| 2030 | |
|---|
| 2031 | /* Disable timer */ |
|---|
| 2032 | timer.bIsTimerInterruptEnable = false; |
|---|
| 2033 | timer.bIsTimerEnable = false; |
|---|
| 2034 | |
|---|
| 2035 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer); |
|---|
| 2036 | |
|---|
| 2037 | if (errCode == BSCD_STATUS_TIME_OUT) { |
|---|
| 2038 | |
|---|
| 2039 | if (i == (in_channelHandle->currentChannelSettings.ucExternalClockDivisor -1)) { |
|---|
| 2040 | |
|---|
| 2041 | /* if this is the last loop and we still timeout, major error */ |
|---|
| 2042 | /* Need to return deactivate for EMV2000 test 1719 xy=30 */ |
|---|
| 2043 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_DEACTIVATE, true); |
|---|
| 2044 | } |
|---|
| 2045 | else { |
|---|
| 2046 | /* If this is not the last loop, continue */ |
|---|
| 2047 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) |
|---|
| 2048 | ulPrevTimerCntVal += BSCD_MAX_ATR_START_IN_CLK_CYCLES; |
|---|
| 2049 | else |
|---|
| 2050 | ulPrevTimerCntVal += in_channelHandle->currentChannelSettings.ATRRecvTimeInteger.ulValue; |
|---|
| 2051 | continue; |
|---|
| 2052 | } |
|---|
| 2053 | } |
|---|
| 2054 | else { |
|---|
| 2055 | /* If the error is not scTimeOut, major error */ |
|---|
| 2056 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 2057 | |
|---|
| 2058 | } |
|---|
| 2059 | |
|---|
| 2060 | } |
|---|
| 2061 | |
|---|
| 2062 | |
|---|
| 2063 | /* Disable timer */ |
|---|
| 2064 | timer.bIsTimerInterruptEnable = false; |
|---|
| 2065 | timer.bIsTimerEnable = false; |
|---|
| 2066 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 2067 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 2068 | BDBG_MSG(("Activating: Disable GP timer \n")); |
|---|
| 2069 | |
|---|
| 2070 | /* Read timer counter, the ATR shall be received after 400 clock cycles */ |
|---|
| 2071 | ulTimerCntVal2 = BREG_Read32( |
|---|
| 2072 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2073 | (in_channelHandle->ulRegStartAddr + BSCD_P_TIMER_CNT_2)) ; |
|---|
| 2074 | ulTimerCntVal1 = BREG_Read32( |
|---|
| 2075 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2076 | (in_channelHandle->ulRegStartAddr + BSCD_P_TIMER_CNT_1)) ; |
|---|
| 2077 | |
|---|
| 2078 | ulTimerCntVal = ((( ulTimerCntVal2) << 8) | ulTimerCntVal1) + ulPrevTimerCntVal; |
|---|
| 2079 | |
|---|
| 2080 | #ifdef BSCD_DSS_ICAM |
|---|
| 2081 | if ((ulTimerCntVal < (BSCD_MIN_ATR_START_IN_CLK_CYCLES*in_channelHandle->currentChannelSettings.ucScClkDiv/((in_channelHandle->currentChannelSettings.unPrescale+1)*in_channelHandle->currentChannelSettings.ucBaudDiv) * in_channelHandle->currentChannelSettings.ucExternalClockDivisor) ) || |
|---|
| 2082 | (ulTimerCntVal > timeValue.ulValue) ) |
|---|
| 2083 | #else |
|---|
| 2084 | if ((ulTimerCntVal < (uint32_t)(BSCD_MIN_ATR_START_IN_CLK_CYCLES * in_channelHandle->currentChannelSettings.ucExternalClockDivisor) ) || |
|---|
| 2085 | (ulTimerCntVal > timeValue.ulValue) ) |
|---|
| 2086 | #endif |
|---|
| 2087 | { |
|---|
| 2088 | |
|---|
| 2089 | BDBG_MSG(("PreATRREceive: ulTimerCmdVal = %lu\n", ulTimerCntVal)); |
|---|
| 2090 | /* Need to return deactivate for EMV2000 test 1719 xy=30 */ |
|---|
| 2091 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_DEACTIVATE, true); |
|---|
| 2092 | } |
|---|
| 2093 | |
|---|
| 2094 | /* |
|---|
| 2095 | Enable WWT to ensure all ATR bytes are received within certain time |
|---|
| 2096 | */ |
|---|
| 2097 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) |
|---|
| 2098 | timeValue.ulValue = BSCD_MAX_EMV_ETU_FOR_ALL_ATR_BYTES_EMV2000; |
|---|
| 2099 | else /* EMV 96 or the rest */ |
|---|
| 2100 | timeValue.ulValue = BSCD_MAX_EMV_ETU_FOR_ALL_ATR_BYTES; |
|---|
| 2101 | timeValue.unit = BSCD_TimerUnit_eETU; |
|---|
| 2102 | timer.bIsTimerInterruptEnable = true; |
|---|
| 2103 | timer.bIsTimerEnable = true; |
|---|
| 2104 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 2105 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 2106 | |
|---|
| 2107 | BDBG_MSG(("ulTimerCntVal = %lu, MIN_ATR_START_IN_CLK_CYCLES = %d\n", ulTimerCntVal, BSCD_MIN_ATR_START_IN_CLK_CYCLES)); |
|---|
| 2108 | |
|---|
| 2109 | if (errCode == BERR_SUCCESS) { |
|---|
| 2110 | break; |
|---|
| 2111 | } |
|---|
| 2112 | } |
|---|
| 2113 | |
|---|
| 2114 | |
|---|
| 2115 | BSCD_P_DONE_LABEL: |
|---|
| 2116 | |
|---|
| 2117 | BDBG_LEAVE(BSCD_Channel_P_Activating); |
|---|
| 2118 | return( errCode ); |
|---|
| 2119 | } |
|---|
| 2120 | |
|---|
| 2121 | |
|---|
| 2122 | |
|---|
| 2123 | |
|---|
| 2124 | void BSCD_P_HexDump( |
|---|
| 2125 | char *inp_cTitle, |
|---|
| 2126 | unsigned char *inp_ucBuf, |
|---|
| 2127 | unsigned int in_unLen |
|---|
| 2128 | ) |
|---|
| 2129 | { |
|---|
| 2130 | size_t i; |
|---|
| 2131 | |
|---|
| 2132 | BDBG_MSG(("\n%s (%u bytes):", inp_cTitle, in_unLen)); |
|---|
| 2133 | |
|---|
| 2134 | for(i=0; i<in_unLen; i++) { |
|---|
| 2135 | |
|---|
| 2136 | if(!(i%20)) { |
|---|
| 2137 | BDBG_MSG(("\n")); |
|---|
| 2138 | } |
|---|
| 2139 | |
|---|
| 2140 | BDBG_MSG(("%02X ",*(inp_ucBuf+i))); |
|---|
| 2141 | } |
|---|
| 2142 | |
|---|
| 2143 | BDBG_MSG(("\n")); |
|---|
| 2144 | |
|---|
| 2145 | BSTD_UNUSED(inp_cTitle); |
|---|
| 2146 | BSTD_UNUSED(inp_ucBuf); |
|---|
| 2147 | |
|---|
| 2148 | } |
|---|
| 2149 | |
|---|
| 2150 | |
|---|
| 2151 | |
|---|
| 2152 | |
|---|
| 2153 | |
|---|
| 2154 | BERR_Code BSCD_Channel_P_T0ReadData( |
|---|
| 2155 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 2156 | uint8_t *outp_ucRcvData, |
|---|
| 2157 | unsigned long *outp_ulNumRcvBytes, |
|---|
| 2158 | unsigned long in_ulMaxReadBytes |
|---|
| 2159 | ) |
|---|
| 2160 | { |
|---|
| 2161 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 2162 | uint32_t ulLen = 0; |
|---|
| 2163 | uint32_t ulStatus2; |
|---|
| 2164 | #ifndef BSCD_DSS_ICAM |
|---|
| 2165 | BSCD_Timer timer = {BSCD_TimerType_eWaitTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 2166 | BSCD_TimerValue timeValue= {BSCD_DEFAULT_WORK_WAITING_TIME, BSCD_TimerUnit_eETU}; |
|---|
| 2167 | #endif |
|---|
| 2168 | |
|---|
| 2169 | BDBG_ENTER(BSCD_Channel_P_T0ReadData); |
|---|
| 2170 | |
|---|
| 2171 | *outp_ulNumRcvBytes = 0; |
|---|
| 2172 | |
|---|
| 2173 | BKNI_EnterCriticalSection(); |
|---|
| 2174 | in_channelHandle->ulStatus2 = ulStatus2 = BREG_Read32( |
|---|
| 2175 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2176 | (in_channelHandle->ulRegStartAddr + BSCD_P_STATUS_2)); |
|---|
| 2177 | BKNI_LeaveCriticalSection(); |
|---|
| 2178 | |
|---|
| 2179 | BDBG_MSG(("in_ulMaxReadBytes = %d\n", in_ulMaxReadBytes)); |
|---|
| 2180 | |
|---|
| 2181 | while (ulLen < in_ulMaxReadBytes ) { |
|---|
| 2182 | |
|---|
| 2183 | #ifndef BSCD_DSS_ICAM |
|---|
| 2184 | /* |
|---|
| 2185 | This is a backup time out for non EMV standard. |
|---|
| 2186 | Just in case, we do not read all the byte in one shot but |
|---|
| 2187 | WWT was disable in BSCD_Channel_Receive |
|---|
| 2188 | */ |
|---|
| 2189 | if ((in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV1996) && |
|---|
| 2190 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) ) { |
|---|
| 2191 | timeValue.ulValue = in_channelHandle->currentChannelSettings.workWaitTime.ulValue; |
|---|
| 2192 | BSCD_P_CHECK_ERR_CODE_FUNC2(errCode, BSCD_STATUS_READ_FAILED, |
|---|
| 2193 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 2194 | } |
|---|
| 2195 | #endif |
|---|
| 2196 | |
|---|
| 2197 | BDBG_MSG(("\nSmartCardReadCmd: After SmartCardSetGPTimer\n")); |
|---|
| 2198 | |
|---|
| 2199 | BKNI_EnterCriticalSection(); |
|---|
| 2200 | ulStatus2 = in_channelHandle->ulStatus2; |
|---|
| 2201 | BKNI_LeaveCriticalSection(); |
|---|
| 2202 | |
|---|
| 2203 | if ( (( ulStatus2 & BCHP_SCA_SC_STATUS_2_rempty_MASK) == BCHP_SCA_SC_STATUS_2_rempty_MASK) && |
|---|
| 2204 | ((errCode = BSCD_Channel_P_WaitForRcv(in_channelHandle)) != |
|---|
| 2205 | BERR_SUCCESS) ) { |
|---|
| 2206 | |
|---|
| 2207 | errCode = BERR_TRACE(errCode); |
|---|
| 2208 | BDBG_MSG (("After BSCD_Channel_P_WaitForRcv in BSCD_Channel_P_T0ReadData errCode = 0x%x\n", |
|---|
| 2209 | errCode)); |
|---|
| 2210 | #ifndef BSCD_DSS_ICAM |
|---|
| 2211 | /* Disable timer */ |
|---|
| 2212 | if ((in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV1996) && |
|---|
| 2213 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) ) { |
|---|
| 2214 | timer.bIsTimerInterruptEnable = false; |
|---|
| 2215 | timer.bIsTimerEnable = false; |
|---|
| 2216 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer); |
|---|
| 2217 | } |
|---|
| 2218 | #endif |
|---|
| 2219 | |
|---|
| 2220 | if (errCode == BSCD_STATUS_PARITY_EDC_ERR ) { |
|---|
| 2221 | ; /* No op in software , hardware will retry */ |
|---|
| 2222 | } |
|---|
| 2223 | else if (errCode == BSCD_STATUS_TIME_OUT) |
|---|
| 2224 | break; |
|---|
| 2225 | else { |
|---|
| 2226 | return BSCD_STATUS_READ_FAILED; |
|---|
| 2227 | } |
|---|
| 2228 | } |
|---|
| 2229 | |
|---|
| 2230 | /* BDBG_MSG(("\nSmartCardReadCmd: After ScardDeviceWaitForRcv\n")); */ |
|---|
| 2231 | |
|---|
| 2232 | #ifndef BSCD_DSS_ICAM |
|---|
| 2233 | /* Disable timer */ |
|---|
| 2234 | if ((in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV1996) && |
|---|
| 2235 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) ) { |
|---|
| 2236 | timer.bIsTimerInterruptEnable = false; |
|---|
| 2237 | timer.bIsTimerEnable = false; |
|---|
| 2238 | BSCD_P_CHECK_ERR_CODE_FUNC2(errCode, BSCD_STATUS_READ_FAILED, |
|---|
| 2239 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 2240 | } |
|---|
| 2241 | #endif |
|---|
| 2242 | |
|---|
| 2243 | while (ulLen < in_ulMaxReadBytes ) { |
|---|
| 2244 | BDBG_MSG (("In ulLen < in_ulMaxReadBytes\n")); |
|---|
| 2245 | if ((errCode = BSCD_Channel_P_ByteRead(in_channelHandle, &outp_ucRcvData[ulLen])) == BERR_SUCCESS) { |
|---|
| 2246 | |
|---|
| 2247 | in_channelHandle->channelStatus.ulStatus1 &= ~BSCD_RX_PARITY; |
|---|
| 2248 | if ((outp_ucRcvData[ulLen] == 0x60) && |
|---|
| 2249 | (in_channelHandle->currentChannelSettings.bNullFilter == true) ) { |
|---|
| 2250 | BDBG_MSG (("Ignore 0x60 == %2X ", outp_ucRcvData[ulLen])); |
|---|
| 2251 | continue; |
|---|
| 2252 | |
|---|
| 2253 | } |
|---|
| 2254 | else { |
|---|
| 2255 | BDBG_MSG (("%2X ", outp_ucRcvData[ulLen])); |
|---|
| 2256 | ulLen++; |
|---|
| 2257 | } |
|---|
| 2258 | |
|---|
| 2259 | } |
|---|
| 2260 | |
|---|
| 2261 | else if (errCode == BSCD_STATUS_PARITY_EDC_ERR) { |
|---|
| 2262 | BDBG_MSG (("errCode == BSCD_STATUS_PARITY_EDC_ERR\n")); |
|---|
| 2263 | continue; |
|---|
| 2264 | } |
|---|
| 2265 | else { |
|---|
| 2266 | break; |
|---|
| 2267 | } |
|---|
| 2268 | } |
|---|
| 2269 | } |
|---|
| 2270 | |
|---|
| 2271 | #ifndef BSCD_DSS_ICAM |
|---|
| 2272 | BSCD_P_DONE_LABEL: |
|---|
| 2273 | #endif |
|---|
| 2274 | |
|---|
| 2275 | /* 09/28/2006 QX: return data even it's a partial read |
|---|
| 2276 | if (errCode != BERR_SUCCESS) |
|---|
| 2277 | ulLen = 0; |
|---|
| 2278 | */ |
|---|
| 2279 | *outp_ulNumRcvBytes = ulLen; |
|---|
| 2280 | |
|---|
| 2281 | BDBG_LEAVE(BSCD_Channel_P_T0ReadData); |
|---|
| 2282 | /* BDBG_MSG (("Leave BSCD_Channel_P_T0ReadData errCode = 0x%x\n", errCode)); */ |
|---|
| 2283 | return errCode; |
|---|
| 2284 | } |
|---|
| 2285 | |
|---|
| 2286 | |
|---|
| 2287 | BERR_Code BSCD_Channel_P_ByteRead( |
|---|
| 2288 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 2289 | unsigned char *outp_ucData |
|---|
| 2290 | ) |
|---|
| 2291 | { |
|---|
| 2292 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 2293 | uint32_t ulStatus2; |
|---|
| 2294 | |
|---|
| 2295 | BDBG_ENTER(BSCD_Channel_P_ByteRead); |
|---|
| 2296 | |
|---|
| 2297 | BKNI_EnterCriticalSection(); |
|---|
| 2298 | in_channelHandle->ulStatus2 = ulStatus2 = BREG_Read32( |
|---|
| 2299 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2300 | (in_channelHandle->ulRegStartAddr + BSCD_P_STATUS_2)); |
|---|
| 2301 | BKNI_LeaveCriticalSection(); |
|---|
| 2302 | |
|---|
| 2303 | if (( ulStatus2 & BCHP_SCA_SC_STATUS_2_rempty_MASK) != BCHP_SCA_SC_STATUS_2_rempty_MASK) { |
|---|
| 2304 | |
|---|
| 2305 | *outp_ucData = (unsigned char) BREG_Read32( |
|---|
| 2306 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2307 | (in_channelHandle->ulRegStartAddr + BSCD_P_RECEIVE)); |
|---|
| 2308 | |
|---|
| 2309 | BKNI_EnterCriticalSection(); |
|---|
| 2310 | in_channelHandle->ulStatus2 = ulStatus2 = BREG_Read32( |
|---|
| 2311 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2312 | (in_channelHandle->ulRegStartAddr + BSCD_P_STATUS_2)); |
|---|
| 2313 | BKNI_LeaveCriticalSection(); |
|---|
| 2314 | |
|---|
| 2315 | |
|---|
| 2316 | if ( (( ulStatus2 & BCHP_SCA_SC_STATUS_2_rpar_err_MASK) == BCHP_SCA_SC_STATUS_2_rpar_err_MASK) && |
|---|
| 2317 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto)) { |
|---|
| 2318 | BDBG_MSG(("Receive a parity error byte\n")); |
|---|
| 2319 | BKNI_EnterCriticalSection(); |
|---|
| 2320 | in_channelHandle->channelStatus.ulStatus1 |= BSCD_RX_PARITY; |
|---|
| 2321 | BKNI_LeaveCriticalSection(); |
|---|
| 2322 | return BSCD_STATUS_PARITY_EDC_ERR; |
|---|
| 2323 | } |
|---|
| 2324 | |
|---|
| 2325 | } |
|---|
| 2326 | else |
|---|
| 2327 | return (BSCD_STATUS_FAILED); |
|---|
| 2328 | |
|---|
| 2329 | BDBG_LEAVE(BSCD_Channel_P_ByteRead); |
|---|
| 2330 | return errCode; |
|---|
| 2331 | } |
|---|
| 2332 | |
|---|
| 2333 | |
|---|
| 2334 | BERR_Code BSCD_Channel_P_T1ReadData( |
|---|
| 2335 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 2336 | uint8_t *outp_ucRcvData, |
|---|
| 2337 | unsigned long *outp_ulNumRcvBytes, |
|---|
| 2338 | unsigned long in_ulMaxReadBytes |
|---|
| 2339 | ) |
|---|
| 2340 | { |
|---|
| 2341 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 2342 | uint32_t ulVal, ulLen1, ulLen2; |
|---|
| 2343 | uint32_t ulLen = 0, i; |
|---|
| 2344 | BSCD_Timer timer = {BSCD_TimerType_eWaitTimer, {BSCD_GPTimerMode_eIMMEDIATE}, false, false}; |
|---|
| 2345 | |
|---|
| 2346 | BDBG_ENTER(BSCD_Channel_P_T1ReadData); |
|---|
| 2347 | |
|---|
| 2348 | BSTD_UNUSED(in_ulMaxReadBytes); |
|---|
| 2349 | *outp_ulNumRcvBytes = 0; |
|---|
| 2350 | |
|---|
| 2351 | ulVal = BREG_Read32( |
|---|
| 2352 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2353 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)); |
|---|
| 2354 | |
|---|
| 2355 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eES) { |
|---|
| 2356 | /* application computes its own LRC or CRC and appends it as the last byte */ |
|---|
| 2357 | ulVal |= BCHP_SCA_SC_PROTO_CMD_tbuf_rst_MASK; |
|---|
| 2358 | } |
|---|
| 2359 | else { |
|---|
| 2360 | |
|---|
| 2361 | if(in_channelHandle->currentChannelSettings.edcSetting.bIsEnabled==false) |
|---|
| 2362 | ulVal |= BCHP_SCA_SC_PROTO_CMD_tbuf_rst_MASK; |
|---|
| 2363 | else{ |
|---|
| 2364 | ulVal |= BCHP_SCA_SC_PROTO_CMD_edc_en_MASK; |
|---|
| 2365 | |
|---|
| 2366 | if (in_channelHandle->currentChannelSettings.edcSetting.edcEncode == BSCD_EDCEncode_eLRC ) { |
|---|
| 2367 | ulVal &= ~BCHP_SCA_SC_PROTO_CMD_crc_lrc_MASK; |
|---|
| 2368 | } |
|---|
| 2369 | else if (in_channelHandle->currentChannelSettings.edcSetting.edcEncode == BSCD_EDCEncode_eCRC) { |
|---|
| 2370 | ulVal |= BCHP_SCA_SC_PROTO_CMD_crc_lrc_MASK; |
|---|
| 2371 | } |
|---|
| 2372 | |
|---|
| 2373 | } |
|---|
| 2374 | } |
|---|
| 2375 | |
|---|
| 2376 | BREG_Write32( |
|---|
| 2377 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2378 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 2379 | ulVal); |
|---|
| 2380 | |
|---|
| 2381 | if ((errCode = BSCD_Channel_P_WaitForRReady(in_channelHandle)) != |
|---|
| 2382 | BERR_SUCCESS) { |
|---|
| 2383 | /* If parity error, continue reading all the bytes */ |
|---|
| 2384 | errCode = BERR_TRACE(errCode); |
|---|
| 2385 | return BSCD_STATUS_NO_SC_RESPONSE; |
|---|
| 2386 | } |
|---|
| 2387 | |
|---|
| 2388 | /* Disable block wait timer */ |
|---|
| 2389 | timer.eTimerType = BSCD_TimerType_eWaitTimer; |
|---|
| 2390 | timer.timerMode.eWaitTimerMode = BSCD_WaitTimerMode_eBlockWaitTime; |
|---|
| 2391 | BSCD_P_CHECK_ERR_CODE_FUNC2(errCode, BSCD_STATUS_READ_FAILED, |
|---|
| 2392 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 2393 | |
|---|
| 2394 | /* Disable cwt since we already receive all the bytes */ |
|---|
| 2395 | ulVal = BREG_Read32( |
|---|
| 2396 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2397 | (in_channelHandle->ulRegStartAddr + BSCD_P_TIMER_CMD)); |
|---|
| 2398 | |
|---|
| 2399 | ulVal &= ~BCHP_SCA_SC_TIMER_CMD_cwt_en_MASK; |
|---|
| 2400 | |
|---|
| 2401 | BREG_Write32( |
|---|
| 2402 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2403 | (in_channelHandle->ulRegStartAddr + BSCD_P_TIMER_CMD), |
|---|
| 2404 | ulVal); |
|---|
| 2405 | |
|---|
| 2406 | /* Clear cwt_intr so that it won't show up next time */ |
|---|
| 2407 | BKNI_EnterCriticalSection(); |
|---|
| 2408 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 2409 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_event1_intr_MASK; |
|---|
| 2410 | #else |
|---|
| 2411 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK; |
|---|
| 2412 | #endif |
|---|
| 2413 | BKNI_LeaveCriticalSection(); |
|---|
| 2414 | |
|---|
| 2415 | ulLen1 = BREG_Read32( |
|---|
| 2416 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2417 | (in_channelHandle->ulRegStartAddr + BSCD_P_RLEN_1)); |
|---|
| 2418 | ulLen2 = BREG_Read32( |
|---|
| 2419 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2420 | (in_channelHandle->ulRegStartAddr + BSCD_P_RLEN_2)); |
|---|
| 2421 | |
|---|
| 2422 | /* RLEN_9_BIT_MASK = 0x01ff */ |
|---|
| 2423 | ulLen = ((((unsigned short) ulLen2) << 8) | ulLen1) & BSCD_RLEN_9_BIT_MASK; |
|---|
| 2424 | BDBG_MSG(("SmartCardBlockRead: rlen = %d\n", ulLen)); |
|---|
| 2425 | |
|---|
| 2426 | if (ulLen) { |
|---|
| 2427 | |
|---|
| 2428 | for (i = 0; i < ulLen; i++) { |
|---|
| 2429 | |
|---|
| 2430 | outp_ucRcvData[i] = (uint8_t) BREG_Read32( |
|---|
| 2431 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2432 | (in_channelHandle->ulRegStartAddr + BSCD_P_RECEIVE)); |
|---|
| 2433 | ulVal = BREG_Read32( |
|---|
| 2434 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 2435 | (in_channelHandle->ulRegStartAddr + BSCD_P_STATUS_2)); |
|---|
| 2436 | |
|---|
| 2437 | if ((ulVal & BCHP_SCA_SC_STATUS_2_rpar_err_MASK) == BCHP_SCA_SC_STATUS_2_rpar_err_MASK) { |
|---|
| 2438 | BDBG_MSG(("SmartCardBlockRead: parity error\n")); |
|---|
| 2439 | errCode = BSCD_STATUS_PARITY_EDC_ERR; |
|---|
| 2440 | } |
|---|
| 2441 | else if ((ulVal & BCHP_SCA_SC_STATUS_2_edc_err_MASK) == BCHP_SCA_SC_STATUS_2_edc_err_MASK) { |
|---|
| 2442 | BDBG_MSG(("SmartCardBlockRead: EDC error\n")); |
|---|
| 2443 | errCode = BSCD_STATUS_PARITY_EDC_ERR; |
|---|
| 2444 | } |
|---|
| 2445 | |
|---|
| 2446 | if ((i % 16) == 0) { |
|---|
| 2447 | BDBG_MSG(("\n")); |
|---|
| 2448 | /* Need to this to fix the warning if BDBG_MSG is defined to nothing */ |
|---|
| 2449 | ; |
|---|
| 2450 | } |
|---|
| 2451 | |
|---|
| 2452 | BDBG_MSG(("%02x ", outp_ucRcvData[i])); |
|---|
| 2453 | |
|---|
| 2454 | } |
|---|
| 2455 | } |
|---|
| 2456 | |
|---|
| 2457 | BSCD_P_DONE_LABEL: |
|---|
| 2458 | |
|---|
| 2459 | if (errCode != BERR_SUCCESS) |
|---|
| 2460 | ulLen = 0; |
|---|
| 2461 | |
|---|
| 2462 | *outp_ulNumRcvBytes = ulLen; |
|---|
| 2463 | |
|---|
| 2464 | BDBG_LEAVE(BSCD_Channel_P_T1ReadData); |
|---|
| 2465 | return errCode; |
|---|
| 2466 | } |
|---|
| 2467 | |
|---|
| 2468 | |
|---|
| 2469 | BERR_Code BSCD_Channel_P_ReceiveAndDecode( |
|---|
| 2470 | BSCD_ChannelHandle in_channelHandle |
|---|
| 2471 | ) |
|---|
| 2472 | { |
|---|
| 2473 | |
|---|
| 2474 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 2475 | |
|---|
| 2476 | BDBG_ENTER(BSCD_Channel_P_ReceiveAndDecode); |
|---|
| 2477 | |
|---|
| 2478 | if (in_channelHandle->currentChannelSettings.resetCardAction == BSCD_ResetCardAction_eNoAction) { |
|---|
| 2479 | BDBG_MSG(("In BSCD_Channel_P_ReceiveAndDecode BSCD_ResetCardAction_eNoAction\n")); |
|---|
| 2480 | return BERR_SUCCESS; |
|---|
| 2481 | } |
|---|
| 2482 | else if (in_channelHandle->currentChannelSettings.resetCardAction == BSCD_ResetCardAction_eReceiveAndDecode) { |
|---|
| 2483 | BDBG_MSG(("In BSCD_Channel_P_ReceiveAndDecode BSCD_ResetCardAction_eReceiveAndDecode standard = %d\n", |
|---|
| 2484 | in_channelHandle->currentChannelSettings.scStandard)); |
|---|
| 2485 | switch (in_channelHandle->currentChannelSettings.scStandard) { |
|---|
| 2486 | case BSCD_Standard_eEMV1996: |
|---|
| 2487 | case BSCD_Standard_eEMV2000: |
|---|
| 2488 | if ( (errCode = BSCD_Channel_P_EMVATRReceiveAndDecode(in_channelHandle)) != BERR_SUCCESS) { |
|---|
| 2489 | errCode = BERR_TRACE(errCode); |
|---|
| 2490 | goto BSCD_P_DONE_LABEL; |
|---|
| 2491 | } |
|---|
| 2492 | break; |
|---|
| 2493 | default: |
|---|
| 2494 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 2495 | } |
|---|
| 2496 | |
|---|
| 2497 | } |
|---|
| 2498 | |
|---|
| 2499 | |
|---|
| 2500 | BSCD_P_DONE_LABEL: |
|---|
| 2501 | |
|---|
| 2502 | BDBG_LEAVE(BSCD_Channel_P_ReceiveAndDecode); |
|---|
| 2503 | return( errCode ); |
|---|
| 2504 | } |
|---|
| 2505 | |
|---|
| 2506 | |
|---|
| 2507 | void BSCD_Channel_P_IntHandler_isr( |
|---|
| 2508 | void *inp_param1, /* Device channel handle */ |
|---|
| 2509 | int in_param2 /* reserved */ |
|---|
| 2510 | ) |
|---|
| 2511 | { |
|---|
| 2512 | uint32_t unStaReg1 = 0, unStaReg2 = 0, unProtoCmdReg = 0; |
|---|
| 2513 | uint32_t unIntrEn1 = 0, unIntrEn2 = 0, unIntrStaReg1 = 0, unIntrStaReg2 = 0; |
|---|
| 2514 | uint32_t unIFCmdVal, unPrevStaReg1, ulVal; |
|---|
| 2515 | BSCD_IntrType event; |
|---|
| 2516 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 2517 | BSCD_Timer timer = {BSCD_TimerType_eGPTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 2518 | int i; |
|---|
| 2519 | BSCD_ChannelHandle channelHandle = (BSCD_ChannelHandle) inp_param1; |
|---|
| 2520 | |
|---|
| 2521 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 2522 | BSCD_Timer cwtTimer = {BSCD_TimerType_eWaitTimer, {BSCD_WaitTimerMode_eWorkWaitTime}, true, true}; |
|---|
| 2523 | BSCD_TimerValue cwtTimeValue= {16, BSCD_TimerUnit_eETU}; |
|---|
| 2524 | #endif |
|---|
| 2525 | |
|---|
| 2526 | BDBG_ENTER(BSCD_IntHandler_isr); |
|---|
| 2527 | |
|---|
| 2528 | BSTD_UNUSED(in_param2); |
|---|
| 2529 | |
|---|
| 2530 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, (channelHandle == NULL) ); |
|---|
| 2531 | |
|---|
| 2532 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 2533 | (channelHandle->ulMagicNumber != BSCD_P_CHANNEL_HANDLE_MAGIC_NUMBER ) ); |
|---|
| 2534 | |
|---|
| 2535 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 2536 | (channelHandle->bIsOpen == false) ); |
|---|
| 2537 | |
|---|
| 2538 | |
|---|
| 2539 | /* Read Smartcard Interrupt Status & Mask Register */ |
|---|
| 2540 | unProtoCmdReg = BREG_Read32( |
|---|
| 2541 | channelHandle->moduleHandle->regHandle, |
|---|
| 2542 | (channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)); |
|---|
| 2543 | |
|---|
| 2544 | unStaReg1 = BREG_Read32( |
|---|
| 2545 | channelHandle->moduleHandle->regHandle, |
|---|
| 2546 | (channelHandle->ulRegStartAddr + BSCD_P_STATUS_1)); |
|---|
| 2547 | |
|---|
| 2548 | unStaReg2 = BREG_Read32( |
|---|
| 2549 | channelHandle->moduleHandle->regHandle, |
|---|
| 2550 | (channelHandle->ulRegStartAddr + BSCD_P_STATUS_2)); |
|---|
| 2551 | |
|---|
| 2552 | unIntrEn1 = BREG_Read32( |
|---|
| 2553 | channelHandle->moduleHandle->regHandle, |
|---|
| 2554 | (channelHandle->ulRegStartAddr + BSCD_P_INTR_EN_1)); |
|---|
| 2555 | |
|---|
| 2556 | unIntrStaReg1 = BREG_Read32( |
|---|
| 2557 | channelHandle->moduleHandle->regHandle, |
|---|
| 2558 | (channelHandle->ulRegStartAddr + BSCD_P_INTR_STAT_1)); |
|---|
| 2559 | |
|---|
| 2560 | unIntrEn2 = BREG_Read32( |
|---|
| 2561 | channelHandle->moduleHandle->regHandle, |
|---|
| 2562 | (channelHandle->ulRegStartAddr + BSCD_P_INTR_EN_2)); |
|---|
| 2563 | |
|---|
| 2564 | unIntrStaReg2 = BREG_Read32( |
|---|
| 2565 | channelHandle->moduleHandle->regHandle, |
|---|
| 2566 | (channelHandle->ulRegStartAddr + BSCD_P_INTR_STAT_2)); |
|---|
| 2567 | |
|---|
| 2568 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2569 | #if 1 |
|---|
| 2570 | BDBG_MSG(("unIntrEn1 = %2x, unIntrStaReg1 = %2x, ucSlot = %d\n", |
|---|
| 2571 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2572 | BDBG_MSG(("unIntrEn2 = %2x, unIntrStaReg2 = %2x\n", unIntrEn2, unIntrStaReg2)); |
|---|
| 2573 | BDBG_MSG(("unStaReg1 = %2x, unStaReg2= %2x\n", unStaReg1, unStaReg2)); |
|---|
| 2574 | #endif |
|---|
| 2575 | #endif |
|---|
| 2576 | |
|---|
| 2577 | channelHandle->ulStatus1 = unStaReg1; |
|---|
| 2578 | |
|---|
| 2579 | channelHandle->ulStatus2 = unStaReg2; |
|---|
| 2580 | |
|---|
| 2581 | /* Process interrupt */ |
|---|
| 2582 | |
|---|
| 2583 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_pres_ien_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_pres_intr_MASK) ) { |
|---|
| 2584 | |
|---|
| 2585 | /* Disable pres intr to debounce the card pres */ |
|---|
| 2586 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 2587 | BSCD_Channel_DisableIntrCallback_isr ( |
|---|
| 2588 | channelHandle, BSCD_IntType_eCardInsertInt)); |
|---|
| 2589 | |
|---|
| 2590 | /* Store status_1 to determine if hardware failure */ |
|---|
| 2591 | unPrevStaReg1 = BREG_Read32( |
|---|
| 2592 | channelHandle->moduleHandle->regHandle, |
|---|
| 2593 | (channelHandle->ulRegStartAddr + BSCD_P_STATUS_1)); |
|---|
| 2594 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2595 | BDBG_MSG(("unPrevStaReg1 = %2x\n", unPrevStaReg1)); |
|---|
| 2596 | #endif |
|---|
| 2597 | |
|---|
| 2598 | if(channelHandle->currentChannelSettings.bAutoDeactiveReq == false){ |
|---|
| 2599 | /* In case this is an emergency deactivation, we have to set |
|---|
| 2600 | IF_CMD_1[VCC]=1 to detect card pres again. */ |
|---|
| 2601 | unIFCmdVal = BREG_Read32( |
|---|
| 2602 | channelHandle->moduleHandle->regHandle, |
|---|
| 2603 | (channelHandle->ulRegStartAddr + BSCD_P_IF_CMD_1)); |
|---|
| 2604 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2605 | BDBG_MSG(("1 BCM_SC_IF_CMD_1 = %2x\n", unIFCmdVal)); |
|---|
| 2606 | #endif |
|---|
| 2607 | if(channelHandle->currentChannelSettings.bConnectDirectly == true){ |
|---|
| 2608 | #ifdef BSCD_DIRECT_VCC_INVERTED |
|---|
| 2609 | unIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_vcc_MASK; |
|---|
| 2610 | #else |
|---|
| 2611 | unIFCmdVal &= ~BCHP_SCA_SC_IF_CMD_1_vcc_MASK; |
|---|
| 2612 | #endif |
|---|
| 2613 | }else{ |
|---|
| 2614 | unIFCmdVal |= BCHP_SCA_SC_IF_CMD_1_vcc_MASK; |
|---|
| 2615 | } |
|---|
| 2616 | unIFCmdVal &= ~BCHP_SCA_SC_IF_CMD_1_auto_vcc_MASK; |
|---|
| 2617 | BREG_Write32( |
|---|
| 2618 | channelHandle->moduleHandle->regHandle, |
|---|
| 2619 | (channelHandle->ulRegStartAddr + BSCD_P_IF_CMD_1), |
|---|
| 2620 | unIFCmdVal); |
|---|
| 2621 | |
|---|
| 2622 | /* TDA8004 suggests we to wait until debounce stabilizes. NDS suggests to |
|---|
| 2623 | sleep for 10 milli seconds. This may hold the system for 10ms but it is |
|---|
| 2624 | okay since the system should not continue without the card. */ |
|---|
| 2625 | /* All customers should use TDA8024 now */ |
|---|
| 2626 | /* BKNI_Delay(10000);*/ |
|---|
| 2627 | } |
|---|
| 2628 | |
|---|
| 2629 | unStaReg1 = BREG_Read32( |
|---|
| 2630 | channelHandle->moduleHandle->regHandle, |
|---|
| 2631 | (channelHandle->ulRegStartAddr + BSCD_P_STATUS_1)); |
|---|
| 2632 | |
|---|
| 2633 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2634 | BDBG_MSG(("PRES_INTR , IntrEn1 = %x, IntrStaReg1 = %x, unStaReg1 = %x, ucSlot = %d\n", |
|---|
| 2635 | unIntrEn1, unIntrStaReg1, unStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2636 | #endif |
|---|
| 2637 | |
|---|
| 2638 | /* According TDA 8004 Application note, this is how to determine card presence, card removal and hardware failure. */ |
|---|
| 2639 | if ( (unStaReg1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK) && (!(unPrevStaReg1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK)) ) { |
|---|
| 2640 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2641 | BDBG_MSG(("hardware failure\n")); |
|---|
| 2642 | #endif |
|---|
| 2643 | channelHandle->channelStatus.bCardPresent = true; |
|---|
| 2644 | channelHandle->channelStatus.ulStatus1 |= BSCD_HARDWARE_FAILURE | BSCD_RESET_CHANNEL_REQUIRED; |
|---|
| 2645 | } |
|---|
| 2646 | else if ( (unStaReg1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK) && (unPrevStaReg1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK) ) { |
|---|
| 2647 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2648 | BDBG_MSG(("Insert\n")); |
|---|
| 2649 | #endif |
|---|
| 2650 | channelHandle->channelStatus.bCardPresent = true; |
|---|
| 2651 | channelHandle->bIsCardRemoved = false; |
|---|
| 2652 | } |
|---|
| 2653 | else if (!(unStaReg1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK) && !(unPrevStaReg1 & BCHP_SCA_SC_STATUS_1_card_pres_MASK)) { |
|---|
| 2654 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2655 | BDBG_MSG(("Remove\n")); |
|---|
| 2656 | #endif |
|---|
| 2657 | |
|---|
| 2658 | /* Disable all interrupt but pres_intr to support auto-deactivation. |
|---|
| 2659 | Auto Deactvation will cause a parity_intr and retry_intr to loop forever |
|---|
| 2660 | */ |
|---|
| 2661 | BREG_Write32( |
|---|
| 2662 | channelHandle->moduleHandle->regHandle, |
|---|
| 2663 | (channelHandle->ulRegStartAddr + BSCD_P_INTR_EN_1), |
|---|
| 2664 | 0); |
|---|
| 2665 | |
|---|
| 2666 | BREG_Write32( |
|---|
| 2667 | channelHandle->moduleHandle->regHandle, |
|---|
| 2668 | (channelHandle->ulRegStartAddr + BSCD_P_INTR_EN_2), |
|---|
| 2669 | 0); |
|---|
| 2670 | |
|---|
| 2671 | /* 09/20/05,Allen.C, remember Card was removed */ |
|---|
| 2672 | channelHandle->bIsCardRemoved = true; |
|---|
| 2673 | |
|---|
| 2674 | channelHandle->channelStatus.bCardPresent = false; |
|---|
| 2675 | channelHandle->channelStatus.ulStatus1 |= BSCD_RESET_CHANNEL_REQUIRED; |
|---|
| 2676 | } |
|---|
| 2677 | |
|---|
| 2678 | channelHandle->ulIntrStatus1 = unIntrStaReg1; |
|---|
| 2679 | channelHandle->ulStatus1 = unStaReg1; |
|---|
| 2680 | |
|---|
| 2681 | if (channelHandle->channelStatus.bCardPresent == true) { |
|---|
| 2682 | |
|---|
| 2683 | event = BSCD_IntType_eCardInsertInt; |
|---|
| 2684 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2685 | if (channelHandle->callBack.cardInsertIsrCBFunc[i] != NULL) |
|---|
| 2686 | (*(channelHandle->callBack.cardInsertIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2687 | } |
|---|
| 2688 | |
|---|
| 2689 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2690 | BDBG_MSG(("SC %d Insertion Interrupt\n", channelHandle->ucChannelNumber)); |
|---|
| 2691 | |
|---|
| 2692 | #endif |
|---|
| 2693 | |
|---|
| 2694 | } |
|---|
| 2695 | |
|---|
| 2696 | else { |
|---|
| 2697 | event = BSCD_IntType_eCardRemoveInt; |
|---|
| 2698 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2699 | if (channelHandle->callBack.cardRemoveIsrCBFunc[i] != NULL) |
|---|
| 2700 | (*(channelHandle->callBack.cardRemoveIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2701 | } |
|---|
| 2702 | |
|---|
| 2703 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2704 | BDBG_MSG(("SC %d Removal Interrupt\n", channelHandle->ucChannelNumber)); |
|---|
| 2705 | |
|---|
| 2706 | #endif |
|---|
| 2707 | |
|---|
| 2708 | } |
|---|
| 2709 | |
|---|
| 2710 | /* re-enable pres intr */ |
|---|
| 2711 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 2712 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 2713 | channelHandle, BSCD_IntType_eCardInsertInt, |
|---|
| 2714 | BSCD_Channel_P_CardInsertCB_isr)); |
|---|
| 2715 | |
|---|
| 2716 | } |
|---|
| 2717 | |
|---|
| 2718 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_tpar_ien_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_tpar_intr_MASK) ) { |
|---|
| 2719 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2720 | BDBG_MSG(("TPAR_INTR , IntrEn1 = %x, IntrStaReg1 = %x, ucSlot = %d\n", |
|---|
| 2721 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2722 | #endif |
|---|
| 2723 | |
|---|
| 2724 | channelHandle->channelStatus.ulStatus1 |= BSCD_TX_PARITY; |
|---|
| 2725 | |
|---|
| 2726 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2727 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2728 | |
|---|
| 2729 | event = BSCD_IntType_eTParityInt; |
|---|
| 2730 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2731 | if (channelHandle->callBack.tParityIsrCBFunc[i] != NULL) |
|---|
| 2732 | (*(channelHandle->callBack.tParityIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2733 | } |
|---|
| 2734 | } |
|---|
| 2735 | |
|---|
| 2736 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_timer_ien_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK) ) { |
|---|
| 2737 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2738 | BDBG_MSG(("TIMER_INTR , IntrEn1 = %x, IntrStaReg1 = %x, ucSlot = %d\n", |
|---|
| 2739 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2740 | #endif |
|---|
| 2741 | |
|---|
| 2742 | timer.bIsTimerInterruptEnable = false; |
|---|
| 2743 | timer.bIsTimerEnable = false; |
|---|
| 2744 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 2745 | BSCD_Channel_EnableDisableTimer_isr(channelHandle, &timer)); |
|---|
| 2746 | |
|---|
| 2747 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2748 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2749 | |
|---|
| 2750 | /* We need to signal different events to take care of different scenarioes */ |
|---|
| 2751 | event = BSCD_IntType_eTimerInt; |
|---|
| 2752 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2753 | if (channelHandle->callBack.timerIsrCBFunc[i] != NULL) |
|---|
| 2754 | (*(channelHandle->callBack.timerIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2755 | } |
|---|
| 2756 | } |
|---|
| 2757 | |
|---|
| 2758 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_bgt_ien7_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK) ) { |
|---|
| 2759 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2760 | BDBG_MSG(("BGT_INTR , IntrEn1 = %x, IntrStaReg1 = %x, ucSlot = %d\n", |
|---|
| 2761 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2762 | #endif |
|---|
| 2763 | |
|---|
| 2764 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2765 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2766 | |
|---|
| 2767 | /* We need to signal different events to take care of different scenarioes */ |
|---|
| 2768 | event = BSCD_IntType_eBGTInt; |
|---|
| 2769 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2770 | if (channelHandle->callBack.bgtIsrCBFunc[i] != NULL) |
|---|
| 2771 | (*(channelHandle->callBack.bgtIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2772 | } |
|---|
| 2773 | } |
|---|
| 2774 | |
|---|
| 2775 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_tdone_ien_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK) ) { |
|---|
| 2776 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2777 | BDBG_MSG(("TDONE_INTR ,IntrEn1 = %x, IntrStaReg1 = %x, ucSlot = %d\n", |
|---|
| 2778 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2779 | #endif |
|---|
| 2780 | |
|---|
| 2781 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2782 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2783 | |
|---|
| 2784 | /* We need to signal different events to take care of different scenarioes */ |
|---|
| 2785 | event = BSCD_IntType_eTDoneInt; |
|---|
| 2786 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2787 | if (channelHandle->callBack.tDoneIsrCBFunc[i] != NULL) |
|---|
| 2788 | (*(channelHandle->callBack.tDoneIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2789 | } |
|---|
| 2790 | } |
|---|
| 2791 | |
|---|
| 2792 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_retry_ien_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK) ) { |
|---|
| 2793 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2794 | BDBG_MSG(("RETRY_INTR IntrEn1 = %x, IntrStaReg1 = %x, ucSlot = %d\n", |
|---|
| 2795 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2796 | #endif |
|---|
| 2797 | |
|---|
| 2798 | /* If parity tx or rx retrial failes, we should reset uart and NOT to continue tx any more data */ |
|---|
| 2799 | ulVal = BREG_Read32( |
|---|
| 2800 | channelHandle->moduleHandle->regHandle, |
|---|
| 2801 | (channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)) ; |
|---|
| 2802 | ulVal |= (BCHP_SCA_SC_UART_CMD_1_uart_rst_MASK); |
|---|
| 2803 | BREG_Write32( |
|---|
| 2804 | channelHandle->moduleHandle->regHandle, |
|---|
| 2805 | (channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 2806 | ulVal); |
|---|
| 2807 | |
|---|
| 2808 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2809 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2810 | |
|---|
| 2811 | /* We need to signal different events to take care of different scenarioes */ |
|---|
| 2812 | event = BSCD_IntType_eRetryInt; |
|---|
| 2813 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2814 | if (channelHandle->callBack.retryIsrCBFunc[i] != NULL) |
|---|
| 2815 | (*(channelHandle->callBack.retryIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2816 | } |
|---|
| 2817 | } |
|---|
| 2818 | |
|---|
| 2819 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_tempty_ien_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_tempty_intr_MASK) ) { |
|---|
| 2820 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2821 | BDBG_MSG(("TEMPTY_INTR ,IntrEn1 = %x, IntrStaReg1 = %x, ucSlot = %d\n", |
|---|
| 2822 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 2823 | #endif |
|---|
| 2824 | |
|---|
| 2825 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2826 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2827 | |
|---|
| 2828 | /* Currently we do not need this. No signal needed */ |
|---|
| 2829 | event = BSCD_IntType_eTEmptyInt; |
|---|
| 2830 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2831 | if (channelHandle->callBack.tEmptyIsrCBFunc[i] != NULL) |
|---|
| 2832 | (*(channelHandle->callBack.tEmptyIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2833 | } |
|---|
| 2834 | } |
|---|
| 2835 | |
|---|
| 2836 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_rpar_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK) ) { |
|---|
| 2837 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2838 | BDBG_MSG(("RPAR_INTR , IntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 2839 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 2840 | #endif |
|---|
| 2841 | |
|---|
| 2842 | channelHandle->channelStatus.ulStatus2 |= BSCD_RX_PARITY; |
|---|
| 2843 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2844 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2845 | |
|---|
| 2846 | event = BSCD_IntType_eRParityInt; |
|---|
| 2847 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2848 | if (channelHandle->callBack.rParityIsrCBFunc[i] != NULL) |
|---|
| 2849 | (*(channelHandle->callBack.rParityIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2850 | } |
|---|
| 2851 | |
|---|
| 2852 | } |
|---|
| 2853 | |
|---|
| 2854 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_atrs_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_atrs_intr_MASK) ) { |
|---|
| 2855 | BDBG_MSG(("ATRS_INTR unIntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 2856 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 2857 | |
|---|
| 2858 | /* |
|---|
| 2859 | We need this interrupt to measure the period of time we received leading edge of |
|---|
| 2860 | the start bit of the first ATR byte. As soon as we receive this interrupt, we should |
|---|
| 2861 | stop the timer so that we could get more accurate timing |
|---|
| 2862 | */ |
|---|
| 2863 | |
|---|
| 2864 | timer.bIsTimerInterruptEnable = false; |
|---|
| 2865 | timer.bIsTimerEnable = false; |
|---|
| 2866 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 2867 | BSCD_Channel_EnableDisableTimer_isr(channelHandle, &timer)); |
|---|
| 2868 | |
|---|
| 2869 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2870 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2871 | |
|---|
| 2872 | event = BSCD_IntType_eATRInt; |
|---|
| 2873 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2874 | if (channelHandle->callBack.atrIsrCBFunc[i] != NULL) |
|---|
| 2875 | (*(channelHandle->callBack.atrIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2876 | } |
|---|
| 2877 | } |
|---|
| 2878 | |
|---|
| 2879 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_cwt_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK) ) { |
|---|
| 2880 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2881 | BDBG_MSG(("CWT_INTR IntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 2882 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 2883 | #endif |
|---|
| 2884 | |
|---|
| 2885 | /* If cwt_intr comes in after rready_intr, it is considered normal */ |
|---|
| 2886 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2887 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2888 | |
|---|
| 2889 | event = BSCD_IntType_eCWTInt; |
|---|
| 2890 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2891 | if (channelHandle->callBack.cwtIsrCBFunc[i] != NULL) |
|---|
| 2892 | (*(channelHandle->callBack.cwtIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2893 | } |
|---|
| 2894 | } |
|---|
| 2895 | |
|---|
| 2896 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_rlen_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK) ) { |
|---|
| 2897 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2898 | BDBG_MSG(("RLEN_INTR , IntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 2899 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 2900 | #endif |
|---|
| 2901 | |
|---|
| 2902 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2903 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2904 | |
|---|
| 2905 | event = BSCD_IntType_eRLenInt; |
|---|
| 2906 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2907 | if (channelHandle->callBack.rLenIsrCBFunc[i] != NULL) |
|---|
| 2908 | (*(channelHandle->callBack.rLenIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2909 | } |
|---|
| 2910 | } |
|---|
| 2911 | |
|---|
| 2912 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_wait_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK) ) { |
|---|
| 2913 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2914 | BDBG_MSG(("WAIT_INTR , IntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 2915 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 2916 | #endif |
|---|
| 2917 | |
|---|
| 2918 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2919 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2920 | |
|---|
| 2921 | /* We need to signal different events to take care of different scenarioes */ |
|---|
| 2922 | event = BSCD_IntType_eWaitInt; |
|---|
| 2923 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2924 | if (channelHandle->callBack.waitIsrCBFunc[i] != NULL) |
|---|
| 2925 | (*(channelHandle->callBack.waitIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2926 | } |
|---|
| 2927 | } |
|---|
| 2928 | |
|---|
| 2929 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_rcv_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK) ) { |
|---|
| 2930 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2931 | BDBG_MSG(("RCV_INTR IntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 2932 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 2933 | #endif |
|---|
| 2934 | |
|---|
| 2935 | /* Enable RCV_INTR only in T=1, EMV 2000 to resolve CWT+4 issue */ |
|---|
| 2936 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 2937 | if ( (channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) && |
|---|
| 2938 | (channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1) && |
|---|
| 2939 | (channelHandle->bIsReceive == true)) { |
|---|
| 2940 | |
|---|
| 2941 | /* Disable BWT timer */ |
|---|
| 2942 | cwtTimer.bIsTimerInterruptEnable = false; |
|---|
| 2943 | cwtTimer.bIsTimerEnable = false; |
|---|
| 2944 | BSCD_P_CHECK_ERR_CODE_FUNC2(errCode, BSCD_STATUS_READ_FAILED, |
|---|
| 2945 | BSCD_Channel_EnableDisableTimer_isr(channelHandle, &cwtTimer)); |
|---|
| 2946 | |
|---|
| 2947 | /* Enable WWT in lieu of CWT */ |
|---|
| 2948 | cwtTimer.bIsTimerInterruptEnable = true; |
|---|
| 2949 | cwtTimer.bIsTimerEnable = true; |
|---|
| 2950 | if (channelHandle->currentChannelSettings.ulCharacterWaitTimeInteger != 0) |
|---|
| 2951 | cwtTimeValue.ulValue = (2<<(channelHandle->currentChannelSettings.ulCharacterWaitTimeInteger-1)) |
|---|
| 2952 | + 15 + BSCD_CHARACTER_WAIT_TIME_GRACE_PERIOD; |
|---|
| 2953 | BSCD_P_CHECK_ERR_CODE_FUNC2(errCode, BSCD_STATUS_READ_FAILED, |
|---|
| 2954 | BSCD_Channel_ConfigTimer(channelHandle, &cwtTimer, &cwtTimeValue)); |
|---|
| 2955 | |
|---|
| 2956 | BDBG_MSG(("RCV_INTR cwt = %d\n", cwtTimeValue.ulValue)); |
|---|
| 2957 | |
|---|
| 2958 | channelHandle->ulStatus2 |= unStaReg2; |
|---|
| 2959 | unIntrStaReg2 &= ~BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK; |
|---|
| 2960 | |
|---|
| 2961 | } |
|---|
| 2962 | |
|---|
| 2963 | #endif |
|---|
| 2964 | /* Enable RCV_INTR only in T=1, EMV 2000 to resolve CWT+4 issue */ |
|---|
| 2965 | |
|---|
| 2966 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2967 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2968 | |
|---|
| 2969 | event = BSCD_IntType_eRcvInt; |
|---|
| 2970 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 2971 | if (channelHandle->callBack.rcvIsrCBFunc[i] != NULL) |
|---|
| 2972 | (*(channelHandle->callBack.rcvIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 2973 | } |
|---|
| 2974 | } |
|---|
| 2975 | |
|---|
| 2976 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_rready_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK) ) { |
|---|
| 2977 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 2978 | BDBG_MSG(("RREADY_INTR IntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 2979 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 2980 | #endif |
|---|
| 2981 | |
|---|
| 2982 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 2983 | if ( (channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) && |
|---|
| 2984 | (channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1)) { |
|---|
| 2985 | /* Disable WWT timer, which is used as CWT + 4 */ |
|---|
| 2986 | cwtTimer.bIsTimerInterruptEnable = false; |
|---|
| 2987 | cwtTimer.bIsTimerEnable = false; |
|---|
| 2988 | BSCD_P_CHECK_ERR_CODE_FUNC2(errCode, BSCD_STATUS_READ_FAILED, |
|---|
| 2989 | BSCD_Channel_EnableDisableTimer_isr(channelHandle, &cwtTimer)); |
|---|
| 2990 | BDBG_MSG(("RREADY_INTR cwt disable\n")); |
|---|
| 2991 | } |
|---|
| 2992 | #endif |
|---|
| 2993 | |
|---|
| 2994 | channelHandle->ulStatus2 |= unStaReg2; |
|---|
| 2995 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 2996 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 2997 | |
|---|
| 2998 | event = BSCD_IntType_eRReadyInt; |
|---|
| 2999 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 3000 | if (channelHandle->callBack.rReadyIsrCBFunc[i] != NULL) |
|---|
| 3001 | (*(channelHandle->callBack.rReadyIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 3002 | } |
|---|
| 3003 | } |
|---|
| 3004 | |
|---|
| 3005 | if ( (unProtoCmdReg & BCHP_SCA_SC_PROTO_CMD_edc_en_MASK) && (unStaReg2 & BCHP_SCA_SC_STATUS_2_edc_err_MASK) ) { |
|---|
| 3006 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 3007 | BDBG_MSG(("EDC_ERR , ProtoCmdReg = %x, unStaReg2 = %x, ucSlot = %d\n", |
|---|
| 3008 | unProtoCmdReg, unStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 3009 | #endif |
|---|
| 3010 | |
|---|
| 3011 | channelHandle->channelStatus.ulStatus1 |= BSCD_TX_PARITY; |
|---|
| 3012 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 3013 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 3014 | |
|---|
| 3015 | event = BSCD_IntType_eEDCInt; |
|---|
| 3016 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 3017 | if (channelHandle->callBack.edcIsrCBFunc[i] != NULL) |
|---|
| 3018 | (*(channelHandle->callBack.edcIsrCBFunc[i])) (channelHandle, &event); |
|---|
| 3019 | } |
|---|
| 3020 | } |
|---|
| 3021 | |
|---|
| 3022 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 3023 | if ( (unIntrEn1 & BCHP_SCA_SC_INTR_EN_1_event1_ien_MASK) && (unIntrStaReg1 & BCHP_SCA_SC_INTR_STAT_1_event1_intr_MASK) ) { |
|---|
| 3024 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 3025 | BDBG_MSG(("EVENT1_INTR IntrEn1 = %x, IntrStaReg1 = %x, ucSlot = %d\n", |
|---|
| 3026 | unIntrEn1, unIntrStaReg1, channelHandle->ucChannelNumber)); |
|---|
| 3027 | #endif |
|---|
| 3028 | |
|---|
| 3029 | /* If cwt_intr comes in after rready_intr, it is considered normal */ |
|---|
| 3030 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 3031 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 3032 | |
|---|
| 3033 | event = BSCD_IntType_eEvent1Int; |
|---|
| 3034 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 3035 | if (channelHandle->callBack.event1IsrCBFunc[i] != NULL) |
|---|
| 3036 | (*(channelHandle->callBack.event1IsrCBFunc[i])) (channelHandle, &event); |
|---|
| 3037 | } |
|---|
| 3038 | } |
|---|
| 3039 | |
|---|
| 3040 | if ( (unIntrEn2 & BCHP_SCA_SC_INTR_EN_2_event2_ien_MASK) && (unIntrStaReg2 & BCHP_SCA_SC_INTR_STAT_2_event2_intr_MASK) ) { |
|---|
| 3041 | #ifdef BSCD_INTERRUPT_DEBUG |
|---|
| 3042 | BDBG_MSG(("EVENT2_INTR IntrEn2 = %x, IntrStaReg2 = %x, ucSlot = %d\n", |
|---|
| 3043 | unIntrEn2, unIntrStaReg2, channelHandle->ucChannelNumber)); |
|---|
| 3044 | #endif |
|---|
| 3045 | |
|---|
| 3046 | /* If cwt_intr comes in after rready_intr, it is considered normal */ |
|---|
| 3047 | channelHandle->ulIntrStatus1 |= unIntrStaReg1; |
|---|
| 3048 | channelHandle->ulIntrStatus2 |= unIntrStaReg2; |
|---|
| 3049 | |
|---|
| 3050 | event = BSCD_IntType_eEvent2Int; |
|---|
| 3051 | for (i=0; i< BSCD_MAX_NUM_CALLBACK_FUNC; i++) { |
|---|
| 3052 | if (channelHandle->callBack.event2IsrCBFunc[i] != NULL) |
|---|
| 3053 | (*(channelHandle->callBack.event2IsrCBFunc[i])) (channelHandle, &event); |
|---|
| 3054 | } |
|---|
| 3055 | } |
|---|
| 3056 | |
|---|
| 3057 | #endif |
|---|
| 3058 | |
|---|
| 3059 | BSCD_P_DONE_LABEL: |
|---|
| 3060 | |
|---|
| 3061 | BDBG_LEAVE(BSCD_IntHandler_isr); |
|---|
| 3062 | return; |
|---|
| 3063 | } |
|---|
| 3064 | |
|---|
| 3065 | |
|---|
| 3066 | |
|---|
| 3067 | /* For T=0 and T=1 only */ |
|---|
| 3068 | BERR_Code BSCD_Channel_P_T0T1Transmit( |
|---|
| 3069 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 3070 | uint8_t *inp_ucXmitData, |
|---|
| 3071 | unsigned long in_ulNumXmitBytes |
|---|
| 3072 | ) |
|---|
| 3073 | { |
|---|
| 3074 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 3075 | uint32_t ulVal; |
|---|
| 3076 | unsigned int i; |
|---|
| 3077 | BSCD_Timer timer = {BSCD_TimerType_eGPTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 3078 | BSCD_TimerValue timeValue= {BSCD_MIN_DELAY_BEFORE_TZERO_SEND, BSCD_TimerUnit_eETU}; |
|---|
| 3079 | |
|---|
| 3080 | BDBG_ENTER(BSCD_Channel_P_T0T1Transmit); |
|---|
| 3081 | BDBG_ASSERT( in_channelHandle ); |
|---|
| 3082 | |
|---|
| 3083 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 3084 | (in_channelHandle->ulMagicNumber != BSCD_P_CHANNEL_HANDLE_MAGIC_NUMBER ) ); |
|---|
| 3085 | |
|---|
| 3086 | BSCD_P_CHECK_ERR_CODE_CONDITION( |
|---|
| 3087 | errCode,BSCD_STATUS_SEND_FAILED,(in_channelHandle->bIsCardRemoved == true)); |
|---|
| 3088 | |
|---|
| 3089 | /* BSCD_P_HexDump("Send",inp_ucXmitData, in_ulNumXmitBytes); */ |
|---|
| 3090 | |
|---|
| 3091 | BKNI_EnterCriticalSection(); |
|---|
| 3092 | in_channelHandle->ulIntrStatus1 &= |
|---|
| 3093 | ~BCHP_SCA_SC_INTR_STAT_1_tpar_intr_MASK & |
|---|
| 3094 | ~BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK & |
|---|
| 3095 | ~BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK & |
|---|
| 3096 | ~BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK & |
|---|
| 3097 | ~BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK & |
|---|
| 3098 | ~BCHP_SCA_SC_INTR_STAT_1_tempty_intr_MASK |
|---|
| 3099 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 3100 | & ~BCHP_SCA_SC_INTR_STAT_1_event1_intr_MASK |
|---|
| 3101 | #endif |
|---|
| 3102 | ; |
|---|
| 3103 | |
|---|
| 3104 | in_channelHandle->ulIntrStatus2 &= |
|---|
| 3105 | ~BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK & |
|---|
| 3106 | ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK & |
|---|
| 3107 | ~BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK & |
|---|
| 3108 | ~BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK & |
|---|
| 3109 | ~BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK & |
|---|
| 3110 | ~BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK & |
|---|
| 3111 | ~BCHP_SCA_SC_INTR_STAT_2_event2_intr_MASK ; |
|---|
| 3112 | BKNI_LeaveCriticalSection(); |
|---|
| 3113 | |
|---|
| 3114 | |
|---|
| 3115 | |
|---|
| 3116 | /* Reset the Transmit and Receive buffer */ |
|---|
| 3117 | ulVal = BCHP_SCA_SC_PROTO_CMD_tbuf_rst_MASK | BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK | |
|---|
| 3118 | BREG_Read32( |
|---|
| 3119 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3120 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)) ; |
|---|
| 3121 | BREG_Write32( |
|---|
| 3122 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3123 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3124 | ulVal); |
|---|
| 3125 | |
|---|
| 3126 | /* |
|---|
| 3127 | Enable cwt here for only T=1. We will disable cwt in |
|---|
| 3128 | SmartCardTOneReceive() after we receive RREADY_INTR |
|---|
| 3129 | */ |
|---|
| 3130 | if (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1) { |
|---|
| 3131 | |
|---|
| 3132 | /* Clear the possible previous cwt_intr */ |
|---|
| 3133 | in_channelHandle->ulIntrStatus2 &= ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK; |
|---|
| 3134 | |
|---|
| 3135 | ulVal = BCHP_SCA_SC_TIMER_CMD_cwt_en_MASK | |
|---|
| 3136 | BREG_Read32( |
|---|
| 3137 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3138 | (in_channelHandle->ulRegStartAddr + BSCD_P_TIMER_CMD)) ; |
|---|
| 3139 | BREG_Write32( |
|---|
| 3140 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3141 | (in_channelHandle->ulRegStartAddr + BSCD_P_TIMER_CMD), |
|---|
| 3142 | ulVal); |
|---|
| 3143 | |
|---|
| 3144 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 3145 | |
|---|
| 3146 | /* Clear the possible previous event1 intr */ |
|---|
| 3147 | in_channelHandle->ulIntrStatus1 &= ~BCHP_SCA_SC_INTR_STAT_1_event1_intr_MASK; |
|---|
| 3148 | |
|---|
| 3149 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) { |
|---|
| 3150 | /* 4 ETU after CWT */ |
|---|
| 3151 | BREG_Write32( |
|---|
| 3152 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3153 | (in_channelHandle->ulRegStartAddr + BSCD_P_EVENT1_CMP), |
|---|
| 3154 | 5); |
|---|
| 3155 | |
|---|
| 3156 | /* start event src */ |
|---|
| 3157 | BREG_Write32( |
|---|
| 3158 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3159 | (in_channelHandle->ulRegStartAddr + BSCD_P_EVENT1_CMD_3), |
|---|
| 3160 | BSCD_P_CWT_INTR_EVENT_SRC); |
|---|
| 3161 | |
|---|
| 3162 | /* increment event src */ |
|---|
| 3163 | BREG_Write32( |
|---|
| 3164 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3165 | (in_channelHandle->ulRegStartAddr + BSCD_P_EVENT1_CMD_2), |
|---|
| 3166 | BSCD_P_RX_ETU_TICK_EVENT_SRC); |
|---|
| 3167 | |
|---|
| 3168 | /* reset event src */ |
|---|
| 3169 | BREG_Write32( |
|---|
| 3170 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3171 | (in_channelHandle->ulRegStartAddr + BSCD_P_EVENT1_CMD_1), |
|---|
| 3172 | BSCD_P_RX_START_BIT_EVENT_SRC); |
|---|
| 3173 | |
|---|
| 3174 | /* event_en, intr_mode, run_after_reset and run_after_compare*/ |
|---|
| 3175 | ulVal = BCHP_SCA_SC_EVENT1_CMD_4_event_en_MASK | |
|---|
| 3176 | BCHP_SCA_SC_EVENT1_CMD_4_intr_after_compare_MASK | |
|---|
| 3177 | BCHP_SCA_SC_EVENT1_CMD_4_run_after_reset_MASK; |
|---|
| 3178 | |
|---|
| 3179 | ulVal &= ~(BCHP_SCA_SC_EVENT1_CMD_4_intr_after_reset_MASK | |
|---|
| 3180 | BCHP_SCA_SC_EVENT1_CMD_4_run_after_compare_MASK); |
|---|
| 3181 | BREG_Write32( |
|---|
| 3182 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3183 | (in_channelHandle->ulRegStartAddr + BSCD_P_EVENT1_CMD_4), |
|---|
| 3184 | ulVal); |
|---|
| 3185 | |
|---|
| 3186 | } |
|---|
| 3187 | #endif |
|---|
| 3188 | |
|---|
| 3189 | } |
|---|
| 3190 | |
|---|
| 3191 | |
|---|
| 3192 | /* |
|---|
| 3193 | For EMV T=0 only, the minimum interval btw the leading |
|---|
| 3194 | edges of the start bits of 2 consecutive characters sent |
|---|
| 3195 | in opposite directions shall be 16. For EMV and ISO T=1, |
|---|
| 3196 | the minimum interval btw the leading edges of the start bits of 2 |
|---|
| 3197 | consecutive characters sent in opposite directions shall be 22. |
|---|
| 3198 | */ |
|---|
| 3199 | |
|---|
| 3200 | if (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e0) { |
|---|
| 3201 | |
|---|
| 3202 | |
|---|
| 3203 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3204 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 3205 | |
|---|
| 3206 | } |
|---|
| 3207 | |
|---|
| 3208 | else { |
|---|
| 3209 | |
|---|
| 3210 | /* Set Timer */ |
|---|
| 3211 | /* timer.bIsTimerInterruptEnable = true; |
|---|
| 3212 | timer.bIsTimerEnable = true; |
|---|
| 3213 | timer.eTimerType = BSCD_TimerType_eGPTimer; |
|---|
| 3214 | timer.timerMode.eGPTimerMode = BSCD_GPTimerMode_eIMMEDIATE; |
|---|
| 3215 | timeValue.ulValue = BSCD_BLOCK_GUARD_TIME; |
|---|
| 3216 | timeValue.unit = BSCD_TimerUnit_eETU; |
|---|
| 3217 | */ |
|---|
| 3218 | |
|---|
| 3219 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3220 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 3221 | |
|---|
| 3222 | } |
|---|
| 3223 | |
|---|
| 3224 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3225 | BSCD_Channel_P_WaitForTimerEvent(in_channelHandle)); |
|---|
| 3226 | |
|---|
| 3227 | |
|---|
| 3228 | /* Disable timer */ |
|---|
| 3229 | timer.bIsTimerInterruptEnable = false; |
|---|
| 3230 | timer.bIsTimerEnable = false; |
|---|
| 3231 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3232 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 3233 | |
|---|
| 3234 | |
|---|
| 3235 | /* For T=1, we have to check the Block wait time */ |
|---|
| 3236 | /* For T=0, we have to check the Work Wait Time. */ |
|---|
| 3237 | /* BSYT Issue: RC0 WWT timer could only check the interval |
|---|
| 3238 | btw the leading edge of 2 consecutive characters sent |
|---|
| 3239 | by the ICC. We will use GP timer to check the interval |
|---|
| 3240 | btw the leading edge of characters in opposite directions |
|---|
| 3241 | */ |
|---|
| 3242 | |
|---|
| 3243 | if (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e0) { |
|---|
| 3244 | |
|---|
| 3245 | /* Restore the original WWT */ |
|---|
| 3246 | timer.bIsTimerInterruptEnable = true; |
|---|
| 3247 | timer.bIsTimerEnable = true; |
|---|
| 3248 | timer.eTimerType = BSCD_TimerType_eWaitTimer; |
|---|
| 3249 | timer.timerMode.eWaitTimerMode = BSCD_WaitTimerMode_eWorkWaitTime; |
|---|
| 3250 | timeValue.ulValue = in_channelHandle->currentChannelSettings.workWaitTime.ulValue; |
|---|
| 3251 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3252 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 3253 | |
|---|
| 3254 | } |
|---|
| 3255 | |
|---|
| 3256 | else if (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1) { |
|---|
| 3257 | timer.bIsTimerInterruptEnable = true; |
|---|
| 3258 | timer.bIsTimerEnable = true; |
|---|
| 3259 | timer.eTimerType = BSCD_TimerType_eWaitTimer; |
|---|
| 3260 | timer.timerMode.eWaitTimerMode = BSCD_WaitTimerMode_eBlockWaitTime; |
|---|
| 3261 | |
|---|
| 3262 | if (in_channelHandle->currentChannelSettings.blockWaitTimeExt.ulValue == 0) |
|---|
| 3263 | timeValue.ulValue = in_channelHandle->currentChannelSettings.blockWaitTime.ulValue ; |
|---|
| 3264 | else |
|---|
| 3265 | timeValue.ulValue = in_channelHandle->currentChannelSettings.blockWaitTimeExt.ulValue; |
|---|
| 3266 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3267 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 3268 | } |
|---|
| 3269 | |
|---|
| 3270 | /* |
|---|
| 3271 | * Fill BCM FIFO with the request message. |
|---|
| 3272 | */ |
|---|
| 3273 | for (i = 0; i < in_ulNumXmitBytes; i++) { |
|---|
| 3274 | |
|---|
| 3275 | BREG_Write32( |
|---|
| 3276 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3277 | (in_channelHandle->ulRegStartAddr + BSCD_P_TRANSMIT), |
|---|
| 3278 | (uint32_t) inp_ucXmitData[i]); |
|---|
| 3279 | |
|---|
| 3280 | BDBG_MSG(("%02x ", inp_ucXmitData[i])); |
|---|
| 3281 | } |
|---|
| 3282 | BDBG_MSG(("\n")); |
|---|
| 3283 | |
|---|
| 3284 | /* Enable EDC */ |
|---|
| 3285 | ulVal = BREG_Read32( |
|---|
| 3286 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3287 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)); |
|---|
| 3288 | |
|---|
| 3289 | if (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e0) { |
|---|
| 3290 | |
|---|
| 3291 | ulVal |= BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK; |
|---|
| 3292 | } |
|---|
| 3293 | else { |
|---|
| 3294 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eES) { |
|---|
| 3295 | |
|---|
| 3296 | /* |
|---|
| 3297 | application computes its own LRC or CRC and appends it as the last byte |
|---|
| 3298 | */ |
|---|
| 3299 | ulVal |= BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK; |
|---|
| 3300 | } |
|---|
| 3301 | else { |
|---|
| 3302 | |
|---|
| 3303 | if(in_channelHandle->currentChannelSettings.edcSetting.bIsEnabled==false) |
|---|
| 3304 | ulVal |= BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK; |
|---|
| 3305 | else{ |
|---|
| 3306 | |
|---|
| 3307 | ulVal |= BCHP_SCA_SC_PROTO_CMD_edc_en_MASK; |
|---|
| 3308 | |
|---|
| 3309 | if (in_channelHandle->currentChannelSettings.edcSetting.edcEncode == BSCD_EDCEncode_eLRC ) { |
|---|
| 3310 | ulVal &= ~BCHP_SCA_SC_PROTO_CMD_crc_lrc_MASK; |
|---|
| 3311 | } |
|---|
| 3312 | else if (in_channelHandle->currentChannelSettings.edcSetting.edcEncode == BSCD_EDCEncode_eCRC) { |
|---|
| 3313 | ulVal |= BCHP_SCA_SC_PROTO_CMD_crc_lrc_MASK; |
|---|
| 3314 | } |
|---|
| 3315 | } |
|---|
| 3316 | } |
|---|
| 3317 | } |
|---|
| 3318 | |
|---|
| 3319 | BREG_Write32( |
|---|
| 3320 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3321 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3322 | ulVal); |
|---|
| 3323 | |
|---|
| 3324 | |
|---|
| 3325 | /* Set flow cmd */ |
|---|
| 3326 | ulVal = BREG_Read32( |
|---|
| 3327 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3328 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD)); |
|---|
| 3329 | |
|---|
| 3330 | if (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e0) { |
|---|
| 3331 | /* |
|---|
| 3332 | Only NDS support smartcard flow control. We MUST NOT set SC_FLOW_EN to 1 for |
|---|
| 3333 | other standards. |
|---|
| 3334 | */ |
|---|
| 3335 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eNDS) { |
|---|
| 3336 | ulVal |= (BCHP_SCA_SC_FLOW_CMD_flow_en_MASK) ; |
|---|
| 3337 | } |
|---|
| 3338 | else { |
|---|
| 3339 | ulVal &= ~BCHP_SCA_SC_FLOW_CMD_flow_en_MASK; |
|---|
| 3340 | } |
|---|
| 3341 | } |
|---|
| 3342 | else { |
|---|
| 3343 | /* No flow control for T=1 protocol or T=14. */ |
|---|
| 3344 | ulVal &= ~BCHP_SCA_SC_FLOW_CMD_flow_en_MASK; |
|---|
| 3345 | } |
|---|
| 3346 | BREG_Write32( |
|---|
| 3347 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3348 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD), |
|---|
| 3349 | ulVal); |
|---|
| 3350 | |
|---|
| 3351 | |
|---|
| 3352 | /* Ready to transmit */ |
|---|
| 3353 | ulVal = BREG_Read32( |
|---|
| 3354 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3355 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)); |
|---|
| 3356 | |
|---|
| 3357 | /* Always set auto receive */ |
|---|
| 3358 | ulVal = BCHP_SCA_SC_UART_CMD_1_t_r_MASK | BCHP_SCA_SC_UART_CMD_1_xmit_go_MASK | |
|---|
| 3359 | BCHP_SCA_SC_UART_CMD_1_io_en_MASK |BCHP_SCA_SC_UART_CMD_1_auto_rcv_MASK ; |
|---|
| 3360 | |
|---|
| 3361 | BREG_Write32( |
|---|
| 3362 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3363 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3364 | ulVal); |
|---|
| 3365 | |
|---|
| 3366 | |
|---|
| 3367 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 3368 | in_channelHandle->bIsReceive = true; |
|---|
| 3369 | #endif |
|---|
| 3370 | |
|---|
| 3371 | /* |
|---|
| 3372 | * Wait until the BCM sent all the data. |
|---|
| 3373 | */ |
|---|
| 3374 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3375 | BSCD_Channel_P_WaitForTDone(in_channelHandle)); |
|---|
| 3376 | |
|---|
| 3377 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eNDS){ |
|---|
| 3378 | |
|---|
| 3379 | ulVal = BREG_Read32( |
|---|
| 3380 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3381 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD)); |
|---|
| 3382 | ulVal &= ~BCHP_SCA_SC_FLOW_CMD_flow_en_MASK; |
|---|
| 3383 | BREG_Write32( |
|---|
| 3384 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3385 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD), |
|---|
| 3386 | ulVal); |
|---|
| 3387 | } |
|---|
| 3388 | |
|---|
| 3389 | BSCD_P_DONE_LABEL: |
|---|
| 3390 | |
|---|
| 3391 | BDBG_LEAVE(BSCD_Channel_P_T0T1Transmit); |
|---|
| 3392 | return( errCode ); |
|---|
| 3393 | } |
|---|
| 3394 | |
|---|
| 3395 | |
|---|
| 3396 | /* For T=14 only */ |
|---|
| 3397 | #if (BCHP_CHIP==7118) /* 7118 has support for T=14 */ |
|---|
| 3398 | BERR_Code BSCD_Channel_P_T14IrdetoTransmit( |
|---|
| 3399 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 3400 | uint8_t *inp_ucXmitData, |
|---|
| 3401 | unsigned long in_ulNumXmitBytes |
|---|
| 3402 | ) |
|---|
| 3403 | { |
|---|
| 3404 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 3405 | uint32_t ulVal; |
|---|
| 3406 | unsigned int i; |
|---|
| 3407 | BSCD_Timer timer = {BSCD_TimerType_eGPTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 3408 | BSCD_TimerValue timeValue= {BSCD_T14_IRDETO_MIN_DELAY_RX2TX, BSCD_TimerUnit_eCLK}; |
|---|
| 3409 | |
|---|
| 3410 | BDBG_ENTER(BSCD_Channel_P_T14IrdetoTransmit); |
|---|
| 3411 | BDBG_ASSERT( in_channelHandle ); |
|---|
| 3412 | |
|---|
| 3413 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 3414 | (in_channelHandle->ulMagicNumber != BSCD_P_CHANNEL_HANDLE_MAGIC_NUMBER ) ); |
|---|
| 3415 | |
|---|
| 3416 | BSCD_P_CHECK_ERR_CODE_CONDITION( |
|---|
| 3417 | errCode,BSCD_STATUS_SEND_FAILED,(in_channelHandle->bIsCardRemoved == true)); |
|---|
| 3418 | |
|---|
| 3419 | /* BSCD_P_HexDump("Send",inp_ucXmitData, in_ulNumXmitBytes); */ |
|---|
| 3420 | |
|---|
| 3421 | BKNI_EnterCriticalSection(); |
|---|
| 3422 | in_channelHandle->ulIntrStatus1 &= |
|---|
| 3423 | ~BCHP_SCA_SC_INTR_STAT_1_tpar_intr_MASK & |
|---|
| 3424 | ~BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK & |
|---|
| 3425 | ~BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK & |
|---|
| 3426 | ~BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK & |
|---|
| 3427 | ~BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK & |
|---|
| 3428 | ~BCHP_SCA_SC_INTR_STAT_1_tempty_intr_MASK; |
|---|
| 3429 | |
|---|
| 3430 | in_channelHandle->ulIntrStatus2 &= |
|---|
| 3431 | ~BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK & |
|---|
| 3432 | ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK & |
|---|
| 3433 | ~BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK & |
|---|
| 3434 | ~BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK & |
|---|
| 3435 | ~BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK & |
|---|
| 3436 | ~BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK; |
|---|
| 3437 | BKNI_LeaveCriticalSection(); |
|---|
| 3438 | |
|---|
| 3439 | |
|---|
| 3440 | |
|---|
| 3441 | /* Reset the Transmit and Receive buffer */ |
|---|
| 3442 | ulVal = BCHP_SCA_SC_PROTO_CMD_tbuf_rst_MASK | BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK | |
|---|
| 3443 | BREG_Read32( |
|---|
| 3444 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3445 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)) ; |
|---|
| 3446 | BREG_Write32( |
|---|
| 3447 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3448 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3449 | ulVal); |
|---|
| 3450 | |
|---|
| 3451 | /* Need to wait for minimum of 1250 from last RX to this TX */ |
|---|
| 3452 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3453 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 3454 | |
|---|
| 3455 | |
|---|
| 3456 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3457 | BSCD_Channel_P_WaitForTimerEvent(in_channelHandle)); |
|---|
| 3458 | |
|---|
| 3459 | /* Disable timer */ |
|---|
| 3460 | timer.bIsTimerInterruptEnable = false; |
|---|
| 3461 | timer.bIsTimerEnable = false; |
|---|
| 3462 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3463 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 3464 | |
|---|
| 3465 | |
|---|
| 3466 | /* Enable EDC */ |
|---|
| 3467 | ulVal = BREG_Read32( |
|---|
| 3468 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3469 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)); |
|---|
| 3470 | |
|---|
| 3471 | ulVal |= BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK; |
|---|
| 3472 | |
|---|
| 3473 | BREG_Write32( |
|---|
| 3474 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3475 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3476 | ulVal); |
|---|
| 3477 | |
|---|
| 3478 | |
|---|
| 3479 | /* Set tguard to be 0*/ |
|---|
| 3480 | /*ulVal = BREG_Read32( |
|---|
| 3481 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3482 | (in_channelHandle->ulRegStartAddr + BSCD_P_TGUARD)); |
|---|
| 3483 | |
|---|
| 3484 | if(ulVal !=1) ulVal = 0; |
|---|
| 3485 | BREG_Write32( |
|---|
| 3486 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3487 | (in_channelHandle->ulRegStartAddr + BSCD_P_TGUARD), |
|---|
| 3488 | ulVal);*/ |
|---|
| 3489 | /* Set flow cmd */ |
|---|
| 3490 | ulVal = BREG_Read32( |
|---|
| 3491 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3492 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD)); |
|---|
| 3493 | |
|---|
| 3494 | /* No flow control for T=1 protocol or T=14. */ |
|---|
| 3495 | ulVal &= ~BCHP_SCA_SC_FLOW_CMD_flow_en_MASK; |
|---|
| 3496 | ulVal |= 0x00000060; /* SC_FLOW_CMD[t10etu]=1 , SC_FLOW_CMD[r10etu] */ |
|---|
| 3497 | |
|---|
| 3498 | BREG_Write32( |
|---|
| 3499 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3500 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD), |
|---|
| 3501 | ulVal); |
|---|
| 3502 | |
|---|
| 3503 | /* Set uart cmd */ |
|---|
| 3504 | ulVal = BREG_Read32( |
|---|
| 3505 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3506 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)); |
|---|
| 3507 | |
|---|
| 3508 | ulVal |= 0x00000008; /* SC_UART_CMD[dispar]=1 */ |
|---|
| 3509 | |
|---|
| 3510 | BREG_Write32( |
|---|
| 3511 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3512 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3513 | ulVal); |
|---|
| 3514 | |
|---|
| 3515 | /* |
|---|
| 3516 | * Fill BCM FIFO with the request message. |
|---|
| 3517 | */ |
|---|
| 3518 | for (i = 0; i < in_ulNumXmitBytes; i++) |
|---|
| 3519 | { |
|---|
| 3520 | |
|---|
| 3521 | BREG_Write32( |
|---|
| 3522 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3523 | (in_channelHandle->ulRegStartAddr + BSCD_P_TRANSMIT), |
|---|
| 3524 | (uint32_t) inp_ucXmitData[i]); |
|---|
| 3525 | |
|---|
| 3526 | BDBG_MSG(("%02x ", inp_ucXmitData[i])); |
|---|
| 3527 | |
|---|
| 3528 | /* Ready to transmit */ |
|---|
| 3529 | ulVal = BREG_Read32( |
|---|
| 3530 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3531 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)); |
|---|
| 3532 | |
|---|
| 3533 | /* Always set auto receive */ |
|---|
| 3534 | /* "xmit_go" will be set only when all the Bytes will be in the FIFO */ |
|---|
| 3535 | ulVal = BCHP_SCA_SC_UART_CMD_1_t_r_MASK | BCHP_SCA_SC_UART_CMD_1_io_en_MASK ; |
|---|
| 3536 | |
|---|
| 3537 | |
|---|
| 3538 | if (i == (in_ulNumXmitBytes - 1)) |
|---|
| 3539 | ulVal |= BCHP_SCA_SC_UART_CMD_1_auto_rcv_MASK; /* Last TX byte, ready to receive */ |
|---|
| 3540 | /* printf("ul val %x \n", ulVal); */ |
|---|
| 3541 | BREG_Write32( |
|---|
| 3542 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3543 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3544 | ulVal); |
|---|
| 3545 | |
|---|
| 3546 | } |
|---|
| 3547 | |
|---|
| 3548 | |
|---|
| 3549 | |
|---|
| 3550 | /* Now that the FIFO is filled we can set the "xmit_go" bit to start the transmission */ |
|---|
| 3551 | ulVal = BREG_Read32( |
|---|
| 3552 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3553 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)); |
|---|
| 3554 | |
|---|
| 3555 | ulVal |= BCHP_SCA_SC_UART_CMD_1_xmit_go_MASK; |
|---|
| 3556 | |
|---|
| 3557 | BREG_Write32( |
|---|
| 3558 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3559 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3560 | ulVal); |
|---|
| 3561 | |
|---|
| 3562 | /* |
|---|
| 3563 | * Wait until the BCM sent all the data. |
|---|
| 3564 | */ |
|---|
| 3565 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3566 | BSCD_Channel_P_WaitForTDone(in_channelHandle)); |
|---|
| 3567 | /*ulVal |= BCHP_SCA_SC_UART_CMD_1_auto_rcv_MASK; */ /* TX done, ready to receive */ |
|---|
| 3568 | /* BREG_Write32( |
|---|
| 3569 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3570 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3571 | ulVal);*/ |
|---|
| 3572 | |
|---|
| 3573 | BDBG_MSG(("\n")); |
|---|
| 3574 | |
|---|
| 3575 | BSCD_P_DONE_LABEL: |
|---|
| 3576 | |
|---|
| 3577 | BDBG_LEAVE(BSCD_Channel_P_T14IrdetoTransmit); |
|---|
| 3578 | return( errCode ); |
|---|
| 3579 | } |
|---|
| 3580 | #else |
|---|
| 3581 | |
|---|
| 3582 | BERR_Code BSCD_Channel_P_T14IrdetoTransmit( |
|---|
| 3583 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 3584 | uint8_t *inp_ucXmitData, |
|---|
| 3585 | unsigned long in_ulNumXmitBytes |
|---|
| 3586 | ) |
|---|
| 3587 | { |
|---|
| 3588 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 3589 | uint32_t ulVal; |
|---|
| 3590 | unsigned int i; |
|---|
| 3591 | BSCD_Timer timer = {BSCD_TimerType_eGPTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 3592 | BSCD_TimerValue timeValue= {BSCD_T14_IRDETO_MIN_DELAY_RX2TX, BSCD_TimerUnit_eCLK}; |
|---|
| 3593 | |
|---|
| 3594 | BDBG_ENTER(BSCD_Channel_P_T14IrdetoTransmit); |
|---|
| 3595 | BDBG_ASSERT( in_channelHandle ); |
|---|
| 3596 | |
|---|
| 3597 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 3598 | (in_channelHandle->ulMagicNumber != BSCD_P_CHANNEL_HANDLE_MAGIC_NUMBER ) ); |
|---|
| 3599 | |
|---|
| 3600 | BSCD_P_CHECK_ERR_CODE_CONDITION( |
|---|
| 3601 | errCode,BSCD_STATUS_SEND_FAILED,(in_channelHandle->bIsCardRemoved == true)); |
|---|
| 3602 | |
|---|
| 3603 | /* BSCD_P_HexDump("Send",inp_ucXmitData, in_ulNumXmitBytes); */ |
|---|
| 3604 | BKNI_EnterCriticalSection(); |
|---|
| 3605 | in_channelHandle->ulIntrStatus1 &= |
|---|
| 3606 | ~BCHP_SCA_SC_INTR_STAT_1_tpar_intr_MASK & |
|---|
| 3607 | ~BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK & |
|---|
| 3608 | ~BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK & |
|---|
| 3609 | ~BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK & |
|---|
| 3610 | ~BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK & |
|---|
| 3611 | ~BCHP_SCA_SC_INTR_STAT_1_tempty_intr_MASK; |
|---|
| 3612 | |
|---|
| 3613 | in_channelHandle->ulIntrStatus2 &= |
|---|
| 3614 | ~BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK & |
|---|
| 3615 | ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK & |
|---|
| 3616 | ~BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK & |
|---|
| 3617 | ~BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK & |
|---|
| 3618 | ~BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK & |
|---|
| 3619 | ~BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK; |
|---|
| 3620 | BKNI_LeaveCriticalSection(); |
|---|
| 3621 | |
|---|
| 3622 | |
|---|
| 3623 | /* Reset the Transmit and Receive buffer */ |
|---|
| 3624 | ulVal = BCHP_SCA_SC_PROTO_CMD_tbuf_rst_MASK | BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK | |
|---|
| 3625 | BREG_Read32( |
|---|
| 3626 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3627 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)) ; |
|---|
| 3628 | BREG_Write32( |
|---|
| 3629 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3630 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3631 | ulVal); |
|---|
| 3632 | |
|---|
| 3633 | /* Need to wait for minimum of 1250 from last RX to this TX */ |
|---|
| 3634 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3635 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 3636 | |
|---|
| 3637 | |
|---|
| 3638 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3639 | BSCD_Channel_P_WaitForTimerEvent(in_channelHandle)); |
|---|
| 3640 | |
|---|
| 3641 | /* Disable timer */ |
|---|
| 3642 | timer.bIsTimerInterruptEnable = false; |
|---|
| 3643 | timer.bIsTimerEnable = false; |
|---|
| 3644 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3645 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 3646 | |
|---|
| 3647 | |
|---|
| 3648 | /* Enable EDC */ |
|---|
| 3649 | ulVal = BREG_Read32( |
|---|
| 3650 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3651 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)); |
|---|
| 3652 | |
|---|
| 3653 | ulVal |= BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK; |
|---|
| 3654 | |
|---|
| 3655 | BREG_Write32( |
|---|
| 3656 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3657 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3658 | ulVal); |
|---|
| 3659 | |
|---|
| 3660 | |
|---|
| 3661 | /* Set flow cmd */ |
|---|
| 3662 | ulVal = BREG_Read32( |
|---|
| 3663 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3664 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD)); |
|---|
| 3665 | |
|---|
| 3666 | /* No flow control for T=1 protocol or T=14. */ |
|---|
| 3667 | ulVal &= ~BCHP_SCA_SC_FLOW_CMD_flow_en_MASK; |
|---|
| 3668 | |
|---|
| 3669 | BREG_Write32( |
|---|
| 3670 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3671 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD), |
|---|
| 3672 | ulVal); |
|---|
| 3673 | |
|---|
| 3674 | |
|---|
| 3675 | |
|---|
| 3676 | |
|---|
| 3677 | /* |
|---|
| 3678 | * Fill BCM FIFO with the request message. |
|---|
| 3679 | */ |
|---|
| 3680 | for (i = 0; i < in_ulNumXmitBytes; i++) { |
|---|
| 3681 | |
|---|
| 3682 | BREG_Write32( |
|---|
| 3683 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3684 | (in_channelHandle->ulRegStartAddr + BSCD_P_TRANSMIT), |
|---|
| 3685 | (uint32_t) inp_ucXmitData[i]); |
|---|
| 3686 | |
|---|
| 3687 | BDBG_MSG(("%02x ", inp_ucXmitData[i])); |
|---|
| 3688 | |
|---|
| 3689 | /* Ready to transmit */ |
|---|
| 3690 | ulVal = BREG_Read32( |
|---|
| 3691 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3692 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)); |
|---|
| 3693 | |
|---|
| 3694 | /* Always set auto receive */ |
|---|
| 3695 | ulVal = BCHP_SCA_SC_UART_CMD_1_t_r_MASK | BCHP_SCA_SC_UART_CMD_1_xmit_go_MASK | |
|---|
| 3696 | BCHP_SCA_SC_UART_CMD_1_io_en_MASK ; |
|---|
| 3697 | |
|---|
| 3698 | /*if (BSCD_P_Popcount[inp_ucXmitData[i]] % 2 == 1) { |
|---|
| 3699 | BDBG_MSG(("flip the parity \n")); |
|---|
| 3700 | ulVal |= BCHP_SCA_SC_UART_CMD_1_inv_par_MASK; |
|---|
| 3701 | }*/ |
|---|
| 3702 | if (BSCD_P_Popcount[inp_ucXmitData[i]] % 2 == 0) |
|---|
| 3703 | { |
|---|
| 3704 | BDBG_MSG(("Even number of one => Parity = 0 => flip the parity \n")); |
|---|
| 3705 | |
|---|
| 3706 | ulVal |= BCHP_SCA_SC_UART_CMD_1_inv_par_MASK; |
|---|
| 3707 | } |
|---|
| 3708 | else |
|---|
| 3709 | { |
|---|
| 3710 | BDBG_MSG(("Odd number of one => Parity = 1 => Do not flip the parity \n")); |
|---|
| 3711 | |
|---|
| 3712 | ulVal &= ~BCHP_SCA_SC_UART_CMD_1_inv_par_MASK; |
|---|
| 3713 | } |
|---|
| 3714 | if (i == (in_ulNumXmitBytes - 1)) |
|---|
| 3715 | ulVal |= BCHP_SCA_SC_UART_CMD_1_auto_rcv_MASK; /* Last TX byte, ready to receive */ |
|---|
| 3716 | |
|---|
| 3717 | BREG_Write32( |
|---|
| 3718 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3719 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3720 | ulVal); |
|---|
| 3721 | |
|---|
| 3722 | /* |
|---|
| 3723 | * Wait until the BCM sent all the data. |
|---|
| 3724 | */ |
|---|
| 3725 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3726 | BSCD_Channel_P_WaitForTDone(in_channelHandle)); |
|---|
| 3727 | |
|---|
| 3728 | } |
|---|
| 3729 | BDBG_MSG(("\n")); |
|---|
| 3730 | |
|---|
| 3731 | BSCD_P_DONE_LABEL: |
|---|
| 3732 | |
|---|
| 3733 | BDBG_LEAVE(BSCD_Channel_P_T14IrdetoTransmit); |
|---|
| 3734 | return( errCode ); |
|---|
| 3735 | } |
|---|
| 3736 | #endif |
|---|
| 3737 | |
|---|
| 3738 | #if 0 /* A582_HAWK */ |
|---|
| 3739 | |
|---|
| 3740 | /* |
|---|
| 3741 | OLO 15/03/2006. See Bug #44565 for more information |
|---|
| 3742 | |
|---|
| 3743 | The function "BSCD_Channel_P_T14IrdetoTransmit" implemented by Broadcom is not efficient. |
|---|
| 3744 | It sends one Byte at a time and thus it is very sensitive to context switch. |
|---|
| 3745 | This new implementation makes a better use of the Transmit FIFO. |
|---|
| 3746 | */ |
|---|
| 3747 | |
|---|
| 3748 | /* For T=14 only */ |
|---|
| 3749 | BERR_Code BSCD_Channel_P_T14IrdetoTransmit( |
|---|
| 3750 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 3751 | uint8_t *inp_ucXmitData, |
|---|
| 3752 | unsigned long in_ulNumXmitBytes |
|---|
| 3753 | ) |
|---|
| 3754 | { |
|---|
| 3755 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 3756 | uint32_t ulVal; |
|---|
| 3757 | unsigned int i; |
|---|
| 3758 | BSCD_Timer timer = {BSCD_TimerType_eGPTimer, {BSCD_GPTimerMode_eIMMEDIATE}, true, true}; |
|---|
| 3759 | BSCD_TimerValue timeValue= {BSCD_T14_IRDETO_MIN_DELAY_RX2TX, BSCD_TimerUnit_eCLK}; |
|---|
| 3760 | |
|---|
| 3761 | BDBG_ENTER(BSCD_Channel_P_T14IrdetoTransmit); |
|---|
| 3762 | BDBG_ASSERT( in_channelHandle ); |
|---|
| 3763 | |
|---|
| 3764 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 3765 | (in_channelHandle->ulMagicNumber != BSCD_P_CHANNEL_HANDLE_MAGIC_NUMBER ) ); |
|---|
| 3766 | |
|---|
| 3767 | /* BSCD_P_HexDump("Send",inp_ucXmitData, in_ulNumXmitBytes); */ |
|---|
| 3768 | |
|---|
| 3769 | BKNI_EnterCriticalSection(); |
|---|
| 3770 | in_channelHandle->ulIntrStatus1 &= |
|---|
| 3771 | ~BCHP_SCA_SC_INTR_STAT_1_tpar_intr_MASK & |
|---|
| 3772 | ~BCHP_SCA_SC_INTR_STAT_1_timer_intr_MASK & |
|---|
| 3773 | ~BCHP_SCA_SC_INTR_STAT_1_bgt_intr_MASK & |
|---|
| 3774 | ~BCHP_SCA_SC_INTR_STAT_1_tdone_intr_MASK & |
|---|
| 3775 | ~BCHP_SCA_SC_INTR_STAT_1_retry_intr_MASK & |
|---|
| 3776 | ~BCHP_SCA_SC_INTR_STAT_1_tempty_intr_MASK; |
|---|
| 3777 | |
|---|
| 3778 | in_channelHandle->ulIntrStatus2 &= |
|---|
| 3779 | ~BCHP_SCA_SC_INTR_STAT_2_rpar_intr_MASK & |
|---|
| 3780 | ~BCHP_SCA_SC_INTR_STAT_2_cwt_intr_MASK & |
|---|
| 3781 | ~BCHP_SCA_SC_INTR_STAT_2_rlen_intr_MASK & |
|---|
| 3782 | ~BCHP_SCA_SC_INTR_STAT_2_wait_intr_MASK & |
|---|
| 3783 | ~BCHP_SCA_SC_INTR_STAT_2_rcv_intr_MASK & |
|---|
| 3784 | ~BCHP_SCA_SC_INTR_STAT_2_rready_intr_MASK; |
|---|
| 3785 | BKNI_LeaveCriticalSection(); |
|---|
| 3786 | |
|---|
| 3787 | |
|---|
| 3788 | |
|---|
| 3789 | /* Reset the Transmit and Receive buffer */ |
|---|
| 3790 | ulVal = BCHP_SCA_SC_PROTO_CMD_tbuf_rst_MASK | BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK | |
|---|
| 3791 | BREG_Read32( |
|---|
| 3792 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3793 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)) ; |
|---|
| 3794 | BREG_Write32( |
|---|
| 3795 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3796 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3797 | ulVal); |
|---|
| 3798 | |
|---|
| 3799 | /* Need to wait for minimum of 1250 from last RX to this TX */ |
|---|
| 3800 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3801 | BSCD_Channel_ConfigTimer(in_channelHandle, &timer, &timeValue)); |
|---|
| 3802 | |
|---|
| 3803 | |
|---|
| 3804 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3805 | BSCD_Channel_P_WaitForTimerEvent(in_channelHandle)); |
|---|
| 3806 | |
|---|
| 3807 | /* Disable timer */ |
|---|
| 3808 | timer.bIsTimerInterruptEnable = false; |
|---|
| 3809 | timer.bIsTimerEnable = false; |
|---|
| 3810 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3811 | BSCD_Channel_EnableDisableTimer_isr(in_channelHandle, &timer)); |
|---|
| 3812 | |
|---|
| 3813 | |
|---|
| 3814 | /* Enable EDC */ |
|---|
| 3815 | ulVal = BREG_Read32( |
|---|
| 3816 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3817 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD)); |
|---|
| 3818 | |
|---|
| 3819 | ulVal |= BCHP_SCA_SC_PROTO_CMD_rbuf_rst_MASK; |
|---|
| 3820 | |
|---|
| 3821 | BREG_Write32( |
|---|
| 3822 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3823 | (in_channelHandle->ulRegStartAddr + BSCD_P_PROTO_CMD), |
|---|
| 3824 | ulVal); |
|---|
| 3825 | |
|---|
| 3826 | |
|---|
| 3827 | /* Set flow cmd */ |
|---|
| 3828 | ulVal = BREG_Read32( |
|---|
| 3829 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3830 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD)); |
|---|
| 3831 | |
|---|
| 3832 | /* No flow control for T=1 protocol or T=14. */ |
|---|
| 3833 | ulVal &= ~BCHP_SCA_SC_FLOW_CMD_flow_en_MASK; |
|---|
| 3834 | |
|---|
| 3835 | BREG_Write32( |
|---|
| 3836 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3837 | (in_channelHandle->ulRegStartAddr + BSCD_P_FLOW_CMD), |
|---|
| 3838 | ulVal); |
|---|
| 3839 | |
|---|
| 3840 | |
|---|
| 3841 | |
|---|
| 3842 | |
|---|
| 3843 | /* |
|---|
| 3844 | * Fill BCM FIFO with the request message. |
|---|
| 3845 | */ |
|---|
| 3846 | for (i = 0; i < in_ulNumXmitBytes; i++) |
|---|
| 3847 | { |
|---|
| 3848 | |
|---|
| 3849 | BREG_Write32( |
|---|
| 3850 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3851 | (in_channelHandle->ulRegStartAddr + BSCD_P_TRANSMIT), |
|---|
| 3852 | (uint32_t) inp_ucXmitData[i]); |
|---|
| 3853 | |
|---|
| 3854 | BDBG_MSG(("%02x ", inp_ucXmitData[i])); |
|---|
| 3855 | |
|---|
| 3856 | /* Ready to transmit */ |
|---|
| 3857 | ulVal = BREG_Read32( |
|---|
| 3858 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3859 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)); |
|---|
| 3860 | |
|---|
| 3861 | /* Always set auto receive */ |
|---|
| 3862 | /* "xmit_go" will be set only when all the Bytes will be in the FIFO */ |
|---|
| 3863 | ulVal = BCHP_SCA_SC_UART_CMD_1_t_r_MASK | BCHP_SCA_SC_UART_CMD_1_io_en_MASK ; |
|---|
| 3864 | |
|---|
| 3865 | /* |
|---|
| 3866 | See Bug #44564 |
|---|
| 3867 | For T=14 parity should be disabled but this is not possible with 7038 hardware |
|---|
| 3868 | So this code is a workaround which ensure that Parity is always equal to '1' |
|---|
| 3869 | */ |
|---|
| 3870 | if (BSCD_P_Popcount[inp_ucXmitData[i]] % 2 == 0) |
|---|
| 3871 | { |
|---|
| 3872 | BDBG_MSG(("Even number of one => Parity = 0 => flip the parity \n")); |
|---|
| 3873 | |
|---|
| 3874 | ulVal |= BCHP_SCA_SC_UART_CMD_1_inv_par_MASK; |
|---|
| 3875 | } |
|---|
| 3876 | else |
|---|
| 3877 | { |
|---|
| 3878 | BDBG_MSG(("Odd number of one => Parity = 1 => Do not flip the parity \n")); |
|---|
| 3879 | |
|---|
| 3880 | ulVal &= ~BCHP_SCA_SC_UART_CMD_1_inv_par_MASK; |
|---|
| 3881 | } |
|---|
| 3882 | |
|---|
| 3883 | if (i == (in_ulNumXmitBytes - 1)) |
|---|
| 3884 | ulVal |= BCHP_SCA_SC_UART_CMD_1_auto_rcv_MASK; /* Last TX byte, ready to receive */ |
|---|
| 3885 | /*printf("ul val %x \n", ulVal);*/ |
|---|
| 3886 | BREG_Write32( |
|---|
| 3887 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3888 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3889 | ulVal); |
|---|
| 3890 | } |
|---|
| 3891 | BDBG_MSG(("\n")); |
|---|
| 3892 | |
|---|
| 3893 | |
|---|
| 3894 | /* Now that the FIFO is filled we can set the "xmit_go" bit to start the transmission */ |
|---|
| 3895 | ulVal = BREG_Read32( |
|---|
| 3896 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3897 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1)); |
|---|
| 3898 | |
|---|
| 3899 | ulVal |= BCHP_SCA_SC_UART_CMD_1_xmit_go_MASK; |
|---|
| 3900 | |
|---|
| 3901 | BREG_Write32( |
|---|
| 3902 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 3903 | (in_channelHandle->ulRegStartAddr + BSCD_P_UART_CMD_1), |
|---|
| 3904 | ulVal); |
|---|
| 3905 | |
|---|
| 3906 | /* |
|---|
| 3907 | * Wait until the BCM sent all the data. |
|---|
| 3908 | */ |
|---|
| 3909 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3910 | BSCD_Channel_P_WaitForTDone(in_channelHandle)); |
|---|
| 3911 | |
|---|
| 3912 | BDBG_MSG(("Transmission done")); |
|---|
| 3913 | |
|---|
| 3914 | |
|---|
| 3915 | BSCD_P_DONE_LABEL: |
|---|
| 3916 | |
|---|
| 3917 | BDBG_LEAVE(BSCD_Channel_P_T14IrdetoTransmit); |
|---|
| 3918 | return( errCode ); |
|---|
| 3919 | } |
|---|
| 3920 | #endif /* A582_HAWK */ |
|---|
| 3921 | |
|---|
| 3922 | |
|---|
| 3923 | |
|---|
| 3924 | BERR_Code BSCD_Channel_P_EnableInterrupts_isr( |
|---|
| 3925 | BSCD_ChannelHandle in_channelHandle |
|---|
| 3926 | ) |
|---|
| 3927 | { |
|---|
| 3928 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 3929 | |
|---|
| 3930 | BDBG_ENTER(BSCD_Channel_P_EnableInterrupts_isr); |
|---|
| 3931 | |
|---|
| 3932 | if (in_channelHandle->bIsOpen == true) { |
|---|
| 3933 | /* Update BSCD_P_INTR_EN_1 and BSCD_P_INTR_EN_2 */ |
|---|
| 3934 | if ((in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e0 ) && |
|---|
| 3935 | (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto)) { |
|---|
| 3936 | |
|---|
| 3937 | /* Enable parity error re-transmission only in T=0 */ |
|---|
| 3938 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3939 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 3940 | in_channelHandle, BSCD_IntType_eRetryInt, |
|---|
| 3941 | BSCD_Channel_P_RetryCB_isr)); |
|---|
| 3942 | |
|---|
| 3943 | /* Enable RCV_INTR only in T=0 */ |
|---|
| 3944 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3945 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 3946 | in_channelHandle, BSCD_IntType_eRcvInt, |
|---|
| 3947 | BSCD_Channel_P_RcvCB_isr)); |
|---|
| 3948 | |
|---|
| 3949 | /* Enable RPAR_INTR only in T=0 */ |
|---|
| 3950 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3951 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 3952 | in_channelHandle, BSCD_IntType_eRParityInt, |
|---|
| 3953 | BSCD_Channel_P_RParityCB_isr)); |
|---|
| 3954 | |
|---|
| 3955 | /* Enable TPAR_INTR only in T=0 */ |
|---|
| 3956 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3957 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 3958 | in_channelHandle, BSCD_IntType_eTParityInt, |
|---|
| 3959 | BSCD_Channel_P_TParityCB_isr)); |
|---|
| 3960 | |
|---|
| 3961 | |
|---|
| 3962 | } |
|---|
| 3963 | |
|---|
| 3964 | |
|---|
| 3965 | else if (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1 ) { /* T=1 protocol */ |
|---|
| 3966 | |
|---|
| 3967 | /* Enable cwt only in T=1 */ |
|---|
| 3968 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 3969 | if ( (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eEMV2000) || |
|---|
| 3970 | (in_channelHandle->currentChannelSettings.eProtocolType != BSCD_AsyncProtocolType_e1)) { |
|---|
| 3971 | #endif |
|---|
| 3972 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3973 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 3974 | in_channelHandle, BSCD_IntType_eCWTInt, |
|---|
| 3975 | BSCD_Channel_P_CWTCB_isr)); |
|---|
| 3976 | |
|---|
| 3977 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 3978 | } |
|---|
| 3979 | #endif |
|---|
| 3980 | |
|---|
| 3981 | |
|---|
| 3982 | #ifdef BSCD_EMV2000_CWT_PLUS_4_EVENT_INTR |
|---|
| 3983 | /* Enable BGT only in T=1 */ |
|---|
| 3984 | if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) { |
|---|
| 3985 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3986 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 3987 | in_channelHandle, BSCD_IntType_eEvent1Int, |
|---|
| 3988 | BSCD_Channel_P_Event1CB_isr)); |
|---|
| 3989 | } |
|---|
| 3990 | |
|---|
| 3991 | #endif |
|---|
| 3992 | |
|---|
| 3993 | /* Enable BGT only in T=1 */ |
|---|
| 3994 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 3995 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 3996 | in_channelHandle, BSCD_IntType_eBGTInt, |
|---|
| 3997 | BSCD_Channel_P_BGTCB_isr)); |
|---|
| 3998 | |
|---|
| 3999 | /* Enable rlen only in T=1 */ |
|---|
| 4000 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4001 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 4002 | in_channelHandle, BSCD_IntType_eRLenInt, |
|---|
| 4003 | BSCD_Channel_P_RLenCB_isr)); |
|---|
| 4004 | |
|---|
| 4005 | /* Enable rreadyonly in T=1 */ |
|---|
| 4006 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4007 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 4008 | in_channelHandle, BSCD_IntType_eRReadyInt, |
|---|
| 4009 | BSCD_Channel_P_RReadyCB_isr)); |
|---|
| 4010 | |
|---|
| 4011 | /* set block guard time for T=1 only */ |
|---|
| 4012 | /* Update the BSCD_P_BGT */ |
|---|
| 4013 | BREG_Write32( |
|---|
| 4014 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4015 | (in_channelHandle->ulRegStartAddr + BSCD_P_BGT), |
|---|
| 4016 | BCHP_SCA_SC_BGT_r2t_MASK| in_channelHandle->currentChannelSettings.blockGuardTime.ulValue); |
|---|
| 4017 | |
|---|
| 4018 | /* Enable RCV_INTR only in T=1, EMV 2000 to resolve CWT+4 issue */ |
|---|
| 4019 | #ifdef BSCD_EMV2000_CWT_PLUS_4 |
|---|
| 4020 | if ( (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eEMV2000) && |
|---|
| 4021 | (in_channelHandle->currentChannelSettings.eProtocolType == BSCD_AsyncProtocolType_e1)) { |
|---|
| 4022 | |
|---|
| 4023 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4024 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 4025 | in_channelHandle, BSCD_IntType_eRcvInt, |
|---|
| 4026 | NULL)); |
|---|
| 4027 | } |
|---|
| 4028 | #endif |
|---|
| 4029 | /* Enable RCV_INTR only in T=1, EMV 2000 to resolve CWT+4 issue */ |
|---|
| 4030 | |
|---|
| 4031 | |
|---|
| 4032 | } |
|---|
| 4033 | else if (in_channelHandle->currentChannelSettings.scStandard == BSCD_Standard_eIrdeto) { /* T=14 Irdeto protocol */ |
|---|
| 4034 | /* Enable RCV_INTR only in T=0 */ |
|---|
| 4035 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4036 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 4037 | in_channelHandle, BSCD_IntType_eRcvInt, |
|---|
| 4038 | BSCD_Channel_P_RcvCB_isr)); |
|---|
| 4039 | } |
|---|
| 4040 | |
|---|
| 4041 | /* Keep the card insertion and removal interrrupt */ |
|---|
| 4042 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4043 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 4044 | in_channelHandle, BSCD_IntType_eCardInsertInt, |
|---|
| 4045 | BSCD_Channel_P_CardInsertCB_isr)); |
|---|
| 4046 | |
|---|
| 4047 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4048 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 4049 | in_channelHandle, BSCD_IntType_eCardRemoveInt, |
|---|
| 4050 | BSCD_Channel_P_CardRemoveCB_isr)); |
|---|
| 4051 | |
|---|
| 4052 | /* Enable tdone for T=0 and T=1 */ |
|---|
| 4053 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4054 | BSCD_Channel_EnableIntrCallback_isr ( |
|---|
| 4055 | in_channelHandle, BSCD_IntType_eTDoneInt, |
|---|
| 4056 | BSCD_Channel_P_TDoneCB_isr)); |
|---|
| 4057 | |
|---|
| 4058 | } |
|---|
| 4059 | |
|---|
| 4060 | BSCD_P_DONE_LABEL: |
|---|
| 4061 | |
|---|
| 4062 | BDBG_LEAVE(BSCD_Channel_P_EnableInterrupts_isr); |
|---|
| 4063 | return( errCode ); |
|---|
| 4064 | |
|---|
| 4065 | } |
|---|
| 4066 | |
|---|
| 4067 | |
|---|
| 4068 | BERR_Code BSCD_Channel_P_SetStandard( |
|---|
| 4069 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 4070 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 4071 | ) |
|---|
| 4072 | { |
|---|
| 4073 | |
|---|
| 4074 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 4075 | |
|---|
| 4076 | BDBG_ENTER(BSCD_Channel_P_SetStandard); |
|---|
| 4077 | |
|---|
| 4078 | /* Asynchronous Protocol Types. */ |
|---|
| 4079 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4080 | ((inp_sSettings->eProtocolType <= BSCD_AsyncProtocolType_eUnknown) || |
|---|
| 4081 | (inp_sSettings->eProtocolType > BSCD_AsyncProtocolType_e14_IRDETO)) ); |
|---|
| 4082 | switch(in_channelHandle->currentChannelSettings.scStandard) { |
|---|
| 4083 | case BSCD_Standard_eNDS: /* NDS. T=0 with flow control. */ |
|---|
| 4084 | case BSCD_Standard_eNDS_NO_FLOWCRTL: /* NDS. T=0 without flow control. */ |
|---|
| 4085 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4086 | (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 )); |
|---|
| 4087 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4088 | break; |
|---|
| 4089 | |
|---|
| 4090 | case BSCD_Standard_eISO: /* ISO 7816. T_0 or T=1*/ |
|---|
| 4091 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4092 | ( (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 ) && |
|---|
| 4093 | (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e1 ))); |
|---|
| 4094 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4095 | break; |
|---|
| 4096 | |
|---|
| 4097 | case BSCD_Standard_eEMV1996: /* EMV. T=0 or T=1 */ |
|---|
| 4098 | case BSCD_Standard_eEMV2000: /* EMV. T=0 or T=1 */ |
|---|
| 4099 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4100 | ((inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 ) && |
|---|
| 4101 | (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e1 ))); |
|---|
| 4102 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4103 | break; |
|---|
| 4104 | |
|---|
| 4105 | case BSCD_Standard_eARIB: /* ARIB. T=1 */ |
|---|
| 4106 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4107 | ( (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 ) && |
|---|
| 4108 | (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e1 ))); |
|---|
| 4109 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4110 | break; |
|---|
| 4111 | |
|---|
| 4112 | case BSCD_Standard_eIrdeto: /* Irdeto. T=14. Need Major software workarouond to support this */ |
|---|
| 4113 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4114 | ( (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 ) && |
|---|
| 4115 | (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e14_IRDETO ))); |
|---|
| 4116 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4117 | break; |
|---|
| 4118 | |
|---|
| 4119 | |
|---|
| 4120 | case BSCD_Standard_eES: /* ES, T=1. Obsolete. Use ISO */ |
|---|
| 4121 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4122 | ( (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 ) && |
|---|
| 4123 | (inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e1 ))); |
|---|
| 4124 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4125 | break; |
|---|
| 4126 | |
|---|
| 4127 | case BSCD_Standard_eMT: /* MT, T=0. Obsolete. Use ISO */ |
|---|
| 4128 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4129 | ((inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 ) )); |
|---|
| 4130 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4131 | break; |
|---|
| 4132 | |
|---|
| 4133 | case BSCD_Standard_eConax: /* Conax, T=0. Obsolete. Use ISO */ |
|---|
| 4134 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4135 | ((inp_sSettings->eProtocolType != BSCD_AsyncProtocolType_e0 ) )); |
|---|
| 4136 | in_channelHandle->currentChannelSettings.eProtocolType = inp_sSettings->eProtocolType; |
|---|
| 4137 | break; |
|---|
| 4138 | |
|---|
| 4139 | default: |
|---|
| 4140 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4141 | break; |
|---|
| 4142 | |
|---|
| 4143 | } |
|---|
| 4144 | BDBG_MSG(("eProtocolType = %d", in_channelHandle->currentChannelSettings.eProtocolType)); |
|---|
| 4145 | |
|---|
| 4146 | |
|---|
| 4147 | BSCD_P_DONE_LABEL: |
|---|
| 4148 | |
|---|
| 4149 | BDBG_LEAVE(BSCD_Channel_P_SetStandard); |
|---|
| 4150 | return( errCode ); |
|---|
| 4151 | } |
|---|
| 4152 | |
|---|
| 4153 | BERR_Code BSCD_Channel_P_SetSrcClock( |
|---|
| 4154 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 4155 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 4156 | ) |
|---|
| 4157 | { |
|---|
| 4158 | |
|---|
| 4159 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 4160 | uint32_t ulVal; |
|---|
| 4161 | |
|---|
| 4162 | BDBG_ENTER(BSCD_Channel_P_SetSrcClock); |
|---|
| 4163 | |
|---|
| 4164 | if(inp_sSettings->srcClkFreqInHz){ |
|---|
| 4165 | |
|---|
| 4166 | BDBG_MSG(("Set smartcard source clock..%d.\n", inp_sSettings->srcClkFreqInHz)); |
|---|
| 4167 | ulVal=BREG_Read32( |
|---|
| 4168 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4169 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD)); |
|---|
| 4170 | ulVal &=~ BCHP_SCA_SC_CLK_CMD_clk_en_MASK; |
|---|
| 4171 | BREG_Write32( |
|---|
| 4172 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4173 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD), |
|---|
| 4174 | ulVal); |
|---|
| 4175 | |
|---|
| 4176 | if(inp_sSettings->srcClkFreqInHz){ |
|---|
| 4177 | in_channelHandle->moduleHandle->currentSettings.moduleClkFreq.ulClkFreq = inp_sSettings->srcClkFreqInHz; |
|---|
| 4178 | switch(inp_sSettings->srcClkFreqInHz){ |
|---|
| 4179 | case 27000000: |
|---|
| 4180 | in_channelHandle->currentChannelSettings.eSrcClkFreq = BSCD_ClockFreq_e27MHZ; |
|---|
| 4181 | break; |
|---|
| 4182 | case 36864000: |
|---|
| 4183 | in_channelHandle->currentChannelSettings.eSrcClkFreq = BSCD_ClockFreq_e36P864MHZ; |
|---|
| 4184 | break; |
|---|
| 4185 | case 36000000: |
|---|
| 4186 | in_channelHandle->currentChannelSettings.eSrcClkFreq = BSCD_ClockFreq_e36MHZ; |
|---|
| 4187 | break; |
|---|
| 4188 | case 24000000: |
|---|
| 4189 | in_channelHandle->currentChannelSettings.eSrcClkFreq = BSCD_ClockFreq_e24MHZ; |
|---|
| 4190 | break; |
|---|
| 4191 | case 108000000: |
|---|
| 4192 | in_channelHandle->currentChannelSettings.eSrcClkFreq = BSCD_ClockFreq_e108MHZ; |
|---|
| 4193 | break; |
|---|
| 4194 | default: |
|---|
| 4195 | BDBG_ERR(("Unknown SC clock freq %d!\n",inp_sSettings->srcClkFreqInHz )); |
|---|
| 4196 | break; |
|---|
| 4197 | |
|---|
| 4198 | } |
|---|
| 4199 | } |
|---|
| 4200 | ulVal = BREG_Read32( |
|---|
| 4201 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4202 | BCHP_CLKGEN_SMARTCARD_MUX_SELECT) ; |
|---|
| 4203 | switch(in_channelHandle->ucChannelNumber){ |
|---|
| 4204 | case 0: |
|---|
| 4205 | ulVal &= ~BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC0_CLOCK_MASK; |
|---|
| 4206 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq != BSCD_ClockFreq_e27MHZ){ |
|---|
| 4207 | |
|---|
| 4208 | #if((BCHP_CHIP==7422)|| (BCHP_CHIP == 7425))&&(BCHP_VER < BCHP_VER_B0) |
|---|
| 4209 | ulVal |= 2 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC0_CLOCK_SHIFT; |
|---|
| 4210 | #elif (BCHP_CHIP==7346)||(BCHP_CHIP==7231)||(BCHP_CHIP==7358)||(BCHP_CHIP==7344)||(BCHP_CHIP==7552)||(BCHP_CHIP == 7425) |
|---|
| 4211 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36P864MHZ) |
|---|
| 4212 | ulVal |= 2 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC0_CLOCK_SHIFT; |
|---|
| 4213 | else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e24MHZ) |
|---|
| 4214 | ulVal |= 3 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC0_CLOCK_SHIFT; |
|---|
| 4215 | else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36MHZ) |
|---|
| 4216 | ulVal |= 4 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC0_CLOCK_SHIFT; |
|---|
| 4217 | else |
|---|
| 4218 | #if(BCHP_CHIP==7346)&&(BCHP_VER==BCHP_VER_A0) |
|---|
| 4219 | ulVal |= 1 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC0_CLOCK_SHIFT; |
|---|
| 4220 | #else |
|---|
| 4221 | ulVal |= 2 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC0_CLOCK_SHIFT; |
|---|
| 4222 | #endif |
|---|
| 4223 | #endif |
|---|
| 4224 | } |
|---|
| 4225 | break; |
|---|
| 4226 | case 1: |
|---|
| 4227 | |
|---|
| 4228 | ulVal &= ~BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC1_CLOCK_MASK; |
|---|
| 4229 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq != BSCD_ClockFreq_e27MHZ){ |
|---|
| 4230 | #if ((BCHP_CHIP==7422)|| (BCHP_CHIP == 7425))&&(BCHP_VER < BCHP_VER_A0) |
|---|
| 4231 | ulVal |= 2 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC1_CLOCK_SHIFT; |
|---|
| 4232 | #elif (BCHP_CHIP ==7346)||(BCHP_CHIP==7231)||(BCHP_CHIP==7358)||(BCHP_CHIP==7344)||(BCHP_CHIP==7552)||(BCHP_CHIP == 7425) |
|---|
| 4233 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36P864MHZ) |
|---|
| 4234 | ulVal |= 2 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC1_CLOCK_SHIFT; |
|---|
| 4235 | else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e24MHZ) |
|---|
| 4236 | ulVal |= 3 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC1_CLOCK_SHIFT; |
|---|
| 4237 | else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36MHZ) |
|---|
| 4238 | ulVal |= 4 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC1_CLOCK_SHIFT; |
|---|
| 4239 | else |
|---|
| 4240 | #if(BCHP_CHIP==7346)&&(BCHP_VER==BCHP_VER_A0) |
|---|
| 4241 | ulVal |= 1 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC1_CLOCK_SHIFT; |
|---|
| 4242 | #else |
|---|
| 4243 | ulVal |= 2 <<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_SC1_CLOCK_SHIFT; |
|---|
| 4244 | #endif |
|---|
| 4245 | #endif |
|---|
| 4246 | } |
|---|
| 4247 | break; |
|---|
| 4248 | default: |
|---|
| 4249 | BDBG_ERR(("Unknown channel number %d\n",in_channelHandle->ucChannelNumber )); |
|---|
| 4250 | break; |
|---|
| 4251 | } |
|---|
| 4252 | #if(BCHP_CHIP==7231)||(BCHP_CHIP==7358)||(BCHP_CHIP==7344)||(BCHP_CHIP==7552)||((BCHP_CHIP==7346)&&(BCHP_VER>BCHP_VER_A0))||((BCHP_CHIP==7425)&&(BCHP_VER>BCHP_VER_A1)) |
|---|
| 4253 | ulVal &= ~BCHP_CLKGEN_SMARTCARD_MUX_SELECT_PLLSC_REFERENCE_CLOCK_MASK; |
|---|
| 4254 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36P864MHZ) |
|---|
| 4255 | ulVal |=1<<BCHP_CLKGEN_SMARTCARD_MUX_SELECT_PLLSC_REFERENCE_CLOCK_SHIFT; |
|---|
| 4256 | #endif |
|---|
| 4257 | BREG_Write32( |
|---|
| 4258 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4259 | BCHP_CLKGEN_SMARTCARD_MUX_SELECT, ulVal); |
|---|
| 4260 | /* Set up reference clock */ |
|---|
| 4261 | #if ((BCHP_CHIP== 7422) || (BCHP_CHIP==7346) || (BCHP_CHIP == 7425))&&(BCHP_VER < BCHP_VER_B0) |
|---|
| 4262 | ulVal = BREG_Read32( |
|---|
| 4263 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4264 | BCHP_CLKGEN_INTERNAL_MUX_SELECT) ; |
|---|
| 4265 | ulVal &= ~BCHP_CLKGEN_INTERNAL_MUX_SELECT_PLLSC_REFERENCE_CLOCK_MASK; |
|---|
| 4266 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36P864MHZ) |
|---|
| 4267 | ulVal |=1<<BCHP_CLKGEN_INTERNAL_MUX_SELECT_PLLSC_REFERENCE_CLOCK_SHIFT; |
|---|
| 4268 | BREG_Write32( |
|---|
| 4269 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4270 | BCHP_CLKGEN_INTERNAL_MUX_SELECT, ulVal); |
|---|
| 4271 | #endif |
|---|
| 4272 | #if((BCHP_CHIP==7422)|| (BCHP_CHIP == 7425))&&(BCHP_VER < BCHP_VER_B0) |
|---|
| 4273 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq != BSCD_ClockFreq_e27MHZ){ |
|---|
| 4274 | ulVal = BREG_Read32( |
|---|
| 4275 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4276 | BCHP_CLKGEN_PLL_SC_PLL_RESET) ; |
|---|
| 4277 | |
|---|
| 4278 | |
|---|
| 4279 | |
|---|
| 4280 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36P864MHZ){ |
|---|
| 4281 | |
|---|
| 4282 | ulVal = BREG_Read32( |
|---|
| 4283 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4284 | BCHP_CLKGEN_PLL_SC_PLL_DIV) ; |
|---|
| 4285 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_MASK; |
|---|
| 4286 | ulVal |= 0x48<<BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_SHIFT; |
|---|
| 4287 | BREG_Write32( |
|---|
| 4288 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4289 | BCHP_CLKGEN_PLL_SC_PLL_DIV, ulVal); |
|---|
| 4290 | |
|---|
| 4291 | ulVal = BREG_Read32( |
|---|
| 4292 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4293 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0) ; |
|---|
| 4294 | |
|---|
| 4295 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK; |
|---|
| 4296 | ulVal |= 0x2D <<BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_SHIFT; |
|---|
| 4297 | |
|---|
| 4298 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4299 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK, |
|---|
| 4300 | ulVal); |
|---|
| 4301 | |
|---|
| 4302 | }else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36MHZ){ |
|---|
| 4303 | |
|---|
| 4304 | ulVal = BREG_Read32( |
|---|
| 4305 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4306 | BCHP_CLKGEN_PLL_SC_PLL_DIV) ; |
|---|
| 4307 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_MASK; |
|---|
| 4308 | ulVal |= 0x40<<BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_SHIFT; |
|---|
| 4309 | BREG_Write32( |
|---|
| 4310 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4311 | BCHP_CLKGEN_PLL_SC_PLL_DIV, ulVal); |
|---|
| 4312 | ulVal = BREG_Read32( |
|---|
| 4313 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4314 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0) ; |
|---|
| 4315 | |
|---|
| 4316 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK; |
|---|
| 4317 | |
|---|
| 4318 | ulVal |= 0x24 <<BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_SHIFT; |
|---|
| 4319 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4320 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK, |
|---|
| 4321 | ulVal); |
|---|
| 4322 | }else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e24MHZ){ |
|---|
| 4323 | |
|---|
| 4324 | ulVal = BREG_Read32( |
|---|
| 4325 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4326 | BCHP_CLKGEN_PLL_SC_PLL_DIV) ; |
|---|
| 4327 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_MASK; |
|---|
| 4328 | ulVal |= 0x40<<BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_SHIFT; |
|---|
| 4329 | BREG_Write32( |
|---|
| 4330 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4331 | BCHP_CLKGEN_PLL_SC_PLL_DIV, ulVal); |
|---|
| 4332 | ulVal = BREG_Read32( |
|---|
| 4333 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4334 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0) ; |
|---|
| 4335 | |
|---|
| 4336 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK; |
|---|
| 4337 | ulVal |= 0x36 <<BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_SHIFT; |
|---|
| 4338 | |
|---|
| 4339 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4340 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK, |
|---|
| 4341 | ulVal); |
|---|
| 4342 | }else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e108MHZ){ |
|---|
| 4343 | |
|---|
| 4344 | ulVal = BREG_Read32( |
|---|
| 4345 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4346 | BCHP_CLKGEN_PLL_SC_PLL_DIV) ; |
|---|
| 4347 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_MASK; |
|---|
| 4348 | ulVal |= 0x40<<BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_SHIFT; |
|---|
| 4349 | BREG_Write32( |
|---|
| 4350 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4351 | BCHP_CLKGEN_PLL_SC_PLL_DIV, ulVal); |
|---|
| 4352 | ulVal = BREG_Read32( |
|---|
| 4353 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4354 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0) ; |
|---|
| 4355 | |
|---|
| 4356 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK; |
|---|
| 4357 | ulVal |= 0xc <<BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_SHIFT; |
|---|
| 4358 | |
|---|
| 4359 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4360 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK, |
|---|
| 4361 | ulVal); |
|---|
| 4362 | } |
|---|
| 4363 | else{ |
|---|
| 4364 | BDBG_WRN(("Clock not set. Please make sure you set up the smartcard source clock correclty\n")); |
|---|
| 4365 | return BSCD_STATUS_FAILED; |
|---|
| 4366 | } |
|---|
| 4367 | ulVal = BREG_Read32( |
|---|
| 4368 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4369 | BCHP_CLKGEN_PLL_SC_PLL_RESET) ; |
|---|
| 4370 | ulVal |= 1<<BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_SHIFT; |
|---|
| 4371 | ulVal |= 1<<BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_SHIFT; |
|---|
| 4372 | |
|---|
| 4373 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4374 | BCHP_CLKGEN_PLL_SC_PLL_RESET,BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK|BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK, |
|---|
| 4375 | ulVal); |
|---|
| 4376 | |
|---|
| 4377 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK; |
|---|
| 4378 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK; |
|---|
| 4379 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4380 | BCHP_CLKGEN_PLL_SC_PLL_RESET,BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK|BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK, |
|---|
| 4381 | ulVal); |
|---|
| 4382 | } |
|---|
| 4383 | #elif (BCHP_CHIP==7346)||(BCHP_CHIP==7231)||(BCHP_CHIP==7358)||(BCHP_CHIP==7344)||(BCHP_CHIP==7552)||(BCHP_CHIP==7425) |
|---|
| 4384 | if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e108MHZ){ |
|---|
| 4385 | |
|---|
| 4386 | ulVal = BREG_Read32( |
|---|
| 4387 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4388 | BCHP_CLKGEN_PLL_SC_PLL_DIV) ; |
|---|
| 4389 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_MASK; |
|---|
| 4390 | ulVal |= 0x40<<BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_SHIFT; |
|---|
| 4391 | BREG_Write32( |
|---|
| 4392 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4393 | BCHP_CLKGEN_PLL_SC_PLL_DIV, ulVal); |
|---|
| 4394 | ulVal = BREG_Read32( |
|---|
| 4395 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4396 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0) ; |
|---|
| 4397 | |
|---|
| 4398 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK; |
|---|
| 4399 | ulVal |= 0xc <<BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_SHIFT; |
|---|
| 4400 | #if (BCHP_VER < BCHP_VER_B0) |
|---|
| 4401 | BREG_Write32( |
|---|
| 4402 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4403 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0, ulVal); |
|---|
| 4404 | |
|---|
| 4405 | #else |
|---|
| 4406 | if(in_channelHandle->ucChannelNumber) |
|---|
| 4407 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4408 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_1,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_1_MDIV_CH1_MASK, |
|---|
| 4409 | ulVal); |
|---|
| 4410 | else |
|---|
| 4411 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4412 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK, |
|---|
| 4413 | ulVal); |
|---|
| 4414 | #endif |
|---|
| 4415 | ulVal = BREG_Read32( |
|---|
| 4416 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4417 | BCHP_CLKGEN_PLL_SC_PLL_RESET) ; |
|---|
| 4418 | ulVal |= 1<<BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_SHIFT; |
|---|
| 4419 | ulVal |= 1<<BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_SHIFT; |
|---|
| 4420 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4421 | BCHP_CLKGEN_PLL_SC_PLL_RESET,BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK|BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK, |
|---|
| 4422 | ulVal); |
|---|
| 4423 | |
|---|
| 4424 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK; |
|---|
| 4425 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK; |
|---|
| 4426 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4427 | BCHP_CLKGEN_PLL_SC_PLL_RESET,BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK|BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK, |
|---|
| 4428 | ulVal); |
|---|
| 4429 | |
|---|
| 4430 | |
|---|
| 4431 | } |
|---|
| 4432 | else if(in_channelHandle->currentChannelSettings.eSrcClkFreq == BSCD_ClockFreq_e36P864MHZ){ |
|---|
| 4433 | ulVal = BREG_Read32( |
|---|
| 4434 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4435 | BCHP_CLKGEN_PLL_SC_PLL_DIV) ; |
|---|
| 4436 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_MASK; |
|---|
| 4437 | ulVal |= 0x40<<BCHP_CLKGEN_PLL_SC_PLL_DIV_NDIV_INT_SHIFT; |
|---|
| 4438 | BREG_Write32( |
|---|
| 4439 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4440 | BCHP_CLKGEN_PLL_SC_PLL_DIV, ulVal); |
|---|
| 4441 | ulVal = BREG_Read32( |
|---|
| 4442 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4443 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0) ; |
|---|
| 4444 | |
|---|
| 4445 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK; |
|---|
| 4446 | ulVal |= 0x28 <<BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_SHIFT; |
|---|
| 4447 | #if (BCHP_VER < BCHP_VER_B0) |
|---|
| 4448 | BREG_Write32( |
|---|
| 4449 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4450 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0, ulVal); |
|---|
| 4451 | |
|---|
| 4452 | #else |
|---|
| 4453 | if(in_channelHandle->ucChannelNumber) |
|---|
| 4454 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4455 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_1,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_1_MDIV_CH1_MASK, |
|---|
| 4456 | ulVal); |
|---|
| 4457 | else |
|---|
| 4458 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4459 | BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0,BCHP_CLKGEN_PLL_SC_PLL_CHANNEL_CTRL_CH_0_MDIV_CH0_MASK, |
|---|
| 4460 | ulVal); |
|---|
| 4461 | #endif |
|---|
| 4462 | ulVal = BREG_Read32( |
|---|
| 4463 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4464 | BCHP_CLKGEN_PLL_SC_PLL_RESET) ; |
|---|
| 4465 | ulVal |= 1<<BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_SHIFT; |
|---|
| 4466 | ulVal |= 1<<BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_SHIFT; |
|---|
| 4467 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4468 | BCHP_CLKGEN_PLL_SC_PLL_RESET,BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK|BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK, |
|---|
| 4469 | ulVal); |
|---|
| 4470 | |
|---|
| 4471 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK; |
|---|
| 4472 | ulVal &= ~BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK; |
|---|
| 4473 | BREG_AtomicUpdate32 (in_channelHandle->moduleHandle->regHandle, |
|---|
| 4474 | BCHP_CLKGEN_PLL_SC_PLL_RESET,BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETD_MASK|BCHP_CLKGEN_PLL_SC_PLL_RESET_RESETA_MASK, |
|---|
| 4475 | ulVal); |
|---|
| 4476 | } |
|---|
| 4477 | |
|---|
| 4478 | #endif |
|---|
| 4479 | |
|---|
| 4480 | } |
|---|
| 4481 | |
|---|
| 4482 | BKNI_EnterCriticalSection(); |
|---|
| 4483 | |
|---|
| 4484 | ulVal=BREG_Read32( |
|---|
| 4485 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4486 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD)); |
|---|
| 4487 | ulVal |=BCHP_SCA_SC_CLK_CMD_clk_en_MASK; |
|---|
| 4488 | BREG_Write32( |
|---|
| 4489 | in_channelHandle->moduleHandle->regHandle, |
|---|
| 4490 | (in_channelHandle->ulRegStartAddr + BSCD_P_CLK_CMD), |
|---|
| 4491 | ulVal); |
|---|
| 4492 | |
|---|
| 4493 | |
|---|
| 4494 | BKNI_LeaveCriticalSection(); |
|---|
| 4495 | |
|---|
| 4496 | return errCode; |
|---|
| 4497 | } |
|---|
| 4498 | |
|---|
| 4499 | BERR_Code BSCD_Channel_P_SetFreq( |
|---|
| 4500 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 4501 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 4502 | ) |
|---|
| 4503 | { |
|---|
| 4504 | |
|---|
| 4505 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 4506 | |
|---|
| 4507 | BDBG_ENTER(BSCD_Channel_P_SetFreq); |
|---|
| 4508 | /* set up soure clock */ |
|---|
| 4509 | |
|---|
| 4510 | |
|---|
| 4511 | /* Set F, Clock Rate Conversion Factor */ |
|---|
| 4512 | if (inp_sSettings->ucFFactor == 0) { |
|---|
| 4513 | in_channelHandle->currentChannelSettings.ucFFactor = BSCD_DEFAULT_F; |
|---|
| 4514 | } |
|---|
| 4515 | else if ((inp_sSettings->ucFFactor >= 1 ) && (inp_sSettings->ucFFactor <= 13)){ |
|---|
| 4516 | in_channelHandle->currentChannelSettings.ucFFactor = inp_sSettings->ucFFactor; |
|---|
| 4517 | } |
|---|
| 4518 | else { |
|---|
| 4519 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4520 | } |
|---|
| 4521 | BDBG_MSG(("ucFFactor = %d", in_channelHandle->currentChannelSettings.ucFFactor)); |
|---|
| 4522 | /* Set D, Baud Rate Adjustor */ |
|---|
| 4523 | if (inp_sSettings->ucDFactor == 0) { |
|---|
| 4524 | in_channelHandle->currentChannelSettings.ucDFactor = BSCD_DEFAULT_D; |
|---|
| 4525 | } |
|---|
| 4526 | if ((inp_sSettings->ucDFactor >= 1 ) && (inp_sSettings->ucDFactor <= 9)) { |
|---|
| 4527 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4528 | (BSCD_P_GetISOBaudRateAdjustor(inp_sSettings->ucDFactor) == ((unsigned char ) -1) ) ); |
|---|
| 4529 | in_channelHandle->currentChannelSettings.ucDFactor = inp_sSettings->ucDFactor; |
|---|
| 4530 | } |
|---|
| 4531 | else { |
|---|
| 4532 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4533 | } |
|---|
| 4534 | BDBG_MSG(("ucDFactor = %d", in_channelHandle->currentChannelSettings.ucDFactor)); |
|---|
| 4535 | |
|---|
| 4536 | /* Set ETU Clock Divider */ |
|---|
| 4537 | if (inp_sSettings->ucEtuClkDiv == 0 ) { |
|---|
| 4538 | in_channelHandle->currentChannelSettings.ucEtuClkDiv = |
|---|
| 4539 | BSCD_P_GetETUClkDiv(in_channelHandle, in_channelHandle->currentChannelSettings.ucDFactor, |
|---|
| 4540 | in_channelHandle->currentChannelSettings.ucFFactor); |
|---|
| 4541 | } |
|---|
| 4542 | else if ( (inp_sSettings->ucEtuClkDiv == 1) || (inp_sSettings->ucEtuClkDiv == 2) || |
|---|
| 4543 | (inp_sSettings->ucEtuClkDiv == 3) || (inp_sSettings->ucEtuClkDiv == 4) || |
|---|
| 4544 | (inp_sSettings->ucEtuClkDiv == 5) || (inp_sSettings->ucEtuClkDiv == 6) || |
|---|
| 4545 | (inp_sSettings->ucEtuClkDiv == 7) || (inp_sSettings->ucEtuClkDiv == 8) ) { |
|---|
| 4546 | |
|---|
| 4547 | in_channelHandle->currentChannelSettings.ucEtuClkDiv = inp_sSettings->ucEtuClkDiv; |
|---|
| 4548 | } |
|---|
| 4549 | else { |
|---|
| 4550 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4551 | } |
|---|
| 4552 | BDBG_MSG(("ucEtuClkDiv = %d", in_channelHandle->currentChannelSettings.ucEtuClkDiv)); |
|---|
| 4553 | /* Set SC Clock Divider */ |
|---|
| 4554 | if (inp_sSettings->ucScClkDiv == 0 ) { |
|---|
| 4555 | in_channelHandle->currentChannelSettings.ucScClkDiv = |
|---|
| 4556 | BSCD_P_GetClkDiv(in_channelHandle, in_channelHandle->currentChannelSettings.ucDFactor, |
|---|
| 4557 | in_channelHandle->currentChannelSettings.ucFFactor) ; |
|---|
| 4558 | } |
|---|
| 4559 | else if ( (inp_sSettings->ucScClkDiv == 1) || (inp_sSettings->ucScClkDiv == 2) || |
|---|
| 4560 | (inp_sSettings->ucScClkDiv == 3) || (inp_sSettings->ucScClkDiv == 4) || |
|---|
| 4561 | (inp_sSettings->ucScClkDiv == 5) || (inp_sSettings->ucScClkDiv == 8) || |
|---|
| 4562 | (inp_sSettings->ucScClkDiv == 10) || (inp_sSettings->ucScClkDiv == 16) ) { |
|---|
| 4563 | |
|---|
| 4564 | in_channelHandle->currentChannelSettings.ucScClkDiv = inp_sSettings->ucScClkDiv; |
|---|
| 4565 | } |
|---|
| 4566 | else { |
|---|
| 4567 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4568 | } |
|---|
| 4569 | BDBG_MSG(("ucScClkDiv = %d", in_channelHandle->currentChannelSettings.ucScClkDiv)); |
|---|
| 4570 | |
|---|
| 4571 | /* Set external Clock Divisor. For TDA only 1, 2,4,8 are valid value. */ |
|---|
| 4572 | if (inp_sSettings->ucExternalClockDivisor == 0 ) { |
|---|
| 4573 | in_channelHandle->currentChannelSettings.ucExternalClockDivisor = BSCD_DEFAULT_EXTERNAL_CLOCK_DIVISOR; |
|---|
| 4574 | } |
|---|
| 4575 | else { |
|---|
| 4576 | in_channelHandle->currentChannelSettings.ucExternalClockDivisor = inp_sSettings->ucExternalClockDivisor; |
|---|
| 4577 | } |
|---|
| 4578 | BDBG_MSG(("ucExternalClockDivisor = %d", in_channelHandle->currentChannelSettings.ucExternalClockDivisor)); |
|---|
| 4579 | |
|---|
| 4580 | /* Set Prescale */ |
|---|
| 4581 | if (inp_sSettings->unPrescale == 0 ) { |
|---|
| 4582 | in_channelHandle->currentChannelSettings.unPrescale = |
|---|
| 4583 | BSCD_P_GetPrescale(in_channelHandle, in_channelHandle->currentChannelSettings.ucDFactor, |
|---|
| 4584 | in_channelHandle->currentChannelSettings.ucFFactor) * |
|---|
| 4585 | in_channelHandle->currentChannelSettings.ucExternalClockDivisor + |
|---|
| 4586 | (in_channelHandle->currentChannelSettings.ucExternalClockDivisor - 1); |
|---|
| 4587 | } |
|---|
| 4588 | else if ( (inp_sSettings->unPrescale <= BSCD_MAX_PRESCALE)) { |
|---|
| 4589 | in_channelHandle->currentChannelSettings.unPrescale = inp_sSettings->unPrescale * |
|---|
| 4590 | in_channelHandle->currentChannelSettings.ucExternalClockDivisor + |
|---|
| 4591 | (in_channelHandle->currentChannelSettings.ucExternalClockDivisor - 1); |
|---|
| 4592 | } |
|---|
| 4593 | else { |
|---|
| 4594 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4595 | } |
|---|
| 4596 | BDBG_MSG(("unPrescale = %d", in_channelHandle->currentChannelSettings.unPrescale)); |
|---|
| 4597 | /* Set baud divisor */ |
|---|
| 4598 | if (inp_sSettings->ucBaudDiv == 0 ) { |
|---|
| 4599 | |
|---|
| 4600 | in_channelHandle->currentChannelSettings.ucBaudDiv = BSCD_P_GetBaudDiv(in_channelHandle, in_channelHandle->currentChannelSettings.ucDFactor, |
|---|
| 4601 | in_channelHandle->currentChannelSettings.ucFFactor); |
|---|
| 4602 | |
|---|
| 4603 | } |
|---|
| 4604 | else if ( (inp_sSettings->ucBaudDiv == 31) || (inp_sSettings->ucBaudDiv == 32) ||(inp_sSettings->ucBaudDiv == 25) ) { |
|---|
| 4605 | |
|---|
| 4606 | in_channelHandle->currentChannelSettings.ucBaudDiv = inp_sSettings->ucBaudDiv; |
|---|
| 4607 | } |
|---|
| 4608 | else { |
|---|
| 4609 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4610 | } |
|---|
| 4611 | BDBG_MSG(("ucBaudDiv = %d", in_channelHandle->currentChannelSettings.ucBaudDiv)); |
|---|
| 4612 | |
|---|
| 4613 | /* Set ICC CLK Freq */ |
|---|
| 4614 | in_channelHandle->currentChannelSettings.currentICCClkFreq = |
|---|
| 4615 | in_channelHandle->moduleHandle->currentSettings.moduleClkFreq.ulClkFreq / |
|---|
| 4616 | in_channelHandle->currentChannelSettings.ucScClkDiv / |
|---|
| 4617 | in_channelHandle->currentChannelSettings.ucEtuClkDiv/ |
|---|
| 4618 | in_channelHandle->currentChannelSettings.ucExternalClockDivisor; |
|---|
| 4619 | BDBG_MSG(("currentICCClkFreq = %d", in_channelHandle->currentChannelSettings.currentICCClkFreq)); |
|---|
| 4620 | |
|---|
| 4621 | in_channelHandle->currentChannelSettings.currentBaudRate = |
|---|
| 4622 | in_channelHandle->moduleHandle->currentSettings.moduleClkFreq.ulClkFreq / |
|---|
| 4623 | in_channelHandle->currentChannelSettings.ucEtuClkDiv/ |
|---|
| 4624 | (in_channelHandle->currentChannelSettings.unPrescale+1)/ |
|---|
| 4625 | in_channelHandle->currentChannelSettings.ucBaudDiv; |
|---|
| 4626 | BDBG_MSG(("currentBaudRate = %d", in_channelHandle->currentChannelSettings.currentBaudRate)); |
|---|
| 4627 | |
|---|
| 4628 | if (in_channelHandle->currentChannelSettings.scStandard != BSCD_Standard_eIrdeto) { |
|---|
| 4629 | BDBG_MSG(("ISO currentBaudRate = %ld", in_channelHandle->currentChannelSettings.currentICCClkFreq * |
|---|
| 4630 | BSCD_P_GetISOBaudRateAdjustor(in_channelHandle->currentChannelSettings.ucDFactor) / |
|---|
| 4631 | BSCD_P_GetISOClockRateConversionFactor(in_channelHandle->currentChannelSettings.ucFFactor) )); |
|---|
| 4632 | |
|---|
| 4633 | BDBG_MSG(("ISOBaudRateAdjustor = %d", |
|---|
| 4634 | BSCD_P_GetISOBaudRateAdjustor(in_channelHandle->currentChannelSettings.ucDFactor ) )); |
|---|
| 4635 | |
|---|
| 4636 | BDBG_MSG(("ISOClockRateConversionFactor = %d", |
|---|
| 4637 | BSCD_P_GetISOClockRateConversionFactor(in_channelHandle->currentChannelSettings.ucFFactor) )); |
|---|
| 4638 | |
|---|
| 4639 | |
|---|
| 4640 | /* If the final ISO baudrate is not equal to the final BRCM baudrate, there is a potential mismatch */ |
|---|
| 4641 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4642 | (in_channelHandle->currentChannelSettings.currentBaudRate != |
|---|
| 4643 | (in_channelHandle->currentChannelSettings.currentICCClkFreq * |
|---|
| 4644 | BSCD_P_GetISOBaudRateAdjustor(in_channelHandle->currentChannelSettings.ucDFactor) / |
|---|
| 4645 | BSCD_P_GetISOClockRateConversionFactor(in_channelHandle->currentChannelSettings.ucFFactor)) )); |
|---|
| 4646 | |
|---|
| 4647 | } |
|---|
| 4648 | else { |
|---|
| 4649 | /* For T=14 Irdeto */ |
|---|
| 4650 | BDBG_MSG(("ISO currentBaudRate = %d", in_channelHandle->currentChannelSettings.currentICCClkFreq / |
|---|
| 4651 | BSCD_T14_IRDETO_CONSTANT_CLOCK_RATE_CONV_FACTOR) ); |
|---|
| 4652 | |
|---|
| 4653 | /* If the final ISO baudrate is not equal to the final BRCM baudrate, there is a potential mismatch */ |
|---|
| 4654 | #ifndef A582_HAWK /* Temporary(?) workaround to get T=14 card to work */ |
|---|
| 4655 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4656 | (in_channelHandle->currentChannelSettings.currentBaudRate != |
|---|
| 4657 | (in_channelHandle->currentChannelSettings.currentICCClkFreq / |
|---|
| 4658 | BSCD_T14_IRDETO_CONSTANT_CLOCK_RATE_CONV_FACTOR) )); |
|---|
| 4659 | #endif |
|---|
| 4660 | } |
|---|
| 4661 | |
|---|
| 4662 | BSCD_P_DONE_LABEL: |
|---|
| 4663 | |
|---|
| 4664 | BDBG_LEAVE(BSCD_Channel_P_SetFreq); |
|---|
| 4665 | return( errCode ); |
|---|
| 4666 | } |
|---|
| 4667 | |
|---|
| 4668 | |
|---|
| 4669 | BERR_Code BSCD_Channel_P_SetWaitTime( |
|---|
| 4670 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 4671 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 4672 | ) |
|---|
| 4673 | { |
|---|
| 4674 | |
|---|
| 4675 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 4676 | |
|---|
| 4677 | BDBG_ENTER(BSCD_Channel_P_SetWaitTime); |
|---|
| 4678 | |
|---|
| 4679 | /* Set work waiting time */ |
|---|
| 4680 | if (inp_sSettings->workWaitTime.ulValue == 0) { |
|---|
| 4681 | |
|---|
| 4682 | BSCD_P_CHECK_ERR_CODE_FUNC(errCode, |
|---|
| 4683 | BSCD_P_AdjustWWT(in_channelHandle, in_channelHandle->currentChannelSettings.ucFFactor, |
|---|
| 4684 | in_channelHandle->currentChannelSettings.ucDFactor, |
|---|
| 4685 | BSCD_ISO_DEFAULT_WORK_WAIT_TIME_INTEGER)); |
|---|
| 4686 | |
|---|
| 4687 | } |
|---|
| 4688 | else { |
|---|
| 4689 | switch (inp_sSettings->workWaitTime.unit) { |
|---|
| 4690 | case BSCD_TimerUnit_eETU: |
|---|
| 4691 | in_channelHandle->currentChannelSettings.workWaitTime.ulValue = inp_sSettings->workWaitTime.ulValue ; |
|---|
| 4692 | break; |
|---|
| 4693 | case BSCD_TimerUnit_eCLK: |
|---|
| 4694 | in_channelHandle->currentChannelSettings.workWaitTime.ulValue = |
|---|
| 4695 | inp_sSettings->workWaitTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/ |
|---|
| 4696 | in_channelHandle->currentChannelSettings.currentICCClkFreq; |
|---|
| 4697 | break; |
|---|
| 4698 | case BSCD_TimerUnit_eMilliSec: |
|---|
| 4699 | in_channelHandle->currentChannelSettings.workWaitTime.ulValue = |
|---|
| 4700 | inp_sSettings->workWaitTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/1000; |
|---|
| 4701 | in_channelHandle->currentChannelSettings.workWaitTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 4702 | |
|---|
| 4703 | break; |
|---|
| 4704 | default: |
|---|
| 4705 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4706 | break; |
|---|
| 4707 | } |
|---|
| 4708 | in_channelHandle->currentChannelSettings.workWaitTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 4709 | } |
|---|
| 4710 | BDBG_MSG(("workWaitTime.ulValue in ETU = %d", in_channelHandle->currentChannelSettings.workWaitTime.ulValue)); |
|---|
| 4711 | BDBG_MSG(("workWaitTime.unit = %d", in_channelHandle->currentChannelSettings.workWaitTime.unit)); |
|---|
| 4712 | |
|---|
| 4713 | /* Set block Wait time */ |
|---|
| 4714 | if (inp_sSettings->blockWaitTime.ulValue == 0) { |
|---|
| 4715 | in_channelHandle->currentChannelSettings.blockWaitTime.ulValue = BSCD_DEFAULT_BLOCK_WAITING_TIME ; |
|---|
| 4716 | in_channelHandle->currentChannelSettings.blockWaitTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 4717 | } |
|---|
| 4718 | else { |
|---|
| 4719 | switch (inp_sSettings->blockWaitTime.unit) { |
|---|
| 4720 | case BSCD_TimerUnit_eETU: |
|---|
| 4721 | in_channelHandle->currentChannelSettings.blockWaitTime.ulValue = inp_sSettings->blockWaitTime.ulValue ; |
|---|
| 4722 | break; |
|---|
| 4723 | case BSCD_TimerUnit_eCLK: |
|---|
| 4724 | in_channelHandle->currentChannelSettings.blockWaitTime.ulValue = |
|---|
| 4725 | inp_sSettings->blockWaitTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/ |
|---|
| 4726 | in_channelHandle->currentChannelSettings.currentICCClkFreq; |
|---|
| 4727 | break; |
|---|
| 4728 | case BSCD_TimerUnit_eMilliSec: |
|---|
| 4729 | in_channelHandle->currentChannelSettings.blockWaitTime.ulValue = |
|---|
| 4730 | inp_sSettings->blockWaitTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/ |
|---|
| 4731 | 1000; |
|---|
| 4732 | break; |
|---|
| 4733 | default: |
|---|
| 4734 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4735 | break; |
|---|
| 4736 | } |
|---|
| 4737 | in_channelHandle->currentChannelSettings.blockWaitTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 4738 | } |
|---|
| 4739 | BDBG_MSG(("blockWaitTime.ulValue in ETU = %d", in_channelHandle->currentChannelSettings.blockWaitTime.ulValue)); |
|---|
| 4740 | BDBG_MSG(("blockWaitTime.unit = %d", in_channelHandle->currentChannelSettings.blockWaitTime.unit)); |
|---|
| 4741 | |
|---|
| 4742 | /* Set Character Waiting Time Integer */ |
|---|
| 4743 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4744 | (inp_sSettings->ulCharacterWaitTimeInteger > BSCD_MAX_CHARACTER_WAIT_TIME_INTEGER)); |
|---|
| 4745 | in_channelHandle->currentChannelSettings.ulCharacterWaitTimeInteger = inp_sSettings->ulCharacterWaitTimeInteger ; |
|---|
| 4746 | BDBG_MSG(("ulCharacterWaitTimeInteger = %d", in_channelHandle->currentChannelSettings.ulCharacterWaitTimeInteger)); |
|---|
| 4747 | |
|---|
| 4748 | |
|---|
| 4749 | |
|---|
| 4750 | BSCD_P_DONE_LABEL: |
|---|
| 4751 | |
|---|
| 4752 | BDBG_LEAVE(BSCD_Channel_P_SetWaitTime); |
|---|
| 4753 | return( errCode ); |
|---|
| 4754 | } |
|---|
| 4755 | |
|---|
| 4756 | |
|---|
| 4757 | BERR_Code BSCD_Channel_P_SetGuardTime( |
|---|
| 4758 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 4759 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 4760 | ) |
|---|
| 4761 | { |
|---|
| 4762 | |
|---|
| 4763 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 4764 | |
|---|
| 4765 | BDBG_ENTER(BSCD_Channel_P_SetGuardTime); |
|---|
| 4766 | |
|---|
| 4767 | /* Set Extra Guard Time */ |
|---|
| 4768 | switch (inp_sSettings->extraGuardTime.unit) { |
|---|
| 4769 | case BSCD_TimerUnit_eETU: |
|---|
| 4770 | in_channelHandle->currentChannelSettings.extraGuardTime.ulValue = inp_sSettings->extraGuardTime.ulValue ; |
|---|
| 4771 | break; |
|---|
| 4772 | case BSCD_TimerUnit_eCLK: |
|---|
| 4773 | in_channelHandle->currentChannelSettings.extraGuardTime.ulValue = |
|---|
| 4774 | inp_sSettings->extraGuardTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/ |
|---|
| 4775 | in_channelHandle->currentChannelSettings.currentICCClkFreq; |
|---|
| 4776 | break; |
|---|
| 4777 | case BSCD_TimerUnit_eMilliSec: |
|---|
| 4778 | in_channelHandle->currentChannelSettings.extraGuardTime.ulValue = |
|---|
| 4779 | inp_sSettings->extraGuardTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/ |
|---|
| 4780 | 1000; |
|---|
| 4781 | break; |
|---|
| 4782 | default: |
|---|
| 4783 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4784 | break; |
|---|
| 4785 | } |
|---|
| 4786 | in_channelHandle->currentChannelSettings.extraGuardTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 4787 | |
|---|
| 4788 | BDBG_MSG(("extraGuardTime.ulValue in ETU = %d", in_channelHandle->currentChannelSettings.extraGuardTime.ulValue)); |
|---|
| 4789 | BDBG_MSG(("extraGuardTime.unit = %d", in_channelHandle->currentChannelSettings.extraGuardTime.unit)); |
|---|
| 4790 | |
|---|
| 4791 | /* Set block Guard time */ |
|---|
| 4792 | if (inp_sSettings->blockGuardTime.ulValue == 0) { |
|---|
| 4793 | in_channelHandle->currentChannelSettings.blockGuardTime.ulValue = BSCD_DEFAULT_BLOCK_GUARD_TIME ; |
|---|
| 4794 | in_channelHandle->currentChannelSettings.blockGuardTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 4795 | } |
|---|
| 4796 | else { |
|---|
| 4797 | switch (inp_sSettings->blockGuardTime.unit) { |
|---|
| 4798 | case BSCD_TimerUnit_eETU: |
|---|
| 4799 | in_channelHandle->currentChannelSettings.blockGuardTime.ulValue = inp_sSettings->blockGuardTime.ulValue ; |
|---|
| 4800 | break; |
|---|
| 4801 | case BSCD_TimerUnit_eCLK: |
|---|
| 4802 | in_channelHandle->currentChannelSettings.blockGuardTime.ulValue = |
|---|
| 4803 | inp_sSettings->blockGuardTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/ |
|---|
| 4804 | in_channelHandle->currentChannelSettings.currentICCClkFreq; |
|---|
| 4805 | break; |
|---|
| 4806 | case BSCD_TimerUnit_eMilliSec: |
|---|
| 4807 | in_channelHandle->currentChannelSettings.blockGuardTime.ulValue = |
|---|
| 4808 | inp_sSettings->blockGuardTime.ulValue*in_channelHandle->currentChannelSettings.currentBaudRate/ |
|---|
| 4809 | 1000; |
|---|
| 4810 | break; |
|---|
| 4811 | default: |
|---|
| 4812 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4813 | break; |
|---|
| 4814 | } |
|---|
| 4815 | in_channelHandle->currentChannelSettings.blockGuardTime.unit = BSCD_TimerUnit_eETU; |
|---|
| 4816 | } |
|---|
| 4817 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4818 | ((in_channelHandle->currentChannelSettings.blockGuardTime.ulValue > BSCD_MAX_BLOCK_GUARD_TIME) || |
|---|
| 4819 | (in_channelHandle->currentChannelSettings.blockGuardTime.ulValue < BSCD_MIN_BLOCK_GUARD_TIME)) ); |
|---|
| 4820 | BDBG_MSG(("blockGuardTime.ulValue in ETU = %d", in_channelHandle->currentChannelSettings.blockGuardTime.ulValue)); |
|---|
| 4821 | BDBG_MSG(("blockGuardTime.unit = %d", in_channelHandle->currentChannelSettings.blockGuardTime.unit)); |
|---|
| 4822 | |
|---|
| 4823 | |
|---|
| 4824 | BSCD_P_DONE_LABEL: |
|---|
| 4825 | |
|---|
| 4826 | BDBG_LEAVE(BSCD_Channel_P_SetGuardTime); |
|---|
| 4827 | return( errCode ); |
|---|
| 4828 | } |
|---|
| 4829 | |
|---|
| 4830 | BERR_Code BSCD_Channel_P_SetTransactionTimeout( |
|---|
| 4831 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 4832 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 4833 | ) |
|---|
| 4834 | { |
|---|
| 4835 | |
|---|
| 4836 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 4837 | |
|---|
| 4838 | BDBG_ENTER(BSCD_Channel_P_SetTransactionTimeout); |
|---|
| 4839 | |
|---|
| 4840 | if (inp_sSettings->timeOut.ulValue == 0) { |
|---|
| 4841 | in_channelHandle->currentChannelSettings.timeOut.ulValue = BSCD_DEFAULT_TIME_OUT ; |
|---|
| 4842 | in_channelHandle->currentChannelSettings.timeOut.unit = BSCD_TimerUnit_eMilliSec; |
|---|
| 4843 | } |
|---|
| 4844 | else { |
|---|
| 4845 | switch (inp_sSettings->timeOut.unit) { |
|---|
| 4846 | case BSCD_TimerUnit_eETU: |
|---|
| 4847 | in_channelHandle->currentChannelSettings.timeOut.ulValue = inp_sSettings->timeOut.ulValue * 1000000 / |
|---|
| 4848 | in_channelHandle->currentChannelSettings.currentBaudRate; |
|---|
| 4849 | break; |
|---|
| 4850 | case BSCD_TimerUnit_eCLK: |
|---|
| 4851 | in_channelHandle->currentChannelSettings.timeOut.ulValue = |
|---|
| 4852 | inp_sSettings->timeOut.ulValue * 1000000 / |
|---|
| 4853 | in_channelHandle->currentChannelSettings.currentICCClkFreq ; |
|---|
| 4854 | break; |
|---|
| 4855 | case BSCD_TimerUnit_eMilliSec: |
|---|
| 4856 | in_channelHandle->currentChannelSettings.timeOut.ulValue = inp_sSettings->timeOut.ulValue ; |
|---|
| 4857 | break; |
|---|
| 4858 | default: |
|---|
| 4859 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, true); |
|---|
| 4860 | break; |
|---|
| 4861 | } |
|---|
| 4862 | in_channelHandle->currentChannelSettings.timeOut.unit = BSCD_TimerUnit_eMilliSec; |
|---|
| 4863 | } |
|---|
| 4864 | BDBG_MSG(("timeOut.ulValue in milliseconds = %d", in_channelHandle->currentChannelSettings.timeOut.ulValue)); |
|---|
| 4865 | BDBG_MSG(("timeOut.unit = %d", in_channelHandle->currentChannelSettings.timeOut.unit)); |
|---|
| 4866 | |
|---|
| 4867 | |
|---|
| 4868 | BSCD_P_DONE_LABEL: |
|---|
| 4869 | |
|---|
| 4870 | BDBG_LEAVE(BSCD_Channel_P_SetTransactionTimeout); |
|---|
| 4871 | return( errCode ); |
|---|
| 4872 | } |
|---|
| 4873 | |
|---|
| 4874 | BERR_Code BSCD_Channel_P_SetEdcParity( |
|---|
| 4875 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 4876 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 4877 | ) |
|---|
| 4878 | { |
|---|
| 4879 | |
|---|
| 4880 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 4881 | |
|---|
| 4882 | BDBG_ENTER(BSCD_Channel_P_SetEdcParity); |
|---|
| 4883 | |
|---|
| 4884 | /* Set Number of transmit parity retries */ |
|---|
| 4885 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4886 | (inp_sSettings->ucTxRetries > BSCD_MAX_TX_PARITY_RETRIES)); |
|---|
| 4887 | in_channelHandle->currentChannelSettings.ucTxRetries = inp_sSettings->ucTxRetries ; |
|---|
| 4888 | BDBG_MSG(("ucTxRetries = %d", in_channelHandle->currentChannelSettings.ucTxRetries)); |
|---|
| 4889 | |
|---|
| 4890 | /* Set Number of receive parity retries */ |
|---|
| 4891 | BSCD_P_CHECK_ERR_CODE_CONDITION( errCode, BSCD_STATUS_FAILED, |
|---|
| 4892 | (inp_sSettings->ucRxRetries > BSCD_MAX_TX_PARITY_RETRIES)); |
|---|
| 4893 | in_channelHandle->currentChannelSettings.ucRxRetries = inp_sSettings->ucRxRetries ; |
|---|
| 4894 | BDBG_MSG(("ucRxRetries = %d", in_channelHandle->currentChannelSettings.ucRxRetries)); |
|---|
| 4895 | |
|---|
| 4896 | /* Set EDC encoding */ |
|---|
| 4897 | in_channelHandle->currentChannelSettings.edcSetting.bIsEnabled = inp_sSettings->edcSetting.bIsEnabled; |
|---|
| 4898 | in_channelHandle->currentChannelSettings.edcSetting.edcEncode = inp_sSettings->edcSetting.edcEncode; |
|---|
| 4899 | |
|---|
| 4900 | BDBG_MSG(("edcSetting.bIsEnabled = %d", in_channelHandle->currentChannelSettings.edcSetting.bIsEnabled )); |
|---|
| 4901 | BDBG_MSG(("edcSetting.edcEncode = %d", in_channelHandle->currentChannelSettings.edcSetting.edcEncode)); |
|---|
| 4902 | |
|---|
| 4903 | |
|---|
| 4904 | BSCD_P_DONE_LABEL: |
|---|
| 4905 | |
|---|
| 4906 | BDBG_LEAVE(BSCD_Channel_P_SetEdcParity); |
|---|
| 4907 | return( errCode ); |
|---|
| 4908 | } |
|---|
| 4909 | |
|---|
| 4910 | |
|---|
| 4911 | #ifdef BSCD_MEMDEBUG |
|---|
| 4912 | char BSCD_Channel_P_gDebugBuffer[BSCD_Channel_P_MAX_COUNT][BSCD_Channel_P_MAX_SIZE]; |
|---|
| 4913 | int BSCD_Channel_P_gCount = 0; |
|---|
| 4914 | int BSCD_Channel_P_gbLoop = 0; |
|---|
| 4915 | |
|---|
| 4916 | void BSCD_Channel_P_StoreInMemory( |
|---|
| 4917 | char *inp_format, |
|---|
| 4918 | ... |
|---|
| 4919 | ) |
|---|
| 4920 | { |
|---|
| 4921 | va_list arg_pointer; |
|---|
| 4922 | |
|---|
| 4923 | va_start(arg_pointer, inp_format); |
|---|
| 4924 | vsprintf(BSCD_Channel_P_gDebugBuffer[BSCD_Channel_P_gCount], inp_format, arg_pointer); |
|---|
| 4925 | va_end(arg_pointer); |
|---|
| 4926 | if (++BSCD_Channel_P_gCount >= BSCD_Channel_P_MAX_COUNT) { |
|---|
| 4927 | BSCD_Channel_P_gCount = 0; |
|---|
| 4928 | BSCD_Channel_P_gbLoop = 1; |
|---|
| 4929 | } |
|---|
| 4930 | } |
|---|
| 4931 | |
|---|
| 4932 | void BSCD_Channel_P_PrintDebug( |
|---|
| 4933 | void |
|---|
| 4934 | ) |
|---|
| 4935 | { |
|---|
| 4936 | unsigned int i; |
|---|
| 4937 | if (BSCD_Channel_P_gbLoop == 0) { |
|---|
| 4938 | for (i=0; i< BSCD_Channel_P_gCount; i++) { |
|---|
| 4939 | DBGMSG(BSCD_Channel_P_gDebugBuffer[i]); |
|---|
| 4940 | } |
|---|
| 4941 | } |
|---|
| 4942 | else { |
|---|
| 4943 | for (i=BSCD_Channel_P_gCount; i< BSCD_Channel_P_MAX_COUNT; i++) { |
|---|
| 4944 | DBGMSG(BSCD_Channel_P_gDebugBuffer[i]); |
|---|
| 4945 | } |
|---|
| 4946 | for (i=0; i< BSCD_Channel_P_gCount; i++) { |
|---|
| 4947 | DBGMSG(BSCD_Channel_P_gDebugBuffer[i]); |
|---|
| 4948 | } |
|---|
| 4949 | } |
|---|
| 4950 | } |
|---|
| 4951 | #endif |
|---|
| 4952 | |
|---|
| 4953 | |
|---|