Skip to content

Commit 76413a9

Browse files
skuepHiFiPhile
authored andcommitted
Added TU_ATTR_ALWAYS_INLINE to all static inline functions
1 parent 9ec2124 commit 76413a9

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ typedef struct
175175

176176
static xfer_ctl_t xfer_status[MAX_EP_COUNT][2];
177177

178-
static inline xfer_ctl_t* xfer_ctl_ptr(uint32_t ep_addr)
178+
TU_ATTR_ALWAYS_INLINE static inline xfer_ctl_t* xfer_ctl_ptr(uint32_t ep_addr)
179179
{
180180
uint8_t epnum = tu_edpt_number(ep_addr);
181181
uint8_t dir = tu_edpt_dir(ep_addr);
@@ -207,12 +207,12 @@ static bool dcd_read_packet_memory_ff(tu_fifo_t * ff, uint16_t src, uint16_t wNB
207207

208208
// Using a function due to better type checks
209209
// This seems better than having to do type casts everywhere else
210-
static inline void reg16_clear_bits(__IO uint16_t *reg, uint16_t mask) {
210+
TU_ATTR_ALWAYS_INLINE static inline void reg16_clear_bits(__IO uint16_t *reg, uint16_t mask) {
211211
*reg = (uint16_t)(*reg & ~mask);
212212
}
213213

214214
// Bits in ISTR are cleared upon writing 0
215-
static inline void clear_istr_bits(uint16_t mask) {
215+
TU_ATTR_ALWAYS_INLINE static inline void clear_istr_bits(uint16_t mask) {
216216
USB->ISTR = ~mask;
217217
}
218218

src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
131131
TU_ATTR_WEAK uint8_t tu_stm32_edpt_number_cb(uint8_t addr);
132132

133133
// 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);
137137

138138
/* 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)
140140
{
141141
/* The STM32 full speed USB peripheral supports only a limited set of
142142
* 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)
149149
}
150150

151151
/* 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)
153153
{
154154
__O uint16_t *reg = (__O uint16_t *)((&USBx->EP0R) + bEpNum*2u);
155155
*reg = (uint16_t)wRegValue;
156156
}
157157

158158
/* 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) {
160160
__I uint16_t *reg = (__I uint16_t *)((&USBx->EP0R) + bEpNum*2u);
161161
return *reg;
162162
}
163163

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)
165165
{
166166
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
167167
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
170170
pcd_set_endpoint(USBx, bEpNum, regVal);
171171
}
172172

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)
174174
{
175175
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
176176
regVal &= USB_EP_T_FIELD;
@@ -182,15 +182,16 @@ static inline uint32_t pcd_get_eptype(USB_TypeDef * USBx, uint32_t bEpNum)
182182
* @param bEpNum Endpoint Number.
183183
* @retval None
184184
*/
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)
186186
{
187187
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
188188
regVal &= USB_EPREG_MASK;
189189
regVal &= ~USB_EP_CTR_RX;
190190
regVal |= USB_EP_CTR_TX; // preserve CTR_TX (clears on writing 0)
191191
pcd_set_endpoint(USBx, bEpNum, regVal);
192192
}
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)
194195
{
195196
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
196197
regVal &= USB_EPREG_MASK;
@@ -204,13 +205,13 @@ static inline void pcd_clear_tx_ep_ctr(USB_TypeDef * USBx, uint32_t bEpNum)
204205
* @param bEpNum Endpoint Number.
205206
* @retval Counter value
206207
*/
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)
208209
{
209210
__I uint16_t *regPtr = pcd_ep_tx_cnt_ptr(USBx, bEpNum);
210211
return *regPtr & 0x3ffU;
211212
}
212213

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)
214215
{
215216
__I uint16_t *regPtr = pcd_ep_rx_cnt_ptr(USBx, bEpNum);
216217
return *regPtr & 0x3ffU;
@@ -223,7 +224,7 @@ static inline uint32_t pcd_get_ep_rx_cnt(USB_TypeDef * USBx, uint32_t bEpNum)
223224
* @param wNBlocks no. of Blocks.
224225
* @retval None
225226
*/
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)
227228
{
228229
/* We assume that the buffer size is already aligned to hardware requirements. */
229230
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)
243244
* @param bAddr Address.
244245
* @retval None
245246
*/
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)
247248
{
248249
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
249250
regVal &= USB_EPREG_MASK;
@@ -252,46 +253,46 @@ static inline void pcd_set_ep_address(USB_TypeDef * USBx, uint32_t bEpNum, uint
252253
pcd_set_endpoint(USBx, bEpNum,regVal);
253254
}
254255

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)
256257
{
257258
size_t total_word_offset = (((USBx)->BTABLE)>>1) + x;
258259
total_word_offset *= PMA_STRIDE;
259260
return &(pma[total_word_offset]);
260261
}
261262

262263
// 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)
264265
{
265266
return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 0u);
266267
}
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)
268269
{
269270
return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 1u);
270271
}
271272

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)
273274
{
274275
return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 2u);
275276
}
276277

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)
278279
{
279280
return pcd_btable_word_ptr(USBx,(bEpNum)*4u + 3u);
280281
}
281282

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)
283284
{
284285
__IO uint16_t * reg = pcd_ep_tx_cnt_ptr(USBx, bEpNum);
285286
*reg = (uint16_t) (*reg & (uint16_t) ~0x3FFU) | (wCount & 0x3FFU);
286287
}
287288

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)
289290
{
290291
__IO uint16_t * reg = pcd_ep_rx_cnt_ptr(USBx, bEpNum);
291292
*reg = (uint16_t) (*reg & (uint16_t) ~0x3FFU) | (wCount & 0x3FFU);
292293
}
293294

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)
295296
{
296297
__IO uint16_t *pdwReg = pcd_ep_rx_cnt_ptr((USBx),(bEpNum));
297298
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
305306
* @param wState new state
306307
* @retval None
307308
*/
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)
309310
{
310311
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
311312
regVal &= USB_EPTX_DTOGMASK;
@@ -332,7 +333,7 @@ static inline void pcd_set_ep_tx_status(USB_TypeDef * USBx, uint32_t bEpNum, ui
332333
* @retval None
333334
*/
334335

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)
336337
{
337338
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
338339
regVal &= USB_EPRX_DTOGMASK;
@@ -351,7 +352,7 @@ static inline void pcd_set_ep_rx_status(USB_TypeDef * USBx, uint32_t bEpNum, ui
351352
pcd_set_endpoint(USBx, bEpNum, regVal);
352353
} /* pcd_set_ep_rx_status */
353354

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)
355356
{
356357
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
357358
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
364365
* @param bEpNum Endpoint Number.
365366
* @retval None
366367
*/
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)
368369
{
369370
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
370371
regVal &= USB_EPREG_MASK;
371372
regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX|USB_EP_DTOG_RX;
372373
pcd_set_endpoint(USBx, bEpNum, regVal);
373374
}
374375

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)
376377
{
377378
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
378379
regVal &= USB_EPREG_MASK;
@@ -387,7 +388,7 @@ static inline void pcd_tx_dtog(USB_TypeDef * USBx, uint32_t bEpNum)
387388
* @retval None
388389
*/
389390

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)
391392
{
392393
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
393394
if((regVal & USB_EP_DTOG_RX) != 0)
@@ -396,7 +397,7 @@ static inline void pcd_clear_rx_dtog(USB_TypeDef * USBx, uint32_t bEpNum)
396397
}
397398
}
398399

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)
400401
{
401402
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
402403
if((regVal & USB_EP_DTOG_TX) != 0)
@@ -412,15 +413,15 @@ static inline void pcd_clear_tx_dtog(USB_TypeDef * USBx, uint32_t bEpNum)
412413
* @retval None
413414
*/
414415

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)
416417
{
417418
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
418419
regVal |= USB_EP_KIND;
419420
regVal &= USB_EPREG_MASK;
420421
regVal |= USB_EP_CTR_RX|USB_EP_CTR_TX;
421422
pcd_set_endpoint(USBx, bEpNum, regVal);
422423
}
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)
424425
{
425426
uint32_t regVal = pcd_get_endpoint(USBx, bEpNum);
426427
regVal &= USB_EPKIND_MASK;

0 commit comments

Comments
 (0)