Files
@ 7e85f405b6d0
Branch filter:
Location: therm/libraries/USB/usb_mem.c - annotation
7e85f405b6d0
3.6 KiB
text/plain
PID setting now more user friendly
675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 675c16cde5b1 | /**
******************************************************************************
* @file usb_mem.c
* @author MCD Application Team
* @version V4.0.0
* @date 28-August-2012
* @brief Utility functions for memory transfers to/from PMA
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Extern variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : UserToPMABufferCopy
* Description : Copy a buffer from user memory area to packet memory area (PMA)
* Input : - pbUsrBuf: pointer to user memory area.
* - wPMABufAddr: address into PMA.
* - wNBytes: no. of bytes to be copied.
* Output : None.
* Return : None .
*******************************************************************************/
void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
{
uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */
uint32_t i, temp1, temp2;
uint16_t *pdwVal;
pdwVal = (uint16_t *)(wPMABufAddr * 2 + PMAAddr);
for (i = n; i != 0; i--)
{
temp1 = (uint16_t) * pbUsrBuf;
pbUsrBuf++;
temp2 = temp1 | (uint16_t) * pbUsrBuf << 8;
*pdwVal++ = temp2;
pdwVal++;
pbUsrBuf++;
}
}
/*******************************************************************************
* Function Name : PMAToUserBufferCopy
* Description : Copy a buffer from user memory area to packet memory area (PMA)
* Input : - pbUsrBuf = pointer to user memory area.
* - wPMABufAddr = address into PMA.
* - wNBytes = no. of bytes to be copied.
* Output : None.
* Return : None.
*******************************************************************************/
void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
{
uint32_t n = (wNBytes + 1) >> 1;/* /2*/
uint32_t i;
uint32_t *pdwVal;
pdwVal = (uint32_t *)(wPMABufAddr * 2 + PMAAddr);
for (i = n; i != 0; i--)
{
*(uint16_t*)pbUsrBuf++ = *pdwVal++;
pbUsrBuf++;
}
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|