aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2019-11-17 19:26:28 +0100
committerHarald Welte <laforge@osmocom.org>2019-11-17 19:33:44 +0100
commit05c11a81925f889e20ca1d5a57e7181555cd081b (patch)
tree7758894bfa8334eccf95015f16b2da710d0a99da
parentab053a25b715ded616ef4313664bb25b75fe2f50 (diff)
HACK: add gpio-toggling on arrival of tx-completion interruptlaforge/tx_complete_delay
-rw-r--r--sysmoOCTSIM/cuart_driver_asf4_usart_async.c10
-rw-r--r--sysmoOCTSIM/hpl/sercom/hpl_sercom.c5
-rw-r--r--sysmoOCTSIM/main.c49
3 files changed, 63 insertions, 1 deletions
diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
index a8f8044..6ed010e 100644
--- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
+++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c
@@ -44,6 +44,14 @@ static void _SIM_tx_cb(const struct usart_async_descriptor *const io_descr, uint
{
struct card_uart *cuart = cuart4slot_nr(slot_nr);
OSMO_ASSERT(cuart);
+ if (slot_nr == 6) {
+ hri_sercomusart_clear_INTFLAG_TXC_bit(SERCOM6);
+#if 0
+ gpio_set_pin_level(PIN_PB13, true);
+ delay_us(1);
+ gpio_set_pin_level(PIN_PB13, false);
+#endif
+ }
card_uart_notification(cuart, CUART_E_TX_COMPLETE, io_descr->tx_buffer);
}
@@ -161,7 +169,7 @@ static const uint8_t SIM_peripheral_GCLK_ID[] = {SERCOM0_GCLK_ID_CORE, SERCOM1_G
* @param[in] baudrate baud rate in bps to set
* @return if the baud rate has been set, else a parameter is out of range
*/
-static bool slot_set_baudrate(uint8_t slotnr, uint32_t baudrate)
+bool slot_set_baudrate(uint8_t slotnr, uint32_t baudrate)
{
ASSERT(slotnr < ARRAY_SIZE(SIM_peripheral_descriptors));
diff --git a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
index f235115..ae19e49 100644
--- a/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
+++ b/sysmoOCTSIM/hpl/sercom/hpl_sercom.c
@@ -45,6 +45,8 @@
#include <utils.h>
#include <utils_assert.h>
+#include <hal_gpio.h>
+
#ifndef CONF_SERCOM_0_USART_ENABLE
#define CONF_SERCOM_0_USART_ENABLE 0
#endif
@@ -2617,6 +2619,9 @@ void SERCOM6_0_Handler(void)
*/
void SERCOM6_1_Handler(void)
{
+ gpio_set_pin_level(PIN_PB13, true);
+ delay_us(1);
+ gpio_set_pin_level(PIN_PB13, false);
_sercom_usart_interrupt_handler(_sercom6_dev);
}
/**
diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 35acff5..e98243d 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -1124,8 +1124,23 @@ static const struct ccid_ops c_ops = {
//#######################
+static void dbgio_init()
+{
+ /* CAN_TX */
+ gpio_set_pin_function(PIN_PB12, GPIO_PIN_FUNCTION_OFF);
+ gpio_set_pin_direction(PIN_PB12, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PB12, false);
+
+ /* CAN_RX */
+ gpio_set_pin_function(PIN_PB13, GPIO_PIN_FUNCTION_OFF);
+ gpio_set_pin_direction(PIN_PB13, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PB13, false);
+}
+
#define NUM_OUT_BUF 7
+extern bool slot_set_baudrate(uint8_t slotnr, uint32_t baudrate);
+
int main(void)
{
char sernr_buf[16*2+1];
@@ -1187,8 +1202,41 @@ int main(void)
submit_next_out();
CRITICAL_SECTION_LEAVE()
+ dbgio_init();
+
+#if 1
+ struct ncn8025_settings settings;
+ settings.rstin = false;
+ settings.cmdvcc = true;
+ settings.led = true;
+ settings.clkdiv = SIM_CLKDIV_1;
+ settings.vsel = SIM_VOLT_3V0;
+ ncn8025_set(6, &settings);
+ slot_set_baudrate(6, 6720);
+ //slot_set_isorate(6, settings.clkdiv, ISO7816_3_DEFAULT_FD, ISO7816_3_DEFAULT_DD);
+ //slot_set_baudrate(6, 300000);
+ hri_sercomusart_write_CTRLB_TXEN_bit(SERCOM6, true);
+ hri_sercomusart_write_CTRLB_RXEN_bit(SERCOM6, false);
+ hri_sercomusart_set_INTEN_TXC_bit(SERCOM6);
+
+ for (uint32_t i = 0; i < 4; i++) {
+ uint32_t irq = 70+i;
+ NVIC_DisableIRQ((IRQn_Type)irq);
+ NVIC_ClearPendingIRQ((IRQn_Type)irq);
+ NVIC_EnableIRQ((IRQn_Type)irq);
+ }
+
+ while (true) {
+ delay_us(100000);
+ while (!hri_sercomusart_get_interrupt_DRE_bit(SERCOM6)) {}
+ hri_sercomusart_set_INTEN_TXC_bit(SERCOM6);
+ hri_sercomusart_write_DATA_reg(SERCOM6, 0x55);
+ }
+
+#else
// command_print_prompt();
while (true) { // main loop
+
command_try_recv();
poll_card_detect();
submit_next_irq();
@@ -1213,4 +1261,5 @@ int main(void)
}
}
+#endif
}