Updated and Validated
[betaflight.git] / lib / main / STM32_USB-FS-Device_Driver / src / usb_regs.c
blobb1e22fe6e384b7a27a4b1cb047a384c998697c85
1 /**
2 ******************************************************************************
3 * @file usb_regs.c
4 * @author MCD Application Team
5 * @version V4.0.0
6 * @date 28-August-2012
7 * @brief Interface functions to USB cell registers
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
13 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 * You may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at:
17 * http://www.st.com/software_license_agreement_liberty_v2
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
25 ******************************************************************************
28 /* Includes ------------------------------------------------------------------*/
29 #include "usb_lib.h"
31 /* Private typedef -----------------------------------------------------------*/
32 /* Private define ------------------------------------------------------------*/
33 /* Private macro -------------------------------------------------------------*/
34 /* Private variables ---------------------------------------------------------*/
35 /* Extern variables ----------------------------------------------------------*/
36 /* Private function prototypes -----------------------------------------------*/
37 /* Private functions ---------------------------------------------------------*/
39 /*******************************************************************************
40 * Function Name : SetCNTR.
41 * Description : Set the CNTR register value.
42 * Input : wRegValue: new register value.
43 * Output : None.
44 * Return : None.
45 *******************************************************************************/
46 void SetCNTR(uint16_t wRegValue)
48 _SetCNTR(wRegValue);
51 /*******************************************************************************
52 * Function Name : GetCNTR.
53 * Description : returns the CNTR register value.
54 * Input : None.
55 * Output : None.
56 * Return : CNTR register Value.
57 *******************************************************************************/
58 uint16_t GetCNTR(void)
60 return(_GetCNTR());
63 /*******************************************************************************
64 * Function Name : SetISTR.
65 * Description : Set the ISTR register value.
66 * Input : wRegValue: new register value.
67 * Output : None.
68 * Return : None.
69 *******************************************************************************/
70 void SetISTR(uint16_t wRegValue)
72 _SetISTR(wRegValue);
75 /*******************************************************************************
76 * Function Name : GetISTR
77 * Description : Returns the ISTR register value.
78 * Input : None.
79 * Output : None.
80 * Return : ISTR register Value
81 *******************************************************************************/
82 uint16_t GetISTR(void)
84 return(_GetISTR());
87 /*******************************************************************************
88 * Function Name : GetFNR
89 * Description : Returns the FNR register value.
90 * Input : None.
91 * Output : None.
92 * Return : FNR register Value
93 *******************************************************************************/
94 uint16_t GetFNR(void)
96 return(_GetFNR());
99 /*******************************************************************************
100 * Function Name : SetDADDR
101 * Description : Set the DADDR register value.
102 * Input : wRegValue: new register value.
103 * Output : None.
104 * Return : None.
105 *******************************************************************************/
106 void SetDADDR(uint16_t wRegValue)
108 _SetDADDR(wRegValue);
111 /*******************************************************************************
112 * Function Name : GetDADDR
113 * Description : Returns the DADDR register value.
114 * Input : None.
115 * Output : None.
116 * Return : DADDR register Value
117 *******************************************************************************/
118 uint16_t GetDADDR(void)
120 return(_GetDADDR());
123 /*******************************************************************************
124 * Function Name : SetBTABLE
125 * Description : Set the BTABLE.
126 * Input : wRegValue: New register value.
127 * Output : None.
128 * Return : None.
129 *******************************************************************************/
130 void SetBTABLE(uint16_t wRegValue)
132 _SetBTABLE(wRegValue);
135 /*******************************************************************************
136 * Function Name : GetBTABLE.
137 * Description : Returns the BTABLE register value.
138 * Input : None.
139 * Output : None.
140 * Return : BTABLE address.
141 *******************************************************************************/
142 uint16_t GetBTABLE(void)
144 return(_GetBTABLE());
147 /*******************************************************************************
148 * Function Name : SetENDPOINT
149 * Description : Set the Endpoint register value.
150 * Input : bEpNum: Endpoint Number.
151 * wRegValue.
152 * Output : None.
153 * Return : None.
154 *******************************************************************************/
155 void SetENDPOINT(uint8_t bEpNum, uint16_t wRegValue)
157 _SetENDPOINT(bEpNum, wRegValue);
160 /*******************************************************************************
161 * Function Name : GetENDPOINT
162 * Description : Return the Endpoint register value.
163 * Input : bEpNum: Endpoint Number.
164 * Output : None.
165 * Return : Endpoint register value.
166 *******************************************************************************/
167 uint16_t GetENDPOINT(uint8_t bEpNum)
169 return(_GetENDPOINT(bEpNum));
172 /*******************************************************************************
173 * Function Name : SetEPType
174 * Description : sets the type in the endpoint register.
175 * Input : bEpNum: Endpoint Number.
176 * wType: type definition.
177 * Output : None.
178 * Return : None.
179 *******************************************************************************/
180 void SetEPType(uint8_t bEpNum, uint16_t wType)
182 _SetEPType(bEpNum, wType);
185 /*******************************************************************************
186 * Function Name : GetEPType
187 * Description : Returns the endpoint type.
188 * Input : bEpNum: Endpoint Number.
189 * Output : None.
190 * Return : Endpoint Type
191 *******************************************************************************/
192 uint16_t GetEPType(uint8_t bEpNum)
194 return(_GetEPType(bEpNum));
197 /*******************************************************************************
198 * Function Name : SetEPTxStatus
199 * Description : Set the status of Tx endpoint.
200 * Input : bEpNum: Endpoint Number.
201 * wState: new state.
202 * Output : None.
203 * Return : None.
204 *******************************************************************************/
205 void SetEPTxStatus(uint8_t bEpNum, uint16_t wState)
207 _SetEPTxStatus(bEpNum, wState);
210 /*******************************************************************************
211 * Function Name : SetEPRxStatus
212 * Description : Set the status of Rx endpoint.
213 * Input : bEpNum: Endpoint Number.
214 * wState: new state.
215 * Output : None.
216 * Return : None.
217 *******************************************************************************/
218 void SetEPRxStatus(uint8_t bEpNum, uint16_t wState)
220 _SetEPRxStatus(bEpNum, wState);
223 /*******************************************************************************
224 * Function Name : SetDouBleBuffEPStall
225 * Description : sets the status for Double Buffer Endpoint to STALL
226 * Input : bEpNum: Endpoint Number.
227 * bDir: Endpoint direction.
228 * Output : None.
229 * Return : None.
230 *******************************************************************************/
231 void SetDouBleBuffEPStall(uint8_t bEpNum, uint8_t bDir)
233 uint16_t Endpoint_DTOG_Status;
234 Endpoint_DTOG_Status = GetENDPOINT(bEpNum);
235 if (bDir == EP_DBUF_OUT)
236 { /* OUT double buffered endpoint */
237 _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPRX_DTOG1);
239 else if (bDir == EP_DBUF_IN)
240 { /* IN double buffered endpoint */
241 _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPTX_DTOG1);
245 /*******************************************************************************
246 * Function Name : GetEPTxStatus
247 * Description : Returns the endpoint Tx status.
248 * Input : bEpNum: Endpoint Number.
249 * Output : None.
250 * Return : Endpoint TX Status
251 *******************************************************************************/
252 uint16_t GetEPTxStatus(uint8_t bEpNum)
254 return(_GetEPTxStatus(bEpNum));
257 /*******************************************************************************
258 * Function Name : GetEPRxStatus
259 * Description : Returns the endpoint Rx status.
260 * Input : bEpNum: Endpoint Number.
261 * Output : None.
262 * Return : Endpoint RX Status
263 *******************************************************************************/
264 uint16_t GetEPRxStatus(uint8_t bEpNum)
266 return(_GetEPRxStatus(bEpNum));
269 /*******************************************************************************
270 * Function Name : SetEPTxValid
271 * Description : Valid the endpoint Tx Status.
272 * Input : bEpNum: Endpoint Number.
273 * Output : None.
274 * Return : None.
275 *******************************************************************************/
276 void SetEPTxValid(uint8_t bEpNum)
278 _SetEPTxStatus(bEpNum, EP_TX_VALID);
281 /*******************************************************************************
282 * Function Name : SetEPRxValid
283 * Description : Valid the endpoint Rx Status.
284 * Input : bEpNum: Endpoint Number.
285 * Output : None.
286 * Return : None.
287 *******************************************************************************/
288 void SetEPRxValid(uint8_t bEpNum)
290 _SetEPRxStatus(bEpNum, EP_RX_VALID);
293 /*******************************************************************************
294 * Function Name : SetEP_KIND
295 * Description : Clear the EP_KIND bit.
296 * Input : bEpNum: Endpoint Number.
297 * Output : None.
298 * Return : None.
299 *******************************************************************************/
300 void SetEP_KIND(uint8_t bEpNum)
302 _SetEP_KIND(bEpNum);
305 /*******************************************************************************
306 * Function Name : ClearEP_KIND
307 * Description : set the EP_KIND bit.
308 * Input : bEpNum: Endpoint Number.
309 * Output : None.
310 * Return : None.
311 *******************************************************************************/
312 void ClearEP_KIND(uint8_t bEpNum)
314 _ClearEP_KIND(bEpNum);
316 /*******************************************************************************
317 * Function Name : Clear_Status_Out
318 * Description : Clear the Status Out of the related Endpoint
319 * Input : bEpNum: Endpoint Number.
320 * Output : None.
321 * Return : None.
322 *******************************************************************************/
323 void Clear_Status_Out(uint8_t bEpNum)
325 _ClearEP_KIND(bEpNum);
327 /*******************************************************************************
328 * Function Name : Set_Status_Out
329 * Description : Set the Status Out of the related Endpoint
330 * Input : bEpNum: Endpoint Number.
331 * Output : None.
332 * Return : None.
333 *******************************************************************************/
334 void Set_Status_Out(uint8_t bEpNum)
336 _SetEP_KIND(bEpNum);
338 /*******************************************************************************
339 * Function Name : SetEPDoubleBuff
340 * Description : Enable the double buffer feature for the endpoint.
341 * Input : bEpNum: Endpoint Number.
342 * Output : None.
343 * Return : None.
344 *******************************************************************************/
345 void SetEPDoubleBuff(uint8_t bEpNum)
347 _SetEP_KIND(bEpNum);
349 /*******************************************************************************
350 * Function Name : ClearEPDoubleBuff
351 * Description : Disable the double buffer feature for the endpoint.
352 * Input : bEpNum: Endpoint Number.
353 * Output : None.
354 * Return : None.
355 *******************************************************************************/
356 void ClearEPDoubleBuff(uint8_t bEpNum)
358 _ClearEP_KIND(bEpNum);
360 /*******************************************************************************
361 * Function Name : GetTxStallStatus
362 * Description : Returns the Stall status of the Tx endpoint.
363 * Input : bEpNum: Endpoint Number.
364 * Output : None.
365 * Return : Tx Stall status.
366 *******************************************************************************/
367 uint16_t GetTxStallStatus(uint8_t bEpNum)
369 return(_GetTxStallStatus(bEpNum));
371 /*******************************************************************************
372 * Function Name : GetRxStallStatus
373 * Description : Returns the Stall status of the Rx endpoint.
374 * Input : bEpNum: Endpoint Number.
375 * Output : None.
376 * Return : Rx Stall status.
377 *******************************************************************************/
378 uint16_t GetRxStallStatus(uint8_t bEpNum)
380 return(_GetRxStallStatus(bEpNum));
382 /*******************************************************************************
383 * Function Name : ClearEP_CTR_RX
384 * Description : Clear the CTR_RX bit.
385 * Input : bEpNum: Endpoint Number.
386 * Output : None.
387 * Return : None.
388 *******************************************************************************/
389 void ClearEP_CTR_RX(uint8_t bEpNum)
391 _ClearEP_CTR_RX(bEpNum);
393 /*******************************************************************************
394 * Function Name : ClearEP_CTR_TX
395 * Description : Clear the CTR_TX bit.
396 * Input : bEpNum: Endpoint Number.
397 * Output : None.
398 * Return : None.
399 *******************************************************************************/
400 void ClearEP_CTR_TX(uint8_t bEpNum)
402 _ClearEP_CTR_TX(bEpNum);
404 /*******************************************************************************
405 * Function Name : ToggleDTOG_RX
406 * Description : Toggle the DTOG_RX bit.
407 * Input : bEpNum: Endpoint Number.
408 * Output : None.
409 * Return : None.
410 *******************************************************************************/
411 void ToggleDTOG_RX(uint8_t bEpNum)
413 _ToggleDTOG_RX(bEpNum);
415 /*******************************************************************************
416 * Function Name : ToggleDTOG_TX
417 * Description : Toggle the DTOG_TX bit.
418 * Input : bEpNum: Endpoint Number.
419 * Output : None.
420 * Return : None.
421 *******************************************************************************/
422 void ToggleDTOG_TX(uint8_t bEpNum)
424 _ToggleDTOG_TX(bEpNum);
426 /*******************************************************************************
427 * Function Name : ClearDTOG_RX.
428 * Description : Clear the DTOG_RX bit.
429 * Input : bEpNum: Endpoint Number.
430 * Output : None.
431 * Return : None.
432 *******************************************************************************/
433 void ClearDTOG_RX(uint8_t bEpNum)
435 _ClearDTOG_RX(bEpNum);
437 /*******************************************************************************
438 * Function Name : ClearDTOG_TX.
439 * Description : Clear the DTOG_TX bit.
440 * Input : bEpNum: Endpoint Number.
441 * Output : None.
442 * Return : None.
443 *******************************************************************************/
444 void ClearDTOG_TX(uint8_t bEpNum)
446 _ClearDTOG_TX(bEpNum);
448 /*******************************************************************************
449 * Function Name : SetEPAddress
450 * Description : Set the endpoint address.
451 * Input : bEpNum: Endpoint Number.
452 * bAddr: New endpoint address.
453 * Output : None.
454 * Return : None.
455 *******************************************************************************/
456 void SetEPAddress(uint8_t bEpNum, uint8_t bAddr)
458 _SetEPAddress(bEpNum, bAddr);
460 /*******************************************************************************
461 * Function Name : GetEPAddress
462 * Description : Get the endpoint address.
463 * Input : bEpNum: Endpoint Number.
464 * Output : None.
465 * Return : Endpoint address.
466 *******************************************************************************/
467 uint8_t GetEPAddress(uint8_t bEpNum)
469 return(_GetEPAddress(bEpNum));
471 /*******************************************************************************
472 * Function Name : SetEPTxAddr
473 * Description : Set the endpoint Tx buffer address.
474 * Input : bEpNum: Endpoint Number.
475 * wAddr: new address.
476 * Output : None.
477 * Return : None.
478 *******************************************************************************/
479 void SetEPTxAddr(uint8_t bEpNum, uint16_t wAddr)
481 _SetEPTxAddr(bEpNum, wAddr);
483 /*******************************************************************************
484 * Function Name : SetEPRxAddr
485 * Description : Set the endpoint Rx buffer address.
486 * Input : bEpNum: Endpoint Number.
487 * wAddr: new address.
488 * Output : None.
489 * Return : None.
490 *******************************************************************************/
491 void SetEPRxAddr(uint8_t bEpNum, uint16_t wAddr)
493 _SetEPRxAddr(bEpNum, wAddr);
495 /*******************************************************************************
496 * Function Name : GetEPTxAddr
497 * Description : Returns the endpoint Tx buffer address.
498 * Input : bEpNum: Endpoint Number.
499 * Output : None.
500 * Return : Rx buffer address.
501 *******************************************************************************/
502 uint16_t GetEPTxAddr(uint8_t bEpNum)
504 return(_GetEPTxAddr(bEpNum));
506 /*******************************************************************************
507 * Function Name : GetEPRxAddr.
508 * Description : Returns the endpoint Rx buffer address.
509 * Input : bEpNum: Endpoint Number.
510 * Output : None.
511 * Return : Rx buffer address.
512 *******************************************************************************/
513 uint16_t GetEPRxAddr(uint8_t bEpNum)
515 return(_GetEPRxAddr(bEpNum));
517 /*******************************************************************************
518 * Function Name : SetEPTxCount.
519 * Description : Set the Tx count.
520 * Input : bEpNum: Endpoint Number.
521 * wCount: new count value.
522 * Output : None.
523 * Return : None.
524 *******************************************************************************/
525 void SetEPTxCount(uint8_t bEpNum, uint16_t wCount)
527 _SetEPTxCount(bEpNum, wCount);
529 /*******************************************************************************
530 * Function Name : SetEPCountRxReg.
531 * Description : Set the Count Rx Register value.
532 * Input : *pdwReg: point to the register.
533 * wCount: the new register value.
534 * Output : None.
535 * Return : None.
536 *******************************************************************************/
537 void SetEPCountRxReg(uint32_t *pdwReg, uint16_t wCount)
539 _SetEPCountRxReg(dwReg, wCount);
541 /*******************************************************************************
542 * Function Name : SetEPRxCount
543 * Description : Set the Rx count.
544 * Input : bEpNum: Endpoint Number.
545 * wCount: the new count value.
546 * Output : None.
547 * Return : None.
548 *******************************************************************************/
549 void SetEPRxCount(uint8_t bEpNum, uint16_t wCount)
551 _SetEPRxCount(bEpNum, wCount);
553 /*******************************************************************************
554 * Function Name : GetEPTxCount
555 * Description : Get the Tx count.
556 * Input : bEpNum: Endpoint Number.
557 * Output : None
558 * Return : Tx count value.
559 *******************************************************************************/
560 uint16_t GetEPTxCount(uint8_t bEpNum)
562 return(_GetEPTxCount(bEpNum));
564 /*******************************************************************************
565 * Function Name : GetEPRxCount
566 * Description : Get the Rx count.
567 * Input : bEpNum: Endpoint Number.
568 * Output : None.
569 * Return : Rx count value.
570 *******************************************************************************/
571 uint16_t GetEPRxCount(uint8_t bEpNum)
573 return(_GetEPRxCount(bEpNum));
575 /*******************************************************************************
576 * Function Name : SetEPDblBuffAddr
577 * Description : Set the addresses of the buffer 0 and 1.
578 * Input : bEpNum: Endpoint Number.
579 * wBuf0Addr: new address of buffer 0.
580 * wBuf1Addr: new address of buffer 1.
581 * Output : None.
582 * Return : None.
583 *******************************************************************************/
584 void SetEPDblBuffAddr(uint8_t bEpNum, uint16_t wBuf0Addr, uint16_t wBuf1Addr)
586 _SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr);
588 /*******************************************************************************
589 * Function Name : SetEPDblBuf0Addr
590 * Description : Set the Buffer 1 address.
591 * Input : bEpNum: Endpoint Number
592 * wBuf0Addr: new address.
593 * Output : None.
594 * Return : None.
595 *******************************************************************************/
596 void SetEPDblBuf0Addr(uint8_t bEpNum, uint16_t wBuf0Addr)
598 _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);
600 /*******************************************************************************
601 * Function Name : SetEPDblBuf1Addr
602 * Description : Set the Buffer 1 address.
603 * Input : bEpNum: Endpoint Number
604 * wBuf1Addr: new address.
605 * Output : None.
606 * Return : None.
607 *******************************************************************************/
608 void SetEPDblBuf1Addr(uint8_t bEpNum, uint16_t wBuf1Addr)
610 _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);
612 /*******************************************************************************
613 * Function Name : GetEPDblBuf0Addr
614 * Description : Returns the address of the Buffer 0.
615 * Input : bEpNum: Endpoint Number.
616 * Output : None.
617 * Return : None.
618 *******************************************************************************/
619 uint16_t GetEPDblBuf0Addr(uint8_t bEpNum)
621 return(_GetEPDblBuf0Addr(bEpNum));
623 /*******************************************************************************
624 * Function Name : GetEPDblBuf1Addr
625 * Description : Returns the address of the Buffer 1.
626 * Input : bEpNum: Endpoint Number.
627 * Output : None.
628 * Return : Address of the Buffer 1.
629 *******************************************************************************/
630 uint16_t GetEPDblBuf1Addr(uint8_t bEpNum)
632 return(_GetEPDblBuf1Addr(bEpNum));
634 /*******************************************************************************
635 * Function Name : SetEPDblBuffCount
636 * Description : Set the number of bytes for a double Buffer
637 * endpoint.
638 * Input : bEpNum,bDir, wCount
639 * Output : None.
640 * Return : None.
641 *******************************************************************************/
642 void SetEPDblBuffCount(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
644 _SetEPDblBuffCount(bEpNum, bDir, wCount);
646 /*******************************************************************************
647 * Function Name : SetEPDblBuf0Count
648 * Description : Set the number of bytes in the buffer 0 of a double Buffer
649 * endpoint.
650 * Input : bEpNum, bDir, wCount
651 * Output : None.
652 * Return : None.
653 *******************************************************************************/
654 void SetEPDblBuf0Count(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
656 _SetEPDblBuf0Count(bEpNum, bDir, wCount);
658 /*******************************************************************************
659 * Function Name : SetEPDblBuf1Count
660 * Description : Set the number of bytes in the buffer 0 of a double Buffer
661 * endpoint.
662 * Input : bEpNum, bDir, wCount
663 * Output : None.
664 * Return : None.
665 *******************************************************************************/
666 void SetEPDblBuf1Count(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
668 _SetEPDblBuf1Count(bEpNum, bDir, wCount);
670 /*******************************************************************************
671 * Function Name : GetEPDblBuf0Count
672 * Description : Returns the number of byte received in the buffer 0 of a double
673 * Buffer endpoint.
674 * Input : bEpNum: Endpoint Number.
675 * Output : None.
676 * Return : Endpoint Buffer 0 count
677 *******************************************************************************/
678 uint16_t GetEPDblBuf0Count(uint8_t bEpNum)
680 return(_GetEPDblBuf0Count(bEpNum));
682 /*******************************************************************************
683 * Function Name : GetEPDblBuf1Count
684 * Description : Returns the number of data received in the buffer 1 of a double
685 * Buffer endpoint.
686 * Input : bEpNum: Endpoint Number.
687 * Output : None.
688 * Return : Endpoint Buffer 1 count.
689 *******************************************************************************/
690 uint16_t GetEPDblBuf1Count(uint8_t bEpNum)
692 return(_GetEPDblBuf1Count(bEpNum));
694 /*******************************************************************************
695 * Function Name : GetEPDblBufDir
696 * Description : gets direction of the double buffered endpoint
697 * Input : bEpNum: Endpoint Number.
698 * Output : None.
699 * Return : EP_DBUF_OUT, EP_DBUF_IN,
700 * EP_DBUF_ERR if the endpoint counter not yet programmed.
701 *******************************************************************************/
702 EP_DBUF_DIR GetEPDblBufDir(uint8_t bEpNum)
704 if ((uint16_t)(*_pEPRxCount(bEpNum) & 0xFC00) != 0)
705 return(EP_DBUF_OUT);
706 else if (((uint16_t)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0)
707 return(EP_DBUF_IN);
708 else
709 return(EP_DBUF_ERR);
711 /*******************************************************************************
712 * Function Name : FreeUserBuffer
713 * Description : free buffer used from the application realizing it to the line
714 toggles bit SW_BUF in the double buffered endpoint register
715 * Input : bEpNum, bDir
716 * Output : None.
717 * Return : None.
718 *******************************************************************************/
719 void FreeUserBuffer(uint8_t bEpNum, uint8_t bDir)
721 if (bDir == EP_DBUF_OUT)
722 { /* OUT double buffered endpoint */
723 _ToggleDTOG_TX(bEpNum);
725 else if (bDir == EP_DBUF_IN)
726 { /* IN double buffered endpoint */
727 _ToggleDTOG_RX(bEpNum);
731 /*******************************************************************************
732 * Function Name : ToWord
733 * Description : merge two byte in a word.
734 * Input : bh: byte high, bl: bytes low.
735 * Output : None.
736 * Return : resulted word.
737 *******************************************************************************/
738 uint16_t ToWord(uint8_t bh, uint8_t bl)
740 uint16_t wRet;
741 wRet = (uint16_t)bl | ((uint16_t)bh << 8);
742 return(wRet);
744 /*******************************************************************************
745 * Function Name : ByteSwap
746 * Description : Swap two byte in a word.
747 * Input : wSwW: word to Swap.
748 * Output : None.
749 * Return : resulted word.
750 *******************************************************************************/
751 uint16_t ByteSwap(uint16_t wSwW)
753 uint8_t bTemp;
754 uint16_t wRet;
755 bTemp = (uint8_t)(wSwW & 0xff);
756 wRet = (wSwW >> 8) | ((uint16_t)bTemp << 8);
757 return(wRet);
760 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/