This commit is contained in:
rushxrushx
2022-07-13 16:52:50 +08:00
parent e92d4ca714
commit 7d6c32cd77
131 changed files with 74090 additions and 0 deletions
+694
View File
@@ -0,0 +1,694 @@
/*----------------------------------------------------------------------------
* RL-ARM - A P I
*----------------------------------------------------------------------------
* Name: RTL.H
* Purpose: Application Programming Interface
* Rev.: V4.73
*----------------------------------------------------------------------------
* This code is part of the RealView Run-Time Library.
* Copyright (c) 2004-2014 KEIL - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/
#ifndef __RTL_H__
#define __RTL_H__
/* RL-ARM version number. */
#define __RL_ARM_VER 473
#define __task __declspec(noreturn)
#define __used __attribute__((used))
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *) 0)
#endif
#endif
#ifndef EOF
#define EOF (-1)
#endif
#ifndef __size_t
#define __size_t 1
typedef unsigned int size_t;
#endif
typedef signed char S8;
typedef unsigned char U8;
typedef short S16;
typedef unsigned short U16;
typedef int S32;
typedef unsigned int U32;
typedef long long S64;
typedef unsigned long long U64;
typedef unsigned char BIT;
typedef unsigned int BOOL;
#ifndef __TRUE
#define __TRUE 1
#endif
#ifndef __FALSE
#define __FALSE 0
#endif
#ifdef __BIG_ENDIAN
#define U32_LE(v) (U32)(__rev(v))
#define U16_LE(v) (U16)(__rev(v) >> 16)
#define U32_BE(v) (U32)(v)
#define U16_BE(v) (U16)(v)
#else
#define U32_BE(v) (U32)(__rev(v))
#define U16_BE(v) (U16)(__rev(v) >> 16)
#define U32_LE(v) (U32)(v)
#define U16_LE(v) (U16)(v)
#endif
#define ntohs(v) U16_BE(v)
#define ntohl(v) U32_BE(v)
#define htons(v) ntohs(v)
#define htonl(v) ntohl(v)
/*----------------------------------------------------------------------------
* RTX Kernel API
*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/* Definition of Semaphore type */
typedef U32 OS_SEM[2];
/* Definition of Mailbox type */
#define os_mbx_declare(name,cnt) U32 name [4 + cnt]
typedef U32 OS_MBX[];
/* Definition of Mutex type */
typedef U32 OS_MUT[4];
/* Task Identification number. */
typedef U32 OS_TID;
/* Function return of system calls returning an object identification */
typedef void *OS_ID;
/* Function return of system calls indicating an event or completion state */
typedef U32 OS_RESULT;
/* Return codes */
#define OS_R_TMO 0x01
#define OS_R_EVT 0x02
#define OS_R_SEM 0x03
#define OS_R_MBX 0x04
#define OS_R_MUT 0x05
#define OS_R_OK 0x00
#define OS_R_NOK 0xff
#define OS_TCB_SIZE 56
#define OS_TMR_SIZE 8
/* Error Codes */
#define OS_ERR_STK_OVF 1
#define OS_ERR_FIFO_OVF 2
#define OS_ERR_MBX_OVF 3
#if !(__TARGET_ARCH_6S_M || __TARGET_ARCH_7_M || __TARGET_ARCH_7E_M)
/*----------------------------------------------------------------------------
* Functions ARM
*---------------------------------------------------------------------------*/
/* Task Management */
#define os_sys_init(tsk) os_sys_init0(tsk,0,NULL)
#define os_sys_init_prio(tsk,prio) os_sys_init0(tsk,prio,NULL)
#define os_sys_init_user(tsk,prio,stk,size) \
os_sys_init0(tsk,prio|(size<<8),stk)
#define os_tsk_create(tsk,prio) os_tsk_create0(tsk,prio,NULL,NULL)
#define os_tsk_create_user(tsk,prio,stk,size) \
os_tsk_create0(tsk,prio|(size<<8),stk,NULL)
#define os_tsk_create_ex(tsk,prio,argv) os_tsk_create_ex0(tsk,prio,NULL,argv)
#define os_tsk_create_user_ex(tsk,prio,stk,size,argv) \
os_tsk_create_ex0(tsk,prio|(size<<8),stk,argv)
#define os_tsk_delete_self() os_tsk_delete(0); for(;;)
#define os_tsk_prio_self(prio) os_tsk_prio(0,prio)
#define isr_tsk_get() os_tsk_self()
extern void os_sys_init0 (void (*task)(void), U32 prio_stksz, void *stk);
extern OS_TID os_tsk_create0 (void (*task)(void), U32 prio_stksz,
void *stk, void *argv);
extern OS_TID os_tsk_create_ex0 (void (*task)(void *), U32 prio_stksz,
void *stk, void *argv);
extern OS_TID os_tsk_self (void);
extern void os_tsk_pass (void);
extern OS_RESULT os_tsk_prio (OS_TID task_id, U8 new_prio);
extern OS_RESULT os_tsk_delete (OS_TID task_id);
/* Event flag Management */
#define os_evt_wait_or(wflags,tmo) os_evt_wait(wflags,tmo,__FALSE)
#define os_evt_wait_and(wflags,tmo) os_evt_wait(wflags,tmo,__TRUE)
extern OS_RESULT os_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait);
extern void os_evt_set (U16 event_flags, OS_TID task_id);
extern void os_evt_clr (U16 clear_flags, OS_TID task_id);
extern void isr_evt_set (U16 event_flags, OS_TID task_id);
extern U16 os_evt_get (void);
/* Semaphore Management */
extern void os_sem_init (OS_ID semaphore, U16 token_count);
extern OS_RESULT os_sem_send (OS_ID semaphore);
extern OS_RESULT os_sem_wait (OS_ID semaphore, U16 timeout);
extern void isr_sem_send (OS_ID semaphore);
/* Mailbox Management */
#define isr_mbx_check(mbx) os_mbx_check(mbx)
extern void os_mbx_init (OS_ID mailbox, U16 mbx_size);
extern OS_RESULT os_mbx_send (OS_ID mailbox, void *message_ptr, U16 timeout);
extern OS_RESULT os_mbx_wait (OS_ID mailbox, void **message, U16 timeout);
extern OS_RESULT os_mbx_check (OS_ID mailbox);
extern void isr_mbx_send (OS_ID mailbox, void *message_ptr);
extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message);
/* Mutex Management */
extern void os_mut_init (OS_ID mutex);
extern OS_RESULT os_mut_release (OS_ID mutex);
extern OS_RESULT os_mut_wait (OS_ID mutex, U16 timeout);
/* Time Management */
extern U32 os_time_get (void);
extern void os_dly_wait (U16 delay_time);
extern void os_itv_set (U16 interval_time);
extern void os_itv_wait (void);
/* User Timer Management */
extern OS_ID os_tmr_create (U16 tcnt, U16 info);
extern OS_ID os_tmr_kill (OS_ID timer);
/* System Functions */
extern U32 os_suspend (void);
extern void os_resume (U32 sleep_time);
extern void tsk_lock (void) __swi (5);
extern void tsk_unlock (void);
/* Fixed Memory Block Management Functions */
extern int _init_box (void *box_mem, U32 box_size, U32 blk_size);
extern void *_alloc_box (void *box_mem) __swi (1);
extern void *_calloc_box (void *box_mem);
extern int _free_box (void *box_mem, void *box) __swi (2);
#else
/*----------------------------------------------------------------------------
* Functions Cortex-M
*---------------------------------------------------------------------------*/
#define __SVC_0 __svc_indirect(0)
/* Task Management */
extern void os_set_env (void);
extern void rt_sys_init (void (*task)(void), U8 priority, void *stk);
extern void rt_tsk_pass (void);
extern OS_TID rt_tsk_self (void);
extern OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio);
extern OS_TID rt_tsk_create (void (*task)(void), U8 priority, void *stk, void *argv);
extern OS_RESULT rt_tsk_delete (OS_TID task_id);
#define os_sys_init(tsk) os_set_env(); \
_os_sys_init((U32)rt_sys_init,tsk,0,NULL)
#define os_sys_init_user(tsk,prio,stk,size) \
os_set_env(); \
_os_sys_init((U32)rt_sys_init,tsk,prio|(size<<8),stk)
#define os_sys_init_prio(tsk,prio) os_set_env(); \
_os_sys_init((U32)rt_sys_init,tsk,prio,NULL)
#define os_tsk_create(tsk,prio) _os_tsk_create((U32)rt_tsk_create,tsk,prio,NULL,NULL)
#define os_tsk_create_user(tsk,prio,stk,size) \
_os_tsk_create((U32)rt_tsk_create,tsk,prio|(size<<8),stk,NULL)
#define os_tsk_create_ex(tsk,prio,argv) _os_tsk_create_ex((U32)rt_tsk_create,tsk,prio,NULL,argv)
#define os_tsk_create_user_ex(tsk,prio,stk,size,argv) \
_os_tsk_create_ex((U32)rt_tsk_create,tsk,prio|(size<<8),stk,argv)
#define os_tsk_self() _os_tsk_self((U32)rt_tsk_self)
#define os_tsk_pass() _os_tsk_pass((U32)rt_tsk_pass)
#define os_tsk_prio(task_id,new_prio) _os_tsk_prio((U32)rt_tsk_prio,task_id,new_prio)
#define os_tsk_prio_self(prio) _os_tsk_prio((U32)rt_tsk_prio,0,prio)
#define os_tsk_delete(task_id) _os_tsk_delete((U32)rt_tsk_delete,task_id)
#define os_tsk_delete_self() _os_tsk_delete((U32)rt_tsk_delete, 0); for(;;)
#define isr_tsk_get() rt_tsk_self()
extern void _os_sys_init(U32 p, void (*task)(void), U32 prio_stksz,
void *stk) __SVC_0;
extern OS_TID _os_tsk_create (U32 p, void (*task)(void), U32 prio_stksz,
void *stk, void *argv) __SVC_0;
extern OS_TID _os_tsk_create_ex (U32 p, void (*task)(void *), U32 prio_stksz,
void *stk, void *argv) __SVC_0;
extern OS_TID _os_tsk_self (U32 p) __SVC_0;
extern void _os_tsk_pass (U32 p) __SVC_0;
extern OS_RESULT _os_tsk_prio (U32 p, OS_TID task_id, U8 new_prio) __SVC_0;
extern OS_RESULT _os_tsk_delete (U32 p, OS_TID task_id) __SVC_0;
/* Event flag Management */
extern OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait);
extern void rt_evt_set (U16 event_flags, OS_TID task_id);
extern void rt_evt_clr (U16 clear_flags, OS_TID task_id);
extern U16 rt_evt_get (void);
#define os_evt_wait_or(wflags,tmo) _os_evt_wait((U32)rt_evt_wait,wflags,tmo,__FALSE)
#define os_evt_wait_and(wflags,tmo) _os_evt_wait((U32)rt_evt_wait,wflags,tmo,__TRUE)
#define os_evt_set(evt_flags,task_id) _os_evt_set((U32)rt_evt_set,evt_flags,task_id)
#define os_evt_clr(clr_flags,task_id) _os_evt_clr((U32)rt_evt_clr,clr_flags,task_id)
#define os_evt_get() _os_evt_get((U32)rt_evt_get)
extern OS_RESULT _os_evt_wait(U32 p, U16 wait_flags, U16 timeout,
BOOL and_wait) __SVC_0;
extern void _os_evt_set (U32 p, U16 event_flags, OS_TID task_id) __SVC_0;
extern void _os_evt_clr (U32 p, U16 clear_flags, OS_TID task_id) __SVC_0;
extern U16 _os_evt_get (U32 p) __SVC_0;
extern void isr_evt_set (U16 event_flags, OS_TID task_id);
/* Semaphore Management */
extern void rt_sem_init (OS_ID semaphore, U16 token_count);
extern OS_RESULT rt_sem_send (OS_ID semaphore);
extern OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout);
#define os_sem_init(sem,t_count) _os_sem_init((U32)rt_sem_init,sem,t_count)
#define os_sem_send(sem) _os_sem_send((U32)rt_sem_send,sem)
#define os_sem_wait(sem,tmo) _os_sem_wait((U32)rt_sem_wait,sem,tmo)
extern void _os_sem_init (U32 p, OS_ID semaphore,
U16 token_count) __SVC_0;
extern OS_RESULT _os_sem_send (U32 p, OS_ID semaphore) __SVC_0;
extern OS_RESULT _os_sem_wait (U32 p, OS_ID semaphore, U16 timeout) __SVC_0;
extern void isr_sem_send (OS_ID semaphore);
/* Mailbox Management */
extern void rt_mbx_init (OS_ID mailbox, U16 mbx_size);
extern OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout);
extern OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout);
extern OS_RESULT rt_mbx_check (OS_ID mailbox);
#define os_mbx_init(mbx,mbx_size) _os_mbx_init((U32)rt_mbx_init,mbx,mbx_size)
#define os_mbx_send(mbx,p_msg,tmo) _os_mbx_send((U32)rt_mbx_send,mbx,p_msg,tmo)
#define os_mbx_wait(mbx,message,tmo) _os_mbx_wait((U32)rt_mbx_wait,mbx,message,tmo)
#define os_mbx_check(mbx) _os_mbx_check((U32)rt_mbx_check,mbx)
#define isr_mbx_check(mbx) rt_mbx_check(mbx)
extern void _os_mbx_init (U32 p, OS_ID mailbox, U16 mbx_size) __SVC_0;
extern OS_RESULT _os_mbx_send (U32 p, OS_ID mailbox, void *message_ptr,
U16 timeout) __SVC_0;
extern OS_RESULT _os_mbx_wait (U32 p, OS_ID mailbox, void **message,
U16 timeout) __SVC_0;
extern OS_RESULT _os_mbx_check (U32 p, OS_ID mailbox) __SVC_0;
extern void isr_mbx_send (OS_ID mailbox, void *message_ptr);
extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message);
/* Mutex Management */
extern void rt_mut_init (OS_ID mutex);
extern OS_RESULT rt_mut_release (OS_ID mutex);
extern OS_RESULT rt_mut_wait (OS_ID mutex, U16 timeout);
#define os_mut_init(mutex) _os_mut_init((U32)rt_mut_init,mutex)
#define os_mut_release(mutex) _os_mut_release((U32)rt_mut_release,mutex)
#define os_mut_wait(mutex,timeout) _os_mut_wait((U32)rt_mut_wait,mutex,timeout)
extern void _os_mut_init (U32 p, OS_ID mutex) __SVC_0;
extern OS_RESULT _os_mut_release (U32 p, OS_ID mutex) __SVC_0;
extern OS_RESULT _os_mut_wait (U32 p, OS_ID mutex, U16 timeout) __SVC_0;
/* Time Management */
extern U32 rt_time_get (void);
extern void rt_dly_wait (U16 delay_time);
extern void rt_itv_set (U16 interval_time);
extern void rt_itv_wait (void);
#define os_time_get() _os_time_get((U32)rt_time_get)
#define os_dly_wait(delay_time) _os_dly_wait((U32)rt_dly_wait,delay_time)
#define os_itv_set(interval_time) _os_itv_set((U32)rt_itv_set,interval_time)
#define os_itv_wait() _os_itv_wait((U32)rt_itv_wait)
extern U32 _os_time_get (U32 p) __SVC_0;
extern void _os_dly_wait (U32 p, U16 delay_time) __SVC_0;
extern void _os_itv_set (U32 p, U16 interval_time) __SVC_0;
extern void _os_itv_wait (U32 p) __SVC_0;
/* User Timer Management */
extern OS_ID rt_tmr_create (U16 tcnt, U16 info);
extern OS_ID rt_tmr_kill (OS_ID timer);
#define os_tmr_create(tcnt,info) _os_tmr_create((U32)rt_tmr_create,tcnt,info)
#define os_tmr_kill(timer) _os_tmr_kill((U32)rt_tmr_kill,timer)
extern OS_ID _os_tmr_create (U32 p, U16 tcnt, U16 info) __SVC_0;
extern OS_ID _os_tmr_kill (U32 p, OS_ID timer) __SVC_0;
/* System Functions */
extern U32 rt_suspend (void);
extern void rt_resume (U32 sleep_time);
extern void rt_tsk_lock (void);
extern void rt_tsk_unlock (void);
#define os_suspend() _os_suspend((U32)rt_suspend)
#define os_resume(sleep_time) _os_resume((U32)rt_resume,sleep_time)
#define tsk_lock() _os_tsk_lock((U32)rt_tsk_lock)
#define tsk_unlock() _os_tsk_unlock((U32)rt_tsk_unlock)
extern U32 _os_suspend (U32 p) __SVC_0;
extern void _os_resume (U32 p, U32 sleep_time) __SVC_0;
extern void _os_tsk_lock (U32 p) __SVC_0;
extern void _os_tsk_unlock (U32 p) __SVC_0;
/* Fixed Memory Block Management Functions */
extern int _init_box (void *box_mem, U32 box_size, U32 blk_size);
extern void *_alloc_box (void *box_mem);
extern void *_calloc_box (void *box_mem);
extern int _free_box (void *box_mem, void *box);
#endif
#define BOX_ALIGN_8 0x80000000
#define _declare_box(pool,size,cnt) U32 pool[(((size)+3)/4)*(cnt) + 3]
#define _declare_box8(pool,size,cnt) U64 pool[(((size)+7)/8)*(cnt) + 2]
#define _init_box8(pool,size,bsize) _init_box (pool,size,bsize | BOX_ALIGN_8)
/* For compatibility with older configurations.*/
#define os_stk_overflow os_error
/*----------------------------------------------------------------------------
* Flash File System API
*---------------------------------------------------------------------------*/
/* File System Type */
typedef enum _FS_TYPE {
FS_TYPE_NONE = 0, /* No file system (volume unformatted)*/
FS_TYPE_UNKNOWN, /* File system type is unknown */
FS_TYPE_FAT12, /* File system type is FAT12 */
FS_TYPE_FAT16, /* File system type is FAT16 */
FS_TYPE_FAT32, /* File system type is FAT32 */
FS_TYPE_EFS /* File system type is EFS */
} FS_TYPE;
typedef struct { /* RL Time format (FFS, TCPnet) */
U8 hr; /* Hours [0..23] */
U8 min; /* Minutes [0..59] */
U8 sec; /* Seconds [0..59] */
U8 day; /* Day [1..31] */
U8 mon; /* Month [1..12] */
U16 year; /* Year [1980..2107] */
} RL_TIME;
typedef struct { /* Search info record */
S8 name[256]; /* Name */
U32 size; /* File size in bytes */
U16 fileID; /* System Identification */
U8 attrib; /* Attributes */
RL_TIME time; /* Create/Modify Time */
} FINFO;
/* Drive information */
typedef struct {
FS_TYPE fs_type; /* Drives file system type */
U64 capacity; /* Drives capacity in bytes */
} Drive_INFO;
extern int finit (const char *drive);
extern int funinit (const char *drive);
extern int fdelete (const char *filename);
extern int frename (const char *oldname, const char *newname);
extern int ffind (const char *pattern, FINFO *info);
extern U64 ffree (const char *drive);
extern int fformat (const char *drive);
extern int fanalyse (const char *drive);
extern int fcheck (const char *drive);
extern int fdefrag (const char *drive);
extern int fattrib (const char *par, const char *path);
extern int fvol (const char *drive, char *buf);
extern int finfo (const char *drive, Drive_INFO *info);
/* The following macros provide for common functions */
#define unlink(fn) fdelete(fn);
/*----------------------------------------------------------------------------
* TCPnet API
*---------------------------------------------------------------------------*/
/* UDP Options */
#define UDP_OPT_SEND_CS 0x01 /* Calculate Checksum for UDP send frames */
#define UDP_OPT_CHK_CS 0x02 /* Verify Checksum for received UDP frames */
/* TCP Socket Types */
#define TCP_TYPE_SERVER 0x01 /* Socket Type Server (open for listening) */
#define TCP_TYPE_CLIENT 0x02 /* Socket Type Client (initiate connect) */
#define TCP_TYPE_DELAY_ACK 0x04 /* Socket Type Delayed Acknowledge */
#define TCP_TYPE_FLOW_CTRL 0x08 /* Socket Type Flow Control */
#define TCP_TYPE_KEEP_ALIVE 0x10 /* Socket Type Keep Alive */
#define TCP_TYPE_CLIENT_SERVER (TCP_TYPE_SERVER | TCP_TYPE_CLIENT)
/* TCP Callback Events */
#define TCP_EVT_CONREQ 0 /* Connect request received event */
#define TCP_EVT_CONNECT 1 /* Connection established event */
#define TCP_EVT_CLOSE 2 /* Connection was properly closed */
#define TCP_EVT_ABORT 3 /* Connection is for some reason aborted */
#define TCP_EVT_ACK 4 /* Previously send data acknowledged */
#define TCP_EVT_DATA 5 /* Data received event */
/* TCP States */
#define TCP_STATE_FREE 0 /* Entry is free and unused */
#define TCP_STATE_CLOSED 1 /* Entry allocated, socket still closed */
#define TCP_STATE_LISTEN 2 /* Socket waiting for incoming connection */
#define TCP_STATE_SYN_REC 3 /* SYN frame received */
#define TCP_STATE_SYN_SENT 4 /* SYN packet sent to establish a connect. */
#define TCP_STATE_FINW1 5 /* Tcp_close started FIN packet was sent */
#define TCP_STATE_FINW2 6 /* Our FIN ack-ed, waiting for remote FIN */
#define TCP_STATE_CLOSING 7 /* Received FIN independently of our FIN */
#define TCP_STATE_LAST_ACK 8 /* Waiting for last ACK for our FIN */
#define TCP_STATE_TWAIT 9 /* Timed waiting for 2MSL */
#define TCP_STATE_CONNECT 10 /* TCP Connection established */
/* BSD Socket Address Family */
#define AF_UNSPEC 0 /* Unspecified */
#define AF_INET 1 /* Internet Address Family (UDP, TCP) */
#define AF_NETBIOS 2 /* NetBios-style addresses */
/* BSD Protocol families, same as address families */
#define PF_UNSPEC AF_UNSPEC
#define PF_INET AF_INET
#define PF_NETBIOS AF_NETBIOS
/* BSD Socket Type */
#define SOCK_STREAM 1 /* Stream Socket (Connection oriented) */
#define SOCK_DGRAM 2 /* Datagram Socket (Connectionless) */
/* BSD Socket Protocol */
#define IPPROTO_TCP 1 /* TCP Protocol */
#define IPPROTO_UDP 2 /* UDP Protocol */
/* BSD Internet Addresses */
#define INADDR_ANY 0x00000000 /* All IP addresses accepted */
#define INADDR_NONE 0xffffffff /* No IP address accepted */
/* BSD Socket Return values */
#define SCK_SUCCESS 0 /* Success */
#define SCK_ERROR (-1) /* General Error */
#define SCK_EINVALID (-2) /* Invalid socket descriptor */
#define SCK_EINVALIDPARA (-3) /* Invalid parameter */
#define SCK_EWOULDBLOCK (-4) /* It would have blocked. */
#define SCK_EMEMNOTAVAIL (-5) /* Not enough memory in memory pool */
#define SCK_ECLOSED (-6) /* Connection is closed or aborted */
#define SCK_ELOCKED (-7) /* Socket is locked in RTX environment */
#define SCK_ETIMEOUT (-8) /* Socket, Host Resolver timeout */
#define SCK_EINPROGRESS (-9) /* Host Name resolving in progress */
#define SCK_ENONAME (-10) /* Host Name not existing */
/* BSD Socket flags parameter */
#define MSG_DONTWAIT 0x01 /* Enables non-blocking operation */
#define MSG_PEEK 0x02 /* Peeks at the incoming data */
/* BSD Socket ioctl commands */
#define FIONBIO 1 /* Set mode (blocking/non-blocking) */
#define FIO_DELAY_ACK 2 /* Set DELAY_ACK mode for stream socket */
#define FIO_KEEP_ALIVE 3 /* Set KEEP_ALIVE mode for stream socket */
#define FIO_FLOW_CTRL 4 /* Set FLOW_CTRL mode for stream socket */
/* ICMP (ping) Callback Events */
#define ICMP_EVT_SUCCESS 0 /* Pinged Host responded */
#define ICMP_EVT_TIMEOUT 1 /* Timeout, no ping response received */
/* DNS Client Callback Events */
#define DNS_EVT_SUCCESS 0 /* Host name successfully resolved */
#define DNS_EVT_NONAME 1 /* DNS Error, no such name */
#define DNS_EVT_TIMEOUT 2 /* Timeout resolving host */
#define DNS_EVT_ERROR 3 /* Erroneous response packet */
/* DNS 'get_host_by_name()' result codes */
#define DNS_RES_OK 0 /* Resolver successfully started */
#define DNS_ERROR_BUSY 1 /* Resolver busy, can't process request */
#define DNS_ERROR_LABEL 2 /* Label in Hostname not valid */
#define DNS_ERROR_NAME 3 /* Entire Hostname not valid */
#define DNS_ERROR_NOSRV 4 /* Prim. DNS server not specified (0.0.0.0)*/
#define DNS_ERROR_PARAM 5 /* Invalid parameter */
/* SMTP Client Callback Events */
#define SMTP_EVT_SUCCESS 0 /* Email successfully sent */
#define SMTP_EVT_TIMEOUT 1 /* Timeout sending email */
#define SMTP_EVT_ERROR 2 /* Error when sending email */
/* FTP Client Commands */
#define FTPC_CMD_PUT 0 /* Puts a file on FTP server */
#define FTPC_CMD_GET 1 /* Retrieves a file from FTP server */
#define FTPC_CMD_APPEND 2 /* Append file on FTP server (with create) */
#define FTPC_CMD_DELETE 3 /* Deletes a file on FTP server */
#define FTPC_CMD_LIST 4 /* Lists files stored on FTP server */
#define FTPC_CMD_RENAME 5 /* Renames a file on FTP server */
#define FTPC_CMD_MKDIR 6 /* Makes a directory on FTP server */
#define FTPC_CMD_RMDIR 7 /* Removes an empty directory on FTP server*/
#define FTPC_CMD_NLIST 8 /* Lists file names only (short format) */
/* FTP Client Callback Events */
#define FTPC_EVT_SUCCESS 0 /* File operation successful */
#define FTPC_EVT_TIMEOUT 1 /* Timeout on file operation */
#define FTPC_EVT_LOGINFAIL 2 /* Login error, username/passw invalid */
#define FTPC_EVT_NOACCESS 3 /* File access not allowed */
#define FTPC_EVT_NOTFOUND 4 /* File not found */
#define FTPC_EVT_NOPATH 5 /* Working directory path not found */
#define FTPC_EVT_ERRLOCAL 6 /* Local file open error */
#define FTPC_EVT_ERROR 7 /* Generic FTP client error */
/* TFTP Client Callback Events */
#define TFTPC_EVT_SUCCESS 0 /* File operation successful */
#define TFTPC_EVT_TIMEOUT 1 /* Timeout on file operation */
#define TFTPC_EVT_NOACCESS 2 /* File access not allowed */
#define TFTPC_EVT_NOTFOUND 3 /* File not found */
#define TFTPC_EVT_DISKFULL 4 /* Disk full (local or remote) */
#define TFTPC_EVT_ERROR 5 /* Generic TFTP client error */
/* FTP Server Notification events */
#define FTP_EVT_LOGIN 0 /* User logged in, session is busy */
#define FTP_EVT_LOGOUT 1 /* User logged out, session is idle */
#define FTP_EVT_LOGFAIL 2 /* User login failed (invalid credentials) */
#define FTP_EVT_DOWNLOAD 3 /* File download ended */
#define FTP_EVT_UPLOAD 4 /* File upload ended */
#define FTP_EVT_DELETE 5 /* File deleted */
#define FTP_EVT_RENAME 6 /* File or directory renamed */
#define FTP_EVT_MKDIR 7 /* Directory created */
#define FTP_EVT_RMDIR 8 /* Directory removed */
#define FTP_EVT_ERRLOCAL 9 /* Local file operation error */
#define FTP_EVT_DENIED 10 /* Requested file operation denied */
#define FTP_EVT_ERROR 11 /* Generic file operation error */
/* ARP Cache Entry types */
#define ARP_FIXED_IP 0 /* Fixed IP adrs is refreshed after tout */
#define ARP_TEMP_IP 1 /* Temp adrs is removed after timeout */
/* BSD Socket typedef's */
typedef struct sockaddr { /* << Generic Socket Address structure >> */
U16 sa_family; /* Address family */
char sa_data[14]; /* Direct address (up to 14 bytes) */
} SOCKADDR;
#pragma push
#pragma anon_unions
typedef struct in_addr { /* << Generic IPv4 Address structure >> */
union {
struct {
U8 s_b1,s_b2,s_b3,s_b4; /* IP address, byte access */
};
struct {
U16 s_w1,s_w2; /* IP address, short int access */
};
U32 s_addr; /* IP address in network byte order */
};
} IN_ADDR;
#pragma pop
typedef struct sockaddr_in { /* << IPv4 Socket Address structure >> */
S16 sin_family; /* Socket domain */
U16 sin_port; /* Port */
IN_ADDR sin_addr; /* IP address */
S8 sin_zero[8]; /* reserved */
} SOCKADDR_IN;
typedef struct hostent { /* << BSD Host Entry structure >> */
char *h_name; /* Official name of host */
char **h_aliases; /* Pointer to an array of alias names */
S16 h_addrtype; /* Address Type: AF_INET, AF_NETBIOS */
S16 h_length; /* Length of address in bytes */
char **h_addr_list; /* Pointer to an array of IPv4 addresses */
} HOSTENT;
extern void init_TcpNet (void);
extern BOOL main_TcpNet (void);
extern void timer_tick (void);
extern U8 udp_get_socket (U8 tos, U8 opt,
U16 (*listener)(U8 socket, U8 *remip, U16 port, U8 *buf, U16 len));
extern BOOL udp_release_socket (U8 socket);
extern BOOL udp_open (U8 socket, U16 locport);
extern BOOL udp_close (U8 socket);
extern BOOL udp_mcast_ttl (U8 socket, U8 ttl);
extern U8 *udp_get_buf (U16 size);
extern BOOL udp_send (U8 socket, U8 *remip, U16 remport, U8 *buf, U16 dlen);
extern U8 tcp_get_socket (U8 type, U8 tos, U16 tout,
U16 (*listener)(U8 socket, U8 event, U8 *buf, U16 len));
extern BOOL tcp_release_socket (U8 socket);
extern BOOL tcp_listen (U8 socket, U16 locport);
extern BOOL tcp_connect (U8 socket, U8 *remip, U16 remport, U16 locport);
extern U8 *tcp_get_buf (U16 size);
extern U16 tcp_max_dsize (U8 socket);
extern BOOL tcp_check_send (U8 socket);
extern U8 tcp_get_state (U8 socket);
extern BOOL tcp_send (U8 socket, U8 *buf, U16 dlen);
extern BOOL tcp_close (U8 socket);
extern BOOL tcp_abort (U8 socket);
extern void tcp_reset_window (U8 socket);
extern BOOL arp_cache_ip (U8 *ipadr, U8 type);
extern BOOL arp_cache_mac (U8 *hwadr);
extern void ppp_listen (const char *user, const char *passw);
extern void ppp_connect (const char *dialnum, const char *user, const char *passw);
extern void ppp_close (void);
extern BOOL ppp_is_up (void);
extern void slip_listen (void);
extern void slip_connect (const char *dialnum);
extern void slip_close (void);
extern BOOL slip_is_up (void);
extern U8 get_host_by_name (U8 *hostn, void (*cbfunc)(U8 event, U8 *host_ip));
extern BOOL smtp_connect (U8 *ipadr, U16 port, void (*cbfunc)(U8 event));
extern void dhcp_disable (void);
extern BOOL igmp_join (U8 *group_ip);
extern BOOL igmp_leave (U8 *group_ip);
extern BOOL snmp_trap (U8 *manager_ip, U8 gen_trap, U8 spec_trap, U16 *obj_list);
extern BOOL snmp_set_community (const char *community);
extern BOOL icmp_ping (U8 *remip, void (*cbfunc)(U8 event));
extern BOOL ftpc_connect (U8 *ipadr, U16 port, U8 command, void (*cbfunc)(U8 event));
extern BOOL tftpc_put (U8 *ipadr, U16 port,
const char *src, const char *dst, void (*cbfunc)(U8 event));
extern BOOL tftpc_get (U8 *ipadr, U16 port,
const char *src, const char *dst, void (*cbfunc)(U8 event));
extern BOOL sntp_get_time (U8 *ipadr, void (*cbfunc)(U32 utc_time));
extern void ftp_evt_notify (U8 evt);
/* BSD Socket API */
extern int socket (int family, int type, int protocol);
extern int bind (int sock, const SOCKADDR *addr, int addrlen);
extern int listen (int sock, int backlog);
extern int accept (int sock, SOCKADDR *addr, int *addrlen);
extern int connect (int sock, SOCKADDR *addr, int addrlen);
extern int send (int sock, const char *buf, int len, int flags);
extern int sendto (int sock, const char *buf, int len, int flags, SOCKADDR *to, int tolen);
extern int recv (int sock, char *buf, int len, int flags);
extern int recvfrom (int sock, char *buf, int len, int flags, SOCKADDR *from, int *fromlen);
extern int closesocket (int sock);
extern int getpeername (int sock, SOCKADDR *name, int *namelen);
extern int getsockname (int sock, SOCKADDR *name, int *namelen);
extern int ioctlsocket (int sock, long cmd, unsigned long *argp);
extern HOSTENT *gethostbyname (const char *name, int *err);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
#endif
+91
View File
@@ -0,0 +1,91 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __RL_USB_H__
#define __RL_USB_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "usb.h"
/***************** Functions *************************************************/
/* USB Device functions exported from USB Device Core module */
extern void usbd_init (void);
extern void usbd_connect (BOOL con);
extern void usbd_reset_core (void);
extern BOOL usbd_configured (void);
/* USB Device user functions imported to USB HID Class module */
extern void usbd_hid_init (void);
extern BOOL usbd_hid_get_report_trigger(U8 rid, U8 *buf, int len);
extern int usbd_hid_get_report (U8 rtype, U8 rid, U8 *buf, U8 req);
extern void usbd_hid_set_report (U8 rtype, U8 rid, U8 *buf, int len, U8 req);
extern U8 usbd_hid_get_protocol (void);
extern void usbd_hid_set_protocol (U8 protocol);
/* USB Device user functions imported to USB Mass Storage Class module */
extern void usbd_msc_init (void);
extern void usbd_msc_read_sect (U32 block, U8 *buf, U32 num_of_blocks);
extern void usbd_msc_write_sect (U32 block, U8 *buf, U32 num_of_blocks);
extern void usbd_msc_start_stop (BOOL start);
/* USB Device user functions imported to USB Audio Class module */
extern void usbd_adc_init (void);
/* USB Device CDC ACM class functions called automatically by USBD Core module*/
extern int32_t USBD_CDC_ACM_Initialize (void);
extern int32_t USBD_CDC_ACM_Uninitialize (void);
extern int32_t USBD_CDC_ACM_Reset (void);
/* USB Device CDC ACM class user functions */
extern int32_t USBD_CDC_ACM_PortInitialize (void);
extern int32_t USBD_CDC_ACM_PortUninitialize (void);
extern int32_t USBD_CDC_ACM_PortReset (void);
extern int32_t USBD_CDC_ACM_PortSetLineCoding (CDC_LINE_CODING *line_coding);
extern int32_t USBD_CDC_ACM_PortGetLineCoding (CDC_LINE_CODING *line_coding);
extern int32_t USBD_CDC_ACM_PortSetControlLineState (uint16_t ctrl_bmp);
extern int32_t USBD_CDC_ACM_DataSend (const uint8_t *buf, int32_t len);
extern int32_t USBD_CDC_ACM_DataFree (void);
extern int32_t USBD_CDC_ACM_PutChar (const uint8_t ch);
extern int32_t USBD_CDC_ACM_DataRead ( uint8_t *buf, int32_t len);
extern int32_t USBD_CDC_ACM_GetChar (void);
extern int32_t USBD_CDC_ACM_DataAvailable (void);
extern int32_t USBD_CDC_ACM_Notify (uint16_t stat);
/* USB Device CDC ACM class overridable functions */
extern int32_t USBD_CDC_ACM_SendEncapsulatedCommand (void);
extern int32_t USBD_CDC_ACM_GetEncapsulatedResponse (void);
extern int32_t USBD_CDC_ACM_SetCommFeature (uint16_t feat);
extern int32_t USBD_CDC_ACM_GetCommFeature (uint16_t feat);
extern int32_t USBD_CDC_ACM_ClearCommFeature (uint16_t feat);
extern int32_t USBD_CDC_ACM_SetLineCoding (void);
extern int32_t USBD_CDC_ACM_GetLineCoding (void);
extern int32_t USBD_CDC_ACM_SetControlLineState (uint16_t ctrl_bmp);
extern int32_t USBD_CDC_ACM_SendBreak (uint16_t dur);
/* USB Device user functions imported to USB Custom Class module */
extern void usbd_cls_init (void);
extern void usbd_cls_sof (void);
extern BOOL usbd_cls_dev_req (BOOL setup);
extern BOOL usbd_cls_if_req (BOOL setup);
extern BOOL usbd_cls_ep_req (BOOL setup);
#ifdef __cplusplus
}
#endif
#endif /* __RL_USB_H__ */
+38
View File
@@ -0,0 +1,38 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USB_H__
#define __USB_H__
/* General USB header files */
#include "usb_def.h"
#include "usb_cdc.h"
#include "usb_hid.h"
#include "usb_msc.h"
/* USB Device header files */
#include "usbd_core.h"
#include "usbd_core_cdc.h"
#include "usbd_core_hid.h"
#include "usbd_core_msc.h"
#include "usbd_desc.h"
#include "usbd_event.h"
#include "usbd_cdc_acm.h"
#include "usbd_hid.h"
#include "usbd_msc.h"
#include "usbd_hw.h"
#endif /* __USB_H__ */
+247
View File
@@ -0,0 +1,247 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USB_CDC_H
#define __USB_CDC_H
/*------------------------------------------------------------------------------
* Definitions based on usbcdc11.pdf (www.usb.org)
*----------------------------------------------------------------------------*/
/* Communication device class specification version 1.10 */
#define CDC_V1_10 0x0110
/* Communication interface class code */
/* (usbcdc11.pdf, 4.2, Table 15) */
#define CDC_COMMUNICATION_INTERFACE_CLASS 0x02
/* Communication interface class subclass codes */
/* (usbcdc11.pdf, 4.3, Table 16) */
#define CDC_DIRECT_LINE_CONTROL_MODEL 0x01
#define CDC_ABSTRACT_CONTROL_MODEL 0x02
#define CDC_TELEPHONE_CONTROL_MODEL 0x03
#define CDC_MULTI_CHANNEL_CONTROL_MODEL 0x04
#define CDC_CAPI_CONTROL_MODEL 0x05
#define CDC_ETHERNET_NETWORKING_CONTROL_MODEL 0x06
#define CDC_ATM_NETWORKING_CONTROL_MODEL 0x07
/* Communication interface class control protocol codes */
/* (usbcdc11.pdf, 4.4, Table 17) */
#define CDC_PROTOCOL_COMMON_AT_COMMANDS 0x01
/* Data interface class code */
/* (usbcdc11.pdf, 4.5, Table 18) */
#define CDC_DATA_INTERFACE_CLASS 0x0A
/* Data interface class protocol codes */
/* (usbcdc11.pdf, 4.7, Table 19) */
#define CDC_PROTOCOL_ISDN_BRI 0x30
#define CDC_PROTOCOL_HDLC 0x31
#define CDC_PROTOCOL_TRANSPARENT 0x32
#define CDC_PROTOCOL_Q921_MANAGEMENT 0x50
#define CDC_PROTOCOL_Q921_DATA_LINK 0x51
#define CDC_PROTOCOL_Q921_MULTIPLEXOR 0x52
#define CDC_PROTOCOL_V42 0x90
#define CDC_PROTOCOL_EURO_ISDN 0x91
#define CDC_PROTOCOL_V24_RATE_ADAPTATION 0x92
#define CDC_PROTOCOL_CAPI 0x93
#define CDC_PROTOCOL_HOST_BASED_DRIVER 0xFD
#define CDC_PROTOCOL_DESCRIBED_IN_PUFD 0xFE
/* Type values for bDescriptorType field of functional descriptors */
/* (usbcdc11.pdf, 5.2.3, Table 24) */
#define CDC_CS_INTERFACE 0x24
#define CDC_CS_ENDPOINT 0x25
/* Type values for bDescriptorSubtype field of functional descriptors */
/* (usbcdc11.pdf, 5.2.3, Table 25) */
#define CDC_HEADER 0x00
#define CDC_CALL_MANAGEMENT 0x01
#define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02
#define CDC_DIRECT_LINE_MANAGEMENT 0x03
#define CDC_TELEPHONE_RINGER 0x04
#define CDC_REPORTING_CAPABILITIES 0x05
#define CDC_UNION 0x06
#define CDC_COUNTRY_SELECTION 0x07
#define CDC_TELEPHONE_OPERATIONAL_MODES 0x08
#define CDC_USB_TERMINAL 0x09
#define CDC_NETWORK_CHANNEL 0x0A
#define CDC_PROTOCOL_UNIT 0x0B
#define CDC_EXTENSION_UNIT 0x0C
#define CDC_MULTI_CHANNEL_MANAGEMENT 0x0D
#define CDC_CAPI_CONTROL_MANAGEMENT 0x0E
#define CDC_ETHERNET_NETWORKING 0x0F
#define CDC_ATM_NETWORKING 0x10
/* CDC class-specific request codes */
/* (usbcdc11.pdf, 6.2, Table 46) */
/* see Table 45 for info about the specific requests. */
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
#define CDC_SET_COMM_FEATURE 0x02
#define CDC_GET_COMM_FEATURE 0x03
#define CDC_CLEAR_COMM_FEATURE 0x04
#define CDC_SET_AUX_LINE_STATE 0x10
#define CDC_SET_HOOK_STATE 0x11
#define CDC_PULSE_SETUP 0x12
#define CDC_SEND_PULSE 0x13
#define CDC_SET_PULSE_TIME 0x14
#define CDC_RING_AUX_JACK 0x15
#define CDC_SET_LINE_CODING 0x20
#define CDC_GET_LINE_CODING 0x21
#define CDC_SET_CONTROL_LINE_STATE 0x22
#define CDC_SEND_BREAK 0x23
#define CDC_SET_RINGER_PARMS 0x30
#define CDC_GET_RINGER_PARMS 0x31
#define CDC_SET_OPERATION_PARMS 0x32
#define CDC_GET_OPERATION_PARMS 0x33
#define CDC_SET_LINE_PARMS 0x34
#define CDC_GET_LINE_PARMS 0x35
#define CDC_DIAL_DIGITS 0x36
#define CDC_SET_UNIT_PARAMETER 0x37
#define CDC_GET_UNIT_PARAMETER 0x38
#define CDC_CLEAR_UNIT_PARAMETER 0x39
#define CDC_GET_PROFILE 0x3A
#define CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
#define CDC_SET_ETHERNET_PMP_FILTER 0x41
#define CDC_GET_ETHERNET_PMP_FILTER 0x42
#define CDC_SET_ETHERNET_PACKET_FILTER 0x43
#define CDC_GET_ETHERNET_STATISTIC 0x44
#define CDC_SET_ATM_DATA_FORMAT 0x50
#define CDC_GET_ATM_DEVICE_STATISTICS 0x51
#define CDC_SET_ATM_DEFAULT_VC 0x52
#define CDC_GET_ATM_VC_STATISTICS 0x53
/* Communication feature selector codes */
/* (usbcdc11.pdf, 6.2.2..6.2.4, Table 47) */
#define CDC_ABSTRACT_STATE 0x01
#define CDC_COUNTRY_SETTING 0x02
/* Feature Status returned for ABSTRACT_STATE Selector */
/* (usbcdc11.pdf, 6.2.3, Table 48) */
#define CDC_IDLE_SETTING (1 << 0)
#define CDC_DATA_MULTPLEXED_STATE (1 << 1)
/* Control signal bitmap values for the SetControlLineState request */
/* (usbcdc11.pdf, 6.2.14, Table 51) */
#define CDC_DTE_PRESENT (1 << 0)
#define CDC_ACTIVATE_CARRIER (1 << 1)
/* CDC class-specific notification codes */
/* (usbcdc11.pdf, 6.3, Table 68) */
/* see Table 67 for Info about class-specific notifications */
#define CDC_NOTIFICATION_NETWORK_CONNECTION 0x00
#define CDC_RESPONSE_AVAILABLE 0x01
#define CDC_AUX_JACK_HOOK_STATE 0x08
#define CDC_RING_DETECT 0x09
#define CDC_NOTIFICATION_SERIAL_STATE 0x20
#define CDC_CALL_STATE_CHANGE 0x28
#define CDC_LINE_STATE_CHANGE 0x29
#define CDC_CONNECTION_SPEED_CHANGE 0x2A
/* UART state bitmap values (Serial state notification). */
/* (usbcdc11.pdf, 6.3.5, Table 69) */
#define CDC_SERIAL_STATE_OVERRUN (1 << 6) /* receive data overrun error has occurred */
#define CDC_SERIAL_STATE_OVERRUN_Pos ( 6)
#define CDC_SERIAL_STATE_OVERRUN_Msk (1 << CDC_SERIAL_STATE_OVERRUN_Pos)
#define CDC_SERIAL_STATE_PARITY (1 << 5) /* parity error has occurred */
#define CDC_SERIAL_STATE_PARITY_Pos ( 5)
#define CDC_SERIAL_STATE_PARITY_Msk (1 << CDC_SERIAL_STATE_PARITY_Pos)
#define CDC_SERIAL_STATE_FRAMING (1 << 4) /* framing error has occurred */
#define CDC_SERIAL_STATE_FRAMING_Pos ( 4)
#define CDC_SERIAL_STATE_FRAMING_Msk (1 << CDC_SERIAL_STATE_FRAMING_Pos)
#define CDC_SERIAL_STATE_RING (1 << 3) /* state of ring signal detection */
#define CDC_SERIAL_STATE_RING_Pos ( 3)
#define CDC_SERIAL_STATE_RING_Msk (1 << CDC_SERIAL_STATE_RING_Pos)
#define CDC_SERIAL_STATE_BREAK (1 << 2) /* state of break detection */
#define CDC_SERIAL_STATE_BREAK_Pos ( 2)
#define CDC_SERIAL_STATE_BREAK_Msk (1 << CDC_SERIAL_STATE_BREAK_Pos)
#define CDC_SERIAL_STATE_TX_CARRIER (1 << 1) /* state of transmission carrier */
#define CDC_SERIAL_STATE_TX_CARRIER_Pos ( 1)
#define CDC_SERIAL_STATE_TX_CARRIER_Msk (1 << CDC_SERIAL_STATE_TX_CARRIER_Pos)
#define CDC_SERIAL_STATE_RX_CARRIER (1 << 0) /* state of receiver carrier */
#define CDC_SERIAL_STATE_RX_CARRIER_Pos ( 0)
#define CDC_SERIAL_STATE_RX_CARRIER_Msk (1 << CDC_SERIAL_STATE_RX_CARRIER_Pos)
/*------------------------------------------------------------------------------
* Structures based on usbcdc11.pdf (www.usb.org)
*----------------------------------------------------------------------------*/
/* Header functional descriptor */
/* (usbcdc11.pdf, 5.2.3.1) */
/* This header must precede any list of class-specific descriptors. */
typedef __packed struct _CDC_HEADER_DESCRIPTOR{
U8 bFunctionLength; /* size of this descriptor in bytes */
U8 bDescriptorType; /* CS_INTERFACE descriptor type */
U8 bDescriptorSubtype; /* Header functional descriptor subtype */
U16 bcdCDC; /* USB CDC specification release version */
} CDC_HEADER_DESCRIPTOR;
/* Call management functional descriptor */
/* (usbcdc11.pdf, 5.2.3.2) */
/* Describes the processing of calls for the communication class interface. */
typedef __packed struct _CDC_CALL_MANAGEMENT_DESCRIPTOR {
U8 bFunctionLength; /* size of this descriptor in bytes */
U8 bDescriptorType; /* CS_INTERFACE descriptor type */
U8 bDescriptorSubtype; /* call management functional descriptor subtype */
U8 bmCapabilities; /* capabilities that this configuration supports */
U8 bDataInterface; /* interface number of the data class interface used for call management (optional) */
} CDC_CALL_MANAGEMENT_DESCRIPTOR;
/* Abstract control management functional descriptor */
/* (usbcdc11.pdf, 5.2.3.3) */
/* Describes the command supported by the communication interface class with the Abstract Control Model subclass code. */
typedef __packed struct _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR {
U8 bFunctionLength; /* size of this descriptor in bytes */
U8 bDescriptorType; /* CS_INTERFACE descriptor type */
U8 bDescriptorSubtype; /* abstract control management functional descriptor subtype */
U8 bmCapabilities; /* capabilities supported by this configuration */
} CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR;
/* Union functional descriptors */
/* (usbcdc11.pdf, 5.2.3.8) */
/* Describes the relationship between a group of interfaces that can be considered to form a functional unit. */
typedef __packed struct _CDC_UNION_DESCRIPTOR {
U8 bFunctionLength; /* size of this descriptor in bytes */
U8 bDescriptorType; /* CS_INTERFACE descriptor type */
U8 bDescriptorSubtype; /* union functional descriptor subtype */
U8 bMasterInterface; /* interface number designated as master */
} CDC_UNION_DESCRIPTOR;
/* Union functional descriptors with one slave interface */
/* (usbcdc11.pdf, 5.2.3.8) */
typedef __packed struct _CDC_UNION_1SLAVE_DESCRIPTOR {
CDC_UNION_DESCRIPTOR sUnion; /* Union functional descriptor */
U8 bSlaveInterfaces[1]; /* Slave interface 0 */
} CDC_UNION_1SLAVE_DESCRIPTOR;
/* Line coding structure */
/* Format of the data returned when a GetLineCoding request is received */
/* (usbcdc11.pdf, 6.2.13) */
typedef __packed struct _CDC_LINE_CODING {
U32 dwDTERate; /* Data terminal rate in bits per second */
U8 bCharFormat; /* Number of stop bits */
U8 bParityType; /* Parity bit type */
U8 bDataBits; /* Number of data bits */
} CDC_LINE_CODING;
/* Notification header */
/* Data sent on the notification endpoint must follow this header. */
/* see USB_SETUP_PACKET in file usb.h */
typedef USB_SETUP_PACKET CDC_NOTIFICATION_HEADER;
#endif /* __USB_CDC_H */
+239
View File
@@ -0,0 +1,239 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USB_DEF_H__
#define __USB_DEF_H__
#pragma anon_unions
/* bmRequestType.Dir */
#define REQUEST_HOST_TO_DEVICE 0
#define REQUEST_DEVICE_TO_HOST 1
/* bmRequestType.Type */
#define REQUEST_STANDARD 0
#define REQUEST_CLASS 1
#define REQUEST_VENDOR 2
#define REQUEST_RESERVED 3
/* bmRequestType.Recipient */
#define REQUEST_TO_DEVICE 0
#define REQUEST_TO_INTERFACE 1
#define REQUEST_TO_ENDPOINT 2
#define REQUEST_TO_OTHER 3
/* bmRequestType Definition */
typedef __packed struct _REQUEST_TYPE {
U8 Recipient : 5; /* D4..0: Recipient */
U8 Type : 2; /* D6..5: Type */
U8 Dir : 1; /* D7: Data Phase Txsfer Direction */
} REQUEST_TYPE;
/* USB Standard Request Codes */
#define USB_REQUEST_GET_STATUS 0
#define USB_REQUEST_CLEAR_FEATURE 1
#define USB_REQUEST_SET_FEATURE 3
#define USB_REQUEST_SET_ADDRESS 5
#define USB_REQUEST_GET_DESCRIPTOR 6
#define USB_REQUEST_SET_DESCRIPTOR 7
#define USB_REQUEST_GET_CONFIGURATION 8
#define USB_REQUEST_SET_CONFIGURATION 9
#define USB_REQUEST_GET_INTERFACE 10
#define USB_REQUEST_SET_INTERFACE 11
#define USB_REQUEST_SYNC_FRAME 12
/* USB GET_STATUS Bit Values */
#define USB_GETSTATUS_SELF_POWERED 0x01
#define USB_GETSTATUS_REMOTE_WAKEUP 0x02
#define USB_GETSTATUS_ENDPOINT_STALL 0x01
/* USB Standard Feature selectors */
#define USB_FEATURE_ENDPOINT_STALL 0
#define USB_FEATURE_REMOTE_WAKEUP 1
/* USB Default Control Pipe Setup Packet */
typedef __packed struct _USB_SETUP_PACKET {
REQUEST_TYPE bmRequestType; /* bmRequestType */
U8 bRequest; /* bRequest */
__packed union {
U16 wValue; /* wValue */
__packed struct {
U8 wValueL;
U8 wValueH;
};
};
__packed union {
U16 wIndex; /* wIndex */
__packed struct {
U8 wIndexL;
U8 wIndexH;
};
};
U16 wLength; /* wLength */
} USB_SETUP_PACKET;
/* USB Descriptor Types */
#define USB_DEVICE_DESCRIPTOR_TYPE 1
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
#define USB_STRING_DESCRIPTOR_TYPE 3
#define USB_INTERFACE_DESCRIPTOR_TYPE 4
#define USB_ENDPOINT_DESCRIPTOR_TYPE 5
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6
#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8
#define USB_OTG_DESCRIPTOR_TYPE 9
#define USB_DEBUG_DESCRIPTOR_TYPE 10
#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11
/* USB Device Classes */
#define USB_DEVICE_CLASS_RESERVED 0x00
#define USB_DEVICE_CLASS_AUDIO 0x01
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
#define USB_DEVICE_CLASS_MONITOR 0x04
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
#define USB_DEVICE_CLASS_POWER 0x06
#define USB_DEVICE_CLASS_PRINTER 0x07
#define USB_DEVICE_CLASS_STORAGE 0x08
#define USB_DEVICE_CLASS_HUB 0x09
#define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
/* bmAttributes in Configuration Descriptor */
#define USB_CONFIG_POWERED_MASK 0x40
#define USB_CONFIG_BUS_POWERED 0x80
#define USB_CONFIG_SELF_POWERED 0xC0
#define USB_CONFIG_REMOTE_WAKEUP 0x20
/* bMaxPower in Configuration Descriptor */
#define USB_CONFIG_POWER_MA(mA) ((mA)/2)
/* bEndpointAddress in Endpoint Descriptor */
#define USB_ENDPOINT_DIRECTION_MASK 0x80
#define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)
#define USB_ENDPOINT_IN(addr) ((addr) | 0x80)
/* bmAttributes in Endpoint Descriptor */
#define USB_ENDPOINT_TYPE_MASK 0x03
#define USB_ENDPOINT_TYPE_CONTROL 0x00
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
#define USB_ENDPOINT_TYPE_BULK 0x02
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
#define USB_ENDPOINT_SYNC_MASK 0x0C
#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00
#define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04
#define USB_ENDPOINT_SYNC_ADAPTIVE 0x08
#define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C
#define USB_ENDPOINT_USAGE_MASK 0x30
#define USB_ENDPOINT_USAGE_DATA 0x00
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20
#define USB_ENDPOINT_USAGE_RESERVED 0x30
/* USB Standard Device Descriptor */
typedef __packed struct _USB_DEVICE_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U16 bcdUSB;
U8 bDeviceClass;
U8 bDeviceSubClass;
U8 bDeviceProtocol;
U8 bMaxPacketSize0;
U16 idVendor;
U16 idProduct;
U16 bcdDevice;
U8 iManufacturer;
U8 iProduct;
U8 iSerialNumber;
U8 bNumConfigurations;
} USB_DEVICE_DESCRIPTOR;
/* USB 2.0 Device Qualifier Descriptor */
typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U16 bcdUSB;
U8 bDeviceClass;
U8 bDeviceSubClass;
U8 bDeviceProtocol;
U8 bMaxPacketSize0;
U8 bNumConfigurations;
U8 bReserved;
} USB_DEVICE_QUALIFIER_DESCRIPTOR;
/* USB Standard Configuration Descriptor */
typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U16 wTotalLength;
U8 bNumInterfaces;
U8 bConfigurationValue;
U8 iConfiguration;
U8 bmAttributes;
U8 bMaxPower;
} USB_CONFIGURATION_DESCRIPTOR;
/* USB Standard Interface Descriptor */
typedef __packed struct _USB_INTERFACE_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U8 bInterfaceNumber;
U8 bAlternateSetting;
U8 bNumEndpoints;
U8 bInterfaceClass;
U8 bInterfaceSubClass;
U8 bInterfaceProtocol;
U8 iInterface;
} USB_INTERFACE_DESCRIPTOR;
/* USB Standard Endpoint Descriptor */
typedef __packed struct _USB_ENDPOINT_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U8 bEndpointAddress;
U8 bmAttributes;
U16 wMaxPacketSize;
U8 bInterval;
} USB_ENDPOINT_DESCRIPTOR;
/* USB String Descriptor */
typedef __packed struct _USB_STRING_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U16 bString/*[]*/;
} USB_STRING_DESCRIPTOR;
/* USB Common Descriptor */
typedef __packed struct _USB_COMMON_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
} USB_COMMON_DESCRIPTOR;
/* USB Interface Association Descriptor */
typedef __packed struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U8 bFirstInterface;
U8 bInterfaceCount;
U8 bFunctionClass;
U8 bFunctionSubclass;
U8 bFunctionProtocol;
U8 iFunction;
} USB_INTERFACE_ASSOCIATION_DESCRIPTOR;
#endif /* __USB_DEF_H__ */
@@ -0,0 +1,27 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USB_FOR_LIB_H__
#define __USB_FOR_LIB_H__
/* USB Device header files */
#include "usbd_lib_cdc.h"
#include "usbd_lib_hid.h"
#include "usbd_lib_msc.h"
/* USB System Configuration header file */
#include "usb_lib.h"
#endif /* __USB_FOR_LIB_H__ */
+374
View File
@@ -0,0 +1,374 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USB_HID_H__
#define __USB_HID_H__
/* HID Subclass Codes */
#define HID_SUBCLASS_NONE 0x00
#define HID_SUBCLASS_BOOT 0x01
/* HID Protocol Codes */
#define HID_PROTOCOL_NONE 0x00
#define HID_PROTOCOL_BOOT 0x00
#define HID_PROTOCOL_KEYBOARD 0x01
#define HID_PROTOCOL_REPORT 0x01
#define HID_PROTOCOL_MOUSE 0x02
/* HID Descriptor Types */
#define HID_HID_DESCRIPTOR_TYPE 0x21
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
/* HID Descriptor */
typedef __packed struct _HID_DESCRIPTOR {
U8 bLength;
U8 bDescriptorType;
U16 bcdHID;
U8 bCountryCode;
U8 bNumDescriptors;
/* Array of one or more descriptors */
__packed struct _HID_DESCRIPTOR_LIST {
U8 bDescriptorType;
U16 wDescriptorLength;
} DescriptorList[1];
} HID_DESCRIPTOR;
/* HID Request Codes */
#define HID_REQUEST_GET_REPORT 0x01
#define HID_REQUEST_GET_IDLE 0x02
#define HID_REQUEST_GET_PROTOCOL 0x03
#define HID_REQUEST_SET_REPORT 0x09
#define HID_REQUEST_SET_IDLE 0x0A
#define HID_REQUEST_SET_PROTOCOL 0x0B
/* HID Report Types */
#define HID_REPORT_INPUT 0x01
#define HID_REPORT_OUTPUT 0x02
#define HID_REPORT_FEATURE 0x03
/* Usage Pages */
#define HID_USAGE_PAGE_UNDEFINED 0x00
#define HID_USAGE_PAGE_GENERIC 0x01
#define HID_USAGE_PAGE_SIMULATION 0x02
#define HID_USAGE_PAGE_VR 0x03
#define HID_USAGE_PAGE_SPORT 0x04
#define HID_USAGE_PAGE_GAME 0x05
#define HID_USAGE_PAGE_DEV_CONTROLS 0x06
#define HID_USAGE_PAGE_KEYBOARD 0x07
#define HID_USAGE_PAGE_LED 0x08
#define HID_USAGE_PAGE_BUTTON 0x09
#define HID_USAGE_PAGE_ORDINAL 0x0A
#define HID_USAGE_PAGE_TELEPHONY 0x0B
#define HID_USAGE_PAGE_CONSUMER 0x0C
#define HID_USAGE_PAGE_DIGITIZER 0x0D
#define HID_USAGE_PAGE_UNICODE 0x10
#define HID_USAGE_PAGE_ALPHANUMERIC 0x14
/* ... */
/* Generic Desktop Page (0x01) */
#define HID_USAGE_GENERIC_POINTER 0x01
#define HID_USAGE_GENERIC_MOUSE 0x02
#define HID_USAGE_GENERIC_JOYSTICK 0x04
#define HID_USAGE_GENERIC_GAMEPAD 0x05
#define HID_USAGE_GENERIC_KEYBOARD 0x06
#define HID_USAGE_GENERIC_KEYPAD 0x07
#define HID_USAGE_GENERIC_X 0x30
#define HID_USAGE_GENERIC_Y 0x31
#define HID_USAGE_GENERIC_Z 0x32
#define HID_USAGE_GENERIC_RX 0x33
#define HID_USAGE_GENERIC_RY 0x34
#define HID_USAGE_GENERIC_RZ 0x35
#define HID_USAGE_GENERIC_SLIDER 0x36
#define HID_USAGE_GENERIC_DIAL 0x37
#define HID_USAGE_GENERIC_WHEEL 0x38
#define HID_USAGE_GENERIC_HATSWITCH 0x39
#define HID_USAGE_GENERIC_COUNTED_BUFFER 0x3A
#define HID_USAGE_GENERIC_BYTE_COUNT 0x3B
#define HID_USAGE_GENERIC_MOTION_WAKEUP 0x3C
#define HID_USAGE_GENERIC_VX 0x40
#define HID_USAGE_GENERIC_VY 0x41
#define HID_USAGE_GENERIC_VZ 0x42
#define HID_USAGE_GENERIC_VBRX 0x43
#define HID_USAGE_GENERIC_VBRY 0x44
#define HID_USAGE_GENERIC_VBRZ 0x45
#define HID_USAGE_GENERIC_VNO 0x46
#define HID_USAGE_GENERIC_SYSTEM_CTL 0x80
#define HID_USAGE_GENERIC_SYSCTL_POWER 0x81
#define HID_USAGE_GENERIC_SYSCTL_SLEEP 0x82
#define HID_USAGE_GENERIC_SYSCTL_WAKE 0x83
#define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU 0x84
#define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU 0x85
#define HID_USAGE_GENERIC_SYSCTL_APP_MENU 0x86
#define HID_USAGE_GENERIC_SYSCTL_HELP_MENU 0x87
#define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT 0x88
#define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT 0x89
#define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT 0x8A
#define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT 0x8B
#define HID_USAGE_GENERIC_SYSCTL_MENU_UP 0x8C
#define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN 0x8D
/* ... */
/* Simulation Controls Page (0x02) */
/* ... */
#define HID_USAGE_SIMULATION_RUDDER 0xBA
#define HID_USAGE_SIMULATION_THROTTLE 0xBB
/* ... */
/* Virtual Reality Controls Page (0x03) */
/* ... */
/* Sport Controls Page (0x04) */
/* ... */
/* Game Controls Page (0x05) */
/* ... */
/* Generic Device Controls Page (0x06) */
/* ... */
/* Keyboard/Keypad Page (0x07) */
/* Keyboard Usage Keys */
extern const unsigned char HID_KEYBOARD_ID_TO_ASCII[256];
extern const unsigned char HID_KEYBOARD_ALT_ID_TO_ASCII[57];
/* Error "Keys" */
#define HID_USAGE_KEYBOARD_NOEVENT 0x00
#define HID_USAGE_KEYBOARD_ROLLOVER 0x01
#define HID_USAGE_KEYBOARD_POSTFAIL 0x02
#define HID_USAGE_KEYBOARD_UNDEFINED 0x03
/* Letters */
#define HID_USAGE_KEYBOARD_aA 0x04
#define HID_USAGE_KEYBOARD_zZ 0x1D
/* Numbers */
#define HID_USAGE_KEYBOARD_ONE 0x1E
#define HID_USAGE_KEYBOARD_ZERO 0x27
#define HID_USAGE_KEYBOARD_RETURN 0x28
#define HID_USAGE_KEYBOARD_ESCAPE 0x29
#define HID_USAGE_KEYBOARD_DELETE 0x2A
/* Funtion Keys */
#define HID_USAGE_KEYBOARD_F1 0x3A
#define HID_USAGE_KEYBOARD_F12 0x45
#define HID_USAGE_KEYBOARD_PRINT_SCREEN 0x46
/* Modifier Keys */
#define HID_USAGE_KEYBOARD_LCTRL 0xE0
#define HID_USAGE_KEYBOARD_LSHFT 0xE1
#define HID_USAGE_KEYBOARD_LALT 0xE2
#define HID_USAGE_KEYBOARD_LGUI 0xE3
#define HID_USAGE_KEYBOARD_RCTRL 0xE4
#define HID_USAGE_KEYBOARD_RSHFT 0xE5
#define HID_USAGE_KEYBOARD_RALT 0xE6
#define HID_USAGE_KEYBOARD_RGUI 0xE7
#define HID_USAGE_KEYBOARD_SCROLL_LOCK 0x47
#define HID_USAGE_KEYBOARD_NUM_LOCK 0x53
#define HID_USAGE_KEYBOARD_CAPS_LOCK 0x39
/* Modifier Keys (values) */
#define HID_USAGE_KEYBOARD_MOD_LCTRL 0x01
#define HID_USAGE_KEYBOARD_MOD_LSHIFT 0x02
#define HID_USAGE_KEYBOARD_MOD_LALTL 0x04
#define HID_USAGE_KEYBOARD_MOD_LGUI 0x08
#define HID_USAGE_KEYBOARD_MOD_RCTRL 0x10
#define HID_USAGE_KEYBOARD_MOD_RSHIFT 0x20
#define HID_USAGE_KEYBOARD_MOD_RALTL 0x40
#define HID_USAGE_KEYBOARD_MOD_RGUI 0x80
/* ... */
/* LED Page (0x08) */
#define HID_USAGE_LED_NUM_LOCK 0x01
#define HID_USAGE_LED_CAPS_LOCK 0x02
#define HID_USAGE_LED_SCROLL_LOCK 0x03
#define HID_USAGE_LED_COMPOSE 0x04
#define HID_USAGE_LED_KANA 0x05
#define HID_USAGE_LED_POWER 0x06
#define HID_USAGE_LED_SHIFT 0x07
#define HID_USAGE_LED_DO_NOT_DISTURB 0x08
#define HID_USAGE_LED_MUTE 0x09
#define HID_USAGE_LED_TONE_ENABLE 0x0A
#define HID_USAGE_LED_HIGH_CUT_FILTER 0x0B
#define HID_USAGE_LED_LOW_CUT_FILTER 0x0C
#define HID_USAGE_LED_EQUALIZER_ENABLE 0x0D
#define HID_USAGE_LED_SOUND_FIELD_ON 0x0E
#define HID_USAGE_LED_SURROUND_FIELD_ON 0x0F
#define HID_USAGE_LED_REPEAT 0x10
#define HID_USAGE_LED_STEREO 0x11
#define HID_USAGE_LED_SAMPLING_RATE_DETECT 0x12
#define HID_USAGE_LED_SPINNING 0x13
#define HID_USAGE_LED_CAV 0x14
#define HID_USAGE_LED_CLV 0x15
#define HID_USAGE_LED_RECORDING_FORMAT_DET 0x16
#define HID_USAGE_LED_OFF_HOOK 0x17
#define HID_USAGE_LED_RING 0x18
#define HID_USAGE_LED_MESSAGE_WAITING 0x19
#define HID_USAGE_LED_DATA_MODE 0x1A
#define HID_USAGE_LED_BATTERY_OPERATION 0x1B
#define HID_USAGE_LED_BATTERY_OK 0x1C
#define HID_USAGE_LED_BATTERY_LOW 0x1D
#define HID_USAGE_LED_SPEAKER 0x1E
#define HID_USAGE_LED_HEAD_SET 0x1F
#define HID_USAGE_LED_HOLD 0x20
#define HID_USAGE_LED_MICROPHONE 0x21
#define HID_USAGE_LED_COVERAGE 0x22
#define HID_USAGE_LED_NIGHT_MODE 0x23
#define HID_USAGE_LED_SEND_CALLS 0x24
#define HID_USAGE_LED_CALL_PICKUP 0x25
#define HID_USAGE_LED_CONFERENCE 0x26
#define HID_USAGE_LED_STAND_BY 0x27
#define HID_USAGE_LED_CAMERA_ON 0x28
#define HID_USAGE_LED_CAMERA_OFF 0x29
#define HID_USAGE_LED_ON_LINE 0x2A
#define HID_USAGE_LED_OFF_LINE 0x2B
#define HID_USAGE_LED_BUSY 0x2C
#define HID_USAGE_LED_READY 0x2D
#define HID_USAGE_LED_PAPER_OUT 0x2E
#define HID_USAGE_LED_PAPER_JAM 0x2F
#define HID_USAGE_LED_REMOTE 0x30
#define HID_USAGE_LED_FORWARD 0x31
#define HID_USAGE_LED_REVERSE 0x32
#define HID_USAGE_LED_STOP 0x33
#define HID_USAGE_LED_REWIND 0x34
#define HID_USAGE_LED_FAST_FORWARD 0x35
#define HID_USAGE_LED_PLAY 0x36
#define HID_USAGE_LED_PAUSE 0x37
#define HID_USAGE_LED_RECORD 0x38
#define HID_USAGE_LED_ERROR 0x39
#define HID_USAGE_LED_SELECTED_INDICATOR 0x3A
#define HID_USAGE_LED_IN_USE_INDICATOR 0x3B
#define HID_USAGE_LED_MULTI_MODE_INDICATOR 0x3C
#define HID_USAGE_LED_INDICATOR_ON 0x3D
#define HID_USAGE_LED_INDICATOR_FLASH 0x3E
#define HID_USAGE_LED_INDICATOR_SLOW_BLINK 0x3F
#define HID_USAGE_LED_INDICATOR_FAST_BLINK 0x40
#define HID_USAGE_LED_INDICATOR_OFF 0x41
#define HID_USAGE_LED_FLASH_ON_TIME 0x42
#define HID_USAGE_LED_SLOW_BLINK_ON_TIME 0x43
#define HID_USAGE_LED_SLOW_BLINK_OFF_TIME 0x44
#define HID_USAGE_LED_FAST_BLINK_ON_TIME 0x45
#define HID_USAGE_LED_FAST_BLINK_OFF_TIME 0x46
#define HID_USAGE_LED_INDICATOR_COLOR 0x47
#define HID_USAGE_LED_RED 0x48
#define HID_USAGE_LED_GREEN 0x49
#define HID_USAGE_LED_AMBER 0x4A
#define HID_USAGE_LED_GENERIC_INDICATOR 0x4B
/* Button Page (0x09) */
/* There is no need to label these usages. */
/* Ordinal Page (0x0A) */
/* There is no need to label these usages. */
/* Telephony Device Page (0x0B) */
#define HID_USAGE_TELEPHONY_PHONE 0x01
#define HID_USAGE_TELEPHONY_ANSWERING_MACHINE 0x02
#define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS 0x03
#define HID_USAGE_TELEPHONY_HANDSET 0x04
#define HID_USAGE_TELEPHONY_HEADSET 0x05
#define HID_USAGE_TELEPHONY_KEYPAD 0x06
#define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON 0x07
/* ... */
/* Consumer Page (0x0C) */
#define HID_USAGE_CONSUMER_CONTROL 0x01
/* ... */
/* and others ... */
/* HID Report Item Macros */
/* Main Items */
#define HID_Input(x) 0x81,x
#define HID_Output(x) 0x91,x
#define HID_Feature(x) 0xB1,x
#define HID_Collection(x) 0xA1,x
#define HID_EndCollection 0xC0
/* Data (Input, Output, Feature) */
#define HID_Data 0<<0
#define HID_Constant 1<<0
#define HID_Array 0<<1
#define HID_Variable 1<<1
#define HID_Absolute 0<<2
#define HID_Relative 1<<2
#define HID_NoWrap 0<<3
#define HID_Wrap 1<<3
#define HID_Linear 0<<4
#define HID_NonLinear 1<<4
#define HID_PreferredState 0<<5
#define HID_NoPreferred 1<<5
#define HID_NoNullPosition 0<<6
#define HID_NullState 1<<6
#define HID_NonVolatile 0<<7
#define HID_Volatile 1<<7
/* Collection Data */
#define HID_Physical 0x00
#define HID_Application 0x01
#define HID_Logical 0x02
#define HID_Report 0x03
#define HID_NamedArray 0x04
#define HID_UsageSwitch 0x05
#define HID_UsageModifier 0x06
/* Global Items */
#define HID_UsagePage(x) 0x05,x
#define HID_UsagePageVendor(x) 0x06,x,0xFF
#define HID_LogicalMin(x) 0x15,x
#define HID_LogicalMinS(x) 0x16,(x&0xFF),((x>>8)&0xFF)
#define HID_LogicalMinL(x) 0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_LogicalMax(x) 0x25,x
#define HID_LogicalMaxS(x) 0x26,(x&0xFF),((x>>8)&0xFF)
#define HID_LogicalMaxL(x) 0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_PhysicalMin(x) 0x35,x
#define HID_PhysicalMinS(x) 0x36,(x&0xFF),((x>>8)&0xFF)
#define HID_PhysicalMinL(x) 0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_PhysicalMax(x) 0x45,x
#define HID_PhysicalMaxS(x) 0x46,(x&0xFF),((x>>8)&0xFF)
#define HID_PhysicalMaxL(x) 0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_UnitExponent(x) 0x55,x
#define HID_Unit(x) 0x65,x
#define HID_UnitS(x) 0x66,(x&0xFF),((x>>8)&0xFF)
#define HID_UnitL(x) 0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_ReportSize(x) 0x75,x
#define HID_ReportSizeS(x) 0x76,(x&0xFF),((x>>8)&0xFF)
#define HID_ReportSizeL(x) 0x77,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_ReportID(x) 0x85,x
#define HID_ReportCount(x) 0x95,x
#define HID_ReportCountS(x) 0x96,(x&0xFF),((x>>8)&0xFF)
#define HID_ReportCountL(x) 0x97,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_Push 0xA4
#define HID_Pop 0xB4
/* Local Items */
#define HID_Usage(x) 0x09,x
#define HID_UsageMin(x) 0x19,x
#define HID_UsageMax(x) 0x29,x
#endif /* __USB_HID_H__ */
File diff suppressed because it is too large Load Diff
+112
View File
@@ -0,0 +1,112 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USB_LIB_H__
#define __USB_LIB_H__
/*------------------------------------------------------------------------------
* USB Device Configuration
*----------------------------------------------------------------------------*/
extern U8 USBD_AltSetting[];
extern U8 USBD_EP0Buf[];
extern const U8 usbd_power;
extern const U8 usbd_hs_enable;
extern const U16 usbd_if_num;
extern const U8 usbd_ep_num;
extern const U8 usbd_max_packet0;
/*------------------------------------------------------------------------------
* USB Device Class Configuration
*----------------------------------------------------------------------------*/
extern const U8 usbd_hid_enable;
extern const U8 usbd_hid_if_num;
extern const U8 usbd_hid_ep_intin;
extern const U8 usbd_hid_ep_intout;
extern const U16 usbd_hid_interval [2];
extern const U16 usbd_hid_maxpacketsize[2];
extern const U8 usbd_hid_inreport_num;
extern const U8 usbd_hid_outreport_num;
extern const U16 usbd_hid_inreport_max_sz;
extern const U16 usbd_hid_outreport_max_sz;
extern const U16 usbd_hid_featreport_max_sz;
extern U16 USBD_HID_PollingCnt;
extern U16 USBD_HID_PollingReload[];
extern U8 USBD_HID_IdleCnt [];
extern U8 USBD_HID_IdleReload [];
extern U8 USBD_HID_IdleSet [];
extern U8 USBD_HID_InReport [];
extern U8 USBD_HID_OutReport [];
extern U8 USBD_HID_FeatReport [];
extern const U8 usbd_msc_enable;
extern const U8 usbd_msc_if_num;
extern const U8 usbd_msc_ep_bulkin;
extern const U8 usbd_msc_ep_bulkout;
extern const U16 usbd_msc_maxpacketsize[2];
extern const U8 *usbd_msc_inquiry_data;
extern U8 USBD_MSC_BulkBuf [];
extern const U8 usbd_adc_enable;
extern const U8 usbd_adc_cif_num;
extern const U8 usbd_adc_sif1_num;
extern const U8 usbd_adc_sif2_num;
extern const U8 usbd_adc_ep_isoout;
extern const U32 usbd_adc_cfg_datafreq;
extern const U32 usbd_adc_cfg_p_s;
extern const U32 usbd_adc_cfg_p_c;
extern const U32 usbd_adc_cfg_b_s;
extern S16 USBD_ADC_DataBuf [];
extern const U8 usbd_cdc_acm_enable;
extern const U8 usbd_cdc_acm_cif_num;
extern const U8 usbd_cdc_acm_dif_num;
extern const U8 usbd_cdc_acm_bufsize;
extern const U8 usbd_cdc_acm_ep_intin;
extern const U8 usbd_cdc_acm_ep_bulkin;
extern const U8 usbd_cdc_acm_ep_bulkout;
extern const U16 usbd_cdc_acm_sendbuf_sz;
extern const U16 usbd_cdc_acm_receivebuf_sz;
extern const U16 usbd_cdc_acm_maxpacketsize [2];
extern const U16 usbd_cdc_acm_maxpacketsize1[2];
extern U8 USBD_CDC_ACM_SendBuf [];
extern U8 USBD_CDC_ACM_ReceiveBuf [];
extern U8 USBD_CDC_ACM_NotifyBuf [10];
extern void usbd_os_evt_set (U16 event_flags, U32 task);
extern U16 usbd_os_evt_get (void);
extern U32 usbd_os_evt_wait_or (U16 wait_flags, U16 timeout);
extern const BOOL __rtx;
/*------------------------------------------------------------------------------
* USB Device Descriptors
*----------------------------------------------------------------------------*/
extern const U8 USBD_HID_ReportDescriptor[];
extern const U16 USBD_HID_ReportDescriptorSize;
extern const U16 USBD_HID_DescriptorOffset;
extern const U8 USBD_DeviceDescriptor[];
extern const U8 USBD_DeviceQualifier[];
extern const U8 USBD_DeviceQualifier_HS[];
extern const U8 USBD_ConfigDescriptor[];
extern const U8 USBD_ConfigDescriptor_HS[];
extern const U8 USBD_OtherSpeedConfigDescriptor[];
extern const U8 USBD_OtherSpeedConfigDescriptor_HS[];
extern const U8 USBD_OtherSpeedConfigDescriptor[];
extern const U8 USBD_OtherSpeedConfigDescriptor_HS[];
extern const U8 USBD_StringDescriptor[];
#endif /* __USB_LIB_H__ */
+106
View File
@@ -0,0 +1,106 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USB_MSC_H__
#define __USB_MSC_H__
/* MSC Subclass Codes */
#define MSC_SUBCLASS_RBC 0x01
#define MSC_SUBCLASS_SFF8020I_MMC2 0x02
#define MSC_SUBCLASS_QIC157 0x03
#define MSC_SUBCLASS_UFI 0x04
#define MSC_SUBCLASS_SFF8070I 0x05
#define MSC_SUBCLASS_SCSI 0x06
/* MSC Protocol Codes */
#define MSC_PROTOCOL_CBI_INT 0x00
#define MSC_PROTOCOL_CBI_NOINT 0x01
#define MSC_PROTOCOL_BULK_ONLY 0x50
/* MSC Request Codes */
#define MSC_REQUEST_RESET 0xFF
#define MSC_REQUEST_GET_MAX_LUN 0xFE
/* MSC Bulk-only Stage */
#define MSC_BS_CBW 0 /* Command Block Wrapper */
#define MSC_BS_DATA_OUT 1 /* Data Out Phase */
#define MSC_BS_DATA_IN 2 /* Data In Phase */
#define MSC_BS_DATA_IN_LAST 3 /* Data In Last Phase */
#define MSC_BS_DATA_IN_LAST_STALL 4 /* Data In Last Phase with Stall */
#define MSC_BS_CSW 5 /* Command Status Wrapper */
#define MSC_BS_ERROR 6 /* Error */
/* Bulk-only Command Block Wrapper */
typedef __packed struct _MSC_CBW {
U32 dSignature;
U32 dTag;
U32 dDataLength;
U8 bmFlags;
U8 bLUN;
U8 bCBLength;
U8 CB[16];
} MSC_CBW;
/* Bulk-only Command Status Wrapper */
typedef __packed struct _MSC_CSW {
U32 dSignature;
U32 dTag;
U32 dDataResidue;
U8 bStatus;
} MSC_CSW;
#define MSC_CBW_Signature 0x43425355
#define MSC_CSW_Signature 0x53425355
/* CSW Status Definitions */
#define CSW_CMD_PASSED 0x00
#define CSW_CMD_FAILED 0x01
#define CSW_PHASE_ERROR 0x02
/* SCSI Commands */
#define SCSI_TEST_UNIT_READY 0x00
#define SCSI_REQUEST_SENSE 0x03
#define SCSI_FORMAT_UNIT 0x04
#define SCSI_INQUIRY 0x12
#define SCSI_MODE_SELECT6 0x15
#define SCSI_MODE_SENSE6 0x1A
#define SCSI_START_STOP_UNIT 0x1B
#define SCSI_MEDIA_REMOVAL 0x1E
#define SCSI_READ_FORMAT_CAPACITIES 0x23
#define SCSI_READ_CAPACITY 0x25
#define SCSI_READ10 0x28
#define SCSI_WRITE10 0x2A
#define SCSI_VERIFY10 0x2F
#define SCSI_SYNC_CACHE10 0x35
#define SCSI_READ12 0xA8
#define SCSI_WRITE12 0xAA
#define SCSI_MODE_SELECT10 0x55
#define SCSI_MODE_SENSE10 0x5A
#define SCSI_SYNC_CACHE16 0x91
#define SCSI_ATA_COMMAND_PASS_THROUGH12 0xA1
#define SCSI_ATA_COMMAND_PASS_THROUGH16 0x85
#define SCSI_SERVICE_ACTION_IN12 0xAB
#define SCSI_SERVICE_ACTION_IN16 0x9E
#define SCSI_SERVICE_ACTION_OUT12 0xA9
#define SCSI_SERVICE_ACTION_OUT16 0x9F
#endif /* __USB_MSC_H__ */
@@ -0,0 +1,40 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_CDC_H__
#define __USBD_CDC_H__
/*--------------------------- Event handling routines ------------------------*/
extern void usbd_vcom_serial2usb (void);
extern void usbd_vcom_chkserstate (void);
extern void usbd_vcom_usb2serial (void);
extern void usbd_cdc_ser_flush (void);
extern void USBD_CDC_SOF_Event (void);
extern void USBD_CDC_EP_INTIN_Event (U32 event);
extern void USBD_CDC_EP_BULKIN_Event (U32 event);
extern void USBD_CDC_EP_BULKOUT_Event (U32 event);
extern void USBD_CDC_EP_BULK_Event (U32 event);
extern void USBD_RTX_CDC_EP_INTIN_Event (void);
extern void USBD_RTX_CDC_EP_BULKIN_Event (void);
extern void USBD_RTX_CDC_EP_BULKOUT_Event (void);
extern void USBD_RTX_CDC_EP_BULK_Event (void);
#endif /* __USBD_CDC_H__ */
@@ -0,0 +1,37 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_CDC_ACM_H__
#define __USBD_CDC_ACM_H__
/*--------------------------- Event handling routines ------------------------*/
extern void USBD_CDC_ACM_Reset_Event (void);
extern void USBD_CDC_ACM_SOF_Event (void);
extern void USBD_CDC_ACM_EP_INTIN_Event (U32 event);
extern void USBD_CDC_ACM_EP_BULKIN_Event (U32 event);
extern void USBD_CDC_ACM_EP_BULKOUT_Event (U32 event);
extern void USBD_CDC_ACM_EP_BULK_Event (U32 event);
extern __task void USBD_RTX_CDC_ACM_EP_INTIN_Event (void);
extern __task void USBD_RTX_CDC_ACM_EP_BULKIN_Event (void);
extern __task void USBD_RTX_CDC_ACM_EP_BULKOUT_Event (void);
extern __task void USBD_RTX_CDC_ACM_EP_BULK_Event (void);
#endif /* __USBD_CDC_ACM_H__ */
@@ -0,0 +1,68 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_CORE_H__
#define __USBD_CORE_H__
/*--------------------------- Data structures --------------------------------*/
/* USB Device Core Endpoint Data Structure */
typedef struct _USBD_EP_DATA {
U8 *pData;
U16 Count;
} USBD_EP_DATA;
/*--------------------------- Global variables -------------------------------*/
/* USB Device Core Global Variables */
extern U16 USBD_DeviceStatus;
extern U8 USBD_DeviceAddress;
extern U8 USBD_Configuration;
extern U32 USBD_EndPointMask;
extern U32 USBD_EndPointHalt;
extern U32 USBD_EndPointStall;
extern U8 USBD_NumInterfaces;
extern U8 USBD_HighSpeed;
extern U8 USBD_ZLP;
extern USBD_EP_DATA USBD_EP0Data;
extern USB_SETUP_PACKET USBD_SetupPacket;
extern OS_TID USBD_RTX_DevTask;
extern OS_TID USBD_RTX_EPTask[];
extern OS_TID USBD_RTX_CoreTask;
/*--------------------------- Functions exported to class specific files -----*/
extern void USBD_SetupStage (void);
extern void USBD_DataInStage (void);
extern void USBD_DataOutStage (void);
extern void USBD_StatusInStage (void);
extern void USBD_StatusOutStage (void);
/*--------------------------- Event handling routines ------------------------*/
extern void usbd_class_init (void);
extern void USBD_EndPoint0 (U32 event);
extern __task void USBD_RTX_EndPoint0 (void);
#endif /* __USBD_CORE_H__ */
@@ -0,0 +1,26 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_CORE_CDC_H__
#define __USBD_CORE_CDC_H__
/*--------------------------- Core overridable class specific functions ------*/
extern BOOL USBD_EndPoint0_Setup_CDC_ReqToIF (void);
extern BOOL USBD_EndPoint0_Out_CDC_ReqToIF (void);
#endif /* __USBD_CORE_CDC_H__ */
@@ -0,0 +1,27 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_CORE_HID_H__
#define __USBD_CORE_HID_H__
/*--------------------------- Core overridable class specific functions ------*/
extern BOOL USBD_ReqGetDescriptor_HID (U8 **pD, U32 *len);
extern BOOL USBD_EndPoint0_Setup_HID_ReqToIF (void);
extern BOOL USBD_EndPoint0_Out_HID_ReqToIF (void);
#endif /* __USBD_CORE_HID_H__ */
@@ -0,0 +1,27 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_CORE_MSC_H__
#define __USBD_CORE_MSC_H__
/*--------------------------- Core overridable class specific functions ------*/
extern void USBD_ReqClrFeature_MSC (U32 EPNum);
extern BOOL USBD_EndPoint0_Setup_MSC_ReqToIF (void);
extern BOOL USBD_EndPoint0_Out_MSC_ReqToIF (void);
#endif /* __USBD_CORE_MSC_H__ */
@@ -0,0 +1,30 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_DESC_H__
#define __USBD_DESC_H__
#define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)
#define B3VAL(x) (x & 0xFF),((x >> 8) & 0xFF),((x >> 16) & 0xFF)
#define USB_DEVICE_DESC_SIZE (sizeof(USB_DEVICE_DESCRIPTOR))
#define USB_DEVICE_QUALI_SIZE (sizeof(USB_DEVICE_QUALIFIER_DESCRIPTOR))
#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
#define USB_INTERFACE_ASSOC_DESC_SIZE (sizeof(USB_INTERFACE_ASSOCIATION_DESCRIPTOR))
#define USB_INTERFACE_DESC_SIZE (sizeof(USB_INTERFACE_DESCRIPTOR))
#define USB_ENDPOINT_DESC_SIZE (sizeof(USB_ENDPOINT_DESCRIPTOR))
#define USB_HID_DESC_SIZE (sizeof(HID_DESCRIPTOR))
#define USB_HID_REPORT_DESC_SIZE (sizeof(USBD_HID_ReportDescriptor))
#endif /* __USBD_DESC_H__ */
@@ -0,0 +1,71 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_EVENT_H__
#define __USBD_EVENT_H__
/* USB Device - Device Events */
#define USBD_EVT_POWER_ON (1 << 0) /* USB Power On */
#define USBD_EVT_POWER_OFF (1 << 1) /* USB Power Off */
#define USBD_EVT_RESET (1 << 2) /* USB Bus Reset */
#define USBD_EVT_WAKEUP (1 << 3) /* USB Remote Wakeup */
#define USBD_EVT_SUSPEND (1 << 4) /* USB Suspend */
#define USBD_EVT_RESUME (1 << 5) /* USB Resume */
#define USBD_EVT_SOF (1 << 6) /* USB Start of Frame */
#define USBD_EVT_ERROR (1 << 7) /* USB Error */
/* USB Device - Endpoint Events */
#define USBD_EVT_SETUP (1 << 1) /* Setup Packet */
#define USBD_EVT_OUT (1 << 2) /* OUT Packet */
#define USBD_EVT_IN (1 << 3) /* IN Packet */
#define USBD_EVT_OUT_NAK (1 << 4) /* OUT Packet - Not Acknowledged */
#define USBD_EVT_IN_NAK (1 << 5) /* IN Packet - Not Acknowledged */
#define USBD_EVT_OUT_STALL (1 << 6) /* OUT Packet - Stalled */
#define USBD_EVT_IN_STALL (1 << 7) /* IN Packet - Stalled */
#define USBD_EVT_OUT_DMA_EOT (1 << 8) /* DMA OUT EP - End of Transfer */
#define USBD_EVT_IN_DMA_EOT (1 << 9) /* DMA IN EP - End of Transfer */
#define USBD_EVT_OUT_DMA_NDR (1 << 10) /* DMA OUT EP - New Descriptor Request*/
#define USBD_EVT_IN_DMA_NDR (1 << 11) /* DMA IN EP - New Descriptor Request*/
#define USBD_EVT_OUT_DMA_ERR (1 << 12) /* DMA OUT EP - Error */
#define USBD_EVT_IN_DMA_ERR (1 << 13) /* DMA IN EP - Error */
/* USB Device - Core Events */
#define USBD_EVT_SET_CFG (1 << 0) /* Set Configuration */
#define USBD_EVT_SET_IF (1 << 1) /* Set Interface */
#define USBD_EVT_SET_FEATURE (1 << 2) /* Set Feature */
#define USBD_EVT_CLR_FEATURE (1 << 3) /* Clear Feature */
/* USB Device - Device Events Callback Pointers */
extern void (* const USBD_P_Power_Event )(BOOL power);
extern void (* const USBD_P_Reset_Event )(void);
extern void (* const USBD_P_Suspend_Event )(void);
extern void (* const USBD_P_Resume_Event )(void);
extern void (* const USBD_P_WakeUp_Event )(void);
extern void (* const USBD_P_SOF_Event )(void);
extern void (* const USBD_P_Error_Event )(U32 error);
/* USB Device - Endpoint Events Callback Pointers */
extern void (* const USBD_P_EP[16]) (U32 event);
/* USB Device - Core Events Callback Pointers */
extern void (* const USBD_P_Configure_Event)(void);
extern void (* const USBD_P_Interface_Event)(void);
extern void (* const USBD_P_Feature_Event )(void);
/* USB Device - RTX version RTX tasks initialization */
extern void USBD_RTX_TaskInit (void);
#endif /* __USBD_EVENT_H__ */
@@ -0,0 +1,44 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_HID_H__
#define __USBD_HID_H__
/*--------------------------- Global constants -------------------------------*/
/* USB HID Class API enumerated constants */
enum {
USBD_HID_REQ_EP_CTRL = 0, /* Request from control endpoint */
USBD_HID_REQ_EP_INT, /* Request from interrupt endpoint */
USBD_HID_REQ_PERIOD_UPDATE /* Request from periodic update */
};
/*--------------------------- Event handling routines ------------------------*/
extern void USBD_HID_Configure_Event (void);
extern void USBD_HID_SOF_Event (void);
extern void USBD_HID_EP_INTIN_Event (U32 event);
extern void USBD_HID_EP_INTOUT_Event (U32 event);
extern void USBD_HID_EP_INT_Event (U32 event);
extern __task void USBD_RTX_HID_EP_INTIN_Event (void);
extern __task void USBD_RTX_HID_EP_INTOUT_Event(void);
extern __task void USBD_RTX_HID_EP_INT_Event (void);
#endif /* __USBD_HID_H__ */
@@ -0,0 +1,43 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_HW_H__
#define __USBD_HW_H__
/* USB Hardware Functions */
extern void USBD_Init (void);
extern void USBD_Connect (BOOL con);
extern void USBD_Reset (void);
extern void USBD_Suspend (void);
extern void USBD_Resume (void);
extern void USBD_WakeUp (void);
extern void USBD_WakeUpCfg (BOOL cfg);
extern void USBD_SetAddress (U32 adr, U32 setup);
extern void USBD_Configure (BOOL cfg);
extern void USBD_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD);
extern void USBD_DirCtrlEP (U32 dir);
extern void USBD_EnableEP (U32 EPNum);
extern void USBD_DisableEP (U32 EPNum);
extern void USBD_ResetEP (U32 EPNum);
extern void USBD_SetStallEP (U32 EPNum);
extern void USBD_ClrStallEP (U32 EPNum);
extern void USBD_ClearEPBuf (U32 EPNum);
extern U32 USBD_ReadEP (U32 EPNum, U8 *pData);
extern U32 USBD_WriteEP (U32 EPNum, U8 *pData, U32 cnt);
extern U32 USBD_GetFrame (void);
extern U32 USBD_GetError (void);
#endif /* __USBD_HW_H__ */
@@ -0,0 +1,33 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_LIB_CDC_H__
#define __USBD_LIB_CDC_H__
/*--------------------------- USB Requests -----------------------------------*/
extern int32_t USBD_CDC_ACM_SendEncapsulatedCommand (void);
extern int32_t USBD_CDC_ACM_GetEncapsulatedResponse (void);
extern int32_t USBD_CDC_ACM_SetCommFeature (uint16_t feat);
extern int32_t USBD_CDC_ACM_GetCommFeature (uint16_t feat);
extern int32_t USBD_CDC_ACM_ClearCommFeature (uint16_t feat);
extern int32_t USBD_CDC_ACM_SetLineCoding (void);
extern int32_t USBD_CDC_ACM_GetLineCoding (void);
extern int32_t USBD_CDC_ACM_SetControlLineState (uint16_t ctrl_bmp);
extern int32_t USBD_CDC_ACM_SendBreak (uint16_t dur);
#endif /* __USBD_LIB_CDC_H__ */
@@ -0,0 +1,30 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_LIB_HID_H__
#define __USBD_LIB_HID_H__
/*--------------------------- USB Requests -----------------------------------*/
extern BOOL USBD_HID_GetReport (void);
extern BOOL USBD_HID_SetReport (void);
extern BOOL USBD_HID_GetIdle (void);
extern BOOL USBD_HID_SetIdle (void);
extern BOOL USBD_HID_GetProtocol (void);
extern BOOL USBD_HID_SetProtocol (void);
#endif /* __USBD_LIB_HID_H__ */
@@ -0,0 +1,29 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_LIB_MSC_H__
#define __USBD_LIB_MSC_H__
/*--------------------------- USB Requests -----------------------------------*/
extern void USBD_MSC_ClrStallEP(U32 EPNum);
extern BOOL USBD_MSC_Reset (void);
extern BOOL USBD_MSC_GetMaxLUN (void);
extern void USBD_MSC_GetCBW (void);
extern void USBD_MSC_SetCSW (void);
#endif /* __USBD_LIB_MSC_H__ */
@@ -0,0 +1,43 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2009-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __USBD_MSC_H__
#define __USBD_MSC_H__
/*--------------------------- Global variables -------------------------------*/
/* USB Device Mass Storage Device Class Global Variables */
extern BOOL USBD_MSC_MediaReady;
extern BOOL USBD_MSC_ReadOnly;
extern U32 USBD_MSC_MemorySize;
extern U32 USBD_MSC_BlockSize;
extern U32 USBD_MSC_BlockGroup;
extern U32 USBD_MSC_BlockCount;
extern U8 *USBD_MSC_BlockBuf;
/*--------------------------- Event handling routines ------------------------*/
extern void USBD_MSC_EP_BULKIN_Event (U32 event);
extern void USBD_MSC_EP_BULKOUT_Event (U32 event);
extern void USBD_MSC_EP_BULK_Event (U32 event);
extern __task void USBD_RTX_MSC_EP_BULKIN_Event (void);
extern __task void USBD_RTX_MSC_EP_BULKOUT_Event (void);
extern __task void USBD_RTX_MSC_EP_BULK_Event (void);
#endif /* __USBD_MSC_H__ */