command to change fidi send by host

This commit is contained in:
Christina Quast
2015-05-03 14:21:26 +02:00
parent 6246000b3a
commit cb646bc729
5 changed files with 79 additions and 252 deletions

View File

@@ -1,14 +1,14 @@
#include "board.h"
static volatile bool write_to_host_in_progress = false;
static struct iso7816_3_handle ih = {0};
static bool check_for_pts = false;
static enum pts_state state;
static struct Usart_info usart_info = {.base = USART_PHONE, .id = ID_USART_PHONE, .state = USART_RCV};
void USB_write_callback(uint8_t *pArg, uint8_t status, uint32_t transferred, uint32_t remaining)
{
if (status != USBD_STATUS_SUCCESS) {
TRACE_ERROR("USB err status: %d (%s)\n", __FUNCTION__, status);
TRACE_ERROR("USB err status: %d(%s)\n", __FUNCTION__, status);
}
write_to_host_in_progress = false;
TRACE_DEBUG("WR_CB\n");
@@ -40,26 +40,6 @@ int check_data_from_phone()
if((rbuf_is_empty(&sim_rcv_buf) || write_to_host_in_progress == true)) {
return ret;
}
if ((check_for_pts == false) && (rbuf_peek(&sim_rcv_buf) == 0xff)) {
// FIXME: set var to false
check_for_pts = true;
ih = (struct iso7816_3_handle){0};
}
if (check_for_pts == true) {
while (!rbuf_is_empty(&sim_rcv_buf) && (ih.pts_state != PTS_END)) {
state = process_byte_pts(&ih, rbuf_read(&sim_rcv_buf));
}
if (ih.pts_bytes_processed > 6 && ih.pts_state != PTS_END) {
int i;
for (i = 0; i < ih.pts_bytes_processed; i++)
printf("s: %x", ih.pts_req[i]);
check_for_pts = false;
rbuf_write(&sim_rcv_buf, ih.pts_req[i]);
} else {
printf("fin pts\n", ih.pts_state);
check_for_pts = false;
}
}
ret = send_to_host();
return ret;
}