Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
usb_mem.c
00001 /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 00002 * File Name : usb_mem.c 00003 * Author : MCD Application Team 00004 * Version : V3.2.1 00005 * Date : 07/05/2010 00006 * Description : Utility functions for memory transfers to/from PMA 00007 ******************************************************************************** 00008 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 00012 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00014 *******************************************************************************/ 00015 #ifndef STM32F10X_CL 00016 00017 /* Includes ------------------------------------------------------------------*/ 00018 #include "usb_lib.h" 00019 00020 /* Private typedef -----------------------------------------------------------*/ 00021 /* Private define ------------------------------------------------------------*/ 00022 /* Private macro -------------------------------------------------------------*/ 00023 /* Private variables ---------------------------------------------------------*/ 00024 /* Extern variables ----------------------------------------------------------*/ 00025 /* Private function prototypes -----------------------------------------------*/ 00026 /* Private functions ---------------------------------------------------------*/ 00027 /******************************************************************************* 00028 * Function Name : UserToPMABufferCopy 00029 * Description : Copy a buffer from user memory area to packet memory area (PMA) 00030 * Input : - pbUsrBuf: pointer to user memory area. 00031 * - wPMABufAddr: address into PMA. 00032 * - wNBytes: no. of bytes to be copied. 00033 * Output : None. 00034 * Return : None . 00035 *******************************************************************************/ 00036 void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 00037 { 00038 uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */ 00039 uint32_t i, temp1; 00040 uint16_t *pdwVal; 00041 pdwVal = (uint16_t *)(wPMABufAddr * 2 + PMAAddr); 00042 for (i = n; i != 0; i--) 00043 { 00044 temp1 = (uint16_t) * pbUsrBuf; 00045 pbUsrBuf++; 00046 *pdwVal++ = temp1 | (uint16_t) * pbUsrBuf << 8; 00047 pdwVal++; 00048 pbUsrBuf++; 00049 } 00050 } 00051 /******************************************************************************* 00052 * Function Name : PMAToUserBufferCopy 00053 * Description : Copy a buffer from user memory area to packet memory area (PMA) 00054 * Input : - pbUsrBuf = pointer to user memory area. 00055 * - wPMABufAddr = address into PMA. 00056 * - wNBytes = no. of bytes to be copied. 00057 * Output : None. 00058 * Return : None. 00059 *******************************************************************************/ 00060 void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 00061 { 00062 uint32_t n = (wNBytes + 1) >> 1;/* /2*/ 00063 uint32_t i; 00064 uint32_t *pdwVal; 00065 pdwVal = (uint32_t *)(wPMABufAddr * 2 + PMAAddr); 00066 for (i = n; i != 0; i--) 00067 { 00068 *(uint16_t*)pbUsrBuf++ = *pdwVal++; 00069 pbUsrBuf++; 00070 } 00071 } 00072 00073 #endif /* STM32F10X_CL */ 00074 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 20:45:32 by
1.7.2