fix usb_lld.c
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2012-05-17 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* src/usb_lld.c (LAST_OUT_DATA): Remove.
|
||||||
|
(handle_datastage_out): Cleanup and call st103_ep_set_rxtx_status.
|
||||||
|
(handle_datastage_in): Call st103_ep_set_rxtx_status and
|
||||||
|
st103_ep_set_tx_status.
|
||||||
|
(handle_setup0): Likewise.
|
||||||
|
(handle_out0): Remove LAST_OUT_DATA.
|
||||||
|
|
||||||
2012-05-16 Niibe Yutaka <gniibe@fsij.org>
|
2012-05-16 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* tool/gnuk_put_binary.py (main): Fix fileid.
|
* tool/gnuk_put_binary.py (main): Fix fileid.
|
||||||
|
|||||||
16
README
16
README
@@ -235,7 +235,7 @@ USB vendor ID and product ID (USB device ID)
|
|||||||
When you have a vender ID and assign a product ID for Gnuk, edit the
|
When you have a vender ID and assign a product ID for Gnuk, edit the
|
||||||
file GNUK_USB_DEVICE_ID and add an entry for yours. In this case,
|
file GNUK_USB_DEVICE_ID and add an entry for yours. In this case,
|
||||||
please contact Niibe, so that it is listed to the file in the official
|
please contact Niibe, so that it is listed to the file in the official
|
||||||
release of source code.
|
release of the source code.
|
||||||
|
|
||||||
When you are modifing Gnuk and installing the binary to device, you
|
When you are modifing Gnuk and installing the binary to device, you
|
||||||
should replace "FSIJ" in the string gnukStringSerial (usb_desc.c) to
|
should replace "FSIJ" in the string gnukStringSerial (usb_desc.c) to
|
||||||
@@ -264,14 +264,16 @@ with Gnuk under one of following conditions:
|
|||||||
please use that number for your device.
|
please use that number for your device.
|
||||||
(There a file 'GNUK_SERIAL_NUMBER' in the official release.)
|
(There a file 'GNUK_SERIAL_NUMBER' in the official release.)
|
||||||
|
|
||||||
FSIJ could permit companies or business entities to use USB device ID
|
FSIJ could give companies or business entities "second source
|
||||||
of FSIJ for devices with unmodified version of Gnuk, provided they
|
manufacturer" license to use USB device ID of FSIJ for devices with
|
||||||
support Free Software and respect users' freedom for computing.
|
unmodified version of Gnuk, provided they support Free Software and
|
||||||
Please ask FSIJ for permission.
|
respect users' freedom for computing. Please ask FSIJ for the
|
||||||
|
license.
|
||||||
|
|
||||||
Otherwise, companies which want to distribute Gnuk devices, please use
|
Otherwise, companies which want to distribute Gnuk devices, please use
|
||||||
your own USB vendor ID and product ID. When you modify Gnuk, please
|
your own USB vendor ID and product ID. Note that please replace
|
||||||
replace "FSIJ" in the string gnukStringSerial (usb_desc.c) to yours.
|
"FSIJ" in the string gnukStringSerial (usb_desc.c) to yours, when you
|
||||||
|
modify Gnuk.
|
||||||
|
|
||||||
|
|
||||||
Host Requirements
|
Host Requirements
|
||||||
|
|||||||
@@ -27,16 +27,15 @@ enum STANDARD_REQUESTS
|
|||||||
/* The state machine states of a control pipe */
|
/* The state machine states of a control pipe */
|
||||||
enum CONTROL_STATE
|
enum CONTROL_STATE
|
||||||
{
|
{
|
||||||
WAIT_SETUP, /* 0 */
|
WAIT_SETUP,
|
||||||
SETTING_UP, /* 1 */
|
SETTING_UP,
|
||||||
IN_DATA, /* 2 */
|
IN_DATA,
|
||||||
OUT_DATA, /* 3 */
|
OUT_DATA,
|
||||||
LAST_IN_DATA, /* 4 */
|
LAST_IN_DATA,
|
||||||
LAST_OUT_DATA, /* 5 */
|
WAIT_STATUS_IN,
|
||||||
WAIT_STATUS_IN, /* 7 */
|
WAIT_STATUS_OUT,
|
||||||
WAIT_STATUS_OUT, /* 8 */
|
STALLED,
|
||||||
STALLED, /* 9 */
|
PAUSE
|
||||||
PAUSE /* 10 */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FEATURE_SELECTOR
|
enum FEATURE_SELECTOR
|
||||||
@@ -400,24 +399,17 @@ static void handle_datastage_out (void)
|
|||||||
usb_lld_from_pmabuf (buf, st103_get_rx_addr (ENDP0), len);
|
usb_lld_from_pmabuf (buf, st103_get_rx_addr (ENDP0), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_p->len != 0)
|
if (data_p->len == 0)
|
||||||
|
{
|
||||||
|
dev_p->state = WAIT_STATUS_IN;
|
||||||
|
st103_set_tx_count (ENDP0, 0);
|
||||||
|
st103_ep_set_rxtx_status (ENDP0, EP_RX_STALL, EP_TX_VALID);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
st103_ep_set_rx_status (ENDP0, EP_RX_VALID);
|
st103_ep_set_rx_status (ENDP0, EP_RX_VALID);
|
||||||
st103_set_tx_count (ENDP0, 0);
|
dev_p->state = OUT_DATA;
|
||||||
st103_ep_set_tx_status (ENDP0, EP_TX_VALID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_p->len >= USB_MAX_PACKET_SIZE)
|
|
||||||
dev_p->state = OUT_DATA;
|
|
||||||
else
|
|
||||||
if (data_p->len > 0)
|
|
||||||
dev_p->state = LAST_OUT_DATA;
|
|
||||||
else if (data_p->len == 0)
|
|
||||||
{
|
|
||||||
dev_p->state = WAIT_STATUS_IN;
|
|
||||||
st103_set_tx_count (ENDP0, 0);
|
|
||||||
st103_ep_set_tx_status (ENDP0, EP_TX_VALID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_datastage_in (void)
|
static void handle_datastage_in (void)
|
||||||
@@ -437,10 +429,11 @@ static void handle_datastage_in (void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* No more data to send. Thus, STALL the TX Status*/
|
/* No more data to send, but receive OUT.*/
|
||||||
dev_p->state = WAIT_STATUS_OUT;
|
dev_p->state = WAIT_STATUS_OUT;
|
||||||
st103_ep_set_tx_status (ENDP0, EP_TX_STALL);
|
st103_ep_set_rxtx_status (ENDP0, EP_RX_VALID, EP_TX_STALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,11 +444,10 @@ static void handle_datastage_in (void)
|
|||||||
|
|
||||||
buf = (const uint8_t *)data_p->addr + data_p->offset;
|
buf = (const uint8_t *)data_p->addr + data_p->offset;
|
||||||
usb_lld_to_pmabuf (buf, st103_get_tx_addr (ENDP0), len);
|
usb_lld_to_pmabuf (buf, st103_get_tx_addr (ENDP0), len);
|
||||||
st103_set_tx_count (ENDP0, len);
|
|
||||||
|
|
||||||
data_p->len -= len;
|
data_p->len -= len;
|
||||||
data_p->offset += len;
|
data_p->offset += len;
|
||||||
st103_ep_set_rxtx_status (ENDP0, EP_RX_VALID, EP_TX_VALID);
|
st103_set_tx_count (ENDP0, len);
|
||||||
|
st103_ep_set_tx_status (ENDP0, EP_TX_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int (*HANDLER) (uint8_t rcp,
|
typedef int (*HANDLER) (uint8_t rcp,
|
||||||
@@ -781,7 +773,6 @@ static void handle_setup0 (void)
|
|||||||
pw++;
|
pw++;
|
||||||
ctrl_p->wLength = *pw;
|
ctrl_p->wLength = *pw;
|
||||||
|
|
||||||
dev_p->state = STALLED;
|
|
||||||
data_p->len = 0;
|
data_p->len = 0;
|
||||||
data_p->offset = 0;
|
data_p->offset = 0;
|
||||||
|
|
||||||
@@ -812,13 +803,7 @@ static void handle_setup0 (void)
|
|||||||
dev_p->state = STALLED;
|
dev_p->state = STALLED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ctrl_p->wLength == 0)
|
if (ctrl_p->bmRequestType & 0x80)
|
||||||
{
|
|
||||||
dev_p->state = WAIT_STATUS_IN;
|
|
||||||
st103_set_tx_count (ENDP0, 0);
|
|
||||||
st103_ep_set_tx_status (ENDP0, EP_TX_VALID);
|
|
||||||
}
|
|
||||||
else if (ctrl_p->bmRequestType & 0x80)
|
|
||||||
{
|
{
|
||||||
uint32_t len = ctrl_p->wLength;
|
uint32_t len = ctrl_p->wLength;
|
||||||
|
|
||||||
@@ -831,13 +816,19 @@ static void handle_setup0 (void)
|
|||||||
else
|
else
|
||||||
data_p->require_zlp = FALSE;
|
data_p->require_zlp = FALSE;
|
||||||
|
|
||||||
|
dev_p->state = IN_DATA;
|
||||||
handle_datastage_in ();
|
handle_datastage_in ();
|
||||||
}
|
}
|
||||||
else
|
else if (ctrl_p->wLength == 0)
|
||||||
|
{
|
||||||
|
dev_p->state = WAIT_STATUS_IN;
|
||||||
|
st103_set_tx_count (ENDP0, 0);
|
||||||
|
st103_ep_set_rxtx_status (ENDP0, EP_RX_STALL, EP_TX_VALID);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
dev_p->state = OUT_DATA;
|
dev_p->state = OUT_DATA;
|
||||||
st103_ep_set_rx_status (ENDP0, EP_RX_VALID);
|
st103_ep_set_rxtx_status (ENDP0, EP_RX_VALID, EP_TX_STALL);
|
||||||
/* enable for next data reception */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -866,7 +857,7 @@ static void handle_out0 (void)
|
|||||||
if (dev_p->state == IN_DATA || dev_p->state == LAST_IN_DATA)
|
if (dev_p->state == IN_DATA || dev_p->state == LAST_IN_DATA)
|
||||||
/* host aborts the transfer before finish */
|
/* host aborts the transfer before finish */
|
||||||
dev_p->state = STALLED;
|
dev_p->state = STALLED;
|
||||||
else if (dev_p->state == OUT_DATA || dev_p->state == LAST_OUT_DATA)
|
else if (dev_p->state == OUT_DATA)
|
||||||
handle_datastage_out ();
|
handle_datastage_out ();
|
||||||
else if (dev_p->state == WAIT_STATUS_OUT)
|
else if (dev_p->state == WAIT_STATUS_OUT)
|
||||||
dev_p->state = STALLED;
|
dev_p->state = STALLED;
|
||||||
|
|||||||
Reference in New Issue
Block a user