cmsis_ccs.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. //*****************************************************************************
  2. //
  3. // Copyright (C) 2012 - 2017 Texas Instruments Incorporated - http://www.ti.com/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions
  7. // are met:
  8. //
  9. // Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. //
  12. // Redistributions in binary form must reproduce the above copyright
  13. // notice, this list of conditions and the following disclaimer in the
  14. // documentation and/or other materials provided with the
  15. // distribution.
  16. //
  17. // Neither the name of Texas Instruments Incorporated nor the names of
  18. // its contributors may be used to endorse or promote products derived
  19. // from this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. // MSP432 Family CMSIS Definitions
  34. //
  35. //****************************************************************************
  36. #ifndef CMSIS_CCS_H_
  37. #define CMSIS_CCS_H_
  38. #ifndef __TI_ARM__
  39. #error This file should only be compiled by TI compiler (minimum version 15.12.x)
  40. #endif
  41. /** CMSIS compiler control architecture macros */
  42. #if defined ( __TI_ARM_V6M0__ )
  43. #define __ARM_ARCH_6M__ 1
  44. #endif
  45. #if defined ( __TI_ARM_V7M3__ )
  46. #define __ARM_ARCH_7M__ 1
  47. #endif
  48. #if defined ( __TI_ARM_V7M4__ )
  49. #define __ARM_ARCH_7EM__ 1
  50. #endif
  51. /* ########################### Core Function Access ########################### */
  52. /** \ingroup CMSIS_Core_FunctionInterface
  53. * \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
  54. * @{
  55. */
  56. /**
  57. * \brief Enable IRQ Interrupts
  58. * \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
  59. * Can only be executed in Privileged modes.
  60. */
  61. #define __enable_irq _enable_IRQ
  62. /**
  63. * \brief Disable IRQ Interrupts
  64. * \details Disables IRQ interrupts by setting the I-bit in the CPSR.
  65. * Can only be executed in Privileged modes.
  66. */
  67. #define __disable_irq _disable_IRQ
  68. /** @} */ /* end of CMSIS_Core_RegAccFunctions */
  69. /* ########################## Core Instruction Access ######################### */
  70. /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
  71. * Access to dedicated instructions
  72. * @{
  73. */
  74. /**
  75. * \brief Count leading zeros
  76. * \details Counts the number of leading zeros of a data value.
  77. * \param [in] VAL Value to count the leading zeros
  78. * \return number of leading zeros in value
  79. */
  80. #define __CLZ(VAL) ((unsigned char)__clz(VAL))
  81. /**
  82. * \brief Signed Saturate
  83. * \details Saturates a signed value.
  84. * \param [in] VAL Value to be saturated
  85. * \param [in] BITPOS Bit position to saturate to (1..32)
  86. * \return Saturated value
  87. */
  88. #define __SSAT(VAL, BITPOS) _ssatl(VAL, 0, BITPOS)
  89. /**
  90. * \brief No Operation
  91. * \details No Operation does nothing. This instruction can be used for code alignment purposes.
  92. */
  93. #define __NOP __nop
  94. /**
  95. * \brief Wait For Interrupt
  96. * \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
  97. */
  98. #define __WFI __wfi
  99. /**
  100. * \brief Wait For Event
  101. * \details Wait For Event is a hint instruction that permits the processor to enter
  102. * a low-power state until one of a number of events occurs.
  103. */
  104. #define __WFE __wfe
  105. /**
  106. * \brief Data Synchronization Barrier
  107. * \details Acts as a special kind of Data Memory Barrier.
  108. * It completes when all explicit memory accesses before this instruction complete.
  109. */
  110. #define __DSB _dsb
  111. /**
  112. * \brief Instruction Synchronization Barrier
  113. * \details Instruction Synchronization Barrier flushes the pipeline in the processor,
  114. * so that all instructions following the ISB are fetched from cache or memory,
  115. * after the instruction has been completed.
  116. */
  117. #define __ISB _isb
  118. /**
  119. \brief Data Memory Barrier
  120. \details Ensures the apparent order of the explicit memory operations before
  121. and after the instruction, without ensuring their completion.
  122. */
  123. #define __DMB _dmb
  124. /**
  125. * \brief Rotate Right in unsigned value (32 bit)
  126. * \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
  127. * \param [in] VAL Value to rotate
  128. * \param [in] SHIFT Number of Bits to rotate
  129. * \return Rotated value
  130. */
  131. #define __ROR(VAL, SHIFT) ((unsigned int)__ror(VAL, SHIFT))
  132. /** @} */ /* end of group CMSIS_Core_InstructionInterface */
  133. /* ################### Compiler specific Intrinsics ########################### */
  134. /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
  135. * Access to dedicated SIMD instructions
  136. * @{
  137. */
  138. #if (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))
  139. #define __SADD8(VAL1, VAL2) ((unsigned int)_sadd8(VAL1, VAL2))
  140. #define __QADD8(VAL1, VAL2) ((unsigned int)_qadd8(VAL1, VAL2))
  141. #define __SHADD8(VAL1, VAL2) ((unsigned int)_shadd8(VAL1, VAL2))
  142. #define __UADD8(VAL1, VAL2) ((unsigned int)_uadd8(VAL1, VAL2))
  143. #define __UQADD8(VAL1, VAL2) ((unsigned int)_uqadd8(VAL1, VAL2))
  144. #define __UHADD8(VAL1, VAL2) ((unsigned int)_uhadd8(VAL1, VAL2))
  145. #define __SSUB8(VAL1, VAL2) ((unsigned int)_ssub8(VAL1, VAL2))
  146. #define __QSUB8(VAL1, VAL2) ((unsigned int)_qsub8(VAL1, VAL2))
  147. #define __SHSUB8(VAL1, VAL2) ((unsigned int)_shsub8(VAL1, VAL2))
  148. #define __USUB8(VAL1, VAL2) ((unsigned int)_usub8(VAL1, VAL2))
  149. #define __UQSUB8(VAL1, VAL2) ((unsigned int)_uqsub8(VAL1, VAL2))
  150. #define __UHSUB8(VAL1, VAL2) ((unsigned int)_uhsub8(VAL1, VAL2))
  151. #define __SADD16(VAL1, VAL2) ((unsigned int)_sadd16(VAL1, VAL2))
  152. #define __QADD16(VAL1, VAL2) ((unsigned int)_qadd16(VAL1, VAL2))
  153. #define __SHADD16(VAL1, VAL2) ((unsigned int)_shadd16(VAL1, VAL2))
  154. #define __UADD16(VAL1, VAL2) ((unsigned int)_uadd16(VAL1, VAL2))
  155. #define __UQADD16(VAL1, VAL2) ((unsigned int)_uqadd16(VAL1, VAL2))
  156. #define __UHADD16(VAL1, VAL2) ((unsigned int)_uhadd16(VAL1, VAL2))
  157. #define __SSUB16(VAL1, VAL2) ((unsigned int)_ssub16(VAL1, VAL2))
  158. #define __QSUB16(VAL1, VAL2) ((unsigned int)_qsub16(VAL1, VAL2))
  159. #define __SHSUB16(VAL1, VAL2) ((unsigned int)_shsub16(VAL1, VAL2))
  160. #define __USUB16(VAL1, VAL2) ((unsigned int)_usub16(VAL1, VAL2))
  161. #define __UQSUB16(VAL1, VAL2) ((unsigned int)_uqsub16(VAL1, VAL2))
  162. #define __UHSUB16(VAL1, VAL2) ((unsigned int)_uhsub16(VAL1, VAL2))
  163. #define __SASX(VAL1, VAL2) ((unsigned int)_saddsubx(VAL1, VAL2))
  164. #define __QASX(VAL1, VAL2) ((unsigned int)_qaddsubx(VAL1, VAL2))
  165. #define __SHASX(VAL1, VAL2) ((unsigned int)_shaddsubx(VAL1, VAL2))
  166. #define __UASX(VAL1, VAL2) ((unsigned int)_uaddsubx(VAL1, VAL2))
  167. #define __UQASX(VAL1, VAL2) ((unsigned int)_uqaddsubx(VAL1, VAL2))
  168. #define __UHASX(VAL1, VAL2) ((unsigned int)_uhaddsubx(VAL1, VAL2)))
  169. #define __SSAX(VAL1, VAL2) ((unsigned int)_ssubaddx(VAL1, VAL2))
  170. #define __QSAX(VAL1, VAL2) ((unsigned int)_qsubaddx(VAL1, VAL2))
  171. #define __SHSAX(VAL1, VAL2) ((unsigned int)_shsubaddx(VAL1, VAL2))
  172. #define __USAX(VAL1, VAL2) ((unsigned int)_usubaddx(VAL1, VAL2))
  173. #define __UQSAX(VAL1, VAL2) ((unsigned int)_uqsubaddx(VAL1, VAL2))
  174. #define __UHSAX(VAL1, VAL2) ((unsigned int)_uhsubaddx(VAL1, VAL2))
  175. #define __USAD8(VAL1, VAL2) ((unsigned int)_usad8(VAL1, VAL2))
  176. #define __USADA8(VAL1, VAL2, VAL3) ((unsigned int)_usada8(VAL1, VAL2, VAL3))
  177. #define __SSAT16(VAL, BITPOS) ((unsigned int)_ssat16(VAL, BITPOS))
  178. #define __USAT16(VAL, BITPOS) ((unsigned int)_usat16(VAL, BITPOS))
  179. #define __UXTB16(VAL) ((unsigned int)_uxtb16(VAL, 0))
  180. #define __UXTAB16(VAL1, VAL2) ((unsigned int)_uxtab16(VAL1, VAL2, 0))
  181. #define __SXTB16(VAL) ((unsigned int)_sxtb16(VAL, 0))
  182. #define __SXTAB16(VAL1, VAL2) ((unsigned int)_sxtab16(VAL1, VAL2, 0))
  183. #define __SMUAD(VAL1, VAL2) ((unsigned int)_smuad(VAL1, VAL2))
  184. #define __SMUADX(VAL1, VAL2) ((unsigned int)_smuadx(VAL1, VAL2))
  185. #define __SMLAD(VAL1, VAL2, ACCUMULATOR) ((unsigned int)_smlad(VAL1, VAL2, ACCUMULATOR))
  186. #define __SMLADX(VAL1, VAL2, ACCUMULATOR) ((unsigned int)_smladx(VAL1, VAL2, ACCUMULATOR))
  187. #define __SMLALD(VAL1, VAL2, ACCUMULATOR) ((unsigned long long)_smlald(ACCUMULATOR, VAL1, VAL2))
  188. #define __SMLALDX(VAL1, VAL2, ACCUMULATOR) ((unsigned long long)_smlaldx(ACCUMULATOR, VAL1, VAL2))
  189. #define __SMUSD(VAL1, VAL2) ((unsigned int)_smusd(VAL1, VAL2))
  190. #define __SMUSDX(VAL1, VAL2) ((unsigned int)_smusdx(VAL1, VAL2))
  191. #define __SMLSD(VAL1, VAL2, ACCUMULATOR) ((unsigned int)_smlsd(VAL1, VAL2, ACCUMULATOR))
  192. #define __SMLSDX(VAL1, VAL2, ACCUMULATOR) ((unsigned int)_smlsdx(VAL1, VAL2, ACCUMULATOR))
  193. #define __SMLSLD(VAL1, VAL2, ACCUMULATOR) ((unsigned long long)_smlsld(ACCUMULATOR, VAL1, VAL2))
  194. #define __SMLSLDX(VAL1, VAL2, ACCUMULATOR) ((unsigned long long)_smlsldx(ACCUMULATOR, VAL1, VAL2))
  195. #define __SEL(VAL1, VAL2) ((unsigned int)_sel(VAL1, VAL2))
  196. #define __QADD _sadd
  197. #define __QSUB _ssub
  198. #define __PKHBT _pkhbt
  199. #define __PKHTB _pkhtb
  200. #define __SMMLA _smmla
  201. #define __QDADD _sdadd
  202. #define __QDSUB _sdsub
  203. #define __SMLABB _smlabb
  204. #define __SMLABT _smlabt
  205. #define __SMLALBB _smlalbb
  206. #define __SMLALBT _smlalbt
  207. #define __SMLALTB _smlaltb
  208. #define __SMLALTT _smlaltt
  209. #define __SMLATB _smlatb
  210. #define __SMLATT _smlatt
  211. #define __SMLAWB _smlawb
  212. #define __SMLAWT _smlawt
  213. #define __SMULBB _smulbb
  214. #define __SMULBT _smulbt
  215. #define __SMULTB _smultb
  216. #define __SMULTT _smultt
  217. #define __SMULWB _smulwb
  218. #define __SMULWT _smulwt
  219. #define __SMMLAR _smmlar
  220. #define __SMMLS _smmls
  221. #define __SMMLSR _smmlsr
  222. #define __SMMUL _smmul
  223. #define __SMMULR _smmulr
  224. #define __SXTAB _sxtab
  225. #define __SXTAH _sxtah
  226. #define __UMAAL _umaal
  227. #define __UXTAB _uxtab
  228. #define __UXTAH _uxtah
  229. #define __SUBC _subc
  230. #endif /* (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) */
  231. #if (defined (__ARM_ARCH_6M__) && (__ARM_ARCH_6M__ == 1))
  232. #define __SXTB _sxtb
  233. #define __SXTH _sxth
  234. #define __UXTB _uxtb
  235. #define __UXTH _uxth
  236. #endif /* (defined (__ARM_ARCH_6M__) && (__ARM_ARCH_6M__ == 1)) */
  237. /** @} */ /* end of group CMSIS_SIMD_intrinsics */
  238. #endif /* CMSIS_CCS_H_ */