Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_sc.h@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /**************************************************************************//** |
sahilmgandhi | 18:6a4db94011d3 | 2 | * @file sc.h |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @version V3.00 |
sahilmgandhi | 18:6a4db94011d3 | 4 | * $Revision: 13 $ |
sahilmgandhi | 18:6a4db94011d3 | 5 | * $Date: 15/08/11 10:26a $ |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @brief M451 series Smartcard (SC) driver header file |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * @note |
sahilmgandhi | 18:6a4db94011d3 | 9 | * Copyright (C) 2013~2015 Nuvoton Technology Corp. All rights reserved. |
sahilmgandhi | 18:6a4db94011d3 | 10 | *****************************************************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 11 | #ifndef __SC_H__ |
sahilmgandhi | 18:6a4db94011d3 | 12 | #define __SC_H__ |
sahilmgandhi | 18:6a4db94011d3 | 13 | |
sahilmgandhi | 18:6a4db94011d3 | 14 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 15 | extern "C" |
sahilmgandhi | 18:6a4db94011d3 | 16 | { |
sahilmgandhi | 18:6a4db94011d3 | 17 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | |
sahilmgandhi | 18:6a4db94011d3 | 20 | /** @addtogroup Standard_Driver Standard Driver |
sahilmgandhi | 18:6a4db94011d3 | 21 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 22 | */ |
sahilmgandhi | 18:6a4db94011d3 | 23 | |
sahilmgandhi | 18:6a4db94011d3 | 24 | /** @addtogroup SC_Driver SC Driver |
sahilmgandhi | 18:6a4db94011d3 | 25 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 26 | */ |
sahilmgandhi | 18:6a4db94011d3 | 27 | |
sahilmgandhi | 18:6a4db94011d3 | 28 | /** @addtogroup SC_EXPORTED_CONSTANTS SC Exported Constants |
sahilmgandhi | 18:6a4db94011d3 | 29 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 30 | */ |
sahilmgandhi | 18:6a4db94011d3 | 31 | #define SC_INTERFACE_NUM 1 /*!< Smartcard interface numbers */ /* M451 series has only one SC interface */ |
sahilmgandhi | 18:6a4db94011d3 | 32 | #define SC_PIN_STATE_HIGH 1 /*!< Smartcard pin status high */ |
sahilmgandhi | 18:6a4db94011d3 | 33 | #define SC_PIN_STATE_LOW 0 /*!< Smartcard pin status low */ |
sahilmgandhi | 18:6a4db94011d3 | 34 | #define SC_PIN_STATE_IGNORE 0xFFFFFFFF /*!< Ignore pin status */ |
sahilmgandhi | 18:6a4db94011d3 | 35 | #define SC_CLK_ON 1 /*!< Smartcard clock on */ |
sahilmgandhi | 18:6a4db94011d3 | 36 | #define SC_CLK_OFF 0 /*!< Smartcard clock off */ |
sahilmgandhi | 18:6a4db94011d3 | 37 | |
sahilmgandhi | 18:6a4db94011d3 | 38 | #define SC_TMR_MODE_0 (0ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 0, down count */ |
sahilmgandhi | 18:6a4db94011d3 | 39 | #define SC_TMR_MODE_1 (1ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 1, down count, start after detect start bit */ |
sahilmgandhi | 18:6a4db94011d3 | 40 | #define SC_TMR_MODE_2 (2ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 2, down count, start after receive start bit */ |
sahilmgandhi | 18:6a4db94011d3 | 41 | #define SC_TMR_MODE_3 (3ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 3, down count, use for activation, only timer 0 support this mode */ |
sahilmgandhi | 18:6a4db94011d3 | 42 | #define SC_TMR_MODE_4 (4ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 4, down count with reload after timeout */ |
sahilmgandhi | 18:6a4db94011d3 | 43 | #define SC_TMR_MODE_5 (5ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 5, down count, start after detect start bit, reload after timeout */ |
sahilmgandhi | 18:6a4db94011d3 | 44 | #define SC_TMR_MODE_6 (6ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 6, down count, start after receive start bit, reload after timeout */ |
sahilmgandhi | 18:6a4db94011d3 | 45 | #define SC_TMR_MODE_7 (7ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 7, down count, start and reload after detect start bit */ |
sahilmgandhi | 18:6a4db94011d3 | 46 | #define SC_TMR_MODE_8 (8ul << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 8, up count */ |
sahilmgandhi | 18:6a4db94011d3 | 47 | #define SC_TMR_MODE_F (0xF << SC_TMRCTL0_OPMODE_Pos) /*!<Timer Operation Mode 15, down count, reload after detect start bit */ |
sahilmgandhi | 18:6a4db94011d3 | 48 | |
sahilmgandhi | 18:6a4db94011d3 | 49 | |
sahilmgandhi | 18:6a4db94011d3 | 50 | /*@}*/ /* end of group SC_EXPORTED_CONSTANTS */ |
sahilmgandhi | 18:6a4db94011d3 | 51 | |
sahilmgandhi | 18:6a4db94011d3 | 52 | |
sahilmgandhi | 18:6a4db94011d3 | 53 | /** @addtogroup SC_EXPORTED_FUNCTIONS SC Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 54 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 55 | */ |
sahilmgandhi | 18:6a4db94011d3 | 56 | |
sahilmgandhi | 18:6a4db94011d3 | 57 | /** |
sahilmgandhi | 18:6a4db94011d3 | 58 | * @brief Enable smartcard interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 59 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 60 | * @param[in] u32Mask Interrupt mask to be enabled. A combination of |
sahilmgandhi | 18:6a4db94011d3 | 61 | * - \ref SC_INTEN_ACERRIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 62 | * - \ref SC_INTEN_RXTOIF_Msk |
sahilmgandhi | 18:6a4db94011d3 | 63 | * - \ref SC_INTEN_INITIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 64 | * - \ref SC_INTEN_CDIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 65 | * - \ref SC_INTEN_BGTIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 66 | * - \ref SC_INTEN_TMR2IEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 67 | * - \ref SC_INTEN_TMR1IEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 68 | * - \ref SC_INTEN_TMR0IEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 69 | * - \ref SC_INTEN_TERRIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 70 | * - \ref SC_INTEN_TBEIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 71 | * - \ref SC_INTEN_RDAIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 72 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 73 | * @details The macro is used to enable Auto-convention error interrupt, Receiver buffer time-out interrupt, Initial end interrupt, |
sahilmgandhi | 18:6a4db94011d3 | 74 | * Card detect interrupt, Block guard time interrupt, Timer2 interrupt, Timer1 interrupt, Timer0 interrupt, |
sahilmgandhi | 18:6a4db94011d3 | 75 | * Transfer error interrupt, Transmit buffer empty interrupt or Receive data reach trigger level interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 76 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 77 | */ |
sahilmgandhi | 18:6a4db94011d3 | 78 | #define SC_ENABLE_INT(sc, u32Mask) ((sc)->INTEN |= (u32Mask)) |
sahilmgandhi | 18:6a4db94011d3 | 79 | |
sahilmgandhi | 18:6a4db94011d3 | 80 | /** |
sahilmgandhi | 18:6a4db94011d3 | 81 | * @brief Disable smartcard interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 82 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 83 | * @param[in] u32Mask Interrupt mask to be disabled. A combination of |
sahilmgandhi | 18:6a4db94011d3 | 84 | * - \ref SC_INTEN_ACERRIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 85 | * - \ref SC_INTEN_RXTOIF_Msk |
sahilmgandhi | 18:6a4db94011d3 | 86 | * - \ref SC_INTEN_INITIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 87 | * - \ref SC_INTEN_CDIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 88 | * - \ref SC_INTEN_BGTIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 89 | * - \ref SC_INTEN_TMR2IEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 90 | * - \ref SC_INTEN_TMR1IEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 91 | * - \ref SC_INTEN_TMR0IEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 92 | * - \ref SC_INTEN_TERRIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 93 | * - \ref SC_INTEN_TBEIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 94 | * - \ref SC_INTEN_RDAIEN_Msk |
sahilmgandhi | 18:6a4db94011d3 | 95 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 96 | * @details The macro is used to disable Auto-convention error interrupt, Receiver buffer time-out interrupt, Initial end interrupt, |
sahilmgandhi | 18:6a4db94011d3 | 97 | * Card detect interrupt, Block guard time interrupt, Timer2 interrupt, Timer1 interrupt, Timer0 interrupt, |
sahilmgandhi | 18:6a4db94011d3 | 98 | * Transfer error interrupt, Transmit buffer empty interrupt or Receive data reach trigger level interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 99 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 100 | */ |
sahilmgandhi | 18:6a4db94011d3 | 101 | #define SC_DISABLE_INT(sc, u32Mask) ((sc)->INTEN &= ~(u32Mask)) |
sahilmgandhi | 18:6a4db94011d3 | 102 | |
sahilmgandhi | 18:6a4db94011d3 | 103 | /** |
sahilmgandhi | 18:6a4db94011d3 | 104 | * @brief This macro set VCC pin state of smartcard interface. |
sahilmgandhi | 18:6a4db94011d3 | 105 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 106 | * @param[in] u32State Pin state of VCC pin, valid parameters are: |
sahilmgandhi | 18:6a4db94011d3 | 107 | * \ref SC_PIN_STATE_HIGH :Smartcard pin status high. |
sahilmgandhi | 18:6a4db94011d3 | 108 | * \ref SC_PIN_STATE_LOW :Smartcard pin status low. |
sahilmgandhi | 18:6a4db94011d3 | 109 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 110 | * @details User can set PWREN (SC_PINCTL[0]) and PWRINV (SC_PINCTL[11])to decide SC_PWR pin is in high or low level. |
sahilmgandhi | 18:6a4db94011d3 | 111 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 112 | */ |
sahilmgandhi | 18:6a4db94011d3 | 113 | #define SC_SET_VCC_PIN(sc, u32State) \ |
sahilmgandhi | 18:6a4db94011d3 | 114 | do {\ |
sahilmgandhi | 18:6a4db94011d3 | 115 | while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\ |
sahilmgandhi | 18:6a4db94011d3 | 116 | if(u32State)\ |
sahilmgandhi | 18:6a4db94011d3 | 117 | (sc)->PINCTL |= SC_PINCTL_PWREN_Msk;\ |
sahilmgandhi | 18:6a4db94011d3 | 118 | else\ |
sahilmgandhi | 18:6a4db94011d3 | 119 | (sc)->PINCTL &= ~SC_PINCTL_PWREN_Msk;\ |
sahilmgandhi | 18:6a4db94011d3 | 120 | }while(0) |
sahilmgandhi | 18:6a4db94011d3 | 121 | |
sahilmgandhi | 18:6a4db94011d3 | 122 | |
sahilmgandhi | 18:6a4db94011d3 | 123 | /** |
sahilmgandhi | 18:6a4db94011d3 | 124 | * @brief Set CLK output status. |
sahilmgandhi | 18:6a4db94011d3 | 125 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 126 | * @param[in] u32OnOff Clock on or off for selected smartcard module, valid values are: |
sahilmgandhi | 18:6a4db94011d3 | 127 | * \ref SC_CLK_ON :Smartcard clock on. |
sahilmgandhi | 18:6a4db94011d3 | 128 | * \ref SC_CLK_OFF :Smartcard clock off. |
sahilmgandhi | 18:6a4db94011d3 | 129 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 130 | * @details User can set CLKKEEP (SC_PINCTL[6]) to decide SC_CLK pin always keeps free running or not. |
sahilmgandhi | 18:6a4db94011d3 | 131 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 132 | */ |
sahilmgandhi | 18:6a4db94011d3 | 133 | #define SC_SET_CLK_PIN(sc, u32OnOff)\ |
sahilmgandhi | 18:6a4db94011d3 | 134 | do {\ |
sahilmgandhi | 18:6a4db94011d3 | 135 | while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\ |
sahilmgandhi | 18:6a4db94011d3 | 136 | if(u32OnOff)\ |
sahilmgandhi | 18:6a4db94011d3 | 137 | (sc)->PINCTL |= SC_PINCTL_CLKKEEP_Msk;\ |
sahilmgandhi | 18:6a4db94011d3 | 138 | else\ |
sahilmgandhi | 18:6a4db94011d3 | 139 | (sc)->PINCTL &= ~(SC_PINCTL_CLKKEEP_Msk);\ |
sahilmgandhi | 18:6a4db94011d3 | 140 | }while(0) |
sahilmgandhi | 18:6a4db94011d3 | 141 | |
sahilmgandhi | 18:6a4db94011d3 | 142 | /** |
sahilmgandhi | 18:6a4db94011d3 | 143 | * @brief Set I/O pin state. |
sahilmgandhi | 18:6a4db94011d3 | 144 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 145 | * @param[in] u32State Pin state of I/O pin, valid parameters are: |
sahilmgandhi | 18:6a4db94011d3 | 146 | * \ref SC_PIN_STATE_HIGH :Smartcard pin status high. |
sahilmgandhi | 18:6a4db94011d3 | 147 | * \ref SC_PIN_STATE_LOW :Smartcard pin status low. |
sahilmgandhi | 18:6a4db94011d3 | 148 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 149 | * @details User can set SCDOUT(SC_PINCTL[9]) to decide SCDOUT pin to high or low. |
sahilmgandhi | 18:6a4db94011d3 | 150 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 151 | */ |
sahilmgandhi | 18:6a4db94011d3 | 152 | #define SC_SET_IO_PIN(sc, u32State)\ |
sahilmgandhi | 18:6a4db94011d3 | 153 | do {\ |
sahilmgandhi | 18:6a4db94011d3 | 154 | while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\ |
sahilmgandhi | 18:6a4db94011d3 | 155 | if(u32State)\ |
sahilmgandhi | 18:6a4db94011d3 | 156 | (sc)->PINCTL |= SC_PINCTL_SCDOUT_Msk;\ |
sahilmgandhi | 18:6a4db94011d3 | 157 | else\ |
sahilmgandhi | 18:6a4db94011d3 | 158 | (sc)->PINCTL &= ~SC_PINCTL_SCDOUT_Msk;\ |
sahilmgandhi | 18:6a4db94011d3 | 159 | }while(0) |
sahilmgandhi | 18:6a4db94011d3 | 160 | |
sahilmgandhi | 18:6a4db94011d3 | 161 | /** |
sahilmgandhi | 18:6a4db94011d3 | 162 | * @brief Set RST pin state. |
sahilmgandhi | 18:6a4db94011d3 | 163 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 164 | * @param[in] u32State Pin state of RST pin, valid parameters are: |
sahilmgandhi | 18:6a4db94011d3 | 165 | * \ref SC_PIN_STATE_HIGH :Smartcard pin status high. |
sahilmgandhi | 18:6a4db94011d3 | 166 | * \ref SC_PIN_STATE_LOW :Smartcard pin status low. |
sahilmgandhi | 18:6a4db94011d3 | 167 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 168 | * @details User can set SCRST(SC_PINCTL[1]) to decide SCRST pin to high or low. |
sahilmgandhi | 18:6a4db94011d3 | 169 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 170 | */ |
sahilmgandhi | 18:6a4db94011d3 | 171 | #define SC_SET_RST_PIN(sc, u32State)\ |
sahilmgandhi | 18:6a4db94011d3 | 172 | do {\ |
sahilmgandhi | 18:6a4db94011d3 | 173 | while((sc)->PINCTL & SC_PINCTL_SYNC_Msk);\ |
sahilmgandhi | 18:6a4db94011d3 | 174 | if(u32State)\ |
sahilmgandhi | 18:6a4db94011d3 | 175 | (sc)->PINCTL |= SC_PINCTL_SCRST_Msk;\ |
sahilmgandhi | 18:6a4db94011d3 | 176 | else\ |
sahilmgandhi | 18:6a4db94011d3 | 177 | (sc)->PINCTL &= ~SC_PINCTL_SCRST_Msk;\ |
sahilmgandhi | 18:6a4db94011d3 | 178 | }while(0) |
sahilmgandhi | 18:6a4db94011d3 | 179 | |
sahilmgandhi | 18:6a4db94011d3 | 180 | /** |
sahilmgandhi | 18:6a4db94011d3 | 181 | * @brief Read one byte from smartcard module receive FIFO. |
sahilmgandhi | 18:6a4db94011d3 | 182 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 183 | * @return One byte read from receive FIFO. |
sahilmgandhi | 18:6a4db94011d3 | 184 | * @details By reading DAT register, the SC will return an 8-bit received data. |
sahilmgandhi | 18:6a4db94011d3 | 185 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 186 | */ |
sahilmgandhi | 18:6a4db94011d3 | 187 | #define SC_READ(sc) ((char)((sc)->DAT)) |
sahilmgandhi | 18:6a4db94011d3 | 188 | |
sahilmgandhi | 18:6a4db94011d3 | 189 | /** |
sahilmgandhi | 18:6a4db94011d3 | 190 | * @brief Write one byte to smartcard module transmit FIFO. |
sahilmgandhi | 18:6a4db94011d3 | 191 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 192 | * @param[in] u8Data Data to write to transmit FIFO. |
sahilmgandhi | 18:6a4db94011d3 | 193 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 194 | * @details By writing data to DAT register, the SC will send out an 8-bit data. |
sahilmgandhi | 18:6a4db94011d3 | 195 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 196 | */ |
sahilmgandhi | 18:6a4db94011d3 | 197 | #define SC_WRITE(sc, u8Data) ((sc)->DAT = (u8Data)) |
sahilmgandhi | 18:6a4db94011d3 | 198 | |
sahilmgandhi | 18:6a4db94011d3 | 199 | /** |
sahilmgandhi | 18:6a4db94011d3 | 200 | * @brief This macro set smartcard stop bit length. |
sahilmgandhi | 18:6a4db94011d3 | 201 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 202 | * @param[in] u32Len Stop bit length, ether 1 or 2. |
sahilmgandhi | 18:6a4db94011d3 | 203 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 204 | * @details Stop bit length must be 1 for T = 1 protocol and 2 for T = 0 protocol. |
sahilmgandhi | 18:6a4db94011d3 | 205 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 206 | */ |
sahilmgandhi | 18:6a4db94011d3 | 207 | #define SC_SET_STOP_BIT_LEN(sc, u32Len) ((sc)->CTL = ((sc)->CTL & ~SC_CTL_NSB_Msk) | ((u32Len) == 1 ? SC_CTL_NSB_Msk : 0)) |
sahilmgandhi | 18:6a4db94011d3 | 208 | |
sahilmgandhi | 18:6a4db94011d3 | 209 | /** |
sahilmgandhi | 18:6a4db94011d3 | 210 | * @brief Enable/Disable Tx error retry, and set Tx error retry count. |
sahilmgandhi | 18:6a4db94011d3 | 211 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 212 | * @param[in] u32Count The number of times of Tx error retry count, between 0~8. 0 means disable Tx error retry. |
sahilmgandhi | 18:6a4db94011d3 | 213 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 214 | * @details This macro enable/disable transmitter retry function when parity error has occurred, and set error retry count. |
sahilmgandhi | 18:6a4db94011d3 | 215 | */ |
sahilmgandhi | 18:6a4db94011d3 | 216 | __STATIC_INLINE void SC_SetTxRetry(SC_T *sc, uint32_t u32Count) |
sahilmgandhi | 18:6a4db94011d3 | 217 | { |
sahilmgandhi | 18:6a4db94011d3 | 218 | while((sc)->CTL & SC_CTL_SYNC_Msk); |
sahilmgandhi | 18:6a4db94011d3 | 219 | if(u32Count == 0) { // disable Tx error retry |
sahilmgandhi | 18:6a4db94011d3 | 220 | (sc)->CTL &= ~(SC_CTL_TXRTY_Msk | SC_CTL_TXRTYEN_Msk); |
sahilmgandhi | 18:6a4db94011d3 | 221 | } else { |
sahilmgandhi | 18:6a4db94011d3 | 222 | (sc)->CTL = ((sc)->CTL & ~SC_CTL_TXRTY_Msk) | ((u32Count - 1) << SC_CTL_TXRTY_Pos) | SC_CTL_TXRTYEN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 223 | } |
sahilmgandhi | 18:6a4db94011d3 | 224 | } |
sahilmgandhi | 18:6a4db94011d3 | 225 | |
sahilmgandhi | 18:6a4db94011d3 | 226 | /** |
sahilmgandhi | 18:6a4db94011d3 | 227 | * @brief Enable/Disable Rx error retry, and set Rx error retry count. |
sahilmgandhi | 18:6a4db94011d3 | 228 | * @param[in] sc The pointer of smartcard module. |
sahilmgandhi | 18:6a4db94011d3 | 229 | * @param[in] u32Count The number of times of Rx error retry count, between 0~8. 0 means disable Rx error retry. |
sahilmgandhi | 18:6a4db94011d3 | 230 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 231 | * @details This macro enable/disable receiver retry function when parity error has occurred, and set error retry count. |
sahilmgandhi | 18:6a4db94011d3 | 232 | */ |
sahilmgandhi | 18:6a4db94011d3 | 233 | __STATIC_INLINE void SC_SetRxRetry(SC_T *sc, uint32_t u32Count) |
sahilmgandhi | 18:6a4db94011d3 | 234 | { |
sahilmgandhi | 18:6a4db94011d3 | 235 | while((sc)->CTL & SC_CTL_SYNC_Msk); |
sahilmgandhi | 18:6a4db94011d3 | 236 | if(u32Count == 0) { // disable Rx error retry |
sahilmgandhi | 18:6a4db94011d3 | 237 | (sc)->CTL &= ~(SC_CTL_RXRTY_Msk | SC_CTL_RXRTYEN_Msk); |
sahilmgandhi | 18:6a4db94011d3 | 238 | } else { |
sahilmgandhi | 18:6a4db94011d3 | 239 | (sc)->CTL = ((sc)->CTL & ~SC_CTL_RXRTY_Msk) | ((u32Count - 1) << SC_CTL_RXRTY_Pos) | SC_CTL_RXRTYEN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 240 | } |
sahilmgandhi | 18:6a4db94011d3 | 241 | } |
sahilmgandhi | 18:6a4db94011d3 | 242 | |
sahilmgandhi | 18:6a4db94011d3 | 243 | |
sahilmgandhi | 18:6a4db94011d3 | 244 | uint32_t SC_IsCardInserted(SC_T *sc); |
sahilmgandhi | 18:6a4db94011d3 | 245 | void SC_ClearFIFO(SC_T *sc); |
sahilmgandhi | 18:6a4db94011d3 | 246 | void SC_Close(SC_T *sc); |
sahilmgandhi | 18:6a4db94011d3 | 247 | void SC_Open(SC_T *sc, uint32_t u32CardDet, uint32_t u32PWR); |
sahilmgandhi | 18:6a4db94011d3 | 248 | void SC_ResetReader(SC_T *sc); |
sahilmgandhi | 18:6a4db94011d3 | 249 | void SC_SetBlockGuardTime(SC_T *sc, uint32_t u32BGT); |
sahilmgandhi | 18:6a4db94011d3 | 250 | void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT); |
sahilmgandhi | 18:6a4db94011d3 | 251 | void SC_StopAllTimer(SC_T *sc); |
sahilmgandhi | 18:6a4db94011d3 | 252 | void SC_StartTimer(SC_T *sc, uint32_t u32TimerNum, uint32_t u32Mode, uint32_t u32ETUCount); |
sahilmgandhi | 18:6a4db94011d3 | 253 | void SC_StopTimer(SC_T *sc, uint32_t u32TimerNum); |
sahilmgandhi | 18:6a4db94011d3 | 254 | |
sahilmgandhi | 18:6a4db94011d3 | 255 | |
sahilmgandhi | 18:6a4db94011d3 | 256 | /*@}*/ /* end of group SC_EXPORTED_FUNCTIONS */ |
sahilmgandhi | 18:6a4db94011d3 | 257 | |
sahilmgandhi | 18:6a4db94011d3 | 258 | /*@}*/ /* end of group SC_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 259 | |
sahilmgandhi | 18:6a4db94011d3 | 260 | /*@}*/ /* end of group Standard_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 261 | |
sahilmgandhi | 18:6a4db94011d3 | 262 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 263 | } |
sahilmgandhi | 18:6a4db94011d3 | 264 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 265 | |
sahilmgandhi | 18:6a4db94011d3 | 266 | #endif //__SC_H__ |
sahilmgandhi | 18:6a4db94011d3 | 267 | |
sahilmgandhi | 18:6a4db94011d3 | 268 | /*** (C) COPYRIGHT 2013~2015 Nuvoton Technology Corp. ***/ |
sahilmgandhi | 18:6a4db94011d3 | 269 |