Project

General

Profile

SIMtrace Firmware » main_simtrace_osx.diff

, 10/04/2011 02:10 PM

View differences:

firmware/src/os/pcd_enumerate.c
78 78
#ifdef CONFIG_DFU
79 79
static const struct dfuapi *dfu = DFU_API_LOCATION;
80 80
#define udp_init		dfu->udp_init
81
#define udp_ep0_send_data	dfu->ep0_send_data
81
#define udp_ep0_send_data	udp_ep0_send_data_local
82 82
#define udp_ep0_send_zlp	dfu->ep0_send_zlp
83 83
#define udp_ep0_send_stall	dfu->ep0_send_stall
84 84
#else
......
107 107
		  .state_pending = RCTX_STATE_UDP_EP3_PENDING },
108 108
};
109 109

  
110
static void udp_ep0_send_data_local(const char *pData, u_int32_t length)
111
{
112
	AT91PS_UDP pUdp = AT91C_BASE_UDP;
113
	u_int32_t cpt = 0, len_remain = length;
114
	AT91_REG csr;
115

  
116
	DEBUGE("send_data: %u bytes ", length);
117

  
118
	do {
119
		cpt = MIN(len_remain, 8);
120
		len_remain -= cpt;
121

  
122
		while (cpt--)
123
			pUdp->UDP_FDR[0] = *pData++;
124

  
125
		if (pUdp->UDP_CSR[0] & AT91C_UDP_TXCOMP) {
126
			pUdp->UDP_CSR[0] &= ~(AT91C_UDP_TXCOMP);
127
			while (pUdp->UDP_CSR[0] & AT91C_UDP_TXCOMP) ;
128
		}
129

  
130
		pUdp->UDP_CSR[0] |= AT91C_UDP_TXPKTRDY;
131
		do {
132
			csr = pUdp->UDP_CSR[0];
133

  
134
			/* Data IN stage has been stopped by a status OUT */
135
			if (csr & AT91C_UDP_RX_DATA_BK0) {
136
				pUdp->UDP_CSR[0] &= ~(AT91C_UDP_RX_DATA_BK0);
137
				DEBUGE("stopped by status out ");
138
				return;
139
			}
140
		} while (!(csr & AT91C_UDP_TXCOMP));
141

  
142
	} while (len_remain);
143

  
144
	if (pUdp->UDP_CSR[0] & AT91C_UDP_TXCOMP) {
145
		pUdp->UDP_CSR[0] &= ~(AT91C_UDP_TXCOMP);
146
		while (pUdp->UDP_CSR[0] & AT91C_UDP_TXCOMP) ;
147
	}
148

  
149
#if 0
150
	if ((length % 8) == 0) {
151
		/* if the length is a multiple of the EP size, we need
152
		 * to send another ZLP (zero-length packet) to tell the
153
		 * host the transfer has completed.  */
154
		DEBUGE("set_txpktrdy_zlp ");
155
		udp_ep0_send_zlp();
156
	}
157
#endif
158
}
159

  
110 160
static void reset_ep(unsigned int ep)
111 161
{
112 162
	AT91PS_UDP pUDP = upcd.pUdp;
(4-4/8)
Add picture from clipboard (Maximum size: 48.8 MB)