usb_regs.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
  2. * File Name : usb_regs.c
  3. * Author : MCD Application Team
  4. * Version : V3.1.0
  5. * Date : 10/30/2009
  6. * Description : Interface functions to USB cell registers
  7. ********************************************************************************
  8. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  9. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  10. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  11. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  12. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  13. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  14. *******************************************************************************/
  15. #ifndef STM32F10X_CL
  16. /* Includes ------------------------------------------------------------------*/
  17. #include "usb_lib.h"
  18. /* Private typedef -----------------------------------------------------------*/
  19. /* Private define ------------------------------------------------------------*/
  20. /* Private macro -------------------------------------------------------------*/
  21. /* Private variables ---------------------------------------------------------*/
  22. /* Extern variables ----------------------------------------------------------*/
  23. /* Private function prototypes -----------------------------------------------*/
  24. /* Private functions ---------------------------------------------------------*/
  25. /*******************************************************************************
  26. * Function Name : SetCNTR.
  27. * Description : Set the CNTR register value.
  28. * Input : wRegValue: new register value.
  29. * Output : None.
  30. * Return : None.
  31. *******************************************************************************/
  32. void SetCNTR(uint16_t wRegValue)
  33. {
  34. _SetCNTR(wRegValue);
  35. }
  36. /*******************************************************************************
  37. * Function Name : GetCNTR.
  38. * Description : returns the CNTR register value.
  39. * Input : None.
  40. * Output : None.
  41. * Return : CNTR register Value.
  42. *******************************************************************************/
  43. uint16_t GetCNTR(void)
  44. {
  45. return(_GetCNTR());
  46. }
  47. /*******************************************************************************
  48. * Function Name : SetISTR.
  49. * Description : Set the ISTR register value.
  50. * Input : wRegValue: new register value.
  51. * Output : None.
  52. * Return : None.
  53. *******************************************************************************/
  54. void SetISTR(uint16_t wRegValue)
  55. {
  56. _SetISTR(wRegValue);
  57. }
  58. /*******************************************************************************
  59. * Function Name : GetISTR
  60. * Description : Returns the ISTR register value.
  61. * Input : None.
  62. * Output : None.
  63. * Return : ISTR register Value
  64. *******************************************************************************/
  65. uint16_t GetISTR(void)
  66. {
  67. return(_GetISTR());
  68. }
  69. /*******************************************************************************
  70. * Function Name : GetFNR
  71. * Description : Returns the FNR register value.
  72. * Input : None.
  73. * Output : None.
  74. * Return : FNR register Value
  75. *******************************************************************************/
  76. uint16_t GetFNR(void)
  77. {
  78. return(_GetFNR());
  79. }
  80. /*******************************************************************************
  81. * Function Name : SetDADDR
  82. * Description : Set the DADDR register value.
  83. * Input : wRegValue: new register value.
  84. * Output : None.
  85. * Return : None.
  86. *******************************************************************************/
  87. void SetDADDR(uint16_t wRegValue)
  88. {
  89. _SetDADDR(wRegValue);
  90. }
  91. /*******************************************************************************
  92. * Function Name : GetDADDR
  93. * Description : Returns the DADDR register value.
  94. * Input : None.
  95. * Output : None.
  96. * Return : DADDR register Value
  97. *******************************************************************************/
  98. uint16_t GetDADDR(void)
  99. {
  100. return(_GetDADDR());
  101. }
  102. /*******************************************************************************
  103. * Function Name : SetBTABLE
  104. * Description : Set the BTABLE.
  105. * Input : wRegValue: New register value.
  106. * Output : None.
  107. * Return : None.
  108. *******************************************************************************/
  109. void SetBTABLE(uint16_t wRegValue)
  110. {
  111. _SetBTABLE(wRegValue);
  112. }
  113. /*******************************************************************************
  114. * Function Name : GetBTABLE.
  115. * Description : Returns the BTABLE register value.
  116. * Input : None.
  117. * Output : None.
  118. * Return : BTABLE address.
  119. *******************************************************************************/
  120. uint16_t GetBTABLE(void)
  121. {
  122. return(_GetBTABLE());
  123. }
  124. /*******************************************************************************
  125. * Function Name : SetENDPOINT
  126. * Description : Setthe Endpoint register value.
  127. * Input : bEpNum: Endpoint Number.
  128. * wRegValue.
  129. * Output : None.
  130. * Return : None.
  131. *******************************************************************************/
  132. void SetENDPOINT(uint8_t bEpNum, uint16_t wRegValue)
  133. {
  134. _SetENDPOINT(bEpNum, wRegValue);
  135. }
  136. /*******************************************************************************
  137. * Function Name : GetENDPOINT
  138. * Description : Return the Endpoint register value.
  139. * Input : bEpNum: Endpoint Number.
  140. * Output : None.
  141. * Return : Endpoint register value.
  142. *******************************************************************************/
  143. uint16_t GetENDPOINT(uint8_t bEpNum)
  144. {
  145. return(_GetENDPOINT(bEpNum));
  146. }
  147. /*******************************************************************************
  148. * Function Name : SetEPType
  149. * Description : sets the type in the endpoint register.
  150. * Input : bEpNum: Endpoint Number.
  151. * wType: type definition.
  152. * Output : None.
  153. * Return : None.
  154. *******************************************************************************/
  155. void SetEPType(uint8_t bEpNum, uint16_t wType)
  156. {
  157. _SetEPType(bEpNum, wType);
  158. }
  159. /*******************************************************************************
  160. * Function Name : GetEPType
  161. * Description : Returns the endpoint type.
  162. * Input : bEpNum: Endpoint Number.
  163. * Output : None.
  164. * Return : Endpoint Type
  165. *******************************************************************************/
  166. uint16_t GetEPType(uint8_t bEpNum)
  167. {
  168. return(_GetEPType(bEpNum));
  169. }
  170. /*******************************************************************************
  171. * Function Name : SetEPTxStatus
  172. * Description : Set the status of Tx endpoint.
  173. * Input : bEpNum: Endpoint Number.
  174. * wState: new state.
  175. * Output : None.
  176. * Return : None.
  177. *******************************************************************************/
  178. void SetEPTxStatus(uint8_t bEpNum, uint16_t wState)
  179. {
  180. _SetEPTxStatus(bEpNum, wState);
  181. }
  182. /*******************************************************************************
  183. * Function Name : SetEPRxStatus
  184. * Description : Set the status of Rx endpoint.
  185. * Input : bEpNum: Endpoint Number.
  186. * wState: new state.
  187. * Output : None.
  188. * Return : None.
  189. *******************************************************************************/
  190. void SetEPRxStatus(uint8_t bEpNum, uint16_t wState)
  191. {
  192. _SetEPRxStatus(bEpNum, wState);
  193. }
  194. /*******************************************************************************
  195. * Function Name : SetDouBleBuffEPStall
  196. * Description : sets the status for Double Buffer Endpoint to STALL
  197. * Input : bEpNum: Endpoint Number.
  198. * bDir: Endpoint direction.
  199. * Output : None.
  200. * Return : None.
  201. *******************************************************************************/
  202. void SetDouBleBuffEPStall(uint8_t bEpNum, uint8_t bDir)
  203. {
  204. uint16_t Endpoint_DTOG_Status;
  205. Endpoint_DTOG_Status = GetENDPOINT(bEpNum);
  206. if (bDir == EP_DBUF_OUT)
  207. { /* OUT double buffered endpoint */
  208. _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPRX_DTOG1);
  209. }
  210. else if (bDir == EP_DBUF_IN)
  211. { /* IN double buffered endpoint */
  212. _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPTX_DTOG1);
  213. }
  214. }
  215. /*******************************************************************************
  216. * Function Name : GetEPTxStatus
  217. * Description : Returns the endpoint Tx status.
  218. * Input : bEpNum: Endpoint Number.
  219. * Output : None.
  220. * Return : Endpoint TX Status
  221. *******************************************************************************/
  222. uint16_t GetEPTxStatus(uint8_t bEpNum)
  223. {
  224. return(_GetEPTxStatus(bEpNum));
  225. }
  226. /*******************************************************************************
  227. * Function Name : GetEPRxStatus
  228. * Description : Returns the endpoint Rx status.
  229. * Input : bEpNum: Endpoint Number.
  230. * Output : None.
  231. * Return : Endpoint RX Status
  232. *******************************************************************************/
  233. uint16_t GetEPRxStatus(uint8_t bEpNum)
  234. {
  235. return(_GetEPRxStatus(bEpNum));
  236. }
  237. /*******************************************************************************
  238. * Function Name : SetEPTxValid
  239. * Description : Valid the endpoint Tx Status.
  240. * Input : bEpNum: Endpoint Number.
  241. * Output : None.
  242. * Return : None.
  243. *******************************************************************************/
  244. void SetEPTxValid(uint8_t bEpNum)
  245. {
  246. _SetEPTxStatus(bEpNum, EP_TX_VALID);
  247. }
  248. /*******************************************************************************
  249. * Function Name : SetEPRxValid
  250. * Description : Valid the endpoint Rx Status.
  251. * Input : bEpNum: Endpoint Number.
  252. * Output : None.
  253. * Return : None.
  254. *******************************************************************************/
  255. void SetEPRxValid(uint8_t bEpNum)
  256. {
  257. _SetEPRxStatus(bEpNum, EP_RX_VALID);
  258. }
  259. /*******************************************************************************
  260. * Function Name : SetEP_KIND
  261. * Description : Clear the EP_KIND bit.
  262. * Input : bEpNum: Endpoint Number.
  263. * Output : None.
  264. * Return : None.
  265. *******************************************************************************/
  266. void SetEP_KIND(uint8_t bEpNum)
  267. {
  268. _SetEP_KIND(bEpNum);
  269. }
  270. /*******************************************************************************
  271. * Function Name : ClearEP_KIND
  272. * Description : set the EP_KIND bit.
  273. * Input : bEpNum: Endpoint Number.
  274. * Output : None.
  275. * Return : None.
  276. *******************************************************************************/
  277. void ClearEP_KIND(uint8_t bEpNum)
  278. {
  279. _ClearEP_KIND(bEpNum);
  280. }
  281. /*******************************************************************************
  282. * Function Name : Clear_Status_Out
  283. * Description : Clear the Status Out of the related Endpoint
  284. * Input : bEpNum: Endpoint Number.
  285. * Output : None.
  286. * Return : None.
  287. *******************************************************************************/
  288. void Clear_Status_Out(uint8_t bEpNum)
  289. {
  290. _ClearEP_KIND(bEpNum);
  291. }
  292. /*******************************************************************************
  293. * Function Name : Set_Status_Out
  294. * Description : Set the Status Out of the related Endpoint
  295. * Input : bEpNum: Endpoint Number.
  296. * Output : None.
  297. * Return : None.
  298. *******************************************************************************/
  299. void Set_Status_Out(uint8_t bEpNum)
  300. {
  301. _SetEP_KIND(bEpNum);
  302. }
  303. /*******************************************************************************
  304. * Function Name : SetEPDoubleBuff
  305. * Description : Enable the double buffer feature for the endpoint.
  306. * Input : bEpNum: Endpoint Number.
  307. * Output : None.
  308. * Return : None.
  309. *******************************************************************************/
  310. void SetEPDoubleBuff(uint8_t bEpNum)
  311. {
  312. _SetEP_KIND(bEpNum);
  313. }
  314. /*******************************************************************************
  315. * Function Name : ClearEPDoubleBuff
  316. * Description : Disable the double buffer feature for the endpoint.
  317. * Input : bEpNum: Endpoint Number.
  318. * Output : None.
  319. * Return : None.
  320. *******************************************************************************/
  321. void ClearEPDoubleBuff(uint8_t bEpNum)
  322. {
  323. _ClearEP_KIND(bEpNum);
  324. }
  325. /*******************************************************************************
  326. * Function Name : GetTxStallStatus
  327. * Description : Returns the Stall status of the Tx endpoint.
  328. * Input : bEpNum: Endpoint Number.
  329. * Output : None.
  330. * Return : Tx Stall status.
  331. *******************************************************************************/
  332. uint16_t GetTxStallStatus(uint8_t bEpNum)
  333. {
  334. return(_GetTxStallStatus(bEpNum));
  335. }
  336. /*******************************************************************************
  337. * Function Name : GetRxStallStatus
  338. * Description : Returns the Stall status of the Rx endpoint.
  339. * Input : bEpNum: Endpoint Number.
  340. * Output : None.
  341. * Return : Rx Stall status.
  342. *******************************************************************************/
  343. uint16_t GetRxStallStatus(uint8_t bEpNum)
  344. {
  345. return(_GetRxStallStatus(bEpNum));
  346. }
  347. /*******************************************************************************
  348. * Function Name : ClearEP_CTR_RX
  349. * Description : Clear the CTR_RX bit.
  350. * Input : bEpNum: Endpoint Number.
  351. * Output : None.
  352. * Return : None.
  353. *******************************************************************************/
  354. void ClearEP_CTR_RX(uint8_t bEpNum)
  355. {
  356. _ClearEP_CTR_RX(bEpNum);
  357. }
  358. /*******************************************************************************
  359. * Function Name : ClearEP_CTR_TX
  360. * Description : Clear the CTR_TX bit.
  361. * Input : bEpNum: Endpoint Number.
  362. * Output : None.
  363. * Return : None.
  364. *******************************************************************************/
  365. void ClearEP_CTR_TX(uint8_t bEpNum)
  366. {
  367. _ClearEP_CTR_TX(bEpNum);
  368. }
  369. /*******************************************************************************
  370. * Function Name : ToggleDTOG_RX
  371. * Description : Toggle the DTOG_RX bit.
  372. * Input : bEpNum: Endpoint Number.
  373. * Output : None.
  374. * Return : None.
  375. *******************************************************************************/
  376. void ToggleDTOG_RX(uint8_t bEpNum)
  377. {
  378. _ToggleDTOG_RX(bEpNum);
  379. }
  380. /*******************************************************************************
  381. * Function Name : ToggleDTOG_TX
  382. * Description : Toggle the DTOG_TX bit.
  383. * Input : bEpNum: Endpoint Number.
  384. * Output : None.
  385. * Return : None.
  386. *******************************************************************************/
  387. void ToggleDTOG_TX(uint8_t bEpNum)
  388. {
  389. _ToggleDTOG_TX(bEpNum);
  390. }
  391. /*******************************************************************************
  392. * Function Name : ClearDTOG_RX.
  393. * Description : Clear the DTOG_RX bit.
  394. * Input : bEpNum: Endpoint Number.
  395. * Output : None.
  396. * Return : None.
  397. *******************************************************************************/
  398. void ClearDTOG_RX(uint8_t bEpNum)
  399. {
  400. _ClearDTOG_RX(bEpNum);
  401. }
  402. /*******************************************************************************
  403. * Function Name : ClearDTOG_TX.
  404. * Description : Clear the DTOG_TX bit.
  405. * Input : bEpNum: Endpoint Number.
  406. * Output : None.
  407. * Return : None.
  408. *******************************************************************************/
  409. void ClearDTOG_TX(uint8_t bEpNum)
  410. {
  411. _ClearDTOG_TX(bEpNum);
  412. }
  413. /*******************************************************************************
  414. * Function Name : SetEPAddress
  415. * Description : Set the endpoint address.
  416. * Input : bEpNum: Endpoint Number.
  417. * bAddr: New endpoint address.
  418. * Output : None.
  419. * Return : None.
  420. *******************************************************************************/
  421. void SetEPAddress(uint8_t bEpNum, uint8_t bAddr)
  422. {
  423. _SetEPAddress(bEpNum, bAddr);
  424. }
  425. /*******************************************************************************
  426. * Function Name : GetEPAddress
  427. * Description : Get the endpoint address.
  428. * Input : bEpNum: Endpoint Number.
  429. * Output : None.
  430. * Return : Endpoint address.
  431. *******************************************************************************/
  432. uint8_t GetEPAddress(uint8_t bEpNum)
  433. {
  434. return(_GetEPAddress(bEpNum));
  435. }
  436. /*******************************************************************************
  437. * Function Name : SetEPTxAddr
  438. * Description : Set the endpoint Tx buffer address.
  439. * Input : bEpNum: Endpoint Number.
  440. * wAddr: new address.
  441. * Output : None.
  442. * Return : None.
  443. *******************************************************************************/
  444. void SetEPTxAddr(uint8_t bEpNum, uint16_t wAddr)
  445. {
  446. _SetEPTxAddr(bEpNum, wAddr);
  447. }
  448. /*******************************************************************************
  449. * Function Name : SetEPRxAddr
  450. * Description : Set the endpoint Rx buffer address.
  451. * Input : bEpNum: Endpoint Number.
  452. * wAddr: new address.
  453. * Output : None.
  454. * Return : None.
  455. *******************************************************************************/
  456. void SetEPRxAddr(uint8_t bEpNum, uint16_t wAddr)
  457. {
  458. _SetEPRxAddr(bEpNum, wAddr);
  459. }
  460. /*******************************************************************************
  461. * Function Name : GetEPTxAddr
  462. * Description : Returns the endpoint Tx buffer address.
  463. * Input : bEpNum: Endpoint Number.
  464. * Output : None.
  465. * Return : Rx buffer address.
  466. *******************************************************************************/
  467. uint16_t GetEPTxAddr(uint8_t bEpNum)
  468. {
  469. return(_GetEPTxAddr(bEpNum));
  470. }
  471. /*******************************************************************************
  472. * Function Name : GetEPRxAddr.
  473. * Description : Returns the endpoint Rx buffer address.
  474. * Input : bEpNum: Endpoint Number.
  475. * Output : None.
  476. * Return : Rx buffer address.
  477. *******************************************************************************/
  478. uint16_t GetEPRxAddr(uint8_t bEpNum)
  479. {
  480. return(_GetEPRxAddr(bEpNum));
  481. }
  482. /*******************************************************************************
  483. * Function Name : SetEPTxCount.
  484. * Description : Set the Tx count.
  485. * Input : bEpNum: Endpoint Number.
  486. * wCount: new count value.
  487. * Output : None.
  488. * Return : None.
  489. *******************************************************************************/
  490. void SetEPTxCount(uint8_t bEpNum, uint16_t wCount)
  491. {
  492. _SetEPTxCount(bEpNum, wCount);
  493. }
  494. /*******************************************************************************
  495. * Function Name : SetEPCountRxReg.
  496. * Description : Set the Count Rx Register value.
  497. * Input : *pdwReg: point to the register.
  498. * wCount: the new register value.
  499. * Output : None.
  500. * Return : None.
  501. *******************************************************************************/
  502. void SetEPCountRxReg(uint32_t *pdwReg, uint16_t wCount)
  503. {
  504. _SetEPCountRxReg(dwReg, wCount);
  505. }
  506. /*******************************************************************************
  507. * Function Name : SetEPRxCount
  508. * Description : Set the Rx count.
  509. * Input : bEpNum: Endpoint Number.
  510. * wCount: the new count value.
  511. * Output : None.
  512. * Return : None.
  513. *******************************************************************************/
  514. void SetEPRxCount(uint8_t bEpNum, uint16_t wCount)
  515. {
  516. _SetEPRxCount(bEpNum, wCount);
  517. }
  518. /*******************************************************************************
  519. * Function Name : GetEPTxCount
  520. * Description : Get the Tx count.
  521. * Input : bEpNum: Endpoint Number.
  522. * Output : None
  523. * Return : Tx count value.
  524. *******************************************************************************/
  525. uint16_t GetEPTxCount(uint8_t bEpNum)
  526. {
  527. return(_GetEPTxCount(bEpNum));
  528. }
  529. /*******************************************************************************
  530. * Function Name : GetEPRxCount
  531. * Description : Get the Rx count.
  532. * Input : bEpNum: Endpoint Number.
  533. * Output : None.
  534. * Return : Rx count value.
  535. *******************************************************************************/
  536. uint16_t GetEPRxCount(uint8_t bEpNum)
  537. {
  538. return(_GetEPRxCount(bEpNum));
  539. }
  540. /*******************************************************************************
  541. * Function Name : SetEPDblBuffAddr
  542. * Description : Set the addresses of the buffer 0 and 1.
  543. * Input : bEpNum: Endpoint Number.
  544. * wBuf0Addr: new address of buffer 0.
  545. * wBuf1Addr: new address of buffer 1.
  546. * Output : None.
  547. * Return : None.
  548. *******************************************************************************/
  549. void SetEPDblBuffAddr(uint8_t bEpNum, uint16_t wBuf0Addr, uint16_t wBuf1Addr)
  550. {
  551. _SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr);
  552. }
  553. /*******************************************************************************
  554. * Function Name : SetEPDblBuf0Addr
  555. * Description : Set the Buffer 1 address.
  556. * Input : bEpNum: Endpoint Number
  557. * wBuf0Addr: new address.
  558. * Output : None.
  559. * Return : None.
  560. *******************************************************************************/
  561. void SetEPDblBuf0Addr(uint8_t bEpNum, uint16_t wBuf0Addr)
  562. {
  563. _SetEPDblBuf0Addr(bEpNum, wBuf0Addr);
  564. }
  565. /*******************************************************************************
  566. * Function Name : SetEPDblBuf1Addr
  567. * Description : Set the Buffer 1 address.
  568. * Input : bEpNum: Endpoint Number
  569. * wBuf1Addr: new address.
  570. * Output : None.
  571. * Return : None.
  572. *******************************************************************************/
  573. void SetEPDblBuf1Addr(uint8_t bEpNum, uint16_t wBuf1Addr)
  574. {
  575. _SetEPDblBuf1Addr(bEpNum, wBuf1Addr);
  576. }
  577. /*******************************************************************************
  578. * Function Name : GetEPDblBuf0Addr
  579. * Description : Returns the address of the Buffer 0.
  580. * Input : bEpNum: Endpoint Number.
  581. * Output : None.
  582. * Return : None.
  583. *******************************************************************************/
  584. uint16_t GetEPDblBuf0Addr(uint8_t bEpNum)
  585. {
  586. return(_GetEPDblBuf0Addr(bEpNum));
  587. }
  588. /*******************************************************************************
  589. * Function Name : GetEPDblBuf1Addr
  590. * Description : Returns the address of the Buffer 1.
  591. * Input : bEpNum: Endpoint Number.
  592. * Output : None.
  593. * Return : Address of the Buffer 1.
  594. *******************************************************************************/
  595. uint16_t GetEPDblBuf1Addr(uint8_t bEpNum)
  596. {
  597. return(_GetEPDblBuf1Addr(bEpNum));
  598. }
  599. /*******************************************************************************
  600. * Function Name : SetEPDblBuffCount
  601. * Description : Set the number of bytes for a double Buffer
  602. * endpoint.
  603. * Input : bEpNum,bDir, wCount
  604. * Output : None.
  605. * Return : None.
  606. *******************************************************************************/
  607. void SetEPDblBuffCount(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
  608. {
  609. _SetEPDblBuffCount(bEpNum, bDir, wCount);
  610. }
  611. /*******************************************************************************
  612. * Function Name : SetEPDblBuf0Count
  613. * Description : Set the number of bytes in the buffer 0 of a double Buffer
  614. * endpoint.
  615. * Input : bEpNum, bDir, wCount
  616. * Output : None.
  617. * Return : None.
  618. *******************************************************************************/
  619. void SetEPDblBuf0Count(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
  620. {
  621. _SetEPDblBuf0Count(bEpNum, bDir, wCount);
  622. }
  623. /*******************************************************************************
  624. * Function Name : SetEPDblBuf1Count
  625. * Description : Set the number of bytes in the buffer 0 of a double Buffer
  626. * endpoint.
  627. * Input : bEpNum, bDir, wCount
  628. * Output : None.
  629. * Return : None.
  630. *******************************************************************************/
  631. void SetEPDblBuf1Count(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
  632. {
  633. _SetEPDblBuf1Count(bEpNum, bDir, wCount);
  634. }
  635. /*******************************************************************************
  636. * Function Name : GetEPDblBuf0Count
  637. * Description : Returns the number of byte received in the buffer 0 of a double
  638. * Buffer endpoint.
  639. * Input : bEpNum: Endpoint Number.
  640. * Output : None.
  641. * Return : Endpoint Buffer 0 count
  642. *******************************************************************************/
  643. uint16_t GetEPDblBuf0Count(uint8_t bEpNum)
  644. {
  645. return(_GetEPDblBuf0Count(bEpNum));
  646. }
  647. /*******************************************************************************
  648. * Function Name : GetEPDblBuf1Count
  649. * Description : Returns the number of data received in the buffer 1 of a double
  650. * Buffer endpoint.
  651. * Input : bEpNum: Endpoint Number.
  652. * Output : None.
  653. * Return : Endpoint Buffer 1 count.
  654. *******************************************************************************/
  655. uint16_t GetEPDblBuf1Count(uint8_t bEpNum)
  656. {
  657. return(_GetEPDblBuf1Count(bEpNum));
  658. }
  659. /*******************************************************************************
  660. * Function Name : GetEPDblBufDir
  661. * Description : gets direction of the double buffered endpoint
  662. * Input : bEpNum: Endpoint Number.
  663. * Output : None.
  664. * Return : EP_DBUF_OUT, EP_DBUF_IN,
  665. * EP_DBUF_ERR if the endpoint counter not yet programmed.
  666. *******************************************************************************/
  667. EP_DBUF_DIR GetEPDblBufDir(uint8_t bEpNum)
  668. {
  669. if ((uint16_t)(*_pEPRxCount(bEpNum) & 0xFC00) != 0)
  670. return(EP_DBUF_OUT);
  671. else if (((uint16_t)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0)
  672. return(EP_DBUF_IN);
  673. else
  674. return(EP_DBUF_ERR);
  675. }
  676. /*******************************************************************************
  677. * Function Name : FreeUserBuffer
  678. * Description : free buffer used from the application realizing it to the line
  679. toggles bit SW_BUF in the double buffered endpoint register
  680. * Input : bEpNum, bDir
  681. * Output : None.
  682. * Return : None.
  683. *******************************************************************************/
  684. void FreeUserBuffer(uint8_t bEpNum, uint8_t bDir)
  685. {
  686. if (bDir == EP_DBUF_OUT)
  687. { /* OUT double buffered endpoint */
  688. _ToggleDTOG_TX(bEpNum);
  689. }
  690. else if (bDir == EP_DBUF_IN)
  691. { /* IN double buffered endpoint */
  692. _ToggleDTOG_RX(bEpNum);
  693. }
  694. }
  695. /*******************************************************************************
  696. * Function Name : ToWord
  697. * Description : merge two byte in a word.
  698. * Input : bh: byte high, bl: bytes low.
  699. * Output : None.
  700. * Return : resulted word.
  701. *******************************************************************************/
  702. uint16_t ToWord(uint8_t bh, uint8_t bl)
  703. {
  704. uint16_t wRet;
  705. wRet = (uint16_t)bl | ((uint16_t)bh << 8);
  706. return(wRet);
  707. }
  708. /*******************************************************************************
  709. * Function Name : ByteSwap
  710. * Description : Swap two byte in a word.
  711. * Input : wSwW: word to Swap.
  712. * Output : None.
  713. * Return : resulted word.
  714. *******************************************************************************/
  715. uint16_t ByteSwap(uint16_t wSwW)
  716. {
  717. uint8_t bTemp;
  718. uint16_t wRet;
  719. bTemp = (uint8_t)(wSwW & 0xff);
  720. wRet = (wSwW >> 8) | ((uint16_t)bTemp << 8);
  721. return(wRet);
  722. }
  723. #endif /* STM32F10X_CL */
  724. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/