fsl_assert.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. *
  8. * Redistribution and use in source and binary forms, with or without modification,
  9. * are permitted (subject to the limitations in the disclaimer below) provided
  10. * that the following conditions are met:
  11. *
  12. * o Redistributions of source code must retain the above copyright notice, this list
  13. * of conditions and the following disclaimer.
  14. *
  15. * o Redistributions in binary form must reproduce the above copyright notice, this
  16. * list of conditions and the following disclaimer in the documentation and/or
  17. * other materials provided with the distribution.
  18. *
  19. * o Neither the name of the copyright holder nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  25. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  28. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  29. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  31. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include "fsl_common.h"
  36. #include "fsl_debug_console.h"
  37. #ifndef NDEBUG
  38. #if (defined(__CC_ARM)) || (defined(__ICCARM__))
  39. void __aeabi_assert(const char *failedExpr, const char *file, int line)
  40. {
  41. PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" \n", failedExpr, file, line);
  42. for (;;)
  43. {
  44. __BKPT(0);
  45. }
  46. }
  47. #elif(defined(__GNUC__))
  48. void __assert_func(const char *file, int line, const char *func, const char *failedExpr)
  49. {
  50. PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func);
  51. for (;;)
  52. {
  53. __BKPT(0);
  54. }
  55. }
  56. #endif /* (defined(__CC_ARM)) || (defined (__ICCARM__)) */
  57. #endif /* NDEBUG */