hc32f460_utility.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*******************************************************************************
  2. * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by HDSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. */
  9. /******************************************************************************/
  10. /** \file hc32f460_utility.h
  11. **
  12. ** A detailed description is available at
  13. ** @link DdlUtilityGroup Ddl Utility description @endlink
  14. **
  15. ** - 2018-11-02 CDT First version for Device Driver Library Utility.
  16. **
  17. ******************************************************************************/
  18. #ifndef __HC32F460_UTILITY_H__
  19. #define __HC32F460_UTILITY_H__
  20. /*******************************************************************************
  21. * Include files
  22. ******************************************************************************/
  23. #include "hc32_common.h"
  24. #include "ddl_config.h"
  25. #if (DDL_UTILITY_ENABLE == DDL_ON)
  26. /* C binding of definitions if building with C++ compiler */
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif
  31. /**
  32. *******************************************************************************
  33. ** \defgroup DdlUtilityGroup Device Driver Library Utility(DDLUTILITY)
  34. **
  35. ******************************************************************************/
  36. //@{
  37. /*******************************************************************************
  38. * Global type definitions ('typedef')
  39. ******************************************************************************/
  40. /*******************************************************************************
  41. * Global pre-processor symbols/macros ('#define')
  42. ******************************************************************************/
  43. /*******************************************************************************
  44. * Global variable definitions ('extern')
  45. ******************************************************************************/
  46. /*******************************************************************************
  47. * Global function prototypes (definition in C source)
  48. ******************************************************************************/
  49. /* A approximate delay */
  50. void Ddl_Delay1ms(uint32_t u32Cnt);
  51. void Ddl_Delay1us(uint32_t u32Cnt);
  52. /* Systick functions */
  53. en_result_t SysTick_Init(uint32_t u32Freq);
  54. void SysTick_Delay(uint32_t u32Delay);
  55. void SysTick_IncTick(void);
  56. uint32_t SysTick_GetTick(void);
  57. void SysTick_Suspend(void);
  58. void SysTick_Resume(void);
  59. /*! Ddl assert, you can add your own assert functions by implement the function
  60. Ddl_AssertHook definition follow the function Ddl_AssertHook declaration */
  61. #ifdef __DEBUG
  62. #define DDL_ASSERT(x) \
  63. do{ \
  64. ((x) ? (void)0 : Ddl_AssertHandler((uint8_t *)__FILE__, __LINE__)); \
  65. }while(0)
  66. /* Exported function */
  67. void Ddl_AssertHandler(uint8_t *file, int16_t line);
  68. #else
  69. #define DDL_ASSERT(x) (void)(0)
  70. #endif /* __DEBUG */
  71. #if (DDL_PRINT_ENABLE == DDL_ON)
  72. #include <stdio.h>
  73. en_result_t UART_PrintfInit(M4_USART_TypeDef *UARTx,
  74. uint32_t u32Baudrate,
  75. void (*PortInit)(void));
  76. #define DDL_PrintfInit (void)UART_PrintfInit
  77. #define DDL_Printf (void)printf
  78. #else
  79. #define DDL_PrintfInit(x, y, z)
  80. #define DDL_Printf(fmt, ...)
  81. #endif
  82. //@} // DdlUtilityGroup
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* DDL_UTILITY_ENABLE */
  87. #endif /* __HC32F460_UTILITY_H__ */
  88. /*******************************************************************************
  89. * EOF (not truncated)
  90. ******************************************************************************/