config.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : CONFIG.h
  3. * Author : WCH
  4. * Version : V1.2
  5. * Date : 2022/01/18
  6. * Description : Configuration description and default value,
  7. * it is recommended to modify the current value in the
  8. * pre-processing of the engineering configuration
  9. *********************************************************************************
  10. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  11. * Attention: This software (modified or not) and binary are used for
  12. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  13. *******************************************************************************/
  14. /******************************************************************************/
  15. #ifndef __CONFIG_H
  16. #define __CONFIG_H
  17. #define ID_CH32V208 0x0208
  18. #define CHIP_ID ID_CH32V208
  19. #ifdef WCHBLE_ROM
  20. #include "WCHBLE_ROM.H"
  21. #else
  22. #include "wchble.H"
  23. #endif
  24. #include "ch32v20x.h"
  25. /*********************************************************************
  26. 【MAC】
  27. BLE_MAC - 是否自定义蓝牙Mac地址 ( 默认:FALSE - 使用芯片Mac地址 ),需要在main.c修改Mac地址定义
  28. 【SLEEP】
  29. HAL_SLEEP - 是否开启睡眠功能 ( 默认:FALSE )
  30. WAKE_UP_MAX_TIME_US - 提前唤醒时间,即系统时钟稳定所需要时间
  31. 暂停模式 - 45
  32. 空闲模式 - 5
  33. 【TEMPERATION】
  34. TEM_SAMPLE - 是否打开根据温度变化校准的功能,单次校准耗时小于10ms( 默认:TRUE )
  35. 【CALIBRATION】
  36. BLE_CALIBRATION_ENABLE - 是否打开定时校准的功能,单次校准耗时小于10ms( 默认:TRUE )
  37. BLE_CALIBRATION_PERIOD - 定时校准的周期,单位ms( 默认:120000 )
  38. 【SNV】
  39. BLE_SNV - 是否开启SNV功能,用于储存绑定信息( 默认:TRUE )
  40. BLE_SNV_ADDR - SNV信息保存地址,使用data flash最后( 默认:0x77E00 )
  41. BLE_SNV_NUM - SNV信息存储扇区数量等于可存储的绑定数量( 默认:3 )
  42. - 如果配置了SNVNum参数,则需要对应修改Lib_Write_Flash函数内擦除的flash大小,大小为SNVBlock*SNVNum
  43. 【RTC】
  44. CLK_OSC32K - RTC时钟选择,如包含主机角色必须使用外部32K( 0 外部(32768Hz),默认:1:内部(32000Hz),2:内部(32768Hz) )
  45. 【MEMORY】
  46. BLE_MEMHEAP_SIZE - 蓝牙协议栈使用的RAM大小,不小于6K ( 默认:(1024*6) )
  47. 【DATA】
  48. BLE_BUFF_MAX_LEN - 单个连接最大包长度( 默认:27 (ATT_MTU=23),取值范围[27~251] )
  49. BLE_BUFF_NUM - 控制器缓存的包数量( 默认:5 )
  50. BLE_TX_NUM_EVENT - 单个连接事件最多可以发多少个数据包( 默认:1 )
  51. BLE_TX_POWER - 发射功率( 默认:LL_TX_POWEER_0_DBM (0dBm) )
  52. 【MULTICONN】
  53. PERIPHERAL_MAX_CONNECTION - 最多可同时做多少从机角色( 默认:1 )
  54. CENTRAL_MAX_CONNECTION - 最多可同时做多少主机角色( 默认:3 )
  55. **********************************************************************/
  56. /*********************************************************************
  57. * 默认配置值
  58. */
  59. #ifndef BLE_MAC
  60. #define BLE_MAC FALSE
  61. #endif
  62. #ifndef HAL_SLEEP
  63. #define HAL_SLEEP FALSE
  64. #endif
  65. #ifndef WAKE_UP_MAX_TIME_US
  66. #define WAKE_UP_MAX_TIME_US 2400
  67. #endif
  68. #ifndef HAL_KEY
  69. #define HAL_KEY FALSE
  70. #endif
  71. #ifndef HAL_LED
  72. #define HAL_LED FALSE
  73. #endif
  74. #ifndef TEM_SAMPLE
  75. #define TEM_SAMPLE TRUE
  76. #endif
  77. #ifndef BLE_CALIBRATION_ENABLE
  78. #define BLE_CALIBRATION_ENABLE TRUE
  79. #endif
  80. #ifndef BLE_CALIBRATION_PERIOD
  81. #define BLE_CALIBRATION_PERIOD 120000
  82. #endif
  83. #ifndef BLE_SNV
  84. #define BLE_SNV TRUE
  85. #endif
  86. #ifndef BLE_SNV_ADDR
  87. #define BLE_SNV_ADDR 0x08077C00
  88. #endif
  89. #ifndef BLE_SNV_NUM
  90. #define BLE_SNV_NUM 3
  91. #endif
  92. #ifndef CLK_OSC32K
  93. #define CLK_OSC32K 1 // 该项请勿在此修改,必须在工程配置里的预处理中修改,如包含主机角色必须使用外部32K
  94. #endif
  95. #ifndef BLE_MEMHEAP_SIZE
  96. #define BLE_MEMHEAP_SIZE (1024*7)
  97. #endif
  98. #ifndef BLE_BUFF_MAX_LEN
  99. #define BLE_BUFF_MAX_LEN 27
  100. #endif
  101. #ifndef BLE_BUFF_NUM
  102. #define BLE_BUFF_NUM 5
  103. #endif
  104. #ifndef BLE_TX_NUM_EVENT
  105. #define BLE_TX_NUM_EVENT 1
  106. #endif
  107. #ifndef BLE_TX_POWER
  108. #define BLE_TX_POWER LL_TX_POWEER_0_DBM
  109. #endif
  110. #ifndef PERIPHERAL_MAX_CONNECTION
  111. #define PERIPHERAL_MAX_CONNECTION 1
  112. #endif
  113. #ifndef CENTRAL_MAX_CONNECTION
  114. #define CENTRAL_MAX_CONNECTION 3
  115. #endif
  116. extern uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
  117. extern uint8_t MacAddr[6];
  118. #endif