app_conf.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #pragma once
  2. #include <ble/core/ble_defs.h>
  3. #define CFG_TX_POWER (0x19) /* +0dBm */
  4. #define CFG_IDENTITY_ADDRESS GAP_PUBLIC_ADDR
  5. /**
  6. * Define IO Authentication
  7. */
  8. #define CFG_ENCRYPTION_KEY_SIZE_MAX (16)
  9. #define CFG_ENCRYPTION_KEY_SIZE_MIN (8)
  10. /**
  11. * Define IO capabilities
  12. */
  13. #define CFG_IO_CAPABILITY IO_CAP_DISPLAY_YES_NO
  14. /**
  15. * Define Secure Connections Support
  16. */
  17. #define CFG_SC_SUPPORT SC_PAIRING_OPTIONAL
  18. /**
  19. * Define PHY
  20. */
  21. #define ALL_PHYS_PREFERENCE 0x00
  22. #define RX_2M_PREFERRED 0x02
  23. #define TX_2M_PREFERRED 0x02
  24. #define TX_1M 0x01
  25. #define TX_2M 0x02
  26. #define RX_1M 0x01
  27. #define RX_2M 0x02
  28. /******************************************************************************
  29. * BLE Stack
  30. ******************************************************************************/
  31. /**
  32. * Maximum number of simultaneous connections that the device will support.
  33. * Valid values are from 1 to 8
  34. */
  35. #define CFG_BLE_NUM_LINK 2
  36. /**
  37. * Maximum number of Services that can be stored in the GATT database.
  38. * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services
  39. */
  40. #define CFG_BLE_NUM_GATT_SERVICES 8
  41. /**
  42. * Maximum number of Attributes
  43. * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services)
  44. * that can be stored in the GATT database.
  45. * Note that certain characteristics and relative descriptors are added automatically during device initialization
  46. * so this parameters should be 9 plus the number of user Attributes
  47. */
  48. #define CFG_BLE_NUM_GATT_ATTRIBUTES 68
  49. /**
  50. * Maximum supported ATT_MTU size
  51. */
  52. #define CFG_BLE_MAX_ATT_MTU (256 + 128 + 16 + 8 + 4 + 2)
  53. /**
  54. * Size of the storage area for Attribute values
  55. * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute:
  56. * - attribute value length
  57. * - 5, if UUID is 16 bit; 19, if UUID is 128 bit
  58. * - 2, if server configuration descriptor is used
  59. * - 2*DTM_NUM_LINK, if client configuration descriptor is used
  60. * - 2, if extended properties is used
  61. * The total amount of memory needed is the sum of the above quantities for each attribute.
  62. */
  63. #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344)
  64. /**
  65. * Prepare Write List size in terms of number of packet
  66. */
  67. #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU)
  68. /**
  69. * Number of allocated memory blocks
  70. */
  71. #define CFG_BLE_MBLOCK_COUNT \
  72. (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK))
  73. /**
  74. * Enable or disable the Extended Packet length feature. Valid values are 0 or 1.
  75. */
  76. #define CFG_BLE_DATA_LENGTH_EXTENSION 1
  77. /**
  78. * Sleep clock accuracy in Slave mode (ppm value)
  79. */
  80. #define CFG_BLE_SLAVE_SCA 500
  81. /**
  82. * Sleep clock accuracy in Master mode
  83. * 0 : 251 ppm to 500 ppm
  84. * 1 : 151 ppm to 250 ppm
  85. * 2 : 101 ppm to 150 ppm
  86. * 3 : 76 ppm to 100 ppm
  87. * 4 : 51 ppm to 75 ppm
  88. * 5 : 31 ppm to 50 ppm
  89. * 6 : 21 ppm to 30 ppm
  90. * 7 : 0 ppm to 20 ppm
  91. */
  92. #define CFG_BLE_MASTER_SCA 0
  93. /**
  94. * Source for the low speed clock for RF wake-up
  95. * 1 : external high speed crystal HSE/32/32
  96. * 0 : external low speed crystal ( no calibration )
  97. */
  98. #define CFG_BLE_LSE_SOURCE \
  99. SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | \
  100. SHCI_C2_BLE_INIT_CFG_BLE_LS_CALIB
  101. /**
  102. * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us)
  103. */
  104. #define CFG_BLE_HSE_STARTUP_TIME 0x148
  105. /**
  106. * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us)
  107. */
  108. #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF)
  109. /**
  110. * Viterbi Mode
  111. * 1 : enabled
  112. * 0 : disabled
  113. */
  114. #define CFG_BLE_VITERBI_MODE 1
  115. /**
  116. * BLE stack Options flags to be configured with:
  117. * - SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY
  118. * - SHCI_C2_BLE_INIT_OPTIONS_LL_HOST
  119. * - SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC
  120. * - SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC
  121. * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO
  122. * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW
  123. * - SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV
  124. * - SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV
  125. * - SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2
  126. * - SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2
  127. * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1
  128. * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3
  129. * which are used to set following configuration bits:
  130. * (bit 0): 1: LL only
  131. * 0: LL + host
  132. * (bit 1): 1: no service change desc.
  133. * 0: with service change desc.
  134. * (bit 2): 1: device name Read-Only
  135. * 0: device name R/W
  136. * (bit 3): 1: extended advertizing supported [NOT SUPPORTED]
  137. * 0: extended advertizing not supported [NOT SUPPORTED]
  138. * (bit 4): 1: CS Algo #2 supported
  139. * 0: CS Algo #2 not supported
  140. * (bit 7): 1: LE Power Class 1
  141. * 0: LE Power Class 2-3
  142. * other bits: reserved (shall be set to 0)
  143. */
  144. #define CFG_BLE_OPTIONS \
  145. (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | \
  146. SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | \
  147. SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3)
  148. /**
  149. * Queue length of BLE Event
  150. * This parameter defines the number of asynchronous events that can be stored in the HCI layer before
  151. * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer
  152. * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large
  153. * enough to store all asynchronous events received in between.
  154. * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events
  155. * between the HCI command and its event.
  156. * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small,
  157. * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting
  158. * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate
  159. * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout).
  160. */
  161. #define CFG_TLBLE_EVT_QUEUE_LENGTH 5
  162. /**
  163. * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element
  164. * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager.
  165. * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will
  166. * never be used)
  167. * With the current wireless firmware implementation, this parameter shall be kept to 255
  168. *
  169. */
  170. #define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE \
  171. 255 /**< Set to 255 with the memory manager and the mailbox */
  172. #define TL_BLE_EVENT_FRAME_SIZE (TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE)
  173. /* Various defines for compatibility with -Wundef - thanks, ST */
  174. #define CFG_DEBUG_TRACE_FULL 0
  175. #define CFG_DEBUG_TRACE_LIGHT 0