lib/stm32wb: hci: Update lib to V1.5.0 Cube version Tested with 1.5 and default binary Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
diff --git a/lib/stm32wb/hci/README b/lib/stm32wb/hci/README index d69f1b8..e9b5936 100644 --- a/lib/stm32wb/hci/README +++ b/lib/stm32wb/hci/README
@@ -6,7 +6,7 @@ https://github.com/STMicroelectronics/STM32CubeWB Status: - version 1.3.0 + version 1.5.0 Purpose: This library is used on stm32wb series to enable HCI communication between @@ -25,7 +25,7 @@ https://github.com/STMicroelectronics/STM32CubeWB commit: - 96abbb67db97bc53e38f9727adfae0e5c70b1498 + 2b2c57a80d71ffeec182cc520e5a72af7b94778d Maintained-by: External
diff --git a/lib/stm32wb/hci/app_conf.h b/lib/stm32wb/hci/app_conf.h index 33acbd4..a3837aa 100644 --- a/lib/stm32wb/hci/app_conf.h +++ b/lib/stm32wb/hci/app_conf.h
@@ -41,6 +41,10 @@ * Define Advertising parameters */ #define CFG_ADV_BD_ADDRESS (0x7257acd87a6c) +#define CFG_FAST_CONN_ADV_INTERVAL_MIN (0x80) /**< 80ms */ +#define CFG_FAST_CONN_ADV_INTERVAL_MAX (0xa0) /**< 100ms */ +#define CFG_LP_CONN_ADV_INTERVAL_MIN (0x640) /**< 1s */ +#define CFG_LP_CONN_ADV_INTERVAL_MAX (0xfa0) /**< 2.5s */ /** * Define IO Authentication @@ -60,7 +64,7 @@ #define CFG_IO_CAPABILITY_NO_INPUT_NO_OUTPUT (0x03) #define CFG_IO_CAPABILITY_KEYBOARD_DISPLAY (0x04) -#define CFG_IO_CAPABILITY CFG_IO_CAPABILITY_DISPLAY_ONLY +#define CFG_IO_CAPABILITY CFG_IO_CAPABILITY_DISPLAY_YES_NO /** * Define MITM modes @@ -71,6 +75,17 @@ #define CFG_MITM_PROTECTION CFG_MITM_PROTECTION_REQUIRED /** + * Define PHY + */ +#define ALL_PHYS_PREFERENCE 0x00 +#define RX_2M_PREFERRED 0x02 +#define TX_2M_PREFERRED 0x02 +#define TX_1M 0x01 +#define TX_2M 0x02 +#define RX_1M 0x01 +#define RX_2M 0x02 + +/** * Identity root key used to derive LTK and CSRK */ #define CFG_BLE_IRK {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0} @@ -91,19 +106,11 @@ /**< specific parameters */ /*****************************************************/ -#define CFG_MAX_CONNECTION 1 -#define UUID_128BIT_FORMAT 1 -#define CFG_DEV_ID_P2P_SERVER1 (0x83) -#define CONN_L(x) ((int)((x)/0.625f)) -#define CONN_P(x) ((int)((x)/1.25f)) -#define SCAN_P (0x320) -#define SCAN_L (0x320) -#define CONN_P1 (CONN_P(50)) -#define CONN_P2 (CONN_P(100)) -#define SUPERV_TIMEOUT (0x1F4) -#define CONN_L1 (CONN_L(10)) -#define CONN_L2 (CONN_L(10)) -#define OOB_DEMO 1 /* Out Of Box Demo */ +/** +* AD Element - Group B Feature +*/ +/* LSB - Second Byte */ +#define CFG_FEATURE_OTA_REBOOT (0x20) /****************************************************************************** * BLE Stack @@ -362,17 +369,17 @@ * keep debugger enabled while in any low power mode when set to 1 * should be set to 0 in production */ -#define CFG_DEBUGGER_SUPPORTED 1 +#define CFG_DEBUGGER_SUPPORTED 0 /** * When set to 1, the traces are enabled in the BLE services */ -#define CFG_DEBUG_BLE_TRACE 1 +#define CFG_DEBUG_BLE_TRACE 0 /** * Enable or Disable traces in application */ -#define CFG_DEBUG_APP_TRACE 1 +#define CFG_DEBUG_APP_TRACE 0 #if (CFG_DEBUG_APP_TRACE != 0) #define APP_DBG_MSG PRINT_MESG_DBG @@ -390,6 +397,7 @@ #define CFG_LPM_SUPPORTED 0 #define CFG_DEBUGGER_SUPPORTED 1 #endif + /** * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output @@ -427,10 +435,18 @@ #define MAX_DBG_TRACE_MSG_SIZE 1024 /* USER CODE BEGIN Defines */ -#define CFG_LED_SUPPORTED 1 +#define CFG_LED_SUPPORTED 0 #define CFG_BUTTON_SUPPORTED 1 -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +#ifdef LITTLE_DORY +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI0_IRQHandler +#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI4_IRQHandler +#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI9_5_IRQHandler +#else +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler +#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler +#endif /* USER CODE END Defines */ /****************************************************************************** @@ -447,11 +463,8 @@ /**< Add in that list all tasks that may send a ACI/HCI command */ typedef enum { - CFG_TASK_START_SCAN_ID, - CFG_TASK_CONN_DEV_1_ID, - CFG_TASK_SEARCH_SERVICE_ID, - CFG_TASK_SW1_BUTTON_PUSHED_ID, - CFG_TASK_CONN_UPDATE_ID, + CFG_TASK_ADV_UPDATE_ID, + CFG_TASK_MEAS_REQ_ID, CFG_TASK_HCI_ASYNCH_EVT_ID, /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */
diff --git a/lib/stm32wb/hci/hci_tl.h b/lib/stm32wb/hci/hci_tl.h index c0339e2..98810d0 100644 --- a/lib/stm32wb/hci/hci_tl.h +++ b/lib/stm32wb/hci/hci_tl.h
@@ -87,9 +87,11 @@ void hci_register_io_bus(tHciIO* fops); /** - * @brief Interrupt service routine that must be called when the BLE core - * reports a packet received or an event to the host through the - * related IPCC RX interrupt line. + * @brief This callback is called from either + * - IPCC RX interrupt context + * - hci_user_evt_proc() context. + * - hci_resume_flow() context + * It requests hci_user_evt_proc() to be executed. * * @param pdata Packet or event pointer * @retval None @@ -107,12 +109,13 @@ /** - * @brief This function is called when an ACI/HCI command is sent and the response - * is waited from the BLE core. - * The application shall implement a mechanism to not return from this function - * until the waited event is received. - * This is notified to the application with hci_cmd_resp_release(). + * @brief This function is called when an ACI/HCI command is sent to the CPU2 and the response is waited. * It is called from the same context the HCI command has been sent. + * It shall not return until the command response notified by hci_cmd_resp_release() is received. + * A weak implementation is available in hci_tl.c based on polling mechanism + * The user may re-implement this function in the application to improve performance : + * - It may use UTIL_SEQ_WaitEvt() API when using the Sequencer + * - It may use a semaphore when using cmsis_os interface * * @param timeout: Waiting timeout * @retval None @@ -120,8 +123,11 @@ void hci_cmd_resp_wait(uint32_t timeout); /** - * @brief This function is called when an ACI/HCI command is sent and the response is - * received from the BLE core. + * @brief This function is called when an ACI/HCI command response is received from the CPU2. + * A weak implementation is available in hci_tl.c based on polling mechanism + * The user may re-implement this function in the application to improve performance : + * - It may use UTIL_SEQ_SetEvt() API when using the Sequencer + * - It may use a semaphore when using cmsis_os interface * * @param flag: Release flag * @retval None @@ -142,7 +148,7 @@ */ /** - * @brief This process shall be called by the scheduler each time it is requested with TL_BLE_HCI_UserEvtProcReq() + * @brief This process shall be called by the scheduler each time it is requested with hci_notify_asynch_evt() * This process may send an ACI/HCI command when the svc_ctl.c module is used * * @param None
diff --git a/lib/stm32wb/hci/hw.h b/lib/stm32wb/hci/hw.h index efcfd50..591215a 100644 --- a/lib/stm32wb/hci/hw.h +++ b/lib/stm32wb/hci/hw.h
@@ -59,10 +59,11 @@ void HW_IPCC_THREAD_CliEvtNot( void ); void HW_IPCC_LLDTESTS_Init( void ); - void HW_IPCC_LLDTESTS_CliSendCmd( void ); - void HW_IPCC_LLDTESTS_EvtNot( void ); - void HW_IPCC_LLDTESTS_CliSendAck( void ); - void HW_IPCC_LLDTESTS_CliEvtNot( void ); + void HW_IPCC_LLDTESTS_SendCliCmd( void ); + void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ); + void HW_IPCC_LLDTESTS_SendCliRspAck( void ); + void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ); + void HW_IPCC_LLDTESTS_SendM0CmdAck( void ); void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); @@ -75,13 +76,13 @@ void HW_IPCC_ZIGBEE_Init( void ); - void HW_IPCC_ZIGBEE_SendAppliCmd(void); - void HW_IPCC_ZIGBEE_AppliCmdNotification(void); + void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ + void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ - void HW_IPCC_ZIGBEE_AppliAsyncEvtNotification(void); - void HW_IPCC_ZIGBEE_SendAppliCmdAck(void); - void HW_IPCC_ZIGBEE_AppliAsyncLoggingNotification( void ); - void HW_IPCC_ZIGBEE_SendLoggingAck(void); + void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ + void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ #ifdef __cplusplus
diff --git a/lib/stm32wb/hci/hw_if.h b/lib/stm32wb/hci/hw_if.h index e86f5ee..f15122f 100644 --- a/lib/stm32wb/hci/hw_if.h +++ b/lib/stm32wb/hci/hw_if.h
@@ -1,250 +1,254 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file hw_if.h - * @author MCD Application Team - * @brief Hardware Interface - ****************************************************************************** - * @attention - * - * <h2><center>© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.</center></h2> - * +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file hw_if.h + * @author MCD Application Team + * @brief Hardware Interface + ****************************************************************************** + * @attention + * + * <h2><center>© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.</center></h2> + * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef HW_IF_H -#define HW_IF_H - -#ifdef __cplusplus -extern "C" { -#endif - - /* Includes ------------------------------------------------------------------*/ -#include "stm32wbxx.h" -#include "stm32wbxx_ll_exti.h" -#include "stm32wbxx_ll_system.h" -#include "stm32wbxx_ll_rcc.h" -#include "stm32wbxx_ll_ipcc.h" -#include "stm32wbxx_ll_bus.h" -#include "stm32wbxx_ll_pwr.h" -#include "stm32wbxx_ll_cortex.h" -#include "stm32wbxx_ll_utils.h" -#include "stm32wbxx_ll_hsem.h" -#include "stm32wbxx_ll_gpio.h" -#include "stm32wbxx_ll_rtc.h" - -#ifdef USE_STM32WBXX_USB_DONGLE -#include "stm32wbxx_usb_dongle.h" -#endif -#ifdef USE_STM32WBXX_NUCLEO -#include "stm32wbxx_nucleo.h" -#endif -#ifdef USE_X_NUCLEO_EPD -#include "x_nucleo_epd.h" -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - - /****************************************************************************** - * HW UART - ******************************************************************************/ - typedef enum - { - hw_uart1, - hw_uart2, - hw_lpuart1, - } hw_uart_id_t; - - typedef enum - { - hw_uart_ok, - hw_uart_error, - hw_uart_busy, - hw_uart_to, - } hw_status_t; - - void HW_UART_Init(hw_uart_id_t hw_uart_id); - void HW_UART_Receive_IT(hw_uart_id_t hw_uart_id, uint8_t *pData, uint16_t Size, void (*Callback)(void)); - void HW_UART_Transmit_IT(hw_uart_id_t hw_uart_id, uint8_t *pData, uint16_t Size, void (*Callback)(void)); - hw_status_t HW_UART_Transmit(hw_uart_id_t hw_uart_id, uint8_t *p_data, uint16_t size, uint32_t timeout); - hw_status_t HW_UART_Transmit_DMA(hw_uart_id_t hw_uart_id, uint8_t *p_data, uint16_t size, void (*Callback)(void)); - void HW_UART_Interrupt_Handler(hw_uart_id_t hw_uart_id); - void HW_UART_DMA_Interrupt_Handler(hw_uart_id_t hw_uart_id); - - /****************************************************************************** - * HW TimerServer - ******************************************************************************/ - /* Exported types ------------------------------------------------------------*/ - /** - * This setting is used when standby mode is supported. - * hw_ts_InitMode_Limited should be used when the device restarts from Standby Mode. In that case, the Timer Server does - * not re-initialized its context. Only the Hardware register which content has been lost is reconfigured - * Otherwise, hw_ts_InitMode_Full should be requested (Start from Power ON) and everything is re-initialized. - */ - typedef enum - { - hw_ts_InitMode_Full, - hw_ts_InitMode_Limited, - } HW_TS_InitMode_t; - - /** - * When a Timer is created as a SingleShot timer, it is not automatically restarted when the timeout occurs. However, - * the timer is kept reserved in the list and could be restarted at anytime with HW_TS_Start() - * - * When a Timer is created as a Repeated timer, it is automatically restarted when the timeout occurs. - */ - typedef enum - { - hw_ts_SingleShot, - hw_ts_Repeated - } HW_TS_Mode_t; - - /** - * hw_ts_Successful is returned when a Timer has been successfully created with HW_TS_Create(). Otherwise, hw_ts_Failed - * is returned. When hw_ts_Failed is returned, that means there are not enough free slots in the list to create a - * Timer. In that case, CFG_HW_TS_MAX_NBR_CONCURRENT_TIMER should be increased - */ - typedef enum - { - hw_ts_Successful, - hw_ts_Failed, - }HW_TS_ReturnStatus_t; - - typedef void (*HW_TS_pTimerCb_t)(void); - - /** - * @brief Initialize the timer server - * This API shall be called by the application before any timer is requested to the timer server. It - * configures the RTC module to be connected to the LSI input clock. - * - * @param TimerInitMode: When the device restarts from Standby, it should request hw_ts_InitMode_Limited so that the - * Timer context is not re-initialized. Otherwise, hw_ts_InitMode_Full should be requested - * @param hrtc: RTC Handle - * @retval None - */ - void HW_TS_Init(HW_TS_InitMode_t TimerInitMode, RTC_HandleTypeDef *hrtc); - - /** - * @brief Interface to create a virtual timer - * The user shall call this API to create a timer. Once created, the timer is reserved to the module until it - * has been deleted. When creating a timer, the user shall specify the mode (single shot or repeated), the - * callback to be notified when the timer expires and a module ID to identify in the timer interrupt handler - * which module is concerned. In return, the user gets a timer ID to handle it. - * - * @param TimerProcessID: This is an identifier provided by the user and returned in the callback to allow - * identification of the requester - * @param pTimerId: Timer Id returned to the user to request operation (start, stop, delete) - * @param TimerMode: Mode of the virtual timer (Single shot or repeated) - * @param pTimerCallBack: Callback when the virtual timer expires - * @retval HW_TS_ReturnStatus_t: Return whether the creation is sucessfull or not - */ - HW_TS_ReturnStatus_t HW_TS_Create(uint32_t TimerProcessID, uint8_t *pTimerId, HW_TS_Mode_t TimerMode, HW_TS_pTimerCb_t pTimerCallBack); - - /** - * @brief Stop a virtual timer - * This API may be used to stop a running timer. A timer which is stopped is move to the pending state. - * A pending timer may be restarted at any time with a different timeout value but the mode cannot be changed. - * Nothing is done when it is called to stop a timer which has been already stopped - * - * @param TimerID: Id of the timer to stop - * @retval None - */ - void HW_TS_Stop(uint8_t TimerID); - - /** - * @brief Start a virtual timer - * This API shall be used to start a timer. The timeout value is specified and may be different each time. - * When the timer is in the single shot mode, it will move to the pending state when it expires. The user may - * restart it at any time with a different timeout value. When the timer is in the repeated mode, it always - * stay in the running state. When the timer expires, it will be restarted with the same timeout value. - * This API shall not be called on a running timer. - * - * @param TimerID: The ID Id of the timer to start - * @param timeout_ticks: Number of ticks of the virtual timer (Maximum value is (0xFFFFFFFF-0xFFFF = 0xFFFF0000) - * @retval None - */ - void HW_TS_Start(uint8_t TimerID, uint32_t timeout_ticks); - - /** - * @brief Delete a virtual timer from the list - * This API should be used when a timer is not needed anymore by the user. A deleted timer is removed from - * the timer list managed by the timer server. It cannot be restarted again. The user has to go with the - * creation of a new timer if required and may get a different timer id - * - * @param TimerID: The ID of the timer to remove from the list - * @retval None - */ - void HW_TS_Delete(uint8_t TimerID); - - /** - * @brief Schedule the timer list on the timer interrupt handler - * This interrupt handler shall be called by the application in the RTC interrupt handler. This handler takes - * care of clearing all status flag required in the RTC and EXTI peripherals - * - * @param None - * @retval None - */ - void HW_TS_RTC_Wakeup_Handler(void); - - /** - * @brief Return the number of ticks to count before the interrupt - * This API returns the number of ticks left to be counted before an interrupt is generated by the - * Timer Server. This API may be used by the application for power management optimization. When the system - * enters low power mode, the mode selection is a tradeoff between the wakeup time where the CPU is running - * and the time while the CPU will be kept in low power mode before next wakeup. The deeper is the - * low power mode used, the longer is the wakeup time. The low power mode management considering wakeup time - * versus time in low power mode is implementation specific - * When the timer is disabled (No timer in the list), it returns 0xFFFF - * - * @param None - * @retval The number of ticks left to count - */ - uint16_t HW_TS_RTC_ReadLeftTicksToCount(void); - - /** - * @brief Notify the application that a registered timer has expired - * This API shall be implemented by the user application. - * This API notifies the application that a timer expires. This API is running in the RTC Wakeup interrupt - * context. The application may implement an Operating System to change the context priority where the timer - * callback may be handled. This API provides the module ID to identify which module is concerned and to allow - * sending the information to the correct task - * - * @param TimerProcessID: The TimerProcessId associated with the timer when it has been created - * @param TimerID: The TimerID of the expired timer - * @param pTimerCallBack: The Callback associated with the timer when it has been created - * @retval None - */ - void HW_TS_RTC_Int_AppNot(uint32_t TimerProcessID, uint8_t TimerID, HW_TS_pTimerCb_t pTimerCallBack); - - /** - * @brief Notify the application that the wakeupcounter has been updated - * This API should be implemented by the user application - * This API notifies the application that the counter has been updated. This is expected to be used along - * with the HW_TS_RTC_ReadLeftTicksToCount () API. It could be that the counter has been updated since the - * last call of HW_TS_RTC_ReadLeftTicksToCount () and before entering low power mode. This notification - * provides a way to the application to solve that race condition to reevaluate the counter value before - * entering low power mode - * - * @param None - * @retval None - */ - void HW_TS_RTC_CountUpdated_AppNot(void); - -#ifdef __cplusplus -} -#endif - -#endif /*HW_IF_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef HW_IF_H +#define HW_IF_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* Includes ------------------------------------------------------------------*/ +#include "stm32wbxx.h" +#include "stm32wbxx_ll_exti.h" +#include "stm32wbxx_ll_system.h" +#include "stm32wbxx_ll_rcc.h" +#include "stm32wbxx_ll_ipcc.h" +#include "stm32wbxx_ll_bus.h" +#include "stm32wbxx_ll_pwr.h" +#include "stm32wbxx_ll_cortex.h" +#include "stm32wbxx_ll_utils.h" +#include "stm32wbxx_ll_hsem.h" +#include "stm32wbxx_ll_gpio.h" +#include "stm32wbxx_ll_rtc.h" + +#ifdef USE_STM32WBXX_USB_DONGLE +#include "stm32wbxx_usb_dongle.h" +#endif +#ifdef USE_STM32WBXX_NUCLEO + #ifdef STM32WB35xx + #include "nucleo_wb35ce.h" + #else + #include "stm32wbxx_nucleo.h" + #endif +#endif +#ifdef USE_X_NUCLEO_EPD +#include "x_nucleo_epd.h" +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + + /****************************************************************************** + * HW UART + ******************************************************************************/ + typedef enum + { + hw_uart1, + hw_uart2, + hw_lpuart1, + } hw_uart_id_t; + + typedef enum + { + hw_uart_ok, + hw_uart_error, + hw_uart_busy, + hw_uart_to, + } hw_status_t; + + void HW_UART_Init(hw_uart_id_t hw_uart_id); + void HW_UART_Receive_IT(hw_uart_id_t hw_uart_id, uint8_t *pData, uint16_t Size, void (*Callback)(void)); + void HW_UART_Transmit_IT(hw_uart_id_t hw_uart_id, uint8_t *pData, uint16_t Size, void (*Callback)(void)); + hw_status_t HW_UART_Transmit(hw_uart_id_t hw_uart_id, uint8_t *p_data, uint16_t size, uint32_t timeout); + hw_status_t HW_UART_Transmit_DMA(hw_uart_id_t hw_uart_id, uint8_t *p_data, uint16_t size, void (*Callback)(void)); + void HW_UART_Interrupt_Handler(hw_uart_id_t hw_uart_id); + void HW_UART_DMA_Interrupt_Handler(hw_uart_id_t hw_uart_id); + + /****************************************************************************** + * HW TimerServer + ******************************************************************************/ + /* Exported types ------------------------------------------------------------*/ + /** + * This setting is used when standby mode is supported. + * hw_ts_InitMode_Limited should be used when the device restarts from Standby Mode. In that case, the Timer Server does + * not re-initialized its context. Only the Hardware register which content has been lost is reconfigured + * Otherwise, hw_ts_InitMode_Full should be requested (Start from Power ON) and everything is re-initialized. + */ + typedef enum + { + hw_ts_InitMode_Full, + hw_ts_InitMode_Limited, + } HW_TS_InitMode_t; + + /** + * When a Timer is created as a SingleShot timer, it is not automatically restarted when the timeout occurs. However, + * the timer is kept reserved in the list and could be restarted at anytime with HW_TS_Start() + * + * When a Timer is created as a Repeated timer, it is automatically restarted when the timeout occurs. + */ + typedef enum + { + hw_ts_SingleShot, + hw_ts_Repeated + } HW_TS_Mode_t; + + /** + * hw_ts_Successful is returned when a Timer has been successfully created with HW_TS_Create(). Otherwise, hw_ts_Failed + * is returned. When hw_ts_Failed is returned, that means there are not enough free slots in the list to create a + * Timer. In that case, CFG_HW_TS_MAX_NBR_CONCURRENT_TIMER should be increased + */ + typedef enum + { + hw_ts_Successful, + hw_ts_Failed, + }HW_TS_ReturnStatus_t; + + typedef void (*HW_TS_pTimerCb_t)(void); + + /** + * @brief Initialize the timer server + * This API shall be called by the application before any timer is requested to the timer server. It + * configures the RTC module to be connected to the LSI input clock. + * + * @param TimerInitMode: When the device restarts from Standby, it should request hw_ts_InitMode_Limited so that the + * Timer context is not re-initialized. Otherwise, hw_ts_InitMode_Full should be requested + * @param hrtc: RTC Handle + * @retval None + */ + void HW_TS_Init(HW_TS_InitMode_t TimerInitMode, RTC_HandleTypeDef *hrtc); + + /** + * @brief Interface to create a virtual timer + * The user shall call this API to create a timer. Once created, the timer is reserved to the module until it + * has been deleted. When creating a timer, the user shall specify the mode (single shot or repeated), the + * callback to be notified when the timer expires and a module ID to identify in the timer interrupt handler + * which module is concerned. In return, the user gets a timer ID to handle it. + * + * @param TimerProcessID: This is an identifier provided by the user and returned in the callback to allow + * identification of the requester + * @param pTimerId: Timer Id returned to the user to request operation (start, stop, delete) + * @param TimerMode: Mode of the virtual timer (Single shot or repeated) + * @param pTimerCallBack: Callback when the virtual timer expires + * @retval HW_TS_ReturnStatus_t: Return whether the creation is sucessfull or not + */ + HW_TS_ReturnStatus_t HW_TS_Create(uint32_t TimerProcessID, uint8_t *pTimerId, HW_TS_Mode_t TimerMode, HW_TS_pTimerCb_t pTimerCallBack); + + /** + * @brief Stop a virtual timer + * This API may be used to stop a running timer. A timer which is stopped is move to the pending state. + * A pending timer may be restarted at any time with a different timeout value but the mode cannot be changed. + * Nothing is done when it is called to stop a timer which has been already stopped + * + * @param TimerID: Id of the timer to stop + * @retval None + */ + void HW_TS_Stop(uint8_t TimerID); + + /** + * @brief Start a virtual timer + * This API shall be used to start a timer. The timeout value is specified and may be different each time. + * When the timer is in the single shot mode, it will move to the pending state when it expires. The user may + * restart it at any time with a different timeout value. When the timer is in the repeated mode, it always + * stay in the running state. When the timer expires, it will be restarted with the same timeout value. + * This API shall not be called on a running timer. + * + * @param TimerID: The ID Id of the timer to start + * @param timeout_ticks: Number of ticks of the virtual timer (Maximum value is (0xFFFFFFFF-0xFFFF = 0xFFFF0000) + * @retval None + */ + void HW_TS_Start(uint8_t TimerID, uint32_t timeout_ticks); + + /** + * @brief Delete a virtual timer from the list + * This API should be used when a timer is not needed anymore by the user. A deleted timer is removed from + * the timer list managed by the timer server. It cannot be restarted again. The user has to go with the + * creation of a new timer if required and may get a different timer id + * + * @param TimerID: The ID of the timer to remove from the list + * @retval None + */ + void HW_TS_Delete(uint8_t TimerID); + + /** + * @brief Schedule the timer list on the timer interrupt handler + * This interrupt handler shall be called by the application in the RTC interrupt handler. This handler takes + * care of clearing all status flag required in the RTC and EXTI peripherals + * + * @param None + * @retval None + */ + void HW_TS_RTC_Wakeup_Handler(void); + + /** + * @brief Return the number of ticks to count before the interrupt + * This API returns the number of ticks left to be counted before an interrupt is generated by the + * Timer Server. This API may be used by the application for power management optimization. When the system + * enters low power mode, the mode selection is a tradeoff between the wakeup time where the CPU is running + * and the time while the CPU will be kept in low power mode before next wakeup. The deeper is the + * low power mode used, the longer is the wakeup time. The low power mode management considering wakeup time + * versus time in low power mode is implementation specific + * When the timer is disabled (No timer in the list), it returns 0xFFFF + * + * @param None + * @retval The number of ticks left to count + */ + uint16_t HW_TS_RTC_ReadLeftTicksToCount(void); + + /** + * @brief Notify the application that a registered timer has expired + * This API shall be implemented by the user application. + * This API notifies the application that a timer expires. This API is running in the RTC Wakeup interrupt + * context. The application may implement an Operating System to change the context priority where the timer + * callback may be handled. This API provides the module ID to identify which module is concerned and to allow + * sending the information to the correct task + * + * @param TimerProcessID: The TimerProcessId associated with the timer when it has been created + * @param TimerID: The TimerID of the expired timer + * @param pTimerCallBack: The Callback associated with the timer when it has been created + * @retval None + */ + void HW_TS_RTC_Int_AppNot(uint32_t TimerProcessID, uint8_t TimerID, HW_TS_pTimerCb_t pTimerCallBack); + + /** + * @brief Notify the application that the wakeupcounter has been updated + * This API should be implemented by the user application + * This API notifies the application that the counter has been updated. This is expected to be used along + * with the HW_TS_RTC_ReadLeftTicksToCount () API. It could be that the counter has been updated since the + * last call of HW_TS_RTC_ReadLeftTicksToCount () and before entering low power mode. This notification + * provides a way to the application to solve that race condition to reevaluate the counter value before + * entering low power mode + * + * @param None + * @retval None + */ + void HW_TS_RTC_CountUpdated_AppNot(void); + +#ifdef __cplusplus +} +#endif + +#endif /*HW_IF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/lib/stm32wb/hci/hw_ipcc.c b/lib/stm32wb/hci/hw_ipcc.c index b03af79..c316cf1 100644 --- a/lib/stm32wb/hci/hw_ipcc.c +++ b/lib/stm32wb/hci/hw_ipcc.c
@@ -1,8 +1,8 @@ /** ****************************************************************************** - * File Name : Target/hw_ipcc.c - * Description : Hardware IPCC source file for BLE - * middleWare. + * File Name : Target/hw_ipcc.c + * Description : Hardware IPCC source file for STM32WPAN Middleware. + * ****************************************************************************** * @attention * @@ -39,23 +39,6 @@ static void HW_IPCC_SYS_EvtHandler( void ); static void HW_IPCC_TRACES_EvtHandler( void ); -#ifdef THREAD_WB -static void HW_IPCC_OT_CmdEvtHandler( void ); -static void HW_IPCC_THREAD_NotEvtHandler( void ); -static void HW_IPCC_THREAD_CliNotEvtHandler( void ); -#endif - -#ifdef MAC_802_15_4_WB -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); -#endif - -#ifdef ZIGBEE_WB -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); -static void HW_IPCC_ZIGBEE_CliNotifEvtHandler( void ); -#endif - /* Public function definition -----------------------------------------------*/ /****************************************************************************** @@ -67,32 +50,6 @@ { HW_IPCC_SYS_EvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_NotEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ -#ifdef THREAD_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_THREAD_NotEvtHandler(); - } - else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_THREAD_CliNotEvtHandler(); - } -#endif /* THREAD_WB */ -#ifdef ZIGBEE_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackNotifEvtHandler(); - } - else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_ZIGBEE_CliNotifEvtHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -111,24 +68,6 @@ { HW_IPCC_SYS_CmdEvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_CmdEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ -#ifdef THREAD_WB - else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) - { - HW_IPCC_OT_CmdEvtHandler(); - } -#endif /* THREAD_WB */ -#ifdef ZIGBEE_WB - if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) - { - HW_IPCC_ZIGBEE_CmdEvtHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); @@ -150,6 +89,12 @@ void HW_IPCC_Enable( void ) { /** + * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 + */ + LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 ); + LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 ); + + /** * In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2. * In that case, to keep the mechanism transparent to the user application, it shall call the system command * SHCI_C2_Reinit( ) before jumping to the application. @@ -264,205 +209,6 @@ __weak void HW_IPCC_SYS_EvtNot( void ){}; /****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -#ifdef MAC_802_15_4_WB -void HW_IPCC_MAC_802_15_4_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - HW_IPCC_MAC_802_15_4_CmdEvtNot(); - - return; -} - -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_MAC_802_15_4_EvtNot(); - - return; -} -__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; -__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; -#endif - -/****************************************************************************** - * THREAD - ******************************************************************************/ -#ifdef THREAD_WB -void HW_IPCC_THREAD_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_OT_SendCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); - - return; -} - -void HW_IPCC_CLI_SendCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_CMD_CHANNEL ); - - return; -} - -void HW_IPCC_THREAD_SendAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_THREAD_CliSendAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_OT_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); - - HW_IPCC_OT_CmdEvtNot(); - - return; -} - -static void HW_IPCC_THREAD_NotEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_THREAD_EvtNot(); - - return; -} - -static void HW_IPCC_THREAD_CliNotEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_THREAD_CliEvtNot(); - - return; -} - -__weak void HW_IPCC_OT_CmdEvtNot( void ){}; -__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; -__weak void HW_IPCC_THREAD_EvtNot( void ){}; - -#endif /* THREAD_WB */ - -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -#ifdef ZIGBEE_WB -void HW_IPCC_ZIGBEE_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendAppliCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendCliCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_CMD_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendAppliCmdAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendCliCmdAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); - - HW_IPCC_ZIGBEE_AppliCmdNotification(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_ZIGBEE_AppliAsyncEvtNotification(); - - return; -} - -static void HW_IPCC_ZIGBEE_CliNotifEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_ZIGBEE_CliEvtNotification(); - - return; -} - -__weak void HW_IPCC_ZIGBEE_AppliCmdNotification( void ){}; -__weak void HW_IPCC_ZIGBEE_AppliAsyncEvtNotification( void ){}; -__weak void HW_IPCC_ZIGBEE_CliEvtNotification( void ){}; -#endif /* ZIGBEE_WB */ - -/****************************************************************************** * MEMORY MANAGER ******************************************************************************/ void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) )
diff --git a/lib/stm32wb/hci/mbox_def.h b/lib/stm32wb/hci/mbox_def.h index 290017f..939d517 100644 --- a/lib/stm32wb/hci/mbox_def.h +++ b/lib/stm32wb/hci/mbox_def.h
@@ -96,15 +96,15 @@ typedef struct { - uint8_t *notack_buffer; uint8_t *clicmdrsp_buffer; + uint8_t *m0cmd_buffer; } MB_LldTestsTable_t; typedef struct { uint8_t *notifM0toM4_buffer; uint8_t *appliCmdM4toM0_buffer; - uint8_t *loggingM0toM4_buffer; + uint8_t *requestM0toM4_buffer; } MB_ZigbeeTable_t; /** * msg @@ -218,8 +218,9 @@ #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 +#define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_HCI_ACL_DATA_CHANNEL LL_IPCC_CHANNEL_6 /** CPU2 */ @@ -228,9 +229,11 @@ #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_ZIGBEE_APPLI_LOGGING_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/lib/stm32wb/hci/shci.c b/lib/stm32wb/hci/shci.c index 0ffc6d4..f548356 100644 --- a/lib/stm32wb/hci/shci.c +++ b/lib/stm32wb/hci/shci.c
@@ -315,6 +315,7 @@ return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } + SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -470,6 +471,51 @@ return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status) +{ + /** + * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_port = gpio_port; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_pin_number = gpio_pin_number; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_polarity = gpio_polarity; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_status = gpio_status; + + shci_send( SHCI_OPCODE_C2_EXTPA_CONFIG, + 8, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source) +{ + /** + * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 1 byte of command parameter + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = (uint8_t)Source; + + shci_send( SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + /** * Local System COMMAND * These commands are NOT sent to the CPU2
diff --git a/lib/stm32wb/hci/shci.h b/lib/stm32wb/hci/shci.h index b6fc8b4..57eb027 100644 --- a/lib/stm32wb/hci/shci.h +++ b/lib/stm32wb/hci/shci.h
@@ -50,6 +50,7 @@ ERR_BLE_INIT = 0, ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the M4 to control the Thread stack is unknown */ + ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the M4 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -135,7 +136,9 @@ SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, SHCI_OCF_C2_ZIGBEE_INIT, - SHCI_OCF_C2_LLD_TESTS_INIT + SHCI_OCF_C2_LLD_TESTS_INIT, + SHCI_OCF_C2_EXTPA_CONFIG, + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL } SHCI_OCF_t; #define SHCI_OPCODE_C2_FUS_GET_STATE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE) @@ -294,6 +297,20 @@ #define SHCI_OPCODE_C2_DEBUG_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_DEBUG_INIT) /** Command parameters */ + typedef PACKED_STRUCT + { + uint8_t thread_config; + uint8_t ble_config; + uint8_t mac_802_15_4_config; + uint8_t zigbee_config; + } SHCI_C2_DEBUG_TracesConfig_t; + + typedef PACKED_STRUCT + { + uint8_t ble_dtb_cfg; + uint8_t reserved[3]; + } SHCI_C2_DEBUG_GeneralConfig_t; + typedef PACKED_STRUCT{ uint8_t *pGpioConfig; uint8_t *pTracesConfig; @@ -325,6 +342,7 @@ { BLE_ENABLE, THREAD_ENABLE, + ZIGBEE_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ @@ -335,18 +353,52 @@ { BLE_IP, THREAD_IP, + ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ -#define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) +#define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) #define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) -#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) +#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) -#define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) +#define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) + +#define SHCI_OPCODE_C2_EXTPA_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_EXTPA_CONFIG) + /** Command parameters */ + enum + { + EXT_PA_ENABLED_LOW, + EXT_PA_ENABLED_HIGH, + }/* gpio_polarity */; + + enum + { + EXT_PA_DISABLED, + EXT_PA_ENABLED, + }/* gpio_status */; + + typedef PACKED_STRUCT{ + uint32_t gpio_port; + uint16_t gpio_pin_number; + uint8_t gpio_polarity; + uint8_t gpio_status; + } SHCI_C2_EXTPA_CONFIG_Cmd_Param_t; + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL (( SHCI_OGF << 10) + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL) + /** Command parameters */ + typedef enum + { + FLASH_ACTIVITY_CONTROL_PES, + FLASH_ACTIVITY_CONTROL_SEM7, + }SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t; + + /** No response parameters*/ /* Exported type --------------------------------------------------------*/ @@ -400,14 +452,19 @@ #define INFO_STACK_TYPE_MASK 0x000000ff #define INFO_STACK_TYPE_NONE 0 -#define INFO_STACK_TYPE_BLE_STANDARD 0x1 -#define INFO_STACK_TYPE_BLE_HCI 0x2 +#define INFO_STACK_TYPE_BLE_STANDARD 0x01 +#define INFO_STACK_TYPE_BLE_HCI 0x02 +#define INFO_STACK_TYPE_BLE_LIGHT 0x03 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 #define INFO_STACK_TYPE_ZIGBEE 0x30 #define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 +#define INFO_STACK_TYPE_802154_PHY_VALID 0x61 +#define INFO_STACK_TYPE_BLE_PHY_VALID 0x62 +#define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 typedef struct { /** @@ -656,6 +713,39 @@ */ SHCI_CmdStatus_t SHCI_C2_Reinit( void ); + /** + * SHCI_C2_ExtpaConfig + * @brief Send the Ext PA configuration + * When the CPU2 receives the command, it controls the Ext PA as requested by the configuration + * This configures only which IO is used to enable/disable the ExtPA and the associated polarity + * This command has no effect on the other IO that is used to control the mode of the Ext PA (Rx/Tx) + * + * @param gpio_port: GPIOx where x can be (A..F) to select the GPIO peripheral for STM32WBxx family + * @param gpio_pin_number: This parameter can be one of GPIO_PIN_x (= LL_GPIO_PIN_x) where x can be (0..15). + * @param gpio_polarity: This parameter can be either + * - EXT_PA_ENABLED_LOW: ExtPA is enabled when GPIO is low + * - EXT_PA_ENABLED_HIGH: ExtPA is enabled when GPIO is high + * @param gpio_status: This parameter can be either + * - EXT_PA_DISABLED: Stop driving the ExtPA + * - EXT_PA_ENABLED: Drive the ExtPA according to radio activity + * (ON before the Event and OFF at the end of the event) + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status); + + /** + * SHCI_C2_SetFlashActivityControl + * @brief Set the mechanism to be used on CPU2 to prevent the CPU1 to either write or erase in flash + * + * @param Source: It can be one of the following list + * - FLASH_ACTIVITY_CONTROL_PES : The CPU2 set the PES bit to prevent the CPU1 to either read or write in flash + * - FLASH_ACTIVITY_CONTROL_SEM7 : The CPU2 gets the semaphore 7 to prevent the CPU1 to either read or write in flash. + * This requires the CPU1 to first get semaphore 7 before erasing or writing the flash. + * + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source); + #ifdef __cplusplus } #endif
diff --git a/lib/stm32wb/hci/shci_tl.c b/lib/stm32wb/hci/shci_tl.c index c2a378d..2269c13 100644 --- a/lib/stm32wb/hci/shci_tl.c +++ b/lib/stm32wb/hci/shci_tl.c
@@ -26,6 +26,12 @@ /* Private typedef -----------------------------------------------------------*/ +typedef enum +{ + SHCI_TL_CMD_RESP_RELEASE, + SHCI_TL_CMD_RESP_WAIT, +} SHCI_TL_CmdRespStatus_t; + /* Private defines -----------------------------------------------------------*/ /** * The default System HCI layer timeout is set to 33s @@ -35,22 +41,31 @@ /* Private macros ------------------------------------------------------------*/ /* Public variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ -/** - * START of Section SYSTEM_DRIVER_CONTEXT - */ - -/* This section is unused and generates warning. Don't use. */ +#if 1 +/* SYSTEM_DRIVER_CONTEXT section is unused and generates useless warnings */ +/* Provide alterative definitions */ static tListNode SHciAsynchEventQueue; static volatile SHCI_TL_CmdStatus_t SHCICmdStatus; static TL_CmdPacket_t *pCmdBuffer; SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow; +#else +/** + * START of Section SYSTEM_DRIVER_CONTEXT + */ +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static tListNode SHciAsynchEventQueue; +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static volatile SHCI_TL_CmdStatus_t SHCICmdStatus; +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static TL_CmdPacket_t *pCmdBuffer; +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow; /** * END of Section SYSTEM_DRIVER_CONTEXT */ +#endif static tSHciContext shciContext; static void (* StatusNotCallBackFunction) (SHCI_TL_CmdStatus_t status); +static volatile SHCI_TL_CmdRespStatus_t CmdRspStatusFlag; + /* Private function prototypes -----------------------------------------------*/ static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus); static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt); @@ -93,14 +108,17 @@ { LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer ); - SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; - if (shciContext.UserEvtRx != NULL) { UserEvtRxParam.pckt = phcievtbuffer; + UserEvtRxParam.status = SHCI_TL_UserEventFlow_Enable; shciContext.UserEvtRx((void *)&UserEvtRxParam); SHCI_TL_UserEventFlow = UserEvtRxParam.status; } + else + { + SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; + } if(SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable) { @@ -211,6 +229,7 @@ static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt) { + (void)(shcievt); shci_cmd_resp_release(0); /**< Notify the application the Cmd response has been received */ return; @@ -223,3 +242,23 @@ return; } + +/* Weak implementation ----------------------------------------------------------------*/ +__WEAK void shci_cmd_resp_wait(uint32_t timeout) +{ + (void)timeout; + + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + + return; +} + +__WEAK void shci_cmd_resp_release(uint32_t flag) +{ + (void)flag; + + CmdRspStatusFlag = SHCI_TL_CMD_RESP_RELEASE; + + return; +}
diff --git a/lib/stm32wb/hci/shci_tl.h b/lib/stm32wb/hci/shci_tl.h index c147e24..d2b555a 100644 --- a/lib/stm32wb/hci/shci_tl.h +++ b/lib/stm32wb/hci/shci_tl.h
@@ -120,12 +120,13 @@ /** - * @brief This function is called when an System HCO Command is sent and the response - * is waited from the CPU2. - * The application shall implement a mechanism to not return from this function - * until the waited event is received. - * This is notified to the application with shci_cmd_resp_release(). + * @brief This function is called when an System HCI Command is sent to the CPU2 and the response is waited. * It is called from the same context the System HCI command has been sent. + * It shall not return until the command response notified by shci_cmd_resp_release() is received. + * A weak implementation is available in shci_tl.c based on polling mechanism + * The user may re-implement this function in the application to improve performance : + * - It may use UTIL_SEQ_WaitEvt() API when using the Sequencer + * - It may use a semaphore when using cmsis_os interface * * @param timeout: Waiting timeout * @retval None @@ -133,8 +134,12 @@ void shci_cmd_resp_wait(uint32_t timeout); /** - * @brief This function is called when an System HCI command is sent and the response is - * received from the CPU2. + * @brief This function is called when an System HCI command is received from the CPU2. + * A weak implementation is available in shci_tl.c based on polling mechanism + * The user may re-implement this function in the application to improve performance : + * - It may use UTIL_SEQ_SetEvt() API when using the Sequencer + * - It may use a semaphore when using cmsis_os interface + * * * @param flag: Release flag * @retval None
diff --git a/lib/stm32wb/hci/stm_list.c b/lib/stm32wb/hci/stm_list.c index dc55169..ffecaa4 100644 --- a/lib/stm32wb/hci/stm_list.c +++ b/lib/stm32wb/hci/stm_list.c
@@ -1,207 +1,208 @@ -/** - ****************************************************************************** - * @file stm_list.c - * @author MCD Application Team - * @brief TCircular Linked List Implementation. - ****************************************************************************** - * @attention - * - * <h2><center>© Copyright (c) 2018 STMicroelectronics. - * All rights reserved.</center></h2> - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -/****************************************************************************** - * Include Files - ******************************************************************************/ -#include "utilities_common.h" - -#include "stm_list.h" - -/****************************************************************************** - * Function Definitions - ******************************************************************************/ -void LST_init_head (tListNode * listHead) -{ - listHead->next = listHead; - listHead->prev = listHead; -} - -uint8_t LST_is_empty (tListNode * listHead) -{ - uint32_t primask_bit; - uint8_t return_value; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - if(listHead->next == listHead) - { - return_value = TRUE; - } - else - { - return_value = FALSE; - } - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return return_value; -} - -void LST_insert_head (tListNode * listHead, tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead->next; - node->prev = listHead; - listHead->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_tail (tListNode * listHead, tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead; - node->prev = listHead->prev; - listHead->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_node (tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - (node->prev)->next = node->next; - (node->next)->prev = node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_head (tListNode * listHead, tListNode ** node ) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->next; - LST_remove_node (listHead->next); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_tail (tListNode * listHead, tListNode ** node ) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->prev; - LST_remove_node (listHead->prev); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_after (tListNode * node, tListNode * ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node->next; - node->prev = ref_node; - ref_node->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_before (tListNode * node, tListNode * ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node; - node->prev = ref_node->prev; - ref_node->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -int LST_get_size (tListNode * listHead) -{ - int size = 0; - tListNode * temp; - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - temp = listHead->next; - while (temp != listHead) - { - size++; - temp = temp->next; - } - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return (size); -} - -void LST_get_next_node (tListNode * ref_node, tListNode ** node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->next; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_get_prev_node (tListNode * ref_node, tListNode ** node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} +/** + ****************************************************************************** + * @file stm_list.c + * @author MCD Application Team + * @brief TCircular Linked List Implementation. + ****************************************************************************** + * @attention + * + * <h2><center>© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.</center></h2> + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/****************************************************************************** + * Include Files + ******************************************************************************/ +#include "utilities_common.h" + +#include "stm_list.h" + +/****************************************************************************** + * Function Definitions + ******************************************************************************/ +void LST_init_head (tListNode * listHead) +{ + listHead->next = listHead; + listHead->prev = listHead; +} + +uint8_t LST_is_empty (tListNode * listHead) +{ + uint32_t primask_bit; + uint8_t return_value; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + if(listHead->next == listHead) + { + return_value = TRUE; + } + else + { + return_value = FALSE; + } + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return return_value; +} + +void LST_insert_head (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead->next; + node->prev = listHead; + listHead->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_tail (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead; + node->prev = listHead->prev; + listHead->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_node (tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + (node->prev)->next = node->next; + (node->next)->prev = node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_head (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->next; + LST_remove_node (listHead->next); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_tail (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->prev; + LST_remove_node (listHead->prev); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_after (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node->next; + node->prev = ref_node; + ref_node->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_before (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node; + node->prev = ref_node->prev; + ref_node->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +int LST_get_size (tListNode * listHead) +{ + int size = 0; + tListNode * temp; + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + temp = listHead->next; + while (temp != listHead) + { + size++; + temp = temp->next; + } + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return (size); +} + +void LST_get_next_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->next; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} +
diff --git a/lib/stm32wb/hci/stm_list.h b/lib/stm32wb/hci/stm_list.h index e344d27..b123227 100644 --- a/lib/stm32wb/hci/stm_list.h +++ b/lib/stm32wb/hci/stm_list.h
@@ -1,55 +1,55 @@ -/** - ****************************************************************************** - * @file stm_list.h - * @author MCD Application Team - * @brief Header file for linked list library. - ****************************************************************************** - * @attention - * - * <h2><center>© Copyright (c) 2018 STMicroelectronics. - * All rights reserved.</center></h2> - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -#ifndef _STM_LIST_H_ -#define _STM_LIST_H_ - -/* Includes ------------------------------------------------------------------*/ - -typedef struct _tListNode { - struct _tListNode * next; - struct _tListNode * prev; -} tListNode; - -void LST_init_head (tListNode * listHead); - -uint8_t LST_is_empty (tListNode * listHead); - -void LST_insert_head (tListNode * listHead, tListNode * node); - -void LST_insert_tail (tListNode * listHead, tListNode * node); - -void LST_remove_node (tListNode * node); - -void LST_remove_head (tListNode * listHead, tListNode ** node ); - -void LST_remove_tail (tListNode * listHead, tListNode ** node ); - -void LST_insert_node_after (tListNode * node, tListNode * ref_node); - -void LST_insert_node_before (tListNode * node, tListNode * ref_node); - -int LST_get_size (tListNode * listHead); - -void LST_get_next_node (tListNode * ref_node, tListNode ** node); - -void LST_get_prev_node (tListNode * ref_node, tListNode ** node); - -#endif /* _STM_LIST_H_ */ +/** + ****************************************************************************** + * @file stm_list.h + * @author MCD Application Team + * @brief Header file for linked list library. + ****************************************************************************** + * @attention + * + * <h2><center>© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.</center></h2> + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +#ifndef _STM_LIST_H_ +#define _STM_LIST_H_ + +/* Includes ------------------------------------------------------------------*/ + +typedef struct _tListNode { + struct _tListNode * next; + struct _tListNode * prev; +} tListNode; + +void LST_init_head (tListNode * listHead); + +uint8_t LST_is_empty (tListNode * listHead); + +void LST_insert_head (tListNode * listHead, tListNode * node); + +void LST_insert_tail (tListNode * listHead, tListNode * node); + +void LST_remove_node (tListNode * node); + +void LST_remove_head (tListNode * listHead, tListNode ** node ); + +void LST_remove_tail (tListNode * listHead, tListNode ** node ); + +void LST_insert_node_after (tListNode * node, tListNode * ref_node); + +void LST_insert_node_before (tListNode * node, tListNode * ref_node); + +int LST_get_size (tListNode * listHead); + +void LST_get_next_node (tListNode * ref_node, tListNode ** node); + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node); + +#endif /* _STM_LIST_H_ */
diff --git a/lib/stm32wb/hci/tl.h b/lib/stm32wb/hci/tl.h index e7b006e..b116589 100644 --- a/lib/stm32wb/hci/tl.h +++ b/lib/stm32wb/hci/tl.h
@@ -31,33 +31,35 @@ #include "stm32_wpan_common.h" /* Exported defines -----------------------------------------------------------*/ -#define TL_BLECMD_PKT_TYPE ( 0x01 ) -#define TL_ACL_DATA_PKT_TYPE ( 0x02 ) -#define TL_BLEEVT_PKT_TYPE ( 0x04 ) -#define TL_OTCMD_PKT_TYPE ( 0x08 ) -#define TL_OTRSP_PKT_TYPE ( 0x09 ) -#define TL_CLICMD_PKT_TYPE ( 0x0A ) -#define TL_OTNOT_PKT_TYPE ( 0x0C ) -#define TL_OTACK_PKT_TYPE ( 0x0D ) -#define TL_CLINOT_PKT_TYPE ( 0x0E ) -#define TL_CLIACK_PKT_TYPE ( 0x0F ) -#define TL_SYSCMD_PKT_TYPE ( 0x10 ) -#define TL_SYSRSP_PKT_TYPE ( 0x11 ) -#define TL_SYSEVT_PKT_TYPE ( 0x12 ) -#define TL_LOCCMD_PKT_TYPE ( 0x20 ) -#define TL_LOCRSP_PKT_TYPE ( 0x21 ) -#define TL_TRACES_APP_PKT_TYPE ( 0x40 ) -#define TL_TRACES_WL_PKT_TYPE ( 0x41 ) +#define TL_BLECMD_PKT_TYPE ( 0x01 ) +#define TL_ACL_DATA_PKT_TYPE ( 0x02 ) +#define TL_BLEEVT_PKT_TYPE ( 0x04 ) +#define TL_OTCMD_PKT_TYPE ( 0x08 ) +#define TL_OTRSP_PKT_TYPE ( 0x09 ) +#define TL_CLICMD_PKT_TYPE ( 0x0A ) +#define TL_OTNOT_PKT_TYPE ( 0x0C ) +#define TL_OTACK_PKT_TYPE ( 0x0D ) +#define TL_CLINOT_PKT_TYPE ( 0x0E ) +#define TL_CLIACK_PKT_TYPE ( 0x0F ) +#define TL_SYSCMD_PKT_TYPE ( 0x10 ) +#define TL_SYSRSP_PKT_TYPE ( 0x11 ) +#define TL_SYSEVT_PKT_TYPE ( 0x12 ) +#define TL_CLIRESP_PKT_TYPE ( 0x15 ) +#define TL_M0CMD_PKT_TYPE ( 0x16 ) +#define TL_LOCCMD_PKT_TYPE ( 0x20 ) +#define TL_LOCRSP_PKT_TYPE ( 0x21 ) +#define TL_TRACES_APP_PKT_TYPE ( 0x40 ) +#define TL_TRACES_WL_PKT_TYPE ( 0x41 ) -#define TL_CMD_HDR_SIZE (4) -#define TL_EVT_HDR_SIZE (3) -#define TL_EVT_CS_PAYLOAD_SIZE (4) +#define TL_CMD_HDR_SIZE (4) +#define TL_EVT_HDR_SIZE (3) +#define TL_EVT_CS_PAYLOAD_SIZE (4) -#define TL_BLEEVT_CC_OPCODE (0x0E) -#define TL_BLEEVT_CS_OPCODE (0x0F) +#define TL_BLEEVT_CC_OPCODE (0x0E) +#define TL_BLEEVT_CS_OPCODE (0x0F) -#define TL_BLEEVT_CS_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)) -#define TL_BLEEVT_CS_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CS_PACKET_SIZE) +#define TL_BLEEVT_CS_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)) +#define TL_BLEEVT_CS_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CS_PACKET_SIZE) /* Exported types ------------------------------------------------------------*/ /**< Packet header */ @@ -186,8 +188,8 @@ typedef struct { - uint8_t *p_LldTestsCliRspBuffer; - uint8_t *p_LldTestsNotAckBuffer; + uint8_t *p_LldTestsCliCmdRspBuffer; + uint8_t *p_LldTestsM0CmdBuffer; } TL_LLD_tests_Config_t; typedef struct @@ -200,7 +202,7 @@ { uint8_t *p_ZigbeeOtCmdRspBuffer; uint8_t *p_ZigbeeNotAckBuffer; - uint8_t *p_ZigbeeLoggingBuffer; + uint8_t *p_ZigbeeNotifRequestBuffer; } TL_ZIGBEE_Config_t; /** @@ -263,13 +265,14 @@ void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ); /****************************************************************************** - * LLD tests + * LLD TESTS ******************************************************************************/ void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config ); -void TL_LLDTESTS_CliSendCmd( void ); -void TL_LLDTESTS_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_LLDTESTS_CliSendAck ( void ); -void TL_LLDTESTS_CliNotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_LLDTESTS_SendCliCmd( void ); +void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ); +void TL_LLDTESTS_SendCliRspAck( void ); +void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); +void TL_LLDTESTS_SendM0CmdAck( void ); /****************************************************************************** * MEMORY MANAGER @@ -296,12 +299,12 @@ * ZIGBEE ******************************************************************************/ void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); -void TL_ZIGBEE_SendAppliCmdToM0( void ); -void TL_ZIGBEE_SendAckAfterAppliNotifFromM0 ( void ); +void TL_ZIGBEE_SendM4RequestToM0( void ); +void TL_ZIGBEE_SendM4AckToM0Notify ( void ); void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_LoggingReceived(TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_SendAckAfterAppliLoggingFromM0 ( void ); +void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_SendM4AckToM0Request(void); #ifdef __cplusplus } /* extern "C" */
diff --git a/lib/stm32wb/hci/tl_mbox.c b/lib/stm32wb/hci/tl_mbox.c index 340b5ac..8a97b00 100644 --- a/lib/stm32wb/hci/tl_mbox.c +++ b/lib/stm32wb/hci/tl_mbox.c
@@ -120,6 +120,9 @@ int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size ) { + (void)(buffer); + (void)(size); + ((TL_CmdPacket_t*)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE; HW_IPCC_BLE_SendCmd(); @@ -143,6 +146,9 @@ int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size ) { + (void)(buffer); + (void)(size); + ((TL_AclDataPacket_t *)(TL_RefTable.p_ble_table->phci_acl_data_buffer))->AclDataSerial.type = TL_ACL_DATA_PKT_TYPE; HW_IPCC_BLE_SendAclData(); @@ -181,6 +187,9 @@ int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size ) { + (void)(buffer); + (void)(size); + ((TL_CmdPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer))->cmdserial.type = TL_SYSCMD_PKT_TYPE; HW_IPCC_SYS_SendCmd(); @@ -291,58 +300,55 @@ #endif /* THREAD_WB */ /****************************************************************************** - * LLD 802.15.4 + * LLD TESTS ******************************************************************************/ -#ifdef LLD_802_15_4_WB +#ifdef LLD_TESTS_WB void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config ) { MB_LldTestsTable_t * p_lld_tests_table; p_lld_tests_table = TL_RefTable.p_lld_tests_table; - - p_lld_tests_table->clicmdrsp_buffer = p_Config->p_LldTestsCliRspBuffer; - p_lld_tests_table->notack_buffer = p_Config->p_LldTestsNotAckBuffer; - + p_lld_tests_table->clicmdrsp_buffer = p_Config->p_LldTestsCliCmdRspBuffer; + p_lld_tests_table->m0cmd_buffer = p_Config->p_LldTestsM0CmdBuffer; HW_IPCC_LLDTESTS_Init(); - return; } -void TL_LLDTESTS_CliSendCmd( void ) +void TL_LLDTESTS_SendCliCmd( void ) { ((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; - - HW_IPCC_LLDTESTS_CliSendCmd(); - + HW_IPCC_LLDTESTS_SendCliCmd(); return; } -void TL_LLDTESTS_CliSendAck ( void ) +void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ) { - ((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_LLDTESTS_CliSendAck(); - + TL_LLDTESTS_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer) ); return; } -void HW_IPCC_LLDTESTS_EvtNot( void ) +void TL_LLDTESTS_SendCliRspAck( void ) { - TL_LLDTESTS_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_lld_tests_table->notack_buffer) ); - + HW_IPCC_LLDTESTS_SendCliRspAck(); return; } -void HW_IPCC_LLDTESTS_CliEvtNot( void ) +void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ) { - TL_LLDTESTS_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer) ); - + TL_LLDTESTS_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->m0cmd_buffer) ); return; } -__WEAK void TL_LLDTESTS_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -__WEAK void TL_LLDTESTS_CliNotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif /* LLD_802_15_4_WB */ + +void TL_LLDTESTS_SendM0CmdAck( void ) +{ + HW_IPCC_LLDTESTS_SendM0CmdAck(); + return; +} + +__WEAK void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){}; +__WEAK void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; +#endif /* LLD_TESTS_WB */ #ifdef MAC_802_15_4_WB /****************************************************************************** @@ -404,68 +410,68 @@ ******************************************************************************/ void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) { - MB_ZigbeeTable_t * p_zigbee_table; p_zigbee_table = TL_RefTable.p_zigbee_table; p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; - p_zigbee_table->loggingM0toM4_buffer = p_Config->p_ZigbeeLoggingBuffer; + p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; HW_IPCC_ZIGBEE_Init(); - return; + return; } -void TL_ZIGBEE_SendAppliCmdToM0( void ) +/* Zigbee M4 to M0 Request */ +void TL_ZIGBEE_SendM4RequestToM0( void ) { ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - HW_IPCC_ZIGBEE_SendAppliCmd(); - - return; -} - -/* Send an ACK to the M0 */ -void TL_ZIGBEE_SendAckAfterAppliNotifFromM0 ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendAppliCmdAck(); + HW_IPCC_ZIGBEE_SendM4RequestToM0(); return; } /* Used to receive an ACK from the M0 */ -void HW_IPCC_ZIGBEE_AppliCmdNotification(void) +void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) { TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); return; } -/* Zigbee callback */ -void HW_IPCC_ZIGBEE_AppliAsyncEvtNotification( void ) +/* Zigbee notification from M0 to M4 */ +void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) { TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); return; } -/* Zigbee logging */ -void HW_IPCC_ZIGBEE_AppliAsyncLoggingNotification( void ) +/* Send an ACK to the M0 for a Notification */ +void TL_ZIGBEE_SendM4AckToM0Notify ( void ) { - TL_ZIGBEE_LoggingReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->loggingM0toM4_buffer) ); + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); return; } -/* Send a Logging ACK to the M0 */ -void TL_ZIGBEE_SendAckAfterAppliLoggingFromM0 ( void ) +/* Zigbee M0 to M4 Request */ +void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) { - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->loggingM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); - HW_IPCC_ZIGBEE_SendLoggingAck(); + return; +} + +/* Send an ACK to the M0 for a Request */ +void TL_ZIGBEE_SendM4AckToM0Request(void) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Request(); return; } @@ -550,6 +556,9 @@ return; } -__WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ){}; +__WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) +{ + (void)(hcievt); +} /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/