mirror of
https://salsa.debian.org/gnuk-team/gnuk/gnuk.git
synced 2024-09-20 02:40:08 +00:00
let device runs with three interfaces.
This commit is contained in:
parent
e6116828c5
commit
d42a45c1ee
15
README
15
README
@ -15,3 +15,18 @@ Taken from http://github.com/robots/STM32.git
|
||||
|
||||
* USBCDC
|
||||
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 \
|
||||
$(STMUSBSRC) \
|
||||
$(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
|
||||
ASMSRC = $(PORTASM) \
|
||||
|
@ -70,7 +70,7 @@ stdout_init (void)
|
||||
stdout.str = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
_write (const char *s, int size)
|
||||
{
|
||||
if (size == 0)
|
||||
@ -160,6 +160,9 @@ static msg_t Thread2 (void *arg)
|
||||
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
|
||||
* on entry.
|
||||
@ -185,6 +188,8 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
chThdCreateStatic (waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
|
||||
|
||||
chThdCreateStatic (waUSBThread, sizeof(waUSBThread), NORMALPRIO, USBThread, NULL);
|
||||
|
||||
while (1)
|
||||
{
|
||||
#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
|
||||
0 bMessageType 0x62
|
||||
1 dwLength 0x00000000
|
||||
@ -146,3 +177,19 @@ RDR_to_PC_DataBlock
|
||||
|
||||
PC_to_RDR_XfrBlock
|
||||
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 */
|
||||
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||
0xC0, /* bmAttributes: self powered */
|
||||
0x32, /* MaxPower 0 mA */
|
||||
50, /* MaxPower 100 mA */
|
||||
|
||||
/* Interface Descriptor */
|
||||
9, /* bLength: Interface Descriptor size */
|
||||
@ -53,7 +53,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
||||
/* ICC Descriptor */
|
||||
54, /* bLength: */
|
||||
0x21, /* bDescriptorType: USBDESCR_ICC */
|
||||
0x10, 0x01, /* bcdCCID: 1.1 */
|
||||
0x10, 0x01, /* bcdCCID: 1.1 XXX */
|
||||
0, /* bMaxSlotIndex: */
|
||||
1, /* bVoltageSupport: FIXED VALUE */
|
||||
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, /* dwMechanical: FIXED VALUE */
|
||||
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, /* bClassEnvelope: */
|
||||
0, 0, /* wLCDLayout: FIXED VALUE */
|
||||
@ -109,7 +109,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x01, /* bDescriptorSubtype: Call Management Func Desc */
|
||||
0x00, /* bmCapabilities: D0+D1 */
|
||||
0x01, /* bDataInterface: 1 */
|
||||
0x02, /* bDataInterface: 1 */
|
||||
/*ACM Functional Descriptor*/
|
||||
4, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
@ -119,8 +119,8 @@ static const uint8_t gnukConfigDescriptor[] = {
|
||||
5, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x06, /* bDescriptorSubtype: Union func desc */
|
||||
0x00, /* bMasterInterface: Communication class interface */
|
||||
0x01, /* bSlaveInterface0: Data Class Interface */
|
||||
0x01, /* bMasterInterface: Communication class interface */
|
||||
0x02, /* bSlaveInterface0: Data Class Interface */
|
||||
/*Endpoint 2 Descriptor*/
|
||||
7, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
|
||||
|
Loading…
Reference in New Issue
Block a user