working now
This commit is contained in:
@@ -350,13 +350,15 @@ extern Thread *main_thread;
|
||||
extern void led_blink (int spec);
|
||||
|
||||
#if defined(PINPAD_SUPPORT)
|
||||
#if defined(PINPAD_CIR_SUPPORT)
|
||||
# if defined(PINPAD_CIR_SUPPORT)
|
||||
extern void cir_ext_disable (void);
|
||||
extern void cir_ext_enable (void);
|
||||
#elif defined(PINPAD_DIAL_SUPPORT)
|
||||
# elif defined(PINPAD_DIAL_SUPPORT)
|
||||
extern void dial_sw_disable (void);
|
||||
extern void dial_sw_enable (void);
|
||||
#endif
|
||||
# elif defined(PINPAD_DND_SUPPORT)
|
||||
extern void msc_init (void);
|
||||
# endif
|
||||
#define PIN_INPUT_CURRENT 1
|
||||
#define PIN_INPUT_NEW 2
|
||||
#define PIN_INPUT_CONFIRM 3
|
||||
|
||||
@@ -386,12 +386,17 @@ main (int argc, char **argv)
|
||||
chThdCreateStatic (waUSBthread, sizeof(waUSBthread),
|
||||
NORMALPRIO, USBthread, NULL);
|
||||
|
||||
#ifdef PINPAD_DND_SUPPORT
|
||||
msc_init ();
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
eventmask_t m;
|
||||
|
||||
count++;
|
||||
m = chEvtWaitOneTimeout (ALL_EVENTS, LED_TIMEOUT_INTERVAL);
|
||||
continue;
|
||||
switch (m)
|
||||
{
|
||||
case LED_STATUS_MODE:
|
||||
|
||||
@@ -26,10 +26,11 @@ pinpad_getline (int msg_code, systime_t timeout)
|
||||
|
||||
pin_input_len = 0;
|
||||
|
||||
msc_media_insert_change (1);
|
||||
|
||||
while (1)
|
||||
{
|
||||
chSysLock ();
|
||||
msc_media_insert_change (1);
|
||||
pin_thread = chThdSelf ();
|
||||
chSchGoSleepS (THD_STATE_SUSPENDED);
|
||||
msg = chThdSelf ()->p_u.rdymsg;
|
||||
@@ -253,12 +254,8 @@ msc_scsi_read (uint32_t lba, const uint8_t **sector_p)
|
||||
|
||||
static void parse_directory_sector (const uint8_t *p, uint8_t index)
|
||||
{
|
||||
uint16_t cluster_no = FOLDER_INDEX_TO_CLUSTER_NO (index);
|
||||
int i;
|
||||
uint8_t filename[11] = { 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20 };
|
||||
uint8_t child;
|
||||
uint8_t *p_orig = p;
|
||||
int input = 0;
|
||||
int num_children = 0;
|
||||
|
||||
@@ -290,7 +287,7 @@ static void parse_directory_sector (const uint8_t *p, uint8_t index)
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if (*p)
|
||||
if (*p >= 'A' && *p <= 'G')
|
||||
{
|
||||
child = DIRCHAR_TO_FOLDER_INDEX (*p);
|
||||
folders[index].children[i] = child;
|
||||
@@ -308,7 +305,7 @@ static void parse_directory_sector (const uint8_t *p, uint8_t index)
|
||||
}
|
||||
|
||||
int
|
||||
msc_scsi_write (uint8_t lun, uint32_t lba, const uint8_t *buf, size_t size)
|
||||
msc_scsi_write (uint32_t lba, const uint8_t *buf, size_t size)
|
||||
{
|
||||
if (!media_available)
|
||||
return SCSI_ERROR_NOT_READY;
|
||||
@@ -316,6 +313,9 @@ msc_scsi_write (uint8_t lun, uint32_t lba, const uint8_t *buf, size_t size)
|
||||
if (lba >= TOTAL_SECTOR)
|
||||
return SCSI_ERROR_ILLEAGAL_REQUEST;
|
||||
|
||||
if (lba == 1)
|
||||
return 0; /* ??? */
|
||||
|
||||
if (lba <= 2 || lba >= 11)
|
||||
return SCSI_ERROR_DATA_PROTECT;
|
||||
else
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
#ifndef __USB_CONF_H
|
||||
#define __USB_CONF_H
|
||||
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
#define EP_NUM (6)
|
||||
#ifdef PINPAD_DND_SUPPORT
|
||||
# define EP_NUM (8)
|
||||
#else
|
||||
#define EP_NUM (3)
|
||||
# ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
# define EP_NUM (6)
|
||||
# else
|
||||
# define EP_NUM (3)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define BTABLE_ADDRESS (0x00)
|
||||
|
||||
@@ -95,6 +95,10 @@ static void usb_start_receive (uint8_t *p, size_t n)
|
||||
ep7_out.rxbuf = p;
|
||||
ep7_out.rxsize = n;
|
||||
ep7_out.rxcnt = 0;
|
||||
if (n < ENDP_MAX_SIZE)
|
||||
SetEPRxCount (ENDP7, n);
|
||||
else
|
||||
SetEPRxCount (ENDP7, ENDP_MAX_SIZE);
|
||||
SetEPRxValid (ENDP7);
|
||||
}
|
||||
|
||||
@@ -131,7 +135,7 @@ void EP7_OUT_Callback (void)
|
||||
chSysLockFromIsr ();
|
||||
tp = the_thread;
|
||||
the_thread = NULL;
|
||||
tp->p_u.rdymsg = err? RDY_OK : RDY_RESET;
|
||||
tp->p_u.rdymsg = err? RDY_RESET : RDY_OK;
|
||||
chSchReadyI (tp);
|
||||
chSysUnlockFromIsr ();
|
||||
}
|
||||
@@ -299,9 +303,12 @@ void msc_handle_command (void)
|
||||
{
|
||||
/* Error occured, ignore the request and go into error state */
|
||||
msc_state = MSC_ERROR;
|
||||
chSysLock ();
|
||||
usb_stall_receive ();
|
||||
chSysUnlock ();
|
||||
if (msg != RDY_TIMEOUT)
|
||||
{
|
||||
chSysLock ();
|
||||
usb_stall_receive ();
|
||||
chSysUnlock ();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,20 @@ gnuk_device_reset (void)
|
||||
SetEPTxStatus (ENDP5, EP_TX_DIS);
|
||||
#endif
|
||||
|
||||
#ifdef PINPAD_DND_SUPPORT
|
||||
/* Initialize Endpoint 6 */
|
||||
SetEPType (ENDP6, EP_BULK);
|
||||
SetEPTxAddr (ENDP6, ENDP6_TXADDR);
|
||||
SetEPTxStatus (ENDP6, EP_TX_NAK);
|
||||
SetEPRxStatus (ENDP6, EP_RX_DIS);
|
||||
|
||||
/* Initialize Endpoint 7 */
|
||||
SetEPType (ENDP7, EP_BULK);
|
||||
SetEPRxAddr (ENDP7, ENDP7_RXADDR);
|
||||
SetEPRxStatus (ENDP7, EP_RX_STALL);
|
||||
SetEPTxStatus (ENDP7, EP_TX_DIS);
|
||||
#endif
|
||||
|
||||
/* Set this device to response on default address */
|
||||
SetDeviceAddress (0);
|
||||
|
||||
@@ -157,6 +171,21 @@ gnuk_device_SetInterface (void)
|
||||
ClearDTOG_TX (ENDP3);
|
||||
}
|
||||
#endif
|
||||
#ifdef PINPAD_DND_SUPPORT
|
||||
# ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
else if (intf == 3)
|
||||
{
|
||||
ClearDTOG_TX (ENDP6);
|
||||
ClearDTOG_RX (ENDP7);
|
||||
}
|
||||
# else
|
||||
else if (intf == 1)
|
||||
{
|
||||
ClearDTOG_TX (ENDP6);
|
||||
ClearDTOG_RX (ENDP7);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -204,10 +233,18 @@ gnuk_device_GetStringDescriptor (uint16_t Length)
|
||||
(PONE_DESCRIPTOR)&String_Descriptor[wValue0]);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
#define NUM_INTERFACES 3 /* two for CDC, one for CCID */
|
||||
#ifdef PINPAD_DND_SUPPORT
|
||||
# ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
# define NUM_INTERFACES 4 /* two for CDC, one for CCID, and MSC */
|
||||
# else
|
||||
# define NUM_INTERFACES 2 /* CCID and MSC */
|
||||
# endif
|
||||
#else
|
||||
#define NUM_INTERFACES 1 /* CCID only */
|
||||
# ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
# define NUM_INTERFACES 3 /* two for CDC, one for CCID */
|
||||
# else
|
||||
# define NUM_INTERFACES 1 /* CCID only */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static RESULT
|
||||
|
||||
Reference in New Issue
Block a user