support Board

This commit is contained in:
NIIBE Yutaka
2015-07-15 16:37:19 +09:00
parent 6a8f8dffcb
commit 8ddcc1e896
9 changed files with 70 additions and 26 deletions

6
src/configure vendored
View File

@@ -252,7 +252,11 @@ SERIALNO="FSIJ-`cat ../VERSION | sed -e 's%^[^/]*/%%'`-"
SERIALNO_STR_LEN_DEFINE="#define SERIALNO_STR_LEN ${#SERIALNO}"
CONFIG="$target:dfu=$with_dfu:debug=$debug:pinpad=$pinpad:certdo=$certdo:keygen=$keygen"
if test "$sys1_compat" = "yes"; then
CONFIG="$target:dfu=$with_dfu:debug=$debug:pinpad=$pinpad:certdo=$certdo:keygen=$keygen"
else
CONFIG="dfu=$with_dfu:debug=$debug:pinpad=$pinpad:certdo=$certdo:keygen=$keygen"
fi
if !(IFS=" "
while read VIDPID VERSION PRODUCT VENDOR; do

View File

@@ -3,7 +3,6 @@
#ifndef __USB_CONF_H
#define __USB_CONF_H
#define NUM_STRING_DESC 7
#define ICC_NUM_INTERFACES 1
#define ICC_INTERFACE 0
#ifdef HID_CARD_CHANGE_SUPPORT

View File

@@ -478,7 +478,7 @@ int usb_cb_handle_event (uint8_t event_type, uint16_t value)
int usb_cb_interface (uint8_t cmd, uint16_t interface, uint16_t alt)
{
static const uint8_t zero = 0;
const uint8_t zero = 0;
if (interface >= NUM_INTERFACES)
return USB_UNSUPPORT;
@@ -495,7 +495,8 @@ int usb_cb_interface (uint8_t cmd, uint16_t interface, uint16_t alt)
}
case USB_GET_INTERFACE:
usb_lld_set_data_to_send (&zero, 1);
usb_lld_write (ENDP0, &zero, 1);
usb_lld_set_data_to_send (NULL, 1);
return USB_SUCCESS;
default:

View File

@@ -330,7 +330,7 @@ struct desc
uint16_t size;
};
static const struct desc String_Descriptors[NUM_STRING_DESC] = {
static const struct desc string_descriptors[] = {
{gnukStringLangID, sizeof (gnukStringLangID)},
{gnukStringVendor, sizeof (gnukStringVendor)},
{gnukStringProduct, sizeof (gnukStringProduct)},
@@ -339,13 +339,14 @@ static const struct desc String_Descriptors[NUM_STRING_DESC] = {
{gnuk_config_options, sizeof (gnuk_config_options)},
{sys_version, sizeof (sys_version)},
};
#define NUM_STRING_DESC (sizeof (string_descriptors) / sizeof (struct desc))
#define USB_DT_HID 0x21
#define USB_DT_REPORT 0x22
int
usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
uint16_t index)
uint16_t index, uint16_t length)
{
if (rcp == DEVICE_RECIPIENT)
{
@@ -365,8 +366,30 @@ usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
{
if (desc_index < NUM_STRING_DESC)
{
usb_lld_set_data_to_send (String_Descriptors[desc_index].desc,
String_Descriptors[desc_index].size);
usb_lld_set_data_to_send (string_descriptors[desc_index].desc,
string_descriptors[desc_index].size);
return USB_SUCCESS;
}
else if (desc_index == NUM_STRING_DESC)
{
uint8_t usbbuf[64];
int i;
size_t len;
for (i = 0; i < (int)sizeof (usbbuf)/2 - 2; i++)
{
if (sys_board_name[i] == 0)
break;
usbbuf[i*2+2] = sys_board_name[i];
usbbuf[i*2+3] = 0;
}
usbbuf[0] = len = i*2 + 2;
usbbuf[1] = USB_STRING_DESCRIPTOR_TYPE;
if (len > length)
len = length;
usb_lld_write (ENDP0, usbbuf, len);
usb_lld_set_data_to_send (NULL, len);
return USB_SUCCESS;
}
}
@@ -392,15 +415,6 @@ usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
#else
(void)index;
#endif
if (desc_type == STRING_DESCRIPTOR)
{
if (desc_index < NUM_STRING_DESC)
{
usb_lld_set_data_to_send (String_Descriptors[desc_index].desc,
String_Descriptors[desc_index].size);
return USB_SUCCESS;
}
}
}
return USB_UNSUPPORT;

View File

@@ -61,7 +61,7 @@ void usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no,
int usb_cb_setup (uint8_t req, uint8_t req_no, uint16_t value,
uint16_t index, uint16_t len);
int usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
uint16_t index);
uint16_t index, uint16_t length);
int usb_cb_handle_event (uint8_t event_type, uint16_t value);
int usb_cb_interface (uint8_t cmd, uint16_t interface, uint16_t value);

View File

@@ -698,7 +698,8 @@ static int std_get_descriptor (uint8_t req, uint16_t value,
return USB_UNSUPPORT;
(void)length;
return usb_cb_get_descriptor (rcp, (value >> 8), (value & 0xff), index);
return usb_cb_get_descriptor (rcp, (value >> 8), (value & 0xff),
index, length);
}
static int std_get_configuration (uint8_t req, uint16_t value,
@@ -851,13 +852,22 @@ static void handle_setup0 (void)
if (data_p->len > len)
data_p->len = len;
if ((data_p->len % USB_MAX_PACKET_SIZE) == 0)
if (data_p->len != 0 && (data_p->len % USB_MAX_PACKET_SIZE) == 0)
data_p->require_zlp = TRUE;
else
data_p->require_zlp = FALSE;
dev_p->state = IN_DATA;
handle_datastage_in ();
if (data_p->addr == NULL)
{
/* usb_lld_wite was called already by the setup callback. */
dev_p->state = LAST_IN_DATA;
data_p->len = 0;
}
else
{
dev_p->state = IN_DATA;
handle_datastage_in ();
}
}
else if (ctrl_p->wLength == 0)
{