mirror of https://gerrit.osmocom.org/simtrace2
Moved global Usart state into usart struct
This commit is contained in:
parent
f3211e6424
commit
ec9c09e9b9
|
@ -97,6 +97,7 @@
|
|||
|
||||
typedef struct Usart_info {
|
||||
Usart *base;
|
||||
uint8_t state;
|
||||
uint32_t id;
|
||||
} Usart_info;
|
||||
|
||||
|
|
|
@ -60,12 +60,10 @@
|
|||
/*-----------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*-----------------------------------------------------------------------------*/
|
||||
/** Variable for state of send and receive froom USART */
|
||||
static uint8_t StateUsartGlobal = USART_RCV;
|
||||
/** Pin reset master card */
|
||||
static Pin *st_pinIso7816RstMC;
|
||||
|
||||
struct Usart_info usart_sim = {.base = USART_SIM, .id = ID_USART_SIM};
|
||||
struct Usart_info usart_sim = {.base = USART_SIM, .id = ID_USART_SIM, .state = USART_RCV};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
|
@ -84,10 +82,10 @@ uint32_t ISO7816_GetChar( uint8_t *pCharToReceive, Usart_info *usart)
|
|||
Usart *us_base = usart->base;
|
||||
uint32_t us_id = usart->id;
|
||||
|
||||
if( StateUsartGlobal == USART_SEND ) {
|
||||
if( usart->state == USART_SEND ) {
|
||||
while((us_base->US_CSR & US_CSR_TXEMPTY) == 0) {}
|
||||
us_base->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
|
||||
StateUsartGlobal = USART_RCV;
|
||||
usart->state = USART_RCV;
|
||||
}
|
||||
|
||||
/* Wait USART ready for reception */
|
||||
|
@ -133,9 +131,9 @@ uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart )
|
|||
|
||||
TRACE_DEBUG("***Send char: 0x%X\n\r", CharToSend);
|
||||
|
||||
if( StateUsartGlobal == USART_RCV ) {
|
||||
if( usart->state == USART_RCV ) {
|
||||
us_base->US_CR = US_CR_RSTSTA | US_CR_RSTIT | US_CR_RSTNACK;
|
||||
StateUsartGlobal = USART_SEND;
|
||||
usart->state = USART_SEND;
|
||||
}
|
||||
|
||||
/* Wait USART ready for transmit */
|
||||
|
|
|
@ -59,7 +59,7 @@ static const Pin pinsPower[] = {PWR_PINS};
|
|||
static const Pin pinIso7816RstMC = PIN_ISO7816_RSTMC;
|
||||
static uint8_t sim_inserted = 0;
|
||||
|
||||
static struct Usart_info usart_info = {.base = USART_SIM, .id = ID_USART_SIM};
|
||||
static struct Usart_info usart_info = {.base = USART_SIM, .id = ID_USART_SIM, .state = USART_RCV};
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Optional smartcard detection
|
||||
|
|
|
@ -108,7 +108,7 @@ static const Pin pPwr[] = {
|
|||
|
||||
static const Pin pinPhoneRST = PIN_ISO7816_RST_PHONE;
|
||||
|
||||
static struct Usart_info usart_info = {.base = USART_PHONE, .id = ID_USART_PHONE};
|
||||
static struct Usart_info usart_info = {.base = USART_PHONE, .id = ID_USART_PHONE, .state = USART_RCV};
|
||||
|
||||
#define PR TRACE_INFO
|
||||
|
||||
|
@ -123,9 +123,6 @@ static struct Usart_info usart_info = {.base = USART_PHONE, .id = ID_USART_PHONE
|
|||
/*-----------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*-----------------------------------------------------------------------------*/
|
||||
/** Variable for state of send and receive froom USART */
|
||||
static uint8_t StateUsartGlobal = USART_RCV;
|
||||
|
||||
static uint8_t host_to_sim_buf[BUFLEN];
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
|
|
@ -14,8 +14,16 @@
|
|||
#define PHONE_DATAIN 5
|
||||
#define PHONE_INT 6
|
||||
|
||||
#define CLK_MASTER 1
|
||||
#define CLK_SLAVE 0
|
||||
#define CLK_MASTER true
|
||||
#define CLK_SLAVE false
|
||||
|
||||
/* ===================================================*/
|
||||
/* Taken from iso7816_4.c */
|
||||
/* ===================================================*/
|
||||
/** Flip flop for send and receive char */
|
||||
#define USART_SEND 0
|
||||
#define USART_RCV 1
|
||||
|
||||
|
||||
extern volatile ringbuf sim_rcv_buf;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ static const Pin pPwr[] = {
|
|||
{VCC_FWD, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
};
|
||||
|
||||
static struct Usart_info usart_info = {.base = USART_PHONE, .id = ID_USART_PHONE};
|
||||
static struct Usart_info usart_info = {.base = USART_PHONE, .id = ID_USART_PHONE, .state = USART_RCV};
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Initialization routine
|
||||
|
|
Loading…
Reference in New Issue