Functions
Functions
BLE » BLE Common

## Functions
uint16_t | ble_stack_init (ble_evt_handler_t evt_handler, stack_heaps_table_t *p_heaps_table)
| Initialize BLE Stack. More...
void | ble_stack_controller_init (stack_heaps_table_t *p_heaps_table)
| Initialize only BLE Stack Controller. More...
void | ble_hci_uart_register (uint8_t id, hci_uart_call_t *api)
| Register UART instance for HCI. More...
void | ble_idle_time_notify_cb_register (void(*callback)(uint32_t hs))
| Register BLE idle time notification callback function. More...
void | ble_activity_start_notify_cb_register (void(*callback)(ble_gap_actv_role_t e_role, uint8_t index))
| Register BLE activity start notification callback function. More...
void | ble_activity_end_notify_cb_register (void(*callback)(ble_gap_actv_role_t e_role, uint8_t index))
| Register BLE activity end notification callback function. More...
uint16_t | ble_sync_source_create (uint16_t period)
| Create sync source. More...
uint16_t | ble_sync_evt_cb_register (ble_sync_evt_cb_t sync_evt_cb)
| Register sync event callback. More...
uint16_t | ble_sync_source_distribute (uint8_t conn_idx)
| Distribute sync source. More...
uint16_t | ble_sync_source_destroy (void)
| Destroy sync source. More...
uint8_t | ble_rf_tx_mode_set (ble_rf_tx_mode_t e_rf_tx_mode)
| Change the RF TX mode of LP or ULP. More...
ble_rf_tx_mode_t | ble_rf_tx_mode_get (void)
| Get the RF TX mode of LP or ULP. More...
void | ble_rf_match_circuit_set (ble_rf_match_circuit_t e_ohm)
| Set the resistance value of the RF match circuit (unit: ohm). More...
ble_rf_match_circuit_t | ble_rf_match_circuit_get (void)
| Get the resistance value of the RF match circuit (unit: ohm). More...
void | send_signal_carrier_wave (uint8_t channel)
| Generate a signal carrier wave. More...

## Detailed Description

## Function Documentation

## ◆ ble_activity_end_notify_cb_register()

void ble_activity_end_notify_cb_register | ( | void(*)(ble_gap_actv_role_t e_role, uint8_t index) | callback | ) |

Register BLE activity end notification callback function.

Parameters

  [in] | callback | function pointer of BLE activity end notification function.

Note
  param[in] of callback: e_role - the role of activity,gap_activity_role_t for possible roles. param[in] of callback: index - The index parameter is interpreted by role. If role is GAP_ACTIVITY_ROLE_ADV, it's the index of Advertising. If role is GAP_ACTIVITY_ROLE_CON, it's the index of Connection. For all other roles, it should be ignored. Callback will be called by BLE ISR when the BLE activity ends every time. It should be realized as simlpe as you can. You'd better to define it in the RAM space It's not suitable for ISO activities.

## ◆ ble_activity_start_notify_cb_register()

void ble_activity_start_notify_cb_register | ( | void(*)(ble_gap_actv_role_t e_role, uint8_t index) | callback | ) |

Register BLE activity start notification callback function.

Parameters

  [in] | callback | function pointer of BLE activity start notification function.

Note
  param[in] of callback: e_role - the role of activity, gap_activity_role_t for possible roles. param[in] of callback: index - The index parameter is interpreted by role. If role is GAP_ACTIVITY_ROLE_ADV, it's the index of Advertising. If role is GAP_ACTIVITY_ROLE_CON, it's the index of Connection. For all other roles, it should be ignored. Callback will be called by BLE ISR when the BLE activity starts every time. It should be realized as simlpe as you can. Notice: You must define the start callback in the RAM space to avoid hardfault. It's not suitable for ISO activities.

## ◆ ble_hci_uart_register()

void ble_hci_uart_register | ( | uint8_t | id,
|  | hci_uart_call_t * | api
| ) |  |

Register UART instance for HCI.

Parameters

  [in] | id | Instance index.
  [in] | api | Pointer to the struct of function pointers for HCI UART.

## ◆ ble_idle_time_notify_cb_register()

void ble_idle_time_notify_cb_register | ( | void(*)(uint32_t hs) | callback | ) |

Register BLE idle time notification callback function.

Parameters

  [in] | callback | function pointer of BLE idle time notification function.

Note
  param[in] of callback: hs - the idle time of BLE in half slot (312.5μs). Callback will be called by BLE ISR to notify the rest idle time if there are some BLE activities. It should be realized as simlpe as you can. It's not suitable for ISO activities.

## ◆ ble_rf_match_circuit_get()

ble_rf_match_circuit_t ble_rf_match_circuit_get | ( | void |  | ) |

Get the resistance value of the RF match circuit (unit: ohm).

Returns
  The resistance value (ohm) of the RF match circuit according to the board (ohm). BLE_RF_MATCH_CIRCUIT_25OHM: 25 ohm. BLE_RF_MATCH_CIRCUIT_100OHM: 100 ohm. Others: invalid.

## ◆ ble_rf_match_circuit_set()

void ble_rf_match_circuit_set | ( | ble_rf_match_circuit_t | e_ohm | ) |

Set the resistance value of the RF match circuit (unit: ohm).

Note
  This function should be called before BLE stack init.

Parameters

  [in] | e_ohm | The resistance value (ohm) of the RF match circuit according to the board. BLE_RF_MATCH_CIRCUIT_25OHM: 25 ohm. BLE_RF_MATCH_CIRCUIT_100OHM: 100 ohm. Others: invalid.

## ◆ ble_rf_tx_mode_get()

ble_rf_tx_mode_t ble_rf_tx_mode_get | ( | void |  | ) |

Get the RF TX mode of LP or ULP.

Returns
  BLE_RF_TX_MODE_LP_MODE: LP Mode. BLE_RF_TX_MODE_ULP_MODE: ULP Mode. Others: Fail.

## ◆ ble_rf_tx_mode_set()

uint8_t ble_rf_tx_mode_set | ( | ble_rf_tx_mode_t | e_rf_tx_mode | ) |

Change the RF TX mode of LP or ULP.

Parameters

  [in] | e_rf_tx_mode | Refer to ble_rf_tx_mode_t. BLE_RF_TX_MODE_LP_MODE: LP mode. BLE_RF_TX_MODE_ULP_MODE: ULP mode. Others: invalid mode.

Note
  This function should be called before BLE stack init.

Returns
  SDK_SUCCESS: Successfully set Tx mode. SDK_ERR_DISALLOWED: Failed to set Tx mode.

## ◆ ble_stack_controller_init()

void ble_stack_controller_init | ( | stack_heaps_table_t * | p_heaps_table | ) |

Initialize only BLE Stack Controller.

Parameters

  [in] | p_heaps_table | Pointer to the BLE stack heaps table.

## ◆ ble_stack_init()

uint16_t ble_stack_init | ( | ble_evt_handler_t | evt_handler,
|  | stack_heaps_table_t * | p_heaps_table
| ) |  |

Initialize BLE Stack.

Parameters

  [in] | evt_handler | Pointer to ble events handler.
  [in] | p_heaps_table | Pointer to the BLE stack heaps table.

## ◆ ble_sync_evt_cb_register()

uint16_t ble_sync_evt_cb_register | ( | ble_sync_evt_cb_t | sync_evt_cb | ) |

Register sync event callback.

Parameters

  [in] | sync_evt_cb | Sync event callback.

Returns
  SDK_ERR_POINTER_NULL: Pointer to sync event callback is NULL. SDK_SUCCESS: Register successfully.

## ◆ ble_sync_source_create()

uint16_t ble_sync_source_create | ( | uint16_t | period | ) |

Create sync source.

Parameters

  [in] | period | Period of sync source.

Returns
  SDK_ERR_DISALLOWED: Create sync source fail. SDK_SUCCESS: Create sync source successfully.

## ◆ ble_sync_source_destroy()

uint16_t ble_sync_source_destroy | ( | void |  | ) |

Destroy sync source.

Returns
  SDK_SUCCESS: Destroy successfully.

## ◆ ble_sync_source_distribute()

uint16_t ble_sync_source_distribute | ( | uint8_t | conn_idx | ) |

Distribute sync source.

Parameters

  [in] | conn_idx | The connection index.

Returns
  SDK_ERR_INVALID_CONN_IDX: Invalid connect index. SDK_ERR_DISALLOWED: Distribute is disallowed. SDK_SUCCESS: Distribute successfully.

## ◆ send_signal_carrier_wave()

void send_signal_carrier_wave | ( | uint8_t | channel | ) |

Generate a signal carrier wave.

Parameters

  [in] | channel | 0~39 channel, 2402~2480 Mhz.