git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4595 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
34310e401f
commit
44603763e1
|
@ -353,17 +353,22 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
|
||||||
static USBInEndpointState ep1instate;
|
static USBInEndpointState ep1instate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief EP1 initialization structure (IN only).
|
* @brief OUT EP1 state.
|
||||||
|
*/
|
||||||
|
static USBOutEndpointState ep1outstate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EP1 initialization structure (both IN and OUT).
|
||||||
*/
|
*/
|
||||||
static const USBEndpointConfig ep1config = {
|
static const USBEndpointConfig ep1config = {
|
||||||
USB_EP_MODE_TYPE_BULK,
|
USB_EP_MODE_TYPE_BULK,
|
||||||
NULL,
|
NULL,
|
||||||
sduDataTransmitted,
|
sduDataTransmitted,
|
||||||
NULL,
|
sduDataReceived,
|
||||||
|
0x0040,
|
||||||
0x0040,
|
0x0040,
|
||||||
0x0000,
|
|
||||||
&ep1instate,
|
&ep1instate,
|
||||||
NULL,
|
&ep1outstate,
|
||||||
2,
|
2,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
@ -371,7 +376,7 @@ static const USBEndpointConfig ep1config = {
|
||||||
/**
|
/**
|
||||||
* @brief IN EP2 state.
|
* @brief IN EP2 state.
|
||||||
*/
|
*/
|
||||||
USBInEndpointState ep2instate;
|
static USBInEndpointState ep2instate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief EP2 initialization structure (IN only).
|
* @brief EP2 initialization structure (IN only).
|
||||||
|
@ -389,27 +394,6 @@ static const USBEndpointConfig ep2config = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief OUT EP2 state.
|
|
||||||
*/
|
|
||||||
USBOutEndpointState ep3outstate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EP3 initialization structure (OUT only).
|
|
||||||
*/
|
|
||||||
static const USBEndpointConfig ep3config = {
|
|
||||||
USB_EP_MODE_TYPE_BULK,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sduDataReceived,
|
|
||||||
0x0000,
|
|
||||||
0x0040,
|
|
||||||
NULL,
|
|
||||||
&ep3outstate,
|
|
||||||
0,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handles the USB driver global events.
|
* Handles the USB driver global events.
|
||||||
*/
|
*/
|
||||||
|
@ -428,7 +412,6 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
|
||||||
must be used.*/
|
must be used.*/
|
||||||
usbInitEndpointI(usbp, USB_CDC_DATA_REQUEST_EP, &ep1config);
|
usbInitEndpointI(usbp, USB_CDC_DATA_REQUEST_EP, &ep1config);
|
||||||
usbInitEndpointI(usbp, USB_CDC_INTERRUPT_REQUEST_EP, &ep2config);
|
usbInitEndpointI(usbp, USB_CDC_INTERRUPT_REQUEST_EP, &ep2config);
|
||||||
usbInitEndpointI(usbp, USB_CDC_DATA_AVAILABLE_EP, &ep3config);
|
|
||||||
|
|
||||||
/* Resetting the state of the CDC subsystem.*/
|
/* Resetting the state of the CDC subsystem.*/
|
||||||
sduConfigureHookI(usbp);
|
sduConfigureHookI(usbp);
|
||||||
|
@ -446,16 +429,20 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Serial over USB driver configuration.
|
* USB driver configuration.
|
||||||
*/
|
*/
|
||||||
static const SerialUSBConfig serusbcfg = {
|
static const USBConfig usbcfg = {
|
||||||
&USBD1,
|
|
||||||
{
|
|
||||||
usb_event,
|
usb_event,
|
||||||
get_descriptor,
|
get_descriptor,
|
||||||
sduRequestsHook,
|
sduRequestsHook,
|
||||||
NULL
|
NULL
|
||||||
}
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Serial over USB driver configuration.
|
||||||
|
*/
|
||||||
|
static const SerialUSBConfig serusbcfg = {
|
||||||
|
&USBD1
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -627,12 +614,19 @@ int main(void) {
|
||||||
chSysInit();
|
chSysInit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Activates the shell on the USB-CDC.
|
* Initializes a serial-over-USB CDC driver.
|
||||||
|
*/
|
||||||
|
sduObjectInit(&SDU1);
|
||||||
|
sduStart(&SDU1, &serusbcfg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activates the USB driver and then the USB bus pull-up on D+.
|
||||||
|
* Note, a delay is inserted in order to not have to disconnect the cable
|
||||||
|
* after a reset.
|
||||||
*/
|
*/
|
||||||
usbDisconnectBus(serusbcfg.usbp);
|
usbDisconnectBus(serusbcfg.usbp);
|
||||||
chThdSleepMilliseconds(1000);
|
chThdSleepMilliseconds(1000);
|
||||||
sduObjectInit(&SDU1);
|
usbStart(serusbcfg.usbp, &usbcfg);
|
||||||
sduStart(&SDU1, &serusbcfg);
|
|
||||||
usbConnectBus(serusbcfg.usbp);
|
usbConnectBus(serusbcfg.usbp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -408,9 +408,7 @@ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
|
||||||
|
|
||||||
while (chnGetTimeout((BaseChannel *)chp, TIME_IMMEDIATE) == Q_TIMEOUT) {
|
while (chnGetTimeout((BaseChannel *)chp, TIME_IMMEDIATE) == Q_TIMEOUT) {
|
||||||
chSequentialStreamWrite(&SDU1, buf, sizeof buf - 1);
|
chSequentialStreamWrite(&SDU1, buf, sizeof buf - 1);
|
||||||
// palTogglePad(GPIOD, GPIOD_LED4);
|
|
||||||
}
|
}
|
||||||
// palClearPad(GPIOD, GPIOD_LED4);
|
|
||||||
chprintf(chp, "\r\n\nstopped\r\n");
|
chprintf(chp, "\r\n\nstopped\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue