Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16290 )
Change subject: cuart: allow getting the icc baud rate and clock freq ...................................................................... cuart: allow getting the icc baud rate and clock freq Change-Id: I577907e6c60582a80666d43b17c20de4e03cc8df --- M ccid_common/cuart.h M sysmoOCTSIM/cuart_driver_asf4_usart_async.c 2 files changed, 12 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/90/16290/1 diff --git a/ccid_common/cuart.h b/ccid_common/cuart.h index c72b51c..6a782db 100644 --- a/ccid_common/cuart.h +++ b/ccid_common/cuart.h @@ -30,6 +30,8 @@ CUART_CTL_RST, /* enable/disable ICC reset */ CUART_CTL_WTIME, /* set the waiting time (in etu) */ CUART_CTL_SET_FD, + CUART_CTL_GET_BAUDRATE, + CUART_CTL_GET_CLOCK_FREQ, }; struct card_uart; @@ -100,6 +102,7 @@ uint8_t slot_nr; /* in us, required, no delay breaks _rx_ */ uint32_t extrawait_after_rx; + uint32_t current_baudrate; } asf4; } u; }; diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c index db3dc79..f12ed73 100644 --- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c +++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c @@ -203,6 +203,9 @@ if (NULL == slot) { return false; } + + // update cached values + cuart->u.asf4.current_baudrate = baudrate; printf("(%u) switching SERCOM clock to GCLK%u (freq = %lu kHz) and baud rate to %lu bps (baud = %u)\r\n", slotnr, (best + 1) * 2, (uint32_t)(round(sercom_glck_freqs[best] / 1000)), baudrate, bauds[best]); while (!usart_async_is_tx_empty(slot)); // wait for transmission to complete (WARNING no timeout) usart_async_disable(slot); // disable SERCOM peripheral @@ -404,6 +407,12 @@ uint32_t baudrate = (20e6/divider)/arg; cuart->u.asf4.extrawait_after_rx = 1./baudrate * 1000 * 1000; slot_set_baudrate(cuart->u.asf4.slot_nr, baudrate); + case CUART_CTL_GET_BAUDRATE: + return cuart->u.asf4.current_baudrate; + break; + case CUART_CTL_GET_CLOCK_FREQ: + ncn8025_get(cuart->u.asf4.slot_nr, &settings); + return 20e6 / ncn8025_div_val[settings.clkdiv]; break; default: return -EINVAL; -- To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16290 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ccid-firmware Gerrit-Branch: master Gerrit-Change-Id: I577907e6c60582a80666d43b17c20de4e03cc8df Gerrit-Change-Number: 16290 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ew...@sysmocom.de> Gerrit-MessageType: newchange