system.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2006-2020, YICHIP Development Team
  3. * @file yc_system.h
  4. * @brief source file for setting system
  5. *
  6. * Change Logs:
  7. * Date Author Version Notes
  8. * 2020-11-05 wushengyan V1.0.0 the first version
  9. */
  10. #ifndef __SYSTEM_H__
  11. #define __SYSTEM_H__
  12. #define SDK_DEBUG //Debug switch
  13. #include <string.h>
  14. #include "yc_uart.h"
  15. #include "rom_api.h"
  16. #include "board_config.h"
  17. #define BIT_SET(a,b) ((a) |= (1<<(b)))
  18. #define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
  19. #define BIT_FLIP(a,b) ((a) ^= (1<<(b))) //bit Negation
  20. #define BIT_GET(a,b) (((a) & (1<<(b)))>>(b))
  21. /**
  22. * @brief Print format string to serial port 0.You need to initialize the serial port 0 before you use MyPrintf.
  23. *
  24. * @param format : format string
  25. * @param ...: format parameter
  26. */
  27. void MyPrintf(char *format, ...);
  28. void printv(uint8_t *buf, uint32_t len, char *s);
  29. void PrintPort_Set(UART_TypeDef *UARTx);
  30. void Board_Init(void);
  31. void _assert_handler(const char *file, int line, const char *func);
  32. #ifdef SDK_DEBUG
  33. #define _ASSERT(x) \
  34. if (!(x)) \
  35. { \
  36. _assert_handler(__FILE__,__LINE__,__FUNCTION__);\
  37. }
  38. #else
  39. #define _ASSERT(x)
  40. #endif
  41. #define YC_DEBUG_LOG(type, message) \
  42. do \
  43. { \
  44. if (type) \
  45. MyPrintf message; \
  46. } \
  47. while (0)
  48. #endif /*__SYSTEM_H__*/