@@ -131,12 +131,12 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
131
131
TU_ATTR_WEAK uint8_t tu_stm32_edpt_number_cb (uint8_t addr );
132
132
133
133
// prototypes
134
- static inline __IO uint16_t * pcd_ep_rx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum );
135
- static inline __IO uint16_t * pcd_ep_tx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum );
136
- static inline void pcd_set_endpoint (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wRegValue );
134
+ TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t * pcd_ep_rx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum );
135
+ TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t * pcd_ep_tx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum );
136
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_endpoint (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wRegValue );
137
137
138
138
/* Aligned buffer size according to hardware */
139
- static inline uint16_t pcd_aligned_buffer_size (uint16_t size )
139
+ TU_ATTR_ALWAYS_INLINE static inline uint16_t pcd_aligned_buffer_size (uint16_t size )
140
140
{
141
141
/* The STM32 full speed USB peripheral supports only a limited set of
142
142
* buffer sizes given by the RX buffer entry format in the USB_BTABLE. */
@@ -149,19 +149,19 @@ static inline uint16_t pcd_aligned_buffer_size(uint16_t size)
149
149
}
150
150
151
151
/* SetENDPOINT */
152
- static inline void pcd_set_endpoint (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wRegValue )
152
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_endpoint (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wRegValue )
153
153
{
154
154
__O uint16_t * reg = (__O uint16_t * )((& USBx -> EP0R ) + bEpNum * 2u );
155
155
* reg = (uint16_t )wRegValue ;
156
156
}
157
157
158
158
/* GetENDPOINT */
159
- static inline uint16_t pcd_get_endpoint (USB_TypeDef * USBx , uint32_t bEpNum ) {
159
+ TU_ATTR_ALWAYS_INLINE static inline uint16_t pcd_get_endpoint (USB_TypeDef * USBx , uint32_t bEpNum ) {
160
160
__I uint16_t * reg = (__I uint16_t * )((& USBx -> EP0R ) + bEpNum * 2u );
161
161
return * reg ;
162
162
}
163
163
164
- static inline void pcd_set_eptype (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wType )
164
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_eptype (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wType )
165
165
{
166
166
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
167
167
regVal &= (uint32_t )USB_EP_T_MASK ;
@@ -170,7 +170,7 @@ static inline void pcd_set_eptype(USB_TypeDef * USBx, uint32_t bEpNum, uint32_t
170
170
pcd_set_endpoint (USBx , bEpNum , regVal );
171
171
}
172
172
173
- static inline uint32_t pcd_get_eptype (USB_TypeDef * USBx , uint32_t bEpNum )
173
+ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_eptype (USB_TypeDef * USBx , uint32_t bEpNum )
174
174
{
175
175
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
176
176
regVal &= USB_EP_T_FIELD ;
@@ -182,15 +182,16 @@ static inline uint32_t pcd_get_eptype(USB_TypeDef * USBx, uint32_t bEpNum)
182
182
* @param bEpNum Endpoint Number.
183
183
* @retval None
184
184
*/
185
- static inline void pcd_clear_rx_ep_ctr (USB_TypeDef * USBx , uint32_t bEpNum )
185
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_clear_rx_ep_ctr (USB_TypeDef * USBx , uint32_t bEpNum )
186
186
{
187
187
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
188
188
regVal &= USB_EPREG_MASK ;
189
189
regVal &= ~USB_EP_CTR_RX ;
190
190
regVal |= USB_EP_CTR_TX ; // preserve CTR_TX (clears on writing 0)
191
191
pcd_set_endpoint (USBx , bEpNum , regVal );
192
192
}
193
- static inline void pcd_clear_tx_ep_ctr (USB_TypeDef * USBx , uint32_t bEpNum )
193
+
194
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_clear_tx_ep_ctr (USB_TypeDef * USBx , uint32_t bEpNum )
194
195
{
195
196
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
196
197
regVal &= USB_EPREG_MASK ;
@@ -204,13 +205,13 @@ static inline void pcd_clear_tx_ep_ctr(USB_TypeDef * USBx, uint32_t bEpNum)
204
205
* @param bEpNum Endpoint Number.
205
206
* @retval Counter value
206
207
*/
207
- static inline uint32_t pcd_get_ep_tx_cnt (USB_TypeDef * USBx , uint32_t bEpNum )
208
+ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_ep_tx_cnt (USB_TypeDef * USBx , uint32_t bEpNum )
208
209
{
209
210
__I uint16_t * regPtr = pcd_ep_tx_cnt_ptr (USBx , bEpNum );
210
211
return * regPtr & 0x3ffU ;
211
212
}
212
213
213
- static inline uint32_t pcd_get_ep_rx_cnt (USB_TypeDef * USBx , uint32_t bEpNum )
214
+ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_ep_rx_cnt (USB_TypeDef * USBx , uint32_t bEpNum )
214
215
{
215
216
__I uint16_t * regPtr = pcd_ep_rx_cnt_ptr (USBx , bEpNum );
216
217
return * regPtr & 0x3ffU ;
@@ -223,7 +224,7 @@ static inline uint32_t pcd_get_ep_rx_cnt(USB_TypeDef * USBx, uint32_t bEpNum)
223
224
* @param wNBlocks no. of Blocks.
224
225
* @retval None
225
226
*/
226
- static inline void pcd_set_ep_cnt_reg (__O uint16_t * pdwReg , size_t wCount )
227
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_cnt_reg (__O uint16_t * pdwReg , size_t wCount )
227
228
{
228
229
/* We assume that the buffer size is already aligned to hardware requirements. */
229
230
uint16_t blocksize = (wCount > 62 ) ? 1 : 0 ;
@@ -243,7 +244,7 @@ static inline void pcd_set_ep_cnt_reg(__O uint16_t * pdwReg, size_t wCount)
243
244
* @param bAddr Address.
244
245
* @retval None
245
246
*/
246
- static inline void pcd_set_ep_address (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t bAddr )
247
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_address (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t bAddr )
247
248
{
248
249
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
249
250
regVal &= USB_EPREG_MASK ;
@@ -252,46 +253,46 @@ static inline void pcd_set_ep_address(USB_TypeDef * USBx, uint32_t bEpNum, uint
252
253
pcd_set_endpoint (USBx , bEpNum ,regVal );
253
254
}
254
255
255
- static inline __IO uint16_t * pcd_btable_word_ptr (USB_TypeDef * USBx , size_t x )
256
+ TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t * pcd_btable_word_ptr (USB_TypeDef * USBx , size_t x )
256
257
{
257
258
size_t total_word_offset = (((USBx )-> BTABLE )>>1 ) + x ;
258
259
total_word_offset *= PMA_STRIDE ;
259
260
return & (pma [total_word_offset ]);
260
261
}
261
262
262
263
// Pointers to the PMA table entries (using the ARM address space)
263
- static inline __IO uint16_t * pcd_ep_tx_address_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
264
+ TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t * pcd_ep_tx_address_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
264
265
{
265
266
return pcd_btable_word_ptr (USBx ,(bEpNum )* 4u + 0u );
266
267
}
267
- static inline __IO uint16_t * pcd_ep_tx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
268
+ TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t * pcd_ep_tx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
268
269
{
269
270
return pcd_btable_word_ptr (USBx ,(bEpNum )* 4u + 1u );
270
271
}
271
272
272
- static inline __IO uint16_t * pcd_ep_rx_address_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
273
+ TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t * pcd_ep_rx_address_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
273
274
{
274
275
return pcd_btable_word_ptr (USBx ,(bEpNum )* 4u + 2u );
275
276
}
276
277
277
- static inline __IO uint16_t * pcd_ep_rx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
278
+ TU_ATTR_ALWAYS_INLINE static inline __IO uint16_t * pcd_ep_rx_cnt_ptr (USB_TypeDef * USBx , uint32_t bEpNum )
278
279
{
279
280
return pcd_btable_word_ptr (USBx ,(bEpNum )* 4u + 3u );
280
281
}
281
282
282
- static inline void pcd_set_ep_tx_cnt (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wCount )
283
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_cnt (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wCount )
283
284
{
284
285
__IO uint16_t * reg = pcd_ep_tx_cnt_ptr (USBx , bEpNum );
285
286
* reg = (uint16_t ) (* reg & (uint16_t ) ~0x3FFU ) | (wCount & 0x3FFU );
286
287
}
287
288
288
- static inline void pcd_set_ep_rx_cnt (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wCount )
289
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_cnt (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wCount )
289
290
{
290
291
__IO uint16_t * reg = pcd_ep_rx_cnt_ptr (USBx , bEpNum );
291
292
* reg = (uint16_t ) (* reg & (uint16_t ) ~0x3FFU ) | (wCount & 0x3FFU );
292
293
}
293
294
294
- static inline void pcd_set_ep_rx_bufsize (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wCount )
295
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_bufsize (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wCount )
295
296
{
296
297
__IO uint16_t * pdwReg = pcd_ep_rx_cnt_ptr ((USBx ),(bEpNum ));
297
298
wCount = pcd_aligned_buffer_size (wCount );
@@ -305,7 +306,7 @@ static inline void pcd_set_ep_rx_bufsize(USB_TypeDef * USBx, uint32_t bEpNum, u
305
306
* @param wState new state
306
307
* @retval None
307
308
*/
308
- static inline void pcd_set_ep_tx_status (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wState )
309
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_status (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wState )
309
310
{
310
311
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
311
312
regVal &= USB_EPTX_DTOGMASK ;
@@ -332,7 +333,7 @@ static inline void pcd_set_ep_tx_status(USB_TypeDef * USBx, uint32_t bEpNum, ui
332
333
* @retval None
333
334
*/
334
335
335
- static inline void pcd_set_ep_rx_status (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wState )
336
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_status (USB_TypeDef * USBx , uint32_t bEpNum , uint32_t wState )
336
337
{
337
338
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
338
339
regVal &= USB_EPRX_DTOGMASK ;
@@ -351,7 +352,7 @@ static inline void pcd_set_ep_rx_status(USB_TypeDef * USBx, uint32_t bEpNum, ui
351
352
pcd_set_endpoint (USBx , bEpNum , regVal );
352
353
} /* pcd_set_ep_rx_status */
353
354
354
- static inline uint32_t pcd_get_ep_rx_status (USB_TypeDef * USBx , uint32_t bEpNum )
355
+ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_ep_rx_status (USB_TypeDef * USBx , uint32_t bEpNum )
355
356
{
356
357
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
357
358
return (regVal & USB_EPRX_STAT ) >> (12u );
@@ -364,15 +365,15 @@ static inline uint32_t pcd_get_ep_rx_status(USB_TypeDef * USBx, uint32_t bEpNum
364
365
* @param bEpNum Endpoint Number.
365
366
* @retval None
366
367
*/
367
- static inline void pcd_rx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
368
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_rx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
368
369
{
369
370
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
370
371
regVal &= USB_EPREG_MASK ;
371
372
regVal |= USB_EP_CTR_RX |USB_EP_CTR_TX |USB_EP_DTOG_RX ;
372
373
pcd_set_endpoint (USBx , bEpNum , regVal );
373
374
}
374
375
375
- static inline void pcd_tx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
376
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_tx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
376
377
{
377
378
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
378
379
regVal &= USB_EPREG_MASK ;
@@ -387,7 +388,7 @@ static inline void pcd_tx_dtog(USB_TypeDef * USBx, uint32_t bEpNum)
387
388
* @retval None
388
389
*/
389
390
390
- static inline void pcd_clear_rx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
391
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_clear_rx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
391
392
{
392
393
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
393
394
if ((regVal & USB_EP_DTOG_RX ) != 0 )
@@ -396,7 +397,7 @@ static inline void pcd_clear_rx_dtog(USB_TypeDef * USBx, uint32_t bEpNum)
396
397
}
397
398
}
398
399
399
- static inline void pcd_clear_tx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
400
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_clear_tx_dtog (USB_TypeDef * USBx , uint32_t bEpNum )
400
401
{
401
402
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
402
403
if ((regVal & USB_EP_DTOG_TX ) != 0 )
@@ -412,15 +413,15 @@ static inline void pcd_clear_tx_dtog(USB_TypeDef * USBx, uint32_t bEpNum)
412
413
* @retval None
413
414
*/
414
415
415
- static inline void pcd_set_ep_kind (USB_TypeDef * USBx , uint32_t bEpNum )
416
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_kind (USB_TypeDef * USBx , uint32_t bEpNum )
416
417
{
417
418
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
418
419
regVal |= USB_EP_KIND ;
419
420
regVal &= USB_EPREG_MASK ;
420
421
regVal |= USB_EP_CTR_RX |USB_EP_CTR_TX ;
421
422
pcd_set_endpoint (USBx , bEpNum , regVal );
422
423
}
423
- static inline void pcd_clear_ep_kind (USB_TypeDef * USBx , uint32_t bEpNum )
424
+ TU_ATTR_ALWAYS_INLINE static inline void pcd_clear_ep_kind (USB_TypeDef * USBx , uint32_t bEpNum )
424
425
{
425
426
uint32_t regVal = pcd_get_endpoint (USBx , bEpNum );
426
427
regVal &= USB_EPKIND_MASK ;
0 commit comments