mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-19 23:08:34 +03:00
dynamically dispatch USART IRQs
The different modes (configurations) will have different interrupt handlers, so we need to dispatch them via config_func_ptrs
This commit is contained in:
@@ -167,17 +167,13 @@ int card_emu_uart_tx(uint8_t uart_chan, uint8_t byte)
|
||||
|
||||
|
||||
/* FIXME: integrate this with actual irq handler */
|
||||
void usart_irq_rx(uint8_t uart)
|
||||
static void usart_irq_rx(uint8_t inst_num)
|
||||
{
|
||||
Usart *usart = get_usart_by_chan(uart);
|
||||
struct cardem_inst *ci = &cardem_inst[0];
|
||||
Usart *usart = get_usart_by_chan(inst_num);
|
||||
struct cardem_inst *ci = &cardem_inst[inst_num];
|
||||
uint32_t csr;
|
||||
uint8_t byte = 0;
|
||||
|
||||
#ifdef CARDEMU_SECOND_UART
|
||||
if (uart == 1)
|
||||
ci = &cardem_inst[1];
|
||||
#endif
|
||||
csr = usart->US_CSR & usart->US_IMR;
|
||||
|
||||
if (csr & US_CSR_RXRDY) {
|
||||
@@ -197,6 +193,18 @@ void usart_irq_rx(uint8_t uart)
|
||||
}
|
||||
}
|
||||
|
||||
void mode_cardemu_usart0_irq(void)
|
||||
{
|
||||
/* USART0 == Instance 1 == USIM 2 */
|
||||
usart_irq_rx(1);
|
||||
}
|
||||
|
||||
void mode_cardemu_usart1_irq(void)
|
||||
{
|
||||
/* USART1 == Instance 0 == USIM 1 */
|
||||
usart_irq_rx(0);
|
||||
}
|
||||
|
||||
/* call-back from card_emu.c to change UART baud rate */
|
||||
int card_emu_uart_update_fidi(uint8_t uart_chan, unsigned int fidi)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user