⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 etpu_util.bak

📁 mpc55**系列芯片的例程 包括SCI,SPI,TIMER,FIT,EDMA等几乎所有功能的实现
💻 BAK
📖 第 1 页 / 共 3 页
字号:

/* set global variables */
/******************************************************************************
FUNCTION     : fs_etpu_set_global_32
PURPOSE      : This function write to a 32 bit global variable.
INPUTS NOTES : This function has 2 parameters:
				 offset: The offset to the variable. This must be a 32bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
				 value: The value to write to the paramater.
RETURNS NOTES: none
WARNING      :
******************************************************************************/
void fs_etpu_set_global_32(uint32_t offset, uint32_t value)
{

    *(uint32_t *)((uint32_t)fs_etpu_data_ram_start + offset) = value;
}

/******************************************************************************
FUNCTION     : fs_etpu_set_global_24
PURPOSE      : This function write to a 24 bit global variable.
INPUTS NOTES : This function has 2 parameters:
				 offset: The offset to the variable. This must be a 24bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
				 value: The value to write to the paramater.
RETURNS NOTES: none
WARNING      :
******************************************************************************/
void fs_etpu_set_global_24(uint32_t offset, uint24_t value)
{
    *(uint32_t *)((uint32_t)fs_etpu_data_ram_ext + offset-1) = value;
}

/******************************************************************************
FUNCTION     : fs_etpu_set_global_16
PURPOSE      : This function write to a 16 bit global variable.
INPUTS NOTES : This function has 2 parameters:
				 offset: The offset to the variable. This must be a 16bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
				 value: The value to write to the paramater.
RETURNS NOTES: none
WARNING      :
******************************************************************************/
void fs_etpu_set_global_16(uint32_t offset, uint16_t value)
{

    *(uint16_t *)((uint32_t)fs_etpu_data_ram_start + offset) = value;
}

/******************************************************************************
FUNCTION     : fs_etpu_set_global_8
PURPOSE      : This function write to a 8 bit global variable.
INPUTS NOTES : This function has 2 parameters:
				 offset: The offset to the variable. This must be a 8bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
				 value: The value to write to the paramater.
RETURNS NOTES: none
WARNING      :
******************************************************************************/
void fs_etpu_set_global_8(uint32_t offset, uint8_t value)
{

    *(uint8_t *)((uint32_t)fs_etpu_data_ram_start + offset) = value;
}


/* get global variables */
/******************************************************************************
FUNCTION     : fs_etpu_get_global32
PURPOSE      : This function reads a 32 bit global variable.
INPUTS NOTES : This function has 1 parameter:
				 offset: The offset to the variable. This must be a 32bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
RETURNS NOTES: The 32 bit value of the parameter.
WARNING      :
******************************************************************************/
uint32_t fs_etpu_get_global32(uint32_t offset)
{
    return(*(uint32_t *)((uint32_t)fs_etpu_data_ram_start + offset));
}

/******************************************************************************
FUNCTION     : fs_etpu_get_global_24s
PURPOSE      : This function reads a signed 24 bit global variable.
INPUTS NOTES : This function has 1 parameter:
				 offset: The offset to the variable. This must be a 24bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
RETURNS NOTES: The signed 24 bit value of the parameter.
WARNING      : This function uses the sign extended location of the data memory
                 to write only 24 bits to the data memory. This 24 bit write is
                 an atomic operation and does not effect the upper 8 bits of the
                 32 bit value associated with the 24 bits.
******************************************************************************/
int24_t fs_etpu_get_global_24s(uint32_t offset)
{
    return(*(uint32_t *)((uint32_t)fs_etpu_data_ram_ext + offset-1));
}

/******************************************************************************
FUNCTION     : fs_etpu_get_global_24
PURPOSE      : This function reads an unsigned 24 bit global variable.
INPUTS NOTES : This function has 1 parameter:
				 offset: The offset to the variable. This must be a 24bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
RETURNS NOTES: The unsigned 24 bit value of the parameter.
WARNING      :
******************************************************************************/
uint24_t fs_etpu_get_global_24(uint32_t offset)
{
    return( 0x00FFFFFF & (*(uint32_t *)((uint32_t)fs_etpu_data_ram_ext + offset-1)));
}

/******************************************************************************
FUNCTION     : fs_etpu_get_global_16
PURPOSE      : This function reads a 16 bit global variable.
INPUTS NOTES : This function has 1 parameter:
				 offset: The offset to the variable. This must be a 16bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
RETURNS NOTES: The 16 bit value of the parameter.
WARNING      :
******************************************************************************/
uint16_t fs_etpu_get_global_16(uint32_t offset)
{

    return(*(uint16_t *)((uint32_t)fs_etpu_data_ram_start + offset));
}

/******************************************************************************
FUNCTION     : fs_etpu_get_global_8
PURPOSE      : This function reads a 8 bit global variable.
INPUTS NOTES : This function has 1 parameter:
				 offset: The offset to the variable. This must be a 8bit
				           aligned value. This value is normally provided by
				           the eTPU compiler.
RETURNS NOTES: The 8 bit value of the parameter.
WARNING      :
******************************************************************************/
uint8_t fs_etpu_get_global_8(uint32_t offset)
{
    return(*(uint8_t *)((uint32_t)fs_etpu_data_ram_start + offset));
}


/******************************************************************************
FUNCTION     : fs_memcpy32
PURPOSE      : This function is similar to the standard C memcpy() function
                 however it copies 32 bit words rather than bytes.
INPUTS NOTES : This function has 3 parameters:
                 *dest: This is a pointer to the destination location
                 *source this is a pointer to the source location
                 size: This is the size of the data to copy in bytes.
RETURNS NOTES: A pointer to the end of the copied data.
WARNING      : The *dest and *source pointers should be aligned to a 32 bit
                 address. If they are not it may cause memory exceptions. Moving
                 data to the eTPU code memory that is not 32 bit aligned is
                 undefined. The size should be a multiple of 4 to copy 32 bit
                 value. If it is not it is rounded down.
******************************************************************************/
uint32_t *fs_memcpy32(uint32_t *dest, uint32_t *source, uint32_t size)
{
	uint32_t *p = dest;
	uint32_t *q = source;

	size = size >>2;

	while(size--)
		*p++ = *q++;

	return (p);
}
/******************************************************************************
FUNCTION     : fs_memset32
PURPOSE      : This function is similar to the standard C memset() function
                 however it sets 32 bit words rather than bytes.
INPUTS NOTES : This function has 3 parameters:
                 *start: This is a pointer to the start location
                 value: This is the value to write to memory
                 size: This is the size of the data to copy in bytes.
RETURNS NOTES: none.
WARNING      : The *start pointer should be aligned to a 32 bit address. If
                 it is not it may cause memory exceptions. Writing data to the
                eTPU code memory that is not 32 bit aligned is undefined. The
                 size should be a multiple of 4 to copy 32 bit  value. If it
                 is not it is rounded down.
******************************************************************************/
void      fs_memset32(uint32_t *start, uint32_t value, int32_t size)
{
	uint32_t *p = start;

	size = size >>2;

	while(size--)
	*p++ = value;
}

#endif
/*********************************************************************
 *
 * Copyright:
 *	Freescale Semiconductor, INC. All Rights Reserved.
 *  You are hereby granted a copyright license to use, modify, and
 *  distribute the SOFTWARE so long as this entire notice is
 *  retained without alteration in any modified and/or redistributed
 *  versions, and that such modified versions are clearly identified
 *  as such. No licenses are granted by implication, estoppel or
 *  otherwise under any patents or trademarks of Freescale
 *  Semiconductor, Inc. This software is provided on an "AS IS"
 *  basis and without warranty.
 *
 *  To the maximum extent permitted by applicable law, Freescale
 *  Semiconductor DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
 *  INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
 *  PARTICULAR PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH
 *  REGARD TO THE SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
 *  AND ANY ACCOMPANYING WRITTEN MATERIALS.
 *
 *  To the maximum extent permitted by applicable law, IN NO EVENT
 *  SHALL Freescale Semiconductor BE LIABLE FOR ANY DAMAGES WHATSOEVER
 *  (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
 *  BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
 *  PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
 *
 *  Freescale Semiconductor assumes no responsibility for the
 *  maintenance and support of this software
 ********************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -