mirror of
https://salsa.debian.org/gnuk-team/gnuk/gnuk.git
synced 2024-09-20 02:40:08 +00:00
fix usb_lld.c
This commit is contained in:
parent
429c6f3d8b
commit
f2afeacdcb
@ -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>
|
||||
|
||||
* 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
|
||||
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
|
||||
release of source code.
|
||||
release of the source code.
|
||||
|
||||
When you are modifing Gnuk and installing the binary to device, you
|
||||
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.
|
||||
(There a file 'GNUK_SERIAL_NUMBER' in the official release.)
|
||||
|
||||
FSIJ could permit companies or business entities to use USB device ID
|
||||
of FSIJ for devices with unmodified version of Gnuk, provided they
|
||||
support Free Software and respect users' freedom for computing.
|
||||
Please ask FSIJ for permission.
|
||||
FSIJ could give companies or business entities "second source
|
||||
manufacturer" license to use USB device ID of FSIJ for devices with
|
||||
unmodified version of Gnuk, provided they support Free Software and
|
||||
respect users' freedom for computing. Please ask FSIJ for the
|
||||
license.
|
||||
|
||||
Otherwise, companies which want to distribute Gnuk devices, please use
|
||||
your own USB vendor ID and product ID. When you modify Gnuk, please
|
||||
replace "FSIJ" in the string gnukStringSerial (usb_desc.c) to yours.
|
||||
your own USB vendor ID and product ID. Note that please replace
|
||||
"FSIJ" in the string gnukStringSerial (usb_desc.c) to yours, when you
|
||||
modify Gnuk.
|
||||
|
||||
|
||||
Host Requirements
|
||||
|
@ -27,16 +27,15 @@ enum STANDARD_REQUESTS
|
||||
/* The state machine states of a control pipe */
|
||||
enum CONTROL_STATE
|
||||
{
|
||||
WAIT_SETUP, /* 0 */
|
||||
SETTING_UP, /* 1 */
|
||||
IN_DATA, /* 2 */
|
||||
OUT_DATA, /* 3 */
|
||||
LAST_IN_DATA, /* 4 */
|
||||
LAST_OUT_DATA, /* 5 */
|
||||
WAIT_STATUS_IN, /* 7 */
|
||||
WAIT_STATUS_OUT, /* 8 */
|
||||
STALLED, /* 9 */
|
||||
PAUSE /* 10 */
|
||||
WAIT_SETUP,
|
||||
SETTING_UP,
|
||||
IN_DATA,
|
||||
OUT_DATA,
|
||||
LAST_IN_DATA,
|
||||
WAIT_STATUS_IN,
|
||||
WAIT_STATUS_OUT,
|
||||
STALLED,
|
||||
PAUSE
|
||||
};
|
||||
|
||||
enum FEATURE_SELECTOR
|
||||
@ -400,24 +399,17 @@ static void handle_datastage_out (void)
|
||||
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_set_tx_count (ENDP0, 0);
|
||||
st103_ep_set_tx_status (ENDP0, EP_TX_VALID);
|
||||
dev_p->state = OUT_DATA;
|
||||
}
|
||||
|
||||
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)
|
||||
@ -437,10 +429,11 @@ static void handle_datastage_in (void)
|
||||
}
|
||||
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;
|
||||
st103_ep_set_tx_status (ENDP0, EP_TX_STALL);
|
||||
st103_ep_set_rxtx_status (ENDP0, EP_RX_VALID, EP_TX_STALL);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -451,11 +444,10 @@ static void handle_datastage_in (void)
|
||||
|
||||
buf = (const uint8_t *)data_p->addr + data_p->offset;
|
||||
usb_lld_to_pmabuf (buf, st103_get_tx_addr (ENDP0), len);
|
||||
st103_set_tx_count (ENDP0, len);
|
||||
|
||||
data_p->len -= 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,
|
||||
@ -781,7 +773,6 @@ static void handle_setup0 (void)
|
||||
pw++;
|
||||
ctrl_p->wLength = *pw;
|
||||
|
||||
dev_p->state = STALLED;
|
||||
data_p->len = 0;
|
||||
data_p->offset = 0;
|
||||
|
||||
@ -812,13 +803,7 @@ static void handle_setup0 (void)
|
||||
dev_p->state = STALLED;
|
||||
else
|
||||
{
|
||||
if (ctrl_p->wLength == 0)
|
||||
{
|
||||
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)
|
||||
if (ctrl_p->bmRequestType & 0x80)
|
||||
{
|
||||
uint32_t len = ctrl_p->wLength;
|
||||
|
||||
@ -831,13 +816,19 @@ static void handle_setup0 (void)
|
||||
else
|
||||
data_p->require_zlp = FALSE;
|
||||
|
||||
dev_p->state = IN_DATA;
|
||||
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;
|
||||
st103_ep_set_rx_status (ENDP0, EP_RX_VALID);
|
||||
/* enable for next data reception */
|
||||
st103_ep_set_rxtx_status (ENDP0, EP_RX_VALID, EP_TX_STALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -866,7 +857,7 @@ static void handle_out0 (void)
|
||||
if (dev_p->state == IN_DATA || dev_p->state == LAST_IN_DATA)
|
||||
/* host aborts the transfer before finish */
|
||||
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 ();
|
||||
else if (dev_p->state == WAIT_STATUS_OUT)
|
||||
dev_p->state = STALLED;
|
||||
|
Loading…
Reference in New Issue
Block a user