Commit Graph

15 Commits

Author SHA1 Message Date
Harald Welte
7abdb51f8f ringbuffer: Make ring buffer access irq-save
We have to temporarily disable nterrupts when performing rinbuffer
operations, as the ring buffer is used both from IRQ as well as process
context.
2016-03-16 22:22:54 +01:00
Harald Welte
1605564489 ensure USB config numbers always start from 1
Depending on which features (and thus USB configurations) are included
in the firmware, we need to re-define the ordering of the configuration
numbers, as the Atmel USBD driver simply assumes that configurations are
numbered 1..N without any gaps in the sequence.
2016-03-16 20:45:10 +01:00
Harald Welte
13e8202c81 mode_cardem: Prepare for full support of second UART/USIM
So far we have only been working with a single UART/USIM. Let's
make things more data structure driven and pass around handles to
the data structures rather than hardcoding...
2016-03-16 20:45:09 +01:00
Harald Welte
06b27f64a2 mode_cardemu: Implement CEMU_USB_MSGT_DT_SET_ATR
This way the host PC can set the ATR of the emulated card
2016-03-16 20:45:09 +01:00
Harald Welte
ebb80eda19 introduce 'main' queue between USB receive and UART TX
In order to handle other USB commands like GET_STATUS, SET_ATR
or GET_STATS, we introduce an intermediary queue.  The USB receive
completion call-back puts the command on that intermediate 'main'
queue.  From that intermediate queue, the are further
dispatched/processed according to their mesage type.
2016-03-16 20:45:09 +01:00
Harald Welte
12d4bdfbb1 mode_cardemu: Process RX interrupts before TX
It's always more important to pull out a received character from
the receive holding register to avoid the risk of overflow, so let's
do that first.
2016-03-02 10:31:03 +01:00
Harald Welte
acae412b2a explicitly inform card_emu once data to transmit has arrived 2016-03-02 10:27:58 +01:00
Harald Welte
8a416b1812 mode_cardemu: fix ordering of events when switching rx/tx mode 2016-03-01 00:42:04 +01:00
Harald Welte
45688d4c3b mode_cardemu: Disable UART TXRDY generation if we don't have data to TX
When the ISO7816 state machine requires us to transmit something, but
we don't have data ready to transmit, we should switch off TXRDY
interrupt generation.

What's missing is of course the other part that re-enabls TXRDY
generation once new data is available
2016-02-29 21:35:38 +01:00
Harald Welte
54cb3d017f host_communication/card_emu: adapt to nwe req_ctx / queuing paradignm 2016-02-29 14:12:40 +01:00
Harald Welte
c0bd7f0aaa mode_cardemu: Move GPIO detection to IRQ, use ring buffer for UART RX
We don't want to call into the bulk of card_emu.c from interrupt
context, so let's introduce a ring buffer as a softwre-FIFO between
the USART receiving a byte and the processing of that byte in
card_emu.c, which is then performed from the main loop outside
interrupt context.
2016-02-29 10:13:33 +01:00
Harald Welte
99f62a6def mode_cardemu: update_fidi just needs to execute
the actual translation of the Fi/Di values to the divider is
already made, we just need to update the USART divider here.
2016-02-29 10:08:49 +01:00
Harald Welte
9dbc46e799 mode_cardemu: Proper enabling/disabling of USART IRQ sources
we always have to disable all intrerrupts that we don't want to be
enabled
2016-02-29 10:05:10 +01:00
Harald Welte
bd71768e5f mode_card_emu: connect the update_fidi() callback 2016-02-28 19:30:05 +01:00
Harald Welte
2a6d3afd6c re-introduce req_ctx buffers into the host communication 2016-02-28 19:29:14 +01:00