Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 41 additions & 7 deletions lib/stm32wb0/BLE_TransparentMode/Core/Inc/app_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@
#ifndef __ZEPHYR__
/* It is handled by CMakeLists.txt */
#define CFG_BLE_NUM_RADIO_TASKS (CFG_NUM_RADIO_TASKS)
#endif
#endif /* __ZEPHYR__ */

/**
* Maximum number of Attributes that can be stored in the GATT database.
* Maximum number of attributes that can be stored in the GATT database in addition to the attributes number already defined for the GATT and GAP services
* (BLE_STACK_NUM_GATT_MANDATORY_ATTRIBUTES value on STM32_BLE middleware, ble_stack.h header file).
*/
#define CFG_BLE_NUM_GATT_ATTRIBUTES (60)

Expand Down Expand Up @@ -108,7 +109,7 @@
*/
#ifndef __ZEPHYR__
#define CFG_BLE_NUM_EATT_CHANNELS (6)
#endif
#endif /* __ZEPHYR__ */

/**
* Maximum number of channels in LE Credit Based Flow Control mode [0-255].
Expand All @@ -129,7 +130,7 @@
#ifndef __ZEPHYR__
/* It is handled by CMakeLists.txt */
#define CFG_BLE_NUM_ADV_SETS (2)
#endif
#endif /* __ZEPHYR__ */

/**
* Maximum number of Periodic Advertising with Responses subevents.
Expand All @@ -147,15 +148,16 @@
*/
#ifndef __ZEPHYR__
#define CFG_BLE_NUM_AUX_SCAN_SLOTS (4)
#endif
#endif /* __ZEPHYR__ */

/**
* Maximum number of slots for synchronizing to a periodic advertising train,
* if Periodic Advertising and Synchronizing Feature is enabled.
*/
#ifndef __ZEPHYR__
/* It is handled by CMakeLists.txt */
#define CFG_BLE_NUM_SYNC_SLOTS (2)
#endif
#endif /* __ZEPHYR__ */

/**
* Two's logarithm of Filter Accept, Resolving and Advertiser list size.
Expand Down Expand Up @@ -205,6 +207,12 @@
#define CFG_BLE_NUM_CIS_MAX (2U)
#endif /* __ZEPHYR__ */

/**
* Maximum number of simultaneous Link Layer procedures that can be managed, in addition to the minimum required by the stack.
* The minimum number guarantees one LL procedure initiated by the peer for each link, one LL procedure automatically initiated by the Controller and one LL procedure initiated by the Host.
*/
#define CFG_BLE_EXTRA_LL_PROCEDURE_CONTEXTS (0)

/**
* Size of the internal FIFO used for critical controller events produced by the
* ISR (e.g. rx data packets).
Expand All @@ -223,6 +231,16 @@
*/
#define CFG_BLE_USER_FIFO_SIZE (1024)

/**
* If 1, Peripheral Preferred Connection Parameters Characteristic is added in GAP service.
*/
#define CFG_BLE_GAP_PERIPH_PREF_CONN_PARAM_CHARACTERISTIC (1)

/**
* If 1, Encrypted Key Material Characteristic is added in GAP service.
*/
#define CFG_BLE_GAP_ENCRYPTED_KEY_MATERIAL_CHARACTERISTIC (0)

/**
* Number of allocated memory blocks used for packet allocation.
* The use of BLE_STACK_MBLOCKS_CALC macro is suggested to calculate the minimum
Expand Down Expand Up @@ -255,6 +273,7 @@
CFG_BLE_NUM_BRC_BIS_MAX,\
CFG_BLE_NUM_CIG_MAX,\
CFG_BLE_NUM_CIS_MAX,\
CFG_BLE_EXTRA_LL_PROCEDURE_CONTEXTS,\
CFG_BLE_ISR0_FIFO_SIZE,\
CFG_BLE_ISR1_FIFO_SIZE,\
CFG_BLE_USER_FIFO_SIZE))
Expand All @@ -266,6 +285,11 @@
/******************************************************************************
* Initialization parameters used in Network Processor mode
******************************************************************************/
/**
* Network mode (used in gap_profile.c)
*/
#define CFG_BLE_NETWORK_PROC_MODE (1)

/**
* Size of buffer used for ATT queued writes
*/
Expand All @@ -287,6 +311,11 @@
*/
#define CFG_BLE_GATT_ADV_NWK_BUFFER_SIZE (CFG_BLE_GATT_NWK_BUFFER_SIZE + CFG_BLE_ADV_NWK_BUFFER_SIZE + CFG_BLE_ATT_QUEUED_WRITE_SIZE)

/**
* Maximum number of characteristics that can be subscribed to check for security level.
*/
#define CFG_BLE_GATT_CLT_NUM_CHARAC_SUBSCRIPTIONS_MAX (5)

/******************************************************************************
* BLE Stack modularity options
******************************************************************************/
Expand All @@ -308,7 +337,7 @@
#define CFG_BLE_CONTROLLER_BIS_ENABLED (1U)
#define CFG_BLE_CONNECTION_SUBRATING_ENABLED (1U)
#define CFG_BLE_CONTROLLER_CIS_ENABLED (1U)
#endif
#endif /* __ZEPHYR__ */

/******************************************************************************
* Low Power
Expand All @@ -317,12 +346,17 @@
* low power mode. It means that all what can have an impact on the consumptions
* are powered down.(For instance LED, Access to Debugger, Etc.)
*
* When CFG_LPM_SUPPORTED and CFG_FULL_LOW_EMULATED are both set to 1, the system is configured to
* emulate the Deepstop mode without losing the debugger connection and breakpoints nor watchpoints.
*
******************************************************************************/

#define CFG_FULL_LOW_POWER (0)

#define CFG_LPM_SUPPORTED (1)

#define CFG_LPM_EMULATED (0)

/**
* Low Power configuration
*/
Expand Down
124 changes: 70 additions & 54 deletions lib/stm32wb0/BLE_TransparentMode/Core/Src/stm32wb0x_hal_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ void HAL_MspInit(void)

/* USER CODE END MspInit 0 */

__HAL_RCC_SYSCFG_CLK_ENABLE();

/* System interrupt init*/

/* USER CODE BEGIN MspInit 1 */
Expand All @@ -84,69 +86,70 @@ void HAL_MspInit(void)
}

/**
* @brief PKA MSP Initialization
* This function configures the hardware resources used in this example
* @param hpka: PKA handle pointer
* @retval None
*/
* @brief PKA MSP Initialization
* This function configures the hardware resources used in this example
* @param hpka: PKA handle pointer
* @retval None
*/
void HAL_PKA_MspInit(PKA_HandleTypeDef* hpka)
{
if(hpka->Instance==PKA)
{
/* USER CODE BEGIN PKA_MspInit 0 */
/* USER CODE BEGIN PKA_MspInit 0 */

/* USER CODE END PKA_MspInit 0 */
/* USER CODE END PKA_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_PKA_CLK_ENABLE();
/* PKA interrupt Init */
HAL_NVIC_SetPriority(PKA_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(PKA_IRQn);
/* USER CODE BEGIN PKA_MspInit 1 */
/* USER CODE BEGIN PKA_MspInit 1 */

/* USER CODE END PKA_MspInit 1 */

/* USER CODE END PKA_MspInit 1 */
}

}

/**
* @brief PKA MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hpka: PKA handle pointer
* @retval None
*/
* @brief PKA MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hpka: PKA handle pointer
* @retval None
*/
void HAL_PKA_MspDeInit(PKA_HandleTypeDef* hpka)
{
if(hpka->Instance==PKA)
{
/* USER CODE BEGIN PKA_MspDeInit 0 */
/* USER CODE BEGIN PKA_MspDeInit 0 */

/* USER CODE END PKA_MspDeInit 0 */
/* USER CODE END PKA_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_PKA_CLK_DISABLE();

/* PKA interrupt DeInit */
HAL_NVIC_DisableIRQ(PKA_IRQn);
/* USER CODE BEGIN PKA_MspDeInit 1 */
/* USER CODE BEGIN PKA_MspDeInit 1 */

/* USER CODE END PKA_MspDeInit 1 */
/* USER CODE END PKA_MspDeInit 1 */
}

}

/**
* @brief RADIO MSP Initialization
* This function configures the hardware resources used in this example
* @param hradio: RADIO handle pointer
* @retval None
*/
* @brief RADIO MSP Initialization
* This function configures the hardware resources used in this example
* @param hradio: RADIO handle pointer
* @retval None
*/
void HAL_RADIO_MspInit(RADIO_HandleTypeDef* hradio)
{
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
if(hradio->Instance==RADIO)
{
/* USER CODE BEGIN RADIO_MspInit 0 */
/* USER CODE BEGIN RADIO_MspInit 0 */

/* USER CODE END RADIO_MspInit 0 */
/* USER CODE END RADIO_MspInit 0 */

/** Initializes the peripherals clock
*/
Expand All @@ -173,26 +176,29 @@ void HAL_RADIO_MspInit(RADIO_HandleTypeDef* hradio)
HAL_NVIC_EnableIRQ(RADIO_TXRX_IRQn);
HAL_NVIC_SetPriority(RADIO_TXRX_SEQ_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(RADIO_TXRX_SEQ_IRQn);
/* USER CODE BEGIN RADIO_MspInit 1 */
HAL_NVIC_SetPriority(RADIO_RRM_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(RADIO_RRM_IRQn);
/* USER CODE BEGIN RADIO_MspInit 1 */

/* USER CODE END RADIO_MspInit 1 */

/* USER CODE END RADIO_MspInit 1 */
}

}

/**
* @brief RADIO MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hradio: RADIO handle pointer
* @retval None
*/
* @brief RADIO MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hradio: RADIO handle pointer
* @retval None
*/
void HAL_RADIO_MspDeInit(RADIO_HandleTypeDef* hradio)
{
if(hradio->Instance==RADIO)
{
/* USER CODE BEGIN RADIO_MspDeInit 0 */
/* USER CODE BEGIN RADIO_MspDeInit 0 */

/* USER CODE END RADIO_MspDeInit 0 */
/* USER CODE END RADIO_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_RADIO_CLK_DISABLE();
__HAL_RCC_RADIO_FORCE_RESET();
Expand All @@ -201,28 +207,29 @@ void HAL_RADIO_MspDeInit(RADIO_HandleTypeDef* hradio)
/* RADIO interrupt DeInit */
HAL_NVIC_DisableIRQ(RADIO_TXRX_IRQn);
HAL_NVIC_DisableIRQ(RADIO_TXRX_SEQ_IRQn);
/* USER CODE BEGIN RADIO_MspDeInit 1 */
HAL_NVIC_DisableIRQ(RADIO_RRM_IRQn);
/* USER CODE BEGIN RADIO_MspDeInit 1 */

/* USER CODE END RADIO_MspDeInit 1 */
/* USER CODE END RADIO_MspDeInit 1 */
}

}

/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
#ifndef __ZEPHYR__
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspInit 0 */
/* USER CODE BEGIN USART1_MspInit 0 */

/* USER CODE END USART1_MspInit 0 */
/* USER CODE END USART1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_USART1_CLK_ENABLE();

Expand All @@ -246,6 +253,14 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
GPIO_InitStruct.Alternate = GPIO_AF2_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

HAL_PWREx_DisableGPIOPullUp(PWR_GPIO_B, PWR_GPIO_BIT_0);

HAL_PWREx_DisableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_1);

HAL_PWREx_DisableGPIOPullDown(PWR_GPIO_B, PWR_GPIO_BIT_0);

HAL_PWREx_DisableGPIOPullDown(PWR_GPIO_A, PWR_GPIO_BIT_1);

/* USART1 DMA Init */
/* USART1_TX Init */
hdma_usart1_tx.Instance = DMA1_Channel1;
Expand Down Expand Up @@ -284,26 +299,27 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
/* USART1 interrupt Init */
HAL_NVIC_SetPriority(USART1_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspInit 1 */
/* USER CODE BEGIN USART1_MspInit 1 */

/* USER CODE END USART1_MspInit 1 */

/* USER CODE END USART1_MspInit 1 */
}

}

/**
* @brief UART MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
* @brief UART MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
{
if(huart->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspDeInit 0 */
/* USER CODE BEGIN USART1_MspDeInit 0 */

/* USER CODE END USART1_MspDeInit 0 */
/* USER CODE END USART1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART1_CLK_DISABLE();

Expand All @@ -321,9 +337,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)

/* USART1 interrupt DeInit */
HAL_NVIC_DisableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspDeInit 1 */
/* USER CODE BEGIN USART1_MspDeInit 1 */

/* USER CODE END USART1_MspDeInit 1 */
/* USER CODE END USART1_MspDeInit 1 */
}

}
Expand Down
5 changes: 5 additions & 0 deletions lib/stm32wb0/BLE_TransparentMode/STM32_BLE/App/aci_adv_nwk.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ tBleStatus hci_le_set_periodic_advertising_subevent_data(uint8_t Advertising_Han
return BLE_ERROR_UNKNOWN_ADVERTISING_IDENTIFIER;
}

if ((Num_Subevents == 0) || (Num_Subevents > 0x0F))
{
return BLE_ERROR_INVALID_HCI_CMD_PARAMS;
}

if(pawr_buff_subevent_num_available() < Num_Subevents)
{
/* This happens is host has given more data than what requested by the Controller. */
Expand Down
Loading