WXK
2024-09-18 05e2e954bd127de378a9d1dfbb0ed95d725aad63
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/****************************************
 
  endpoint0.h
  Endpoint 0 header file for MUSBFSFC firmware
 
****************************************/
 
#ifndef _ENDPOINT0_H_
#define _ENDPOINT0_H_
 
#include <stdint.h>
 
/* Endpoint 0 states */
#define M_EP0_IDLE      0
#define M_EP0_RX        1
#define M_EP0_TX        2
 
/* Define device states */
#define DEVSTATE_DEFAULT        0
#define DEVSTATE_ADDRESS        1
#define DEVSTATE_CONFIG         2
 
/* CSR0 bit masks */
#define M_CSR0_OUTPKTRDY            0x01
#define M_CSR0_INPKTRDY             0x02
#define M_CSR0_SENTSTALL            0x04
#define M_CSR0_DATAEND              0x08
#define M_CSR0_SETUPEND             0x10
#define M_CSR0_SENDSTALL            0x20
#define M_CSR0_SVDOUTPKTRDY         0x40
#define M_CSR0_SVDSETUPEND          0x80
 
#define M_INCSR2_FrcDataTog         0x08
#define M_INCSR2_DMAEnab             0x10
#define M_INCSR2_MODE                0x20
#define M_INCSR2_ISO                 0x40
#define M_INCSR2_AUTOSET             0x80
 
#define M_OUTCSR2_DMAMode           0x10
#define M_OUTCSR2_DMAEnab           0x20
#define M_OUTCSR2_ISO               0x40
#define M_OUTCSR2_AutoClear         0x80
 
/* Define maximum packet size for endpoint 0 */
#define M_EP0_MAXP                      8
/* Define maximum number of interfaces in a configuration */
#define M_MAXIFS                        16
/* Define maximum number of reportsize in a configuration */
#define M_MAXREPS                        46
 
/* Endpoint 0 status structure */
typedef struct{
    int32_t       nState;         /* IDLE/RX/TX */
    int32_t       nBytesLeft;     /* Number of bytes left to send in TX mode */
    void          *pData;         /* Pointer to data to transmit/receive */
    int32_t       nBytesRecv;     /* Number of bytes received in RX mode */
    uint8_t      byFAddr;        /* New function address */
}USB_EndPointStatusDef;
//typedef USB_EndPointStatusDef *PM_EP0_STATUS;
 
extern uint32_t    gnDevState;
extern uint8_t report[M_MAXREPS];
 
/* Local functions */
void Endpoint0(int32_t nCallState);
void Endpoint0_Tx (USB_EndPointStatusDef *pep0state);
uint32_t ConfigureIfs(void);
 
#endif /* _ENDPOINT0_H_ */