From 1ae3caf7fc8d9d1073684bf2da91b552065a41a7 Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Mon, 30 May 2016 20:06:43 +0900
Subject: USB cleanup

---
 example-fs-bb48/adc.h     |   8 ----
 example-fs-bb48/usb-cdc.c |  26 ++++++-----
 example-fs-bb48/usb_lld.h | 109 ----------------------------------------------
 3 files changed, 15 insertions(+), 128 deletions(-)
 delete mode 100644 example-fs-bb48/adc.h
 delete mode 100644 example-fs-bb48/usb_lld.h

(limited to 'example-fs-bb48')

diff --git a/example-fs-bb48/adc.h b/example-fs-bb48/adc.h
deleted file mode 100644
index 1a009f7..0000000
--- a/example-fs-bb48/adc.h
+++ /dev/null
@@ -1,8 +0,0 @@
-int adc_init (void);
-void adc_start (void);
-void adc_stop (void);
-
-extern uint32_t adc_buf[64];
-
-void adc_start_conversion (int offset, int count);
-int adc_wait_completion (void);
diff --git a/example-fs-bb48/usb-cdc.c b/example-fs-bb48/usb-cdc.c
index c950362..67a6e0e 100644
--- a/example-fs-bb48/usb-cdc.c
+++ b/example-fs-bb48/usb-cdc.c
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <chopstx.h>
 #include <string.h>
+#include "board.h"
 #include "usb_lld.h"
 #include "tty.h"
 
@@ -236,7 +237,7 @@ usb_cb_device_reset (void)
   usb_lld_reset (VCOM_FEATURE_BUS_POWERED);
 
   /* Initialize Endpoint 0 */
-  usb_lld_setup_endpoint (ENDP0, 1, 1);
+  usb_lld_setup_endp (ENDP0, 1, 1);
 
   chopstx_mutex_lock (&tty0.mtx);
   tty0.inputline_len = 0;
@@ -364,7 +365,7 @@ vcom_setup_endpoints_for_interface (uint16_t interface, int stop)
   if (interface == 0)
     {
       if (!stop)
-	usb_lld_setup_endpoint (ENDP2, 0, 1);
+	usb_lld_setup_endp (ENDP2, 0, 1);
       else
 	usb_lld_stall (ENDP2);
     }
@@ -372,8 +373,8 @@ vcom_setup_endpoints_for_interface (uint16_t interface, int stop)
     {
       if (!stop)
 	{
-	  usb_lld_setup_endpoint (ENDP1, 0, 1);
-	  usb_lld_setup_endpoint (ENDP3, 1, 0);
+	  usb_lld_setup_endp (ENDP1, 0, 1);
+	  usb_lld_setup_endp (ENDP3, 1, 0);
 	  /* Start with no data receiving (ENDP3 not enabled)*/
 	}
       else
@@ -510,12 +511,14 @@ tty_echo_char (struct tty *t, int c)
   put_char_to_ringbuffer (t, c);
 }
 
-
 void
-usb_cb_tx_done (uint8_t ep_num)
+usb_cb_tx_done (uint8_t ep_num, uint32_t len, int success)
 {
   struct tty *t = tty_get (-1, ep_num);
 
+  (void)len;
+  (void)success;		/* Always, successful.  */
+
   if (ep_num == ENDP1)
     {
       chopstx_mutex_lock (&t->mtx);
@@ -608,7 +611,7 @@ usb_cb_rx_ready (uint8_t ep_num)
 
       chopstx_mutex_lock (&t->mtx);
       if (t->flag_input_avail == 0)
-	usb_lld_rx_enable (ENDP3, t->recv_buf0, 64);
+	usb_lld_rx_enable_buf (ENDP3, t->recv_buf0, 64);
       chopstx_mutex_unlock (&t->mtx);
     }
 }
@@ -687,7 +690,7 @@ tty_main (void *arg)
 	  if (len)
 	    {
 	      memcpy (t->send_buf0, line, len);
-	      usb_lld_tx_enable (ENDP1, t->send_buf0, len);
+	      usb_lld_tx_enable_buf (ENDP1, t->send_buf0, len);
 	      t->flag_send_ready = 0;
 	    }
 	}
@@ -718,7 +721,8 @@ tty_wait_connection (struct tty *t)
   t->flag_input_avail = 0;
   t->send_head = t->send_tail = 0;
   t->inputline_len = 0;
-  usb_lld_rx_enable (ENDP3, t->recv_buf0, 64);	/* Accept input for line */
+  /* Accept input for line */
+  usb_lld_rx_enable_buf (ENDP3, t->recv_buf0, 64);
   chopstx_mutex_unlock (&t->mtx);
 }
 
@@ -751,7 +755,7 @@ tty_send (struct tty *t, const uint8_t *buf, int len)
 	chopstx_cond_wait (&t->cnd, &t->mtx);
       if (r > 0)
 	{
-	  usb_lld_tx_enable (ENDP1, p, count);
+	  usb_lld_tx_enable_buf (ENDP1, p, count);
 	  t->flag_send_ready = 0;
 	}
       chopstx_mutex_unlock (&t->mtx);
@@ -827,7 +831,7 @@ tty_recv (struct tty *t, uint8_t *buf, uint32_t *timeout)
       r = t->inputline_len;
       memcpy (buf, t->inputline, r);
       t->flag_input_avail = 0;
-      usb_lld_rx_enable (ENDP3, t->recv_buf0, 64);
+      usb_lld_rx_enable_buf (ENDP3, t->recv_buf0, 64);
       t->inputline_len = 0;
     }
   else
diff --git a/example-fs-bb48/usb_lld.h b/example-fs-bb48/usb_lld.h
deleted file mode 100644
index b2ce4fb..0000000
--- a/example-fs-bb48/usb_lld.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#define STANDARD_ENDPOINT_DESC_SIZE             0x09
-
-/* endpoints enumeration */
-#define ENDP0       ((uint8_t)0)
-#define ENDP1       ((uint8_t)1)
-#define ENDP2       ((uint8_t)2)
-#define ENDP3       ((uint8_t)3)
-#define ENDP4       ((uint8_t)4)
-#define ENDP5       ((uint8_t)5)
-#define ENDP6       ((uint8_t)6)
-#define ENDP7       ((uint8_t)7)
-
-enum RECIPIENT_TYPE
-{
-  DEVICE_RECIPIENT,     /* Recipient device    */
-  INTERFACE_RECIPIENT,  /* Recipient interface */
-  ENDPOINT_RECIPIENT,   /* Recipient endpoint  */
-  OTHER_RECIPIENT
-};
-
-enum DESCRIPTOR_TYPE
-{
-  DEVICE_DESCRIPTOR = 1,
-  CONFIG_DESCRIPTOR,
-  STRING_DESCRIPTOR,
-  INTERFACE_DESCRIPTOR,
-  ENDPOINT_DESCRIPTOR
-};
-
-#define REQUEST_DIR       0x80  /* Mask to get request dir  */
-#define REQUEST_TYPE      0x60  /* Mask to get request type */
-#define STANDARD_REQUEST  0x00  /* Standard request         */
-#define CLASS_REQUEST     0x20  /* Class request            */
-#define VENDOR_REQUEST    0x40  /* Vendor request           */
-#define RECIPIENT         0x1F  /* Mask to get recipient    */
-
-#define USB_SETUP_SET(req) ((req & REQUEST_DIR) == 0)
-#define USB_SETUP_GET(req) ((req & REQUEST_DIR) != 0)
-
-enum
-{
-  USB_UNSUPPORT = 0,
-  USB_SUCCESS = 1,
-};
-
-struct req_args {
-  uint16_t value;
-  uint16_t index;
-  uint16_t len;
-};
-
-void usb_cb_device_reset (void);
-int usb_cb_setup (uint8_t req, uint8_t req_no, struct req_args *arg);
-int usb_cb_interface (uint8_t cmd, struct req_args *arg);
-int usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
-			   struct req_args *arg);
-int usb_cb_handle_event (uint8_t event_type, uint16_t value);
-void usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no,
-			       struct req_args *arg);
-void usb_cb_tx_done (uint8_t ep_num);
-void usb_cb_rx_ready (uint8_t ep_num);
-
-enum {
-  USB_EVENT_ADDRESS,
-  USB_EVENT_CONFIG,
-  USB_EVENT_SUSPEND,
-  USB_EVENT_WAKEUP,
-  USB_EVENT_STALL,
-};
-
-enum {
-  USB_SET_INTERFACE,
-  USB_GET_INTERFACE,
-  USB_QUERY_INTERFACE,
-};
-
-enum DEVICE_STATE
-{
-  UNCONNECTED,
-  ATTACHED,
-  POWERED,
-  SUSPENDED,
-  ADDRESSED,
-  CONFIGURED
-};
-
-void usb_lld_init (uint8_t feature);
-
-int usb_lld_reply_request (const void *buf, size_t buflen,
-			   struct req_args *arg);
-void usb_lld_set_data_to_recv (void *p, size_t len);
-
-void usb_lld_tx_enable (uint8_t ep_num, const void *buf, size_t len);
-int usb_lld_tx_result (int ep_num);
-
-void usb_lld_rx_enable (int ep_num, void *buf, size_t len);
-int usb_lld_rx_data_len (int ep_num);
-
-void usb_lld_stall (int ep_num);
-
-void usb_lld_reset (uint8_t feature);
-void usb_lld_setup_endpoint (int n, int rx_en, int tx_en);
-void usb_lld_set_configuration (uint8_t config);
-uint8_t usb_lld_current_configuration (void);
-
-void usb_lld_prepare_shutdown (void);
-void usb_lld_shutdown (void);
-
-void usb_interrupt_handler (void);
-- 
cgit v1.2.3