Change in osmo-ccid-firmware[master]: echo back UART input

2019-02-07 Thread Kévin Redon
Kévin Redon has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/12807 )

Change subject: echo back UART input
..

echo back UART input

let main run the main loop instead of the CDC ACM example.
also rename the CDC ACM example functions.

Change-Id: I44b15079672b4058de1fa08365541317d54958dc
---
M sysmoOCTSIM/main.c
M sysmoOCTSIM/usb_start.c
M sysmoOCTSIM/usb_start.h
3 files changed, 17 insertions(+), 17 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index de954f4..dfe3b03 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -19,19 +19,19 @@
 #include "atmel_start.h"
 #include "atmel_start_pins.h"

-volatile static uint32_t data_arrived = 0;
+volatile static bool data_arrived = false;

 static void tx_cb_UART_debug(const struct usart_async_descriptor *const 
io_descr)
 {
/* Transfer completed */
-   gpio_toggle_pin_level(LED_system);
+   //gpio_toggle_pin_level(LED_system);
 }
 
 static void rx_cb_UART_debug(const struct usart_async_descriptor *const 
io_descr)
 {
/* Receive completed */
gpio_toggle_pin_level(LED_system);
-   data_arrived = 1;
+   data_arrived = true;
 }

 int main(void)
@@ -42,5 +42,15 @@
usart_async_register_callback(_debug, USART_ASYNC_RXC_CB, 
rx_cb_UART_debug);
usart_async_enable(_debug);

-   cdcd_acm_example();
+   usb_start();
+
+   while (true) { // main loop
+   if (data_arrived) { // input on UART debug
+   data_arrived = false; // clear flag
+   uint8_t recv_char; // to store the input
+   while (io_read(_debug.io, _char, 1) == 1) { 
// read input
+   while (io_write(_debug.io, _char, 1) 
!= 1); // echo back to output
+   }
+   }
+   }
 }
diff --git a/sysmoOCTSIM/usb_start.c b/sysmoOCTSIM/usb_start.c
index de86172..d02edc0 100644
--- a/sysmoOCTSIM/usb_start.c
+++ b/sysmoOCTSIM/usb_start.c
@@ -93,25 +93,15 @@
 }

 /**
- * Example of using CDC ACM Function.
- * \note
- * In this example, we will use a PC as a USB host:
- * - Connect the DEBUG USB on XPLAINED board to PC for program download.
- * - Connect the TARGET USB on XPLAINED board to PC for running program.
- * The application will behave as a virtual COM.
- * - Open a HyperTerminal or other COM tools in PC side.
- * - Send out a character or string and it will echo the content received.
+ * \brief Start USB stack
  */
-void cdcd_acm_example(void)
+void usb_start(void)
 {
while (!cdcdf_acm_is_enabled()) {
// wait cdc acm to be installed
};

cdcdf_acm_register_callback(CDCDF_ACM_CB_STATE_C, 
(FUNC_PTR)usb_device_cb_state_c);
-
-   while (1) {
-   }
 }

 void usb_init(void)
diff --git a/sysmoOCTSIM/usb_start.h b/sysmoOCTSIM/usb_start.h
index 48b2735..daf30cc 100644
--- a/sysmoOCTSIM/usb_start.h
+++ b/sysmoOCTSIM/usb_start.h
@@ -15,7 +15,7 @@
 #include "cdcdf_acm.h"
 #include "cdcdf_acm_desc.h"

-void cdcd_acm_example(void);
+void usb_start(void);
 void cdc_device_acm_init(void);

 /**

--
To view, visit https://gerrit.osmocom.org/12807
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I44b15079672b4058de1fa08365541317d54958dc
Gerrit-Change-Number: 12807
Gerrit-PatchSet: 2
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Kévin Redon 


Change in osmo-ccid-firmware[master]: echo back UART input

2019-02-04 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/12807 )

Change subject: echo back UART input
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/12807
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I44b15079672b4058de1fa08365541317d54958dc
Gerrit-Change-Number: 12807
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon 
Gerrit-Reviewer: Harald Welte 
Gerrit-Comment-Date: Mon, 04 Feb 2019 13:58:18 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ccid-firmware[master]: echo back UART input

2019-02-03 Thread Kévin Redon
Kévin Redon has uploaded this change for review. ( 
https://gerrit.osmocom.org/12807


Change subject: echo back UART input
..

echo back UART input

let main run the main loop instead of the CDC ACM example.
also rename the CDC ACM example functions.

Change-Id: I44b15079672b4058de1fa08365541317d54958dc
---
M sysmoOCTSIM/main.c
M sysmoOCTSIM/usb_start.c
M sysmoOCTSIM/usb_start.h
3 files changed, 17 insertions(+), 17 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware 
refs/changes/07/12807/1

diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index de954f4..dfe3b03 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -19,19 +19,19 @@
 #include "atmel_start.h"
 #include "atmel_start_pins.h"

-volatile static uint32_t data_arrived = 0;
+volatile static bool data_arrived = false;

 static void tx_cb_UART_debug(const struct usart_async_descriptor *const 
io_descr)
 {
/* Transfer completed */
-   gpio_toggle_pin_level(LED_system);
+   //gpio_toggle_pin_level(LED_system);
 }

 static void rx_cb_UART_debug(const struct usart_async_descriptor *const 
io_descr)
 {
/* Receive completed */
gpio_toggle_pin_level(LED_system);
-   data_arrived = 1;
+   data_arrived = true;
 }

 int main(void)
@@ -42,5 +42,15 @@
usart_async_register_callback(_debug, USART_ASYNC_RXC_CB, 
rx_cb_UART_debug);
usart_async_enable(_debug);

-   cdcd_acm_example();
+   usb_start();
+
+   while (true) { // main loop
+   if (data_arrived) { // input on UART debug
+   data_arrived = false; // clear flag
+   uint8_t recv_char; // to store the input
+   while (io_read(_debug.io, _char, 1) == 1) { 
// read input
+   while (io_write(_debug.io, _char, 1) 
!= 1); // echo back to output
+   }
+   }
+   }
 }
diff --git a/sysmoOCTSIM/usb_start.c b/sysmoOCTSIM/usb_start.c
index de86172..d02edc0 100644
--- a/sysmoOCTSIM/usb_start.c
+++ b/sysmoOCTSIM/usb_start.c
@@ -93,25 +93,15 @@
 }

 /**
- * Example of using CDC ACM Function.
- * \note
- * In this example, we will use a PC as a USB host:
- * - Connect the DEBUG USB on XPLAINED board to PC for program download.
- * - Connect the TARGET USB on XPLAINED board to PC for running program.
- * The application will behave as a virtual COM.
- * - Open a HyperTerminal or other COM tools in PC side.
- * - Send out a character or string and it will echo the content received.
+ * \brief Start USB stack
  */
-void cdcd_acm_example(void)
+void usb_start(void)
 {
while (!cdcdf_acm_is_enabled()) {
// wait cdc acm to be installed
};

cdcdf_acm_register_callback(CDCDF_ACM_CB_STATE_C, 
(FUNC_PTR)usb_device_cb_state_c);
-
-   while (1) {
-   }
 }

 void usb_init(void)
diff --git a/sysmoOCTSIM/usb_start.h b/sysmoOCTSIM/usb_start.h
index 48b2735..daf30cc 100644
--- a/sysmoOCTSIM/usb_start.h
+++ b/sysmoOCTSIM/usb_start.h
@@ -15,7 +15,7 @@
 #include "cdcdf_acm.h"
 #include "cdcdf_acm_desc.h"

-void cdcd_acm_example(void);
+void usb_start(void);
 void cdc_device_acm_init(void);

 /**

--
To view, visit https://gerrit.osmocom.org/12807
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I44b15079672b4058de1fa08365541317d54958dc
Gerrit-Change-Number: 12807
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon