let device runs with three interfaces.
This commit is contained in:
15
README
15
README
@@ -15,3 +15,18 @@ Taken from http://github.com/robots/STM32.git
|
|||||||
|
|
||||||
* USBCDC
|
* USBCDC
|
||||||
Taken from http://github.com/robots/STM32.git
|
Taken from http://github.com/robots/STM32.git
|
||||||
|
|
||||||
|
|
||||||
|
HOWTO RUN
|
||||||
|
=================
|
||||||
|
|
||||||
|
$ openocd -f interface/olimex-jtag-tiny.cfg -f board/olimex_stm32_h103.cfg
|
||||||
|
|
||||||
|
$ arm-none-eabi-gdb --annotate=3 gnuk.elf
|
||||||
|
|
||||||
|
$ telnet localhost 4444
|
||||||
|
> reset halt
|
||||||
|
> flash write_image erase gnuk.elf
|
||||||
|
> reset
|
||||||
|
> exit
|
||||||
|
$
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ CSRC = $(PORTSRC) \
|
|||||||
$(CHIBIOS)/os/various/syscalls.c \
|
$(CHIBIOS)/os/various/syscalls.c \
|
||||||
$(STMUSBSRC) \
|
$(STMUSBSRC) \
|
||||||
$(USBCDCSRC) \
|
$(USBCDCSRC) \
|
||||||
main.c hw_config.c usb_lld.c usb_desc.c usb_prop.c
|
main.c hw_config.c usb_lld.c usb_desc.c usb_prop.c usb.c
|
||||||
|
|
||||||
# List ASM source files here
|
# List ASM source files here
|
||||||
ASMSRC = $(PORTASM) \
|
ASMSRC = $(PORTASM) \
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ stdout_init (void)
|
|||||||
stdout.str = NULL;
|
stdout.str = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
_write (const char *s, int size)
|
_write (const char *s, int size)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
@@ -160,6 +160,9 @@ static msg_t Thread2 (void *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static WORKING_AREA(waUSBThread, 128);
|
||||||
|
extern msg_t USBThread (void *arg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Entry point, note, the main() function is already a thread in the system
|
* Entry point, note, the main() function is already a thread in the system
|
||||||
* on entry.
|
* on entry.
|
||||||
@@ -185,6 +188,8 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
chThdCreateStatic (waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
|
chThdCreateStatic (waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
|
||||||
|
|
||||||
|
chThdCreateStatic (waUSBThread, sizeof(waUSBThread), NORMALPRIO, USBThread, NULL);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
47
src/usb.c
47
src/usb.c
@@ -21,6 +21,37 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ch.h"
|
||||||
|
#include "hal.h"
|
||||||
|
|
||||||
|
#include "usb_lib.h"
|
||||||
|
#include "usb_desc.h"
|
||||||
|
#include "usb_mem.h"
|
||||||
|
#include "hw_config.h"
|
||||||
|
#include "usb_istr.h"
|
||||||
|
|
||||||
|
static uint8_t icc_buffer_out[64];
|
||||||
|
static uint8_t icc_buffer_in[64];
|
||||||
|
|
||||||
|
static __IO uint32_t icc_count_out = 0;
|
||||||
|
static uint32_t icc_count_in = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
EP4_IN_Callback(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EP5_OUT_Callback(void)
|
||||||
|
{
|
||||||
|
/* Get the received data buffer and update the counter */
|
||||||
|
icc_count_out = USB_SIL_Read (EP5_OUT, icc_buffer_out);
|
||||||
|
|
||||||
|
/* Enable the receive of data on EP5 */
|
||||||
|
SetEPRxValid (ENDP5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
#define ICC_POWER_ON 0x62
|
#define ICC_POWER_ON 0x62
|
||||||
0 bMessageType 0x62
|
0 bMessageType 0x62
|
||||||
1 dwLength 0x00000000
|
1 dwLength 0x00000000
|
||||||
@@ -146,3 +177,19 @@ RDR_to_PC_DataBlock
|
|||||||
|
|
||||||
PC_to_RDR_XfrBlock
|
PC_to_RDR_XfrBlock
|
||||||
RDR_to_PC_DataBlock
|
RDR_to_PC_DataBlock
|
||||||
|
#endif
|
||||||
|
|
||||||
|
msg_t
|
||||||
|
USBThread (void *arg)
|
||||||
|
{
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
while (icc_count_out == 0)
|
||||||
|
chThdSleepMilliseconds (1);
|
||||||
|
|
||||||
|
_write ("!\r\n", 3);
|
||||||
|
icc_count_out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
|||||||
0x01, /* bConfigurationValue: Configuration value */
|
0x01, /* bConfigurationValue: Configuration value */
|
||||||
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
|
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||||
0xC0, /* bmAttributes: self powered */
|
0xC0, /* bmAttributes: self powered */
|
||||||
0x32, /* MaxPower 0 mA */
|
50, /* MaxPower 100 mA */
|
||||||
|
|
||||||
/* Interface Descriptor */
|
/* Interface Descriptor */
|
||||||
9, /* bLength: Interface Descriptor size */
|
9, /* bLength: Interface Descriptor size */
|
||||||
@@ -53,7 +53,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
|||||||
/* ICC Descriptor */
|
/* ICC Descriptor */
|
||||||
54, /* bLength: */
|
54, /* bLength: */
|
||||||
0x21, /* bDescriptorType: USBDESCR_ICC */
|
0x21, /* bDescriptorType: USBDESCR_ICC */
|
||||||
0x10, 0x01, /* bcdCCID: 1.1 */
|
0x10, 0x01, /* bcdCCID: 1.1 XXX */
|
||||||
0, /* bMaxSlotIndex: */
|
0, /* bMaxSlotIndex: */
|
||||||
1, /* bVoltageSupport: FIXED VALUE */
|
1, /* bVoltageSupport: FIXED VALUE */
|
||||||
0x02, 0, 0, 0, /* dwProtocols: T=1 */
|
0x02, 0, 0, 0, /* dwProtocols: T=1 */
|
||||||
@@ -67,7 +67,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
|||||||
0, 0, 0, 0, /* dwSynchProtocols: FIXED VALUE */
|
0, 0, 0, 0, /* dwSynchProtocols: FIXED VALUE */
|
||||||
0, 0, 0, 0, /* dwMechanical: FIXED VALUE */
|
0, 0, 0, 0, /* dwMechanical: FIXED VALUE */
|
||||||
0x40, 0x08, 0x04, 0x00, /* dwFeatures: Short and extended ADPU level */
|
0x40, 0x08, 0x04, 0x00, /* dwFeatures: Short and extended ADPU level */
|
||||||
0x0f, 0x01, 0, 0, /* dwMaxCCIDMessageLength: 261+10 */
|
0x0f, 0x01, 0, 0, /* dwMaxCCIDMessageLength: 261+10 XXX */
|
||||||
0xff, /* bClassGetResponse: */
|
0xff, /* bClassGetResponse: */
|
||||||
0xff, /* bClassEnvelope: */
|
0xff, /* bClassEnvelope: */
|
||||||
0, 0, /* wLCDLayout: FIXED VALUE */
|
0, 0, /* wLCDLayout: FIXED VALUE */
|
||||||
@@ -109,7 +109,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
|||||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||||
0x01, /* bDescriptorSubtype: Call Management Func Desc */
|
0x01, /* bDescriptorSubtype: Call Management Func Desc */
|
||||||
0x00, /* bmCapabilities: D0+D1 */
|
0x00, /* bmCapabilities: D0+D1 */
|
||||||
0x01, /* bDataInterface: 1 */
|
0x02, /* bDataInterface: 1 */
|
||||||
/*ACM Functional Descriptor*/
|
/*ACM Functional Descriptor*/
|
||||||
4, /* bFunctionLength */
|
4, /* bFunctionLength */
|
||||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||||
@@ -119,8 +119,8 @@ static const uint8_t gnukConfigDescriptor[] = {
|
|||||||
5, /* bFunctionLength */
|
5, /* bFunctionLength */
|
||||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||||
0x06, /* bDescriptorSubtype: Union func desc */
|
0x06, /* bDescriptorSubtype: Union func desc */
|
||||||
0x00, /* bMasterInterface: Communication class interface */
|
0x01, /* bMasterInterface: Communication class interface */
|
||||||
0x01, /* bSlaveInterface0: Data Class Interface */
|
0x02, /* bSlaveInterface0: Data Class Interface */
|
||||||
/*Endpoint 2 Descriptor*/
|
/*Endpoint 2 Descriptor*/
|
||||||
7, /* bLength: Endpoint Descriptor size */
|
7, /* bLength: Endpoint Descriptor size */
|
||||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||||
|
|||||||
Reference in New Issue
Block a user