2 ******************************************************************************
4 * @author MCD Application Team
7 * @brief Utility functions for memory transfers to/from PMA
8 ******************************************************************************
11 * <h2><center>© 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 ------------------------------------------------------------------*/
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 : UserToPMABufferCopy
41 * Description : Copy a buffer from user memory area to packet memory area (PMA)
42 * Input : - pbUsrBuf: pointer to user memory area.
43 * - wPMABufAddr: address into PMA.
44 * - wNBytes: no. of bytes to be copied.
47 *******************************************************************************/
48 void UserToPMABufferCopy(const uint8_t *pbUsrBuf
, uint16_t wPMABufAddr
, uint16_t wNBytes
)
50 uint32_t n
= (wNBytes
+ 1) >> 1; /* n = (wNBytes + 1) / 2 */
51 uint32_t i
, temp1
, temp2
;
53 pdwVal
= (uint16_t *)(wPMABufAddr
* 2 + PMAAddr
);
54 for (i
= n
; i
!= 0; i
--)
56 temp1
= (uint16_t) * pbUsrBuf
;
58 temp2
= temp1
| (uint16_t) * pbUsrBuf
<< 8;
65 /*******************************************************************************
66 * Function Name : PMAToUserBufferCopy
67 * Description : Copy a buffer from user memory area to packet memory area (PMA)
68 * Input : - pbUsrBuf = pointer to user memory area.
69 * - wPMABufAddr = address into PMA.
70 * - wNBytes = no. of bytes to be copied.
73 *******************************************************************************/
74 void PMAToUserBufferCopy(uint8_t *pbUsrBuf
, uint16_t wPMABufAddr
, uint16_t wNBytes
)
76 uint32_t n
= (wNBytes
+ 1) >> 1;/* /2*/
79 pdwVal
= (uint32_t *)(wPMABufAddr
* 2 + PMAAddr
);
80 for (i
= n
; i
!= 0; i
--)
82 *(uint16_t*)pbUsrBuf
++ = *pdwVal
++;
87 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/