arm_copy_q15.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_copy_q15.c
  4. * Description: Copies the elements of a Q15 vector
  5. *
  6. * $Date: 18. March 2019
  7. * $Revision: V1.6.0
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #include "arm_math.h"
  29. /**
  30. @ingroup groupSupport
  31. */
  32. /**
  33. @addtogroup copy
  34. @{
  35. */
  36. /**
  37. @brief Copies the elements of a Q15 vector.
  38. @param[in] pSrc points to input vector
  39. @param[out] pDst points to output vector
  40. @param[in] blockSize number of samples in each vector
  41. @return none
  42. */
  43. void arm_copy_q15(
  44. const q15_t * pSrc,
  45. q15_t * pDst,
  46. uint32_t blockSize)
  47. {
  48. uint32_t blkCnt; /* Loop counter */
  49. #if defined (ARM_MATH_LOOPUNROLL)
  50. /* Loop unrolling: Compute 4 outputs at a time */
  51. blkCnt = blockSize >> 2U;
  52. while (blkCnt > 0U)
  53. {
  54. /* C = A */
  55. /* read 2 times 2 samples at a time */
  56. write_q15x2_ia (&pDst, read_q15x2_ia ((q15_t **) &pSrc));
  57. write_q15x2_ia (&pDst, read_q15x2_ia ((q15_t **) &pSrc));
  58. /* Decrement loop counter */
  59. blkCnt--;
  60. }
  61. /* Loop unrolling: Compute remaining outputs */
  62. blkCnt = blockSize % 0x4U;
  63. #else
  64. /* Initialize blkCnt with number of samples */
  65. blkCnt = blockSize;
  66. #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
  67. while (blkCnt > 0U)
  68. {
  69. /* C = A */
  70. /* Copy and store result in destination buffer */
  71. *pDst++ = *pSrc++;
  72. /* Decrement loop counter */
  73. blkCnt--;
  74. }
  75. }
  76. /**
  77. @} end of BasicCopy group
  78. */