lib: stm32wb hci: Update lib from stm32wb cube package 1.3.0

Origin:
    ST Microelectronics
        https://github.com/STMicroelectronics/STM32CubeWB

Status:
    version 1.3.0

Patch list:

Following files are distributed under ST License SLA0044.
For Zephyr they are made available under BSD-3 Clause.
* hw_ipcc.c
* app_common.h
* stm32_wpan_common.h
* app_conf.h
* hw_conf.h
* tl_conf.h

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2020-01-13 17:52:19 +01:00 committed by Kumar Gala
parent 7d9ca4f0c7
commit c1ba924a4b
17 changed files with 4705 additions and 3564 deletions

View File

@ -3,10 +3,10 @@ STM32WB HCI
Origin:
ST Microelectronics
http://www.st.com/en/embedded-software/stm32cubewb.html
https://github.com/STMicroelectronics/STM32CubeWB
Status:
version 1.0.0
version 1.3.0
Purpose:
This library is used on stm32wb series to enable HCI communication between
@ -19,13 +19,13 @@ Description:
Dependencies:
This library depends on STM32Cube IPCC HAL API.
It is available in ext/hal/st/stm32cube/stm32wbxx/drivers
It is available in stm32cube/stm32wbxx/drivers
URL:
http://www.st.com/en/embedded-software/stm32cubewb.html
https://github.com/STMicroelectronics/STM32CubeWB
commit:
version 1.0.0
96abbb67db97bc53e38f9727adfae0e5c70b1498
Maintained-by:
External
@ -38,6 +38,16 @@ License Link:
Patch List:
* Move some files license from ST SLA0044 to BSD-3 Clause
Following files are distributed under ST License SLA0044.
For Zephyr they are made available under BSD-3 Clause.
- hw_ipcc.c
- app_common.h
- stm32_wpan_common.h
- app_conf.h
- hw_conf.h
- tl_conf.h
* Remove use of useless section SYSTEM_DRIVER_CONTEXT
Section has no use. Remove it.
Impacted file: shci_tl.c

View File

@ -1,430 +1,517 @@
/**
******************************************************************************
* File Name : app_conf.h
* Description : Application configuration file for BLE middleWare.
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef APP_CONFIG_H
#define APP_CONFIG_H
#include "hw.h"
#include "hw_conf.h"
/******************************************************************************
* Application Config
******************************************************************************/
/**
* 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}
/**
* Encryption root key used to derive LTK and CSRK
*/
#define CFG_BLE_ERK {0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21,0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21}
/**< specific parameters */
/*****************************************************/
#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler
/******************************************************************************
* Information Table
*
* Version
* [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version
* [4:7] = branch - 0: Mass Market - x: ...
* [8:15] = Subversion
* [16:23] = Version minor
* [24:31] = Version major
*
******************************************************************************/
#define CFG_FW_MAJOR_VERSION (0)
#define CFG_FW_MINOR_VERSION (0)
#define CFG_FW_SUBVERSION (1)
#define CFG_FW_BRANCH (0)
#define CFG_FW_BUILD (0)
/******************************************************************************
* BLE Stack
******************************************************************************/
/**
* Maximum number of simultaneous connections that the device will support.
* Valid values are from 1 to 8
*/
#define CFG_BLE_NUM_LINK 8
/**
* Maximum number of Services that can be stored in the GATT database.
* Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services
*/
#define CFG_BLE_NUM_GATT_SERVICES 8
/**
* Maximum number of Attributes
* (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services)
* that can be stored in the GATT database.
* Note that certain characteristics and relative descriptors are added automatically during device initialization
* so this parameters should be 9 plus the number of user Attributes
*/
#define CFG_BLE_NUM_GATT_ATTRIBUTES 68
/**
* Maximum supported ATT_MTU size
*/
#define CFG_BLE_MAX_ATT_MTU (156)
/**
* Size of the storage area for Attribute values
* This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute:
* - attribute value length
* - 5, if UUID is 16 bit; 19, if UUID is 128 bit
* - 2, if server configuration descriptor is used
* - 2*DTM_NUM_LINK, if client configuration descriptor is used
* - 2, if extended properties is used
* The total amount of memory needed is the sum of the above quantities for each attribute.
*/
#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344)
/**
* Prepare Write List size in terms of number of packet with ATT_MTU=23 bytes
*/
#define CFG_BLE_PREPARE_WRITE_LIST_SIZE ( 0x3A )
/**
* Number of allocated memory blocks
*/
#define CFG_BLE_MBLOCK_COUNT ( 0x79 )
/**
* Enable or disable the Extended Packet length feature. Valid values are 0 or 1.
*/
#define CFG_BLE_DATA_LENGTH_EXTENSION 1
/**
* Sleep clock accuracy in Slave mode (ppm value)
*/
#define CFG_BLE_SLAVE_SCA 500
/**
* Sleep clock accuracy in Master mode
* 0 : 251 ppm to 500 ppm
* 1 : 151 ppm to 250 ppm
* 2 : 101 ppm to 150 ppm
* 3 : 76 ppm to 100 ppm
* 4 : 51 ppm to 75 ppm
* 5 : 31 ppm to 50 ppm
* 6 : 21 ppm to 30 ppm
* 7 : 0 ppm to 20 ppm
*/
#define CFG_BLE_MASTER_SCA 0
/**
* Source for the 32 kHz slow speed clock
* 1 : internal RO
* 0 : external crystal ( no calibration )
*/
#define CFG_BLE_LSE_SOURCE 1
/**
* Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us)
*/
#define CFG_BLE_HSE_STARTUP_TIME 0x148
/**
* Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us)
*/
#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF )
/**
* Viterbi Mode
* 1 : enabled
* 0 : disabled
*/
#define CFG_BLE_VITERBI_MODE 1
/**
* LL Only Mode
* 1 : LL Only
* 0 : LL + Host
*/
#define CFG_BLE_LL_ONLY 1
/******************************************************************************
* Transport Layer
******************************************************************************/
/**
* Queue length of BLE Event
* This parameter defines the number of asynchronous events that can be stored in the HCI layer before
* being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer
* is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large
* enough to store all asynchronous events received in between.
* When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events
* between the HCI command and its event.
* This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small,
* the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting
* for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate
* to the application a HCI command did not receive its command event within 30s (Default HCI Timeout).
*/
#define CFG_TLBLE_EVT_QUEUE_LENGTH 5
/**
* This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element
* allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager.
* It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will
* never be used)
* It shall be at least 4 to receive the command status event in one frame.
* The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced
* further depending on the application.
*
*/
#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */
#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE )
/******************************************************************************
* UART interfaces
******************************************************************************/
/**
* Select UART interfaces
*/
#define CFG_UART_GUI hw_uart1
#define DBG_TRACE_UART_CFG
/******************************************************************************
* USB interface
******************************************************************************/
/**
* Enable/Disable USB interface
*/
#define CFG_USB_INTERFACE_ENABLE 0
/******************************************************************************
* Low Power
******************************************************************************/
/**
* When set to 1, the low power mode is enable
* When set to 0, the device stays in RUN mode
*/
#define CFG_LPM_SUPPORTED 1
/******************************************************************************
* Timer Server
******************************************************************************/
/**
* CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer.
* The higher is the value, the better is the power consumption and the accuracy of the timerserver
* The lower is the value, the finest is the granularity
*
* CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to ouput
* clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding
* the wakeup timer. A lower clock speed would impact the accuracy of the timer server.
*
* CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC.
* When the 1Hz calendar clock is required, it shall be sets according to other settings
* When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE)
*
* CFG_RTCCLK_DIVIDER_CONF:
* Shall be set to either 0,2,4,8,16
* When set to either 2,4,8,16, the 1Hhz calendar is supported
* When set to 0, the user sets its own configuration
*
* The following settings are computed with LSI as input to the RTC
*/
#define CFG_RTCCLK_DIVIDER_CONF 0
#if (CFG_RTCCLK_DIVIDER_CONF == 0)
/**
* Custom configuration
* It does not support 1Hz calendar
* It divides the RTC CLK by 16
*/
#define CFG_RTCCLK_DIV (16)
#define CFG_RTC_WUCKSEL_DIVIDER (0)
#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1)
#define CFG_RTC_SYNCH_PRESCALER (0x7FFF)
#else
#if (CFG_RTCCLK_DIVIDER_CONF == 2)
/**
* It divides the RTC CLK by 2
*/
#define CFG_RTC_WUCKSEL_DIVIDER (3)
#endif
#if (CFG_RTCCLK_DIVIDER_CONF == 4)
/**
* It divides the RTC CLK by 4
*/
#define CFG_RTC_WUCKSEL_DIVIDER (2)
#endif
#if (CFG_RTCCLK_DIVIDER_CONF == 8)
/**
* It divides the RTC CLK by 8
*/
#define CFG_RTC_WUCKSEL_DIVIDER (1)
#endif
#if (CFG_RTCCLK_DIVIDER_CONF == 16)
/**
* It divides the RTC CLK by 16
*/
#define CFG_RTC_WUCKSEL_DIVIDER (0)
#endif
#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF
#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1)
#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 )
#endif
/** tick timer value in us */
#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE )
typedef enum
{
CFG_TIM_PROC_ID_ISR,
} CFG_TimProcID_t;
/******************************************************************************
* Debug
******************************************************************************/
/**
* When set, this resets some hw resources to set the device in the same state than the power up
* The FW resets only register that may prevent the FW to run properly
*
* This shall be set to 0 in a final product
*
*/
#define CFG_HW_RESET_BY_FW 1
/**
* keep debugger enabled while in any low power mode when set to 1
* should be set to 0 in production
*/
#define CFG_DEBUGGER_SUPPORTED 0
/**
* When set to 1, the traces are enabled in the BLE services
*/
#define CFG_DEBUG_BLE_TRACE 0
/**
* Enable or Disable traces in application
*/
#define CFG_DEBUG_APP_TRACE 0
#if defined ( __CC_ARM ) /* Keil */
#undef CFG_DEBUG_BLE_TRACE
#undef CFG_DEBUG_APP_TRACE
#undef CFG_LPM_SUPPORTED
#define CFG_DEBUG_BLE_TRACE 0
#define CFG_DEBUG_APP_TRACE 0
#define CFG_LPM_SUPPORTED 0
#endif
#if (CFG_DEBUG_APP_TRACE != 0)
#define APP_DBG_MSG PRINT_MESG_DBG
#else
#define APP_DBG_MSG PRINT_NO_MESG
#endif
#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) )
#define CFG_DEBUG_TRACE 1
#endif
#if (CFG_DEBUG_TRACE != 0)
#undef CFG_LPM_SUPPORTED
#undef CFG_DEBUGGER_SUPPORTED
#define CFG_LPM_SUPPORTED 0
#define CFG_DEBUGGER_SUPPORTED 1
#endif
/* USER CODE BEGIN Defines */
#define CFG_LED_SUPPORTED 1
#define CFG_BUTTON_SUPPORTED 1
/* USER CODE END Defines */
/******************************************************************************
* Scheduler
******************************************************************************/
/**
* These are the lists of task id registered to the scheduler
* Each task id shall be in the range [0:31]
* This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with
* the requirement that a HCI/ACI command shall never be sent if there is already one pending
*/
/**< Add in that list all tasks that may send a ACI/HCI command */
typedef enum
{
CFG_TASK_BLE_HCI_CMD_ID,
CFG_TASK_SYS_HCI_CMD_ID,
CFG_TASK_HCI_ACL_DATA_ID,
CFG_TASK_SYS_LOCAL_CMD_ID,
CFG_TASK_TX_TO_HOST_ID,
/* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */
/* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */
CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */
} CFG_Task_Id_With_HCI_Cmd_t;
/**< Add in that list all tasks that never send a ACI/HCI command */
typedef enum
{
CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */
CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID,
/* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */
/* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */
CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */
} CFG_Task_Id_With_NO_HCI_Cmd_t;
#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD
/**
* This is the list of priority required by the application
* Each Id shall be in the range 0..31
*/
typedef enum
{
CFG_SCH_PRIO_0,
CFG_PRIO_NBR,
} CFG_SCH_Prio_Id_t;
/**
* This is a bit mapping over 32bits listing all events id supported in the application
*/
typedef enum
{
CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID,
} CFG_IdleEvt_Id_t;
/******************************************************************************
* LOW POWER
******************************************************************************/
/**
* Supported requester to the MCU Low Power Manager - can be increased up to 32
* It lits a bit mapping of all user of the Low Power Manager
*/
typedef enum
{
CFG_LPM_APP,
} CFG_LPM_Id_t;
#endif /*APP_CONFIG_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* File Name : app_conf.h
* Description : Application configuration file for STM32WPAN Middleware.
*
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef APP_CONF_H
#define APP_CONF_H
#include "hw.h"
#include "hw_conf.h"
#include "hw_if.h"
/******************************************************************************
* Application Config
******************************************************************************/
/**< generic parameters ******************************************************/
/**
* Define Tx Power
*/
#define CFG_TX_POWER (0x18) /**< 0dbm */
/**
* Define Advertising parameters
*/
#define CFG_ADV_BD_ADDRESS (0x7257acd87a6c)
/**
* Define IO Authentication
*/
#define CFG_BONDING_MODE (1)
#define CFG_FIXED_PIN (111111)
#define CFG_USED_FIXED_PIN (0)
#define CFG_ENCRYPTION_KEY_SIZE_MAX (16)
#define CFG_ENCRYPTION_KEY_SIZE_MIN (8)
/**
* Define IO capabilities
*/
#define CFG_IO_CAPABILITY_DISPLAY_ONLY (0x00)
#define CFG_IO_CAPABILITY_DISPLAY_YES_NO (0x01)
#define CFG_IO_CAPABILITY_KEYBOARD_ONLY (0x02)
#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 MITM modes
*/
#define CFG_MITM_PROTECTION_NOT_REQUIRED (0x00)
#define CFG_MITM_PROTECTION_REQUIRED (0x01)
#define CFG_MITM_PROTECTION CFG_MITM_PROTECTION_REQUIRED
/**
* 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}
/**
* Encryption root key used to derive LTK and CSRK
*/
#define CFG_BLE_ERK {0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21,0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21}
/* USER CODE BEGIN Generic_Parameters */
/**
* SMPS supply
* SMPS not used when Set to 0
* SMPS used when Set to 1
*/
#define CFG_USE_SMPS 1
/* USER CODE END Generic_Parameters */
/**< 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 */
/******************************************************************************
* BLE Stack
******************************************************************************/
/**
* Maximum number of simultaneous connections that the device will support.
* Valid values are from 1 to 8
*/
#define CFG_BLE_NUM_LINK 8
/**
* Maximum number of Services that can be stored in the GATT database.
* Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services
*/
#define CFG_BLE_NUM_GATT_SERVICES 8
/**
* Maximum number of Attributes
* (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services)
* that can be stored in the GATT database.
* Note that certain characteristics and relative descriptors are added automatically during device initialization
* so this parameters should be 9 plus the number of user Attributes
*/
#define CFG_BLE_NUM_GATT_ATTRIBUTES 68
/**
* Maximum supported ATT_MTU size
*/
#define CFG_BLE_MAX_ATT_MTU (156)
/**
* Size of the storage area for Attribute values
* This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute:
* - attribute value length
* - 5, if UUID is 16 bit; 19, if UUID is 128 bit
* - 2, if server configuration descriptor is used
* - 2*DTM_NUM_LINK, if client configuration descriptor is used
* - 2, if extended properties is used
* The total amount of memory needed is the sum of the above quantities for each attribute.
*/
#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344)
/**
* Prepare Write List size in terms of number of packet with ATT_MTU=23 bytes
*/
#define CFG_BLE_PREPARE_WRITE_LIST_SIZE ( 0x3A )
/**
* Number of allocated memory blocks
*/
#define CFG_BLE_MBLOCK_COUNT ( 0x79 )
/**
* Enable or disable the Extended Packet length feature. Valid values are 0 or 1.
*/
#define CFG_BLE_DATA_LENGTH_EXTENSION 1
/**
* Sleep clock accuracy in Slave mode (ppm value)
*/
#define CFG_BLE_SLAVE_SCA 500
/**
* Sleep clock accuracy in Master mode
* 0 : 251 ppm to 500 ppm
* 1 : 151 ppm to 250 ppm
* 2 : 101 ppm to 150 ppm
* 3 : 76 ppm to 100 ppm
* 4 : 51 ppm to 75 ppm
* 5 : 31 ppm to 50 ppm
* 6 : 21 ppm to 30 ppm
* 7 : 0 ppm to 20 ppm
*/
#define CFG_BLE_MASTER_SCA 0
/**
* Source for the 32 kHz slow speed clock
* 1 : internal RO
* 0 : external crystal ( no calibration )
*/
#define CFG_BLE_LSE_SOURCE 0
/**
* Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us)
*/
#define CFG_BLE_HSE_STARTUP_TIME 0x148
/**
* Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us)
*/
#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF )
/**
* Viterbi Mode
* 1 : enabled
* 0 : disabled
*/
#define CFG_BLE_VITERBI_MODE 1
/**
* LL Only Mode
* 1 : LL Only
* 0 : LL + Host
*/
#define CFG_BLE_LL_ONLY 1
/******************************************************************************
* Transport Layer
******************************************************************************/
/**
* Queue length of BLE Event
* This parameter defines the number of asynchronous events that can be stored in the HCI layer before
* being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer
* is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large
* enough to store all asynchronous events received in between.
* When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events
* between the HCI command and its event.
* This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small,
* the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting
* for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate
* to the application a HCI command did not receive its command event within 30s (Default HCI Timeout).
*/
#define CFG_TLBLE_EVT_QUEUE_LENGTH 5
/**
* This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element
* allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager.
* It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will
* never be used)
* It shall be at least 4 to receive the command status event in one frame.
* The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced
* further depending on the application.
*
*/
#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */
#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE )
/******************************************************************************
* UART interfaces
******************************************************************************/
/**
* Select UART interfaces
*/
#define CFG_DEBUG_TRACE_UART hw_uart1
#define CFG_CONSOLE_MENU
/******************************************************************************
* USB interface
******************************************************************************/
/**
* Enable/Disable USB interface
*/
#define CFG_USB_INTERFACE_ENABLE 0
/******************************************************************************
* Low Power
******************************************************************************/
/**
* When set to 1, the low power mode is enable
* When set to 0, the device stays in RUN mode
*/
#define CFG_LPM_SUPPORTED 1
/******************************************************************************
* Timer Server
******************************************************************************/
/**
* CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer.
* The higher is the value, the better is the power consumption and the accuracy of the timerserver
* The lower is the value, the finest is the granularity
*
* CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to ouput
* clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding
* the wakeup timer. A lower clock speed would impact the accuracy of the timer server.
*
* CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC.
* When the 1Hz calendar clock is required, it shall be sets according to other settings
* When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE)
*
* CFG_RTCCLK_DIVIDER_CONF:
* Shall be set to either 0,2,4,8,16
* When set to either 2,4,8,16, the 1Hhz calendar is supported
* When set to 0, the user sets its own configuration
*
* The following settings are computed with LSI as input to the RTC
*/
#define CFG_RTCCLK_DIVIDER_CONF 0
#if (CFG_RTCCLK_DIVIDER_CONF == 0)
/**
* Custom configuration
* It does not support 1Hz calendar
* It divides the RTC CLK by 16
*/
#define CFG_RTCCLK_DIV (16)
#define CFG_RTC_WUCKSEL_DIVIDER (0)
#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1)
#define CFG_RTC_SYNCH_PRESCALER (0x7FFF)
#else
#if (CFG_RTCCLK_DIVIDER_CONF == 2)
/**
* It divides the RTC CLK by 2
*/
#define CFG_RTC_WUCKSEL_DIVIDER (3)
#endif
#if (CFG_RTCCLK_DIVIDER_CONF == 4)
/**
* It divides the RTC CLK by 4
*/
#define CFG_RTC_WUCKSEL_DIVIDER (2)
#endif
#if (CFG_RTCCLK_DIVIDER_CONF == 8)
/**
* It divides the RTC CLK by 8
*/
#define CFG_RTC_WUCKSEL_DIVIDER (1)
#endif
#if (CFG_RTCCLK_DIVIDER_CONF == 16)
/**
* It divides the RTC CLK by 16
*/
#define CFG_RTC_WUCKSEL_DIVIDER (0)
#endif
#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF
#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1)
#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 )
#endif
/** tick timer value in us */
#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE )
typedef enum
{
CFG_TIM_PROC_ID_ISR,
} CFG_TimProcID_t;
/******************************************************************************
* Debug
******************************************************************************/
/**
* When set, this resets some hw resources to set the device in the same state than the power up
* The FW resets only register that may prevent the FW to run properly
*
* This shall be set to 0 in a final product
*
*/
#define CFG_HW_RESET_BY_FW 1
/**
* 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
/**
* When set to 1, the traces are enabled in the BLE services
*/
#define CFG_DEBUG_BLE_TRACE 1
/**
* Enable or Disable traces in application
*/
#define CFG_DEBUG_APP_TRACE 1
#if (CFG_DEBUG_APP_TRACE != 0)
#define APP_DBG_MSG PRINT_MESG_DBG
#else
#define APP_DBG_MSG PRINT_NO_MESG
#endif
#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) )
#define CFG_DEBUG_TRACE 1
#endif
#if (CFG_DEBUG_TRACE != 0)
#undef CFG_LPM_SUPPORTED
#undef CFG_DEBUGGER_SUPPORTED
#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
*
* When both are set to 0, no trace are output
* When both are set to 1, CFG_DEBUG_TRACE_FULL is selected
*/
#define CFG_DEBUG_TRACE_LIGHT 1
#define CFG_DEBUG_TRACE_FULL 0
#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0))
#undef CFG_DEBUG_TRACE_FULL
#undef CFG_DEBUG_TRACE_LIGHT
#define CFG_DEBUG_TRACE_FULL 0
#define CFG_DEBUG_TRACE_LIGHT 1
#endif
#if ( CFG_DEBUG_TRACE == 0 )
#undef CFG_DEBUG_TRACE_FULL
#undef CFG_DEBUG_TRACE_LIGHT
#define CFG_DEBUG_TRACE_FULL 0
#define CFG_DEBUG_TRACE_LIGHT 0
#endif
/**
* When not set, the traces is looping on sending the trace over UART
*/
#define DBG_TRACE_USE_CIRCULAR_QUEUE 1
/**
* max buffer Size to queue data traces and max data trace allowed.
* Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined
*/
#define DBG_TRACE_MSG_QUEUE_SIZE 4096
#define MAX_DBG_TRACE_MSG_SIZE 1024
/* USER CODE BEGIN Defines */
#define CFG_LED_SUPPORTED 1
#define CFG_BUTTON_SUPPORTED 1
#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler
/* USER CODE END Defines */
/******************************************************************************
* Scheduler
******************************************************************************/
/**
* These are the lists of task id registered to the scheduler
* Each task id shall be in the range [0:31]
* This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with
* the requirement that a HCI/ACI command shall never be sent if there is already one pending
*/
/**< 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_HCI_ASYNCH_EVT_ID,
/* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */
/* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */
CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */
} CFG_Task_Id_With_HCI_Cmd_t;
/**< Add in that list all tasks that never send a ACI/HCI command */
typedef enum
{
CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */
CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID,
/* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */
/* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */
CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */
} CFG_Task_Id_With_NO_HCI_Cmd_t;
#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD
/**
* This is the list of priority required by the application
* Each Id shall be in the range 0..31
*/
typedef enum
{
CFG_SCH_PRIO_0,
CFG_PRIO_NBR,
} CFG_SCH_Prio_Id_t;
/**
* This is a bit mapping over 32bits listing all events id supported in the application
*/
typedef enum
{
CFG_IDLEEVT_HCI_CMD_EVT_RSP_ID,
CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID,
} CFG_IdleEvt_Id_t;
/******************************************************************************
* LOW POWER
******************************************************************************/
/**
* Supported requester to the MCU Low Power Manager - can be increased up to 32
* It lits a bit mapping of all user of the Low Power Manager
*/
typedef enum
{
CFG_LPM_APP,
CFG_LPM_APP_BLE,
/* USER CODE BEGIN CFG_LPM_Id_t */
/* USER CODE END CFG_LPM_Id_t */
} CFG_LPM_Id_t;
/******************************************************************************
* OTP manager
******************************************************************************/
#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE
#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR
#endif /*APP_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,183 +1,183 @@
/**
******************************************************************************
* @file hci_tl.h
* @author MCD Application Team
* @brief Constants and functions for HCI layer. See Bluetooth Core
* v 4.0, Vol. 2, Part E.
******************************************************************************
* @attention
*
* <h2><center>&copy; 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 __HCI_TL_H_
#define __HCI_TL_H_
#include "stm32_wpan_common.h"
#include "tl.h"
/* Exported defines -----------------------------------------------------------*/
typedef enum
{
HCI_TL_UserEventFlow_Disable,
HCI_TL_UserEventFlow_Enable,
} HCI_TL_UserEventFlowStatus_t;
typedef enum
{
HCI_TL_CmdBusy,
HCI_TL_CmdAvailable
} HCI_TL_CmdStatus_t;
/**
* @brief Structure used to manage the BUS IO operations.
* All the structure fields will point to functions defined at user level.
* @{
*/
typedef struct
{
int32_t (* Init) (void* pConf); /**< Pointer to HCI TL function for the IO Bus initialization */
int32_t (* DeInit) (void); /**< Pointer to HCI TL function for the IO Bus de-initialization */
int32_t (* Reset) (void); /**< Pointer to HCI TL function for the IO Bus reset */
int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to HCI TL function for the IO Bus data reception */
int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to HCI TL function for the IO Bus data transmission */
int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to HCI TL function for the IO Bus data ack reception */
int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */
} tHciIO;
/**
* @}
*/
/**
* @brief Contain the HCI context
* @{
*/
typedef struct
{
tHciIO io; /**< Manage the BUS IO operations */
void (* UserEvtRx) (void * pData); /**< ACI events callback function pointer */
} tHciContext;
typedef struct
{
HCI_TL_UserEventFlowStatus_t status;
TL_EvtPacket_t *pckt;
} tHCI_UserEvtRxParam;
typedef struct
{
uint8_t *p_cmdbuffer;
void (* StatusNotCallBack) (HCI_TL_CmdStatus_t status);
} HCI_TL_HciInitConf_t;
/**
* @brief Register IO bus services.
* @param fops The HCI IO structure managing the IO BUS
* @retval None
*/
void hci_register_io_bus(tHciIO* fops);
/**
* @brief Interrupt service routine that must be called when the BlueNRG
* reports a packet received or an event to the host through the
* BlueNRG-MS interrupt line.
*
* @param pdata Packet or event pointer
* @retval None
*/
void hci_notify_asynch_evt(void* pdata);
/**
* @brief This function resume the User Event Flow which has been stopped on return
* from UserEvtRx() when the User Event has not been processed.
*
* @param None
* @retval None
*/
void hci_resume_flow(void);
/**
* @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().
* It is called from the same context the HCI command has been sent.
*
* @param timeout: Waiting timeout
* @retval None
*/
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.
*
* @param flag: Release flag
* @retval None
*/
void hci_cmd_resp_release(uint32_t flag);
/**
* END OF SECTION - FUNCTIONS TO BE IMPLEMENTED BY THE APPLICATION
*********************************************************************************************************************
*/
/**
*********************************************************************************************************************
* START OF SECTION - PROCESS TO BE CALLED BY THE SCHEDULER
*/
/**
* @brief This process shall be called by the scheduler each time it is requested with TL_BLE_HCI_UserEvtProcReq()
* This process may send an ACI/HCI command when the svc_ctl.c module is used
*
* @param None
* @retval None
*/
void hci_user_evt_proc(void);
/**
* END OF SECTION - PROCESS TO BE CALLED BY THE SCHEDULER
*********************************************************************************************************************
*/
/**
*********************************************************************************************************************
* START OF SECTION - INTERFACES USED BY THE BLE DRIVER
*/
/**
* @brief Initialize the Host Controller Interface.
* This function must be called before any data can be received
* from BLE controller.
*
* @param pData: ACI events callback function pointer
* This callback is triggered when an user event is received from
* the BLE core device.
* @param pConf: Configuration structure pointer
* @retval None
*/
void hci_init(void(* UserEvtRx)(void* pData), void* pConf);
/**
* END OF SECTION - INTERFACES USED BY THE BLE DRIVER
*********************************************************************************************************************
*/
#endif /* __TL_BLE_HCI_H_ */
/**
******************************************************************************
* @file hci_tl.h
* @author MCD Application Team
* @brief Constants and functions for HCI layer. See Bluetooth Core
* v 4.0, Vol. 2, Part E.
******************************************************************************
* @attention
*
* <h2><center>&copy; 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 __HCI_TL_H_
#define __HCI_TL_H_
#include "stm32_wpan_common.h"
#include "tl.h"
/* Exported defines -----------------------------------------------------------*/
typedef enum
{
HCI_TL_UserEventFlow_Disable,
HCI_TL_UserEventFlow_Enable,
} HCI_TL_UserEventFlowStatus_t;
typedef enum
{
HCI_TL_CmdBusy,
HCI_TL_CmdAvailable
} HCI_TL_CmdStatus_t;
/**
* @brief Structure used to manage the BUS IO operations.
* All the structure fields will point to functions defined at user level.
* @{
*/
typedef struct
{
int32_t (* Init) (void* pConf); /**< Pointer to HCI TL function for the IO Bus initialization */
int32_t (* DeInit) (void); /**< Pointer to HCI TL function for the IO Bus de-initialization */
int32_t (* Reset) (void); /**< Pointer to HCI TL function for the IO Bus reset */
int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to HCI TL function for the IO Bus data reception */
int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to HCI TL function for the IO Bus data transmission */
int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to HCI TL function for the IO Bus data ack reception */
int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */
} tHciIO;
/**
* @}
*/
/**
* @brief Contain the HCI context
* @{
*/
typedef struct
{
tHciIO io; /**< Manage the BUS IO operations */
void (* UserEvtRx) (void * pData); /**< ACI events callback function pointer */
} tHciContext;
typedef struct
{
HCI_TL_UserEventFlowStatus_t status;
TL_EvtPacket_t *pckt;
} tHCI_UserEvtRxParam;
typedef struct
{
uint8_t *p_cmdbuffer;
void (* StatusNotCallBack) (HCI_TL_CmdStatus_t status);
} HCI_TL_HciInitConf_t;
/**
* @brief Register IO bus services.
* @param fops The HCI IO structure managing the IO BUS
* @retval None
*/
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.
*
* @param pdata Packet or event pointer
* @retval None
*/
void hci_notify_asynch_evt(void* pdata);
/**
* @brief This function resume the User Event Flow which has been stopped on return
* from UserEvtRx() when the User Event has not been processed.
*
* @param None
* @retval None
*/
void hci_resume_flow(void);
/**
* @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().
* It is called from the same context the HCI command has been sent.
*
* @param timeout: Waiting timeout
* @retval None
*/
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.
*
* @param flag: Release flag
* @retval None
*/
void hci_cmd_resp_release(uint32_t flag);
/**
* END OF SECTION - FUNCTIONS TO BE IMPLEMENTED BY THE APPLICATION
*********************************************************************************************************************
*/
/**
*********************************************************************************************************************
* START OF SECTION - PROCESS TO BE CALLED BY THE SCHEDULER
*/
/**
* @brief This process shall be called by the scheduler each time it is requested with TL_BLE_HCI_UserEvtProcReq()
* This process may send an ACI/HCI command when the svc_ctl.c module is used
*
* @param None
* @retval None
*/
void hci_user_evt_proc(void);
/**
* END OF SECTION - PROCESS TO BE CALLED BY THE SCHEDULER
*********************************************************************************************************************
*/
/**
*********************************************************************************************************************
* START OF SECTION - INTERFACES USED BY THE BLE DRIVER
*/
/**
* @brief Initialize the Host Controller Interface.
* This function must be called before any data can be received
* from BLE controller.
*
* @param pData: ACI events callback function pointer
* This callback is triggered when an user event is received from
* the BLE core device.
* @param pConf: Configuration structure pointer
* @retval None
*/
void hci_init(void(* UserEvtRx)(void* pData), void* pConf);
/**
* END OF SECTION - INTERFACES USED BY THE BLE DRIVER
*********************************************************************************************************************
*/
#endif /* __TL_BLE_HCI_H_ */

View File

@ -1,310 +1,93 @@
/**
******************************************************************************
* @file hw.h
* @author MCD Application Team
* @brief Hardware
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HW_H
#define __HW_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"
#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
/******************************************************************************
* HW LOW POWER
******************************************************************************/
/**
* Stop Mode configuration
* The values of enum shall be kept unchanged
*/
typedef enum
{
hw_lpm_stopmode0,
hw_lpm_stopmode1,
hw_lpm_stopmode2,
} HW_LPM_StopModeConf_t;
/**
* Off Mode configuration
* The values of enum shall be kept unchanged
*/
typedef enum
{
hw_lpm_standby,
hw_lpm_shutdown,
} HW_LPM_OffModeConf_t;
void HW_LPM_SleepMode(void);
void HW_LPM_StopMode(HW_LPM_StopModeConf_t configuration);
void HW_LPM_OffMode(HW_LPM_OffModeConf_t configuration);
/******************************************************************************
* 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);
/******************************************************************************
* HW IPCC
******************************************************************************/
void HW_IPCC_Enable( void );
void HW_IPCC_Init( void );
void HW_IPCC_Rx_Handler( void );
void HW_IPCC_Tx_Handler( void );
void HW_IPCC_BLE_Init( void );
void HW_IPCC_BLE_SendCmd( void );
void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) );
void HW_IPCC_BLE_RxEvtNot( void );
void HW_IPCC_BLE_SendAclData( void );
void HW_IPCC_BLE_AclDataAckNot( void );
void HW_IPCC_SYS_Init( void );
void HW_IPCC_SYS_SendCmd( void );
void HW_IPCC_SYS_CmdEvtNot( void );
void HW_IPCC_SYS_EvtNot( void );
void HW_IPCC_THREAD_Init( void );
void HW_IPCC_OT_SendCmd( void );
void HW_IPCC_CLI_SendCmd( void );
void HW_IPCC_THREAD_SendAck( void );
void HW_IPCC_OT_CmdEvtNot( void );
void HW_IPCC_CLI_CmdEvtNot( void );
void HW_IPCC_THREAD_EvtNot( void );
void HW_IPCC_THREAD_CliSendAck( void );
void HW_IPCC_THREAD_CliEvtNot( void );
void HW_IPCC_TRACES_Init( void );
void HW_IPCC_TRACES_EvtNot( void );
void HW_IPCC_MAC_802_15_4_Init( void );
void HW_IPCC_MAC_802_15_4_SendCmd( void );
void HW_IPCC_MAC_802_15_4_SendAck( void );
void HW_IPCC_MAC_802_15_4_CmdEvtNot( void );
void HW_IPCC_MAC_802_15_4_EvtNot( void );
#ifdef __cplusplus
}
#endif
#endif /*__HW_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file hw.h
* @author MCD Application Team
* @brief Hardware
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HW_H
#define __HW_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/******************************************************************************
* HW IPCC
******************************************************************************/
void HW_IPCC_Enable( void );
void HW_IPCC_Init( void );
void HW_IPCC_Rx_Handler( void );
void HW_IPCC_Tx_Handler( void );
void HW_IPCC_BLE_Init( void );
void HW_IPCC_BLE_SendCmd( void );
void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) );
void HW_IPCC_BLE_RxEvtNot( void );
void HW_IPCC_BLE_SendAclData( void );
void HW_IPCC_BLE_AclDataAckNot( void );
void HW_IPCC_SYS_Init( void );
void HW_IPCC_SYS_SendCmd( void );
void HW_IPCC_SYS_CmdEvtNot( void );
void HW_IPCC_SYS_EvtNot( void );
void HW_IPCC_THREAD_Init( void );
void HW_IPCC_OT_SendCmd( void );
void HW_IPCC_CLI_SendCmd( void );
void HW_IPCC_THREAD_SendAck( void );
void HW_IPCC_OT_CmdEvtNot( void );
void HW_IPCC_CLI_CmdEvtNot( void );
void HW_IPCC_THREAD_EvtNot( void );
void HW_IPCC_THREAD_CliSendAck( void );
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_TRACES_Init( void );
void HW_IPCC_TRACES_EvtNot( void );
void HW_IPCC_MAC_802_15_4_Init( void );
void HW_IPCC_MAC_802_15_4_SendCmd( void );
void HW_IPCC_MAC_802_15_4_SendAck( void );
void HW_IPCC_MAC_802_15_4_CmdEvtNot( void );
void HW_IPCC_MAC_802_15_4_EvtNot( void );
void HW_IPCC_ZIGBEE_Init( void );
void HW_IPCC_ZIGBEE_SendAppliCmd(void);
void HW_IPCC_ZIGBEE_AppliCmdNotification(void);
void HW_IPCC_ZIGBEE_AppliAsyncEvtNotification(void);
void HW_IPCC_ZIGBEE_SendAppliCmdAck(void);
void HW_IPCC_ZIGBEE_AppliAsyncLoggingNotification( void );
void HW_IPCC_ZIGBEE_SendLoggingAck(void);
#ifdef __cplusplus
}
#endif
#endif /*__HW_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

250
lib/stm32wb/hci/hw_if.h Normal file
View File

@ -0,0 +1,250 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file hw_if.h
* @author MCD Application Team
* @brief Hardware Interface
******************************************************************************
* @attention
*
* <h2><center>&copy; 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****/

View File

@ -1,329 +1,517 @@
/**
******************************************************************************
* File Name : Target/hw_ipcc.c
* Description : Hardware IPCC source file for BLE
* middleWare.
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "app_common.h"
#include "mbox_def.h"
/* Global variables ---------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
#define HW_IPCC_TX_PENDING( channel ) ( !(LL_C1_IPCC_IsActiveFlag_CHx( IPCC, channel )) ) && (((~(IPCC->C1MR)) & (channel << 16U)))
#define HW_IPCC_RX_PENDING( channel ) (LL_C2_IPCC_IsActiveFlag_CHx( IPCC, channel )) && (((~(IPCC->C1MR)) & (channel << 0U)))
/* Private macros ------------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static void (*FreeBufCb)( void );
/* Private function prototypes -----------------------------------------------*/
static void HW_IPCC_BLE_EvtHandler( void );
static void HW_IPCC_BLE_AclDataEvtHandler( void );
static void HW_IPCC_MM_FreeBufHandler( void );
static void HW_IPCC_SYS_CmdEvtHandler( void );
static void HW_IPCC_SYS_EvtHandler( void );
static void HW_IPCC_TRACES_EvtHandler( void );
static void HW_IPCC_OT_CmdEvtHandler( void );
static void HW_IPCC_THREAD_NotEvtHandler( void );
static void HW_IPCC_THREAD_CliNotEvtHandler( void );
/* Public function definition -----------------------------------------------*/
/******************************************************************************
* INTERRUPT HANDLER
******************************************************************************/
void HW_IPCC_Rx_Handler( void )
{
if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ))
{
HW_IPCC_THREAD_NotEvtHandler();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL ))
{
HW_IPCC_BLE_EvtHandler();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL ))
{
HW_IPCC_SYS_EvtHandler();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_TRACES_CHANNEL ))
{
HW_IPCC_TRACES_EvtHandler();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ))
{
HW_IPCC_THREAD_CliNotEvtHandler();
}
return;
}
void HW_IPCC_Tx_Handler( void )
{
if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ))
{
HW_IPCC_OT_CmdEvtHandler();
}
else if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ))
{
HW_IPCC_SYS_CmdEvtHandler();
}
else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ))
{
HW_IPCC_MM_FreeBufHandler();
}
else if (HW_IPCC_TX_PENDING( HW_IPCC_HCI_ACL_DATA_CHANNEL ))
{
HW_IPCC_BLE_AclDataEvtHandler();
}
return;
}
/******************************************************************************
* GENERAL
******************************************************************************/
void HW_IPCC_Enable( void )
{
LL_PWR_EnableBootC2();
return;
}
void HW_IPCC_Init( void )
{
LL_AHB3_GRP1_EnableClock( LL_AHB3_GRP1_PERIPH_IPCC );
LL_C1_IPCC_EnableIT_RXO( IPCC );
LL_C1_IPCC_EnableIT_TXF( IPCC );
HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_EnableIRQ(IPCC_C1_TX_IRQn);
return;
}
/******************************************************************************
* BLE
******************************************************************************/
void HW_IPCC_BLE_Init( void )
{
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL );
return;
}
void HW_IPCC_BLE_SendCmd( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_BLE_CMD_CHANNEL );
return;
}
static void HW_IPCC_BLE_EvtHandler( void )
{
HW_IPCC_BLE_RxEvtNot();
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_BLE_EVENT_CHANNEL );
return;
}
void HW_IPCC_BLE_SendAclData( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
return;
}
static void HW_IPCC_BLE_AclDataEvtHandler( void )
{
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
HW_IPCC_BLE_AclDataAckNot();
return;
}
__weak void HW_IPCC_BLE_AclDataAckNot( void ){};
__weak void HW_IPCC_BLE_RxEvtNot( void ){};
/******************************************************************************
* SYSTEM
******************************************************************************/
void HW_IPCC_SYS_Init( void )
{
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL );
return;
}
void HW_IPCC_SYS_SendCmd( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
return;
}
static void HW_IPCC_SYS_CmdEvtHandler( void )
{
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
HW_IPCC_SYS_CmdEvtNot();
return;
}
static void HW_IPCC_SYS_EvtHandler( void )
{
HW_IPCC_SYS_EvtNot();
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL );
return;
}
__weak void HW_IPCC_SYS_CmdEvtNot( void ){};
__weak void HW_IPCC_SYS_EvtNot( void ){};
/******************************************************************************
* THREAD
******************************************************************************/
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 ){};
/******************************************************************************
* MEMORY MANAGER
******************************************************************************/
void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) )
{
if ( LL_C1_IPCC_IsActiveFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ) )
{
FreeBufCb = cb;
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
}
else
{
cb();
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
}
return;
}
static void HW_IPCC_MM_FreeBufHandler( void )
{
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
FreeBufCb();
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
return;
}
/******************************************************************************
* TRACES
******************************************************************************/
void HW_IPCC_TRACES_Init( void )
{
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_TRACES_CHANNEL );
return;
}
static void HW_IPCC_TRACES_EvtHandler( void )
{
HW_IPCC_TRACES_EvtNot();
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_TRACES_CHANNEL );
return;
}
__weak void HW_IPCC_TRACES_EvtNot( void ){};
/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* File Name : Target/hw_ipcc.c
* Description : Hardware IPCC source file for BLE
* middleWare.
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "app_common.h"
#include "mbox_def.h"
/* Global variables ---------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
#define HW_IPCC_TX_PENDING( channel ) ( !(LL_C1_IPCC_IsActiveFlag_CHx( IPCC, channel )) ) && (((~(IPCC->C1MR)) & (channel << 16U)))
#define HW_IPCC_RX_PENDING( channel ) (LL_C2_IPCC_IsActiveFlag_CHx( IPCC, channel )) && (((~(IPCC->C1MR)) & (channel << 0U)))
/* Private macros ------------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static void (*FreeBufCb)( void );
/* Private function prototypes -----------------------------------------------*/
static void HW_IPCC_BLE_EvtHandler( void );
static void HW_IPCC_BLE_AclDataEvtHandler( void );
static void HW_IPCC_MM_FreeBufHandler( void );
static void HW_IPCC_SYS_CmdEvtHandler( void );
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 -----------------------------------------------*/
/******************************************************************************
* INTERRUPT HANDLER
******************************************************************************/
void HW_IPCC_Rx_Handler( void )
{
if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL ))
{
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();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_TRACES_CHANNEL ))
{
HW_IPCC_TRACES_EvtHandler();
}
return;
}
void HW_IPCC_Tx_Handler( void )
{
if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ))
{
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();
}
else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ))
{
HW_IPCC_MM_FreeBufHandler();
}
else if (HW_IPCC_TX_PENDING( HW_IPCC_HCI_ACL_DATA_CHANNEL ))
{
HW_IPCC_BLE_AclDataEvtHandler();
}
return;
}
/******************************************************************************
* GENERAL
******************************************************************************/
void HW_IPCC_Enable( void )
{
/**
* 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.
* When the CPU2 receives that command, it waits for its event input to be set to restart the CPU2 firmware.
* This is required because once C2BOOT has been set once, a clear/set on C2BOOT has no effect.
* When SHCI_C2_Reinit( ) is not called, generating an event to the CPU2 does not have any effect
* So, by default, the application shall both set the event flag and set the C2BOOT bit.
*/
__SEV( ); /* Set the internal event flag and send an event to the CPU2 */
__WFE( ); /* Clear the internal event flag */
LL_PWR_EnableBootC2( );
return;
}
void HW_IPCC_Init( void )
{
LL_AHB3_GRP1_EnableClock( LL_AHB3_GRP1_PERIPH_IPCC );
LL_C1_IPCC_EnableIT_RXO( IPCC );
LL_C1_IPCC_EnableIT_TXF( IPCC );
HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_EnableIRQ(IPCC_C1_TX_IRQn);
return;
}
/******************************************************************************
* BLE
******************************************************************************/
void HW_IPCC_BLE_Init( void )
{
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL );
return;
}
void HW_IPCC_BLE_SendCmd( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_BLE_CMD_CHANNEL );
return;
}
static void HW_IPCC_BLE_EvtHandler( void )
{
HW_IPCC_BLE_RxEvtNot();
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_BLE_EVENT_CHANNEL );
return;
}
void HW_IPCC_BLE_SendAclData( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
return;
}
static void HW_IPCC_BLE_AclDataEvtHandler( void )
{
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
HW_IPCC_BLE_AclDataAckNot();
return;
}
__weak void HW_IPCC_BLE_AclDataAckNot( void ){};
__weak void HW_IPCC_BLE_RxEvtNot( void ){};
/******************************************************************************
* SYSTEM
******************************************************************************/
void HW_IPCC_SYS_Init( void )
{
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL );
return;
}
void HW_IPCC_SYS_SendCmd( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
return;
}
static void HW_IPCC_SYS_CmdEvtHandler( void )
{
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
HW_IPCC_SYS_CmdEvtNot();
return;
}
static void HW_IPCC_SYS_EvtHandler( void )
{
HW_IPCC_SYS_EvtNot();
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL );
return;
}
__weak void HW_IPCC_SYS_CmdEvtNot( void ){};
__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 ) )
{
if ( LL_C1_IPCC_IsActiveFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ) )
{
FreeBufCb = cb;
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
}
else
{
cb();
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
}
return;
}
static void HW_IPCC_MM_FreeBufHandler( void )
{
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
FreeBufCb();
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
return;
}
/******************************************************************************
* TRACES
******************************************************************************/
void HW_IPCC_TRACES_Init( void )
{
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_TRACES_CHANNEL );
return;
}
static void HW_IPCC_TRACES_EvtHandler( void )
{
HW_IPCC_TRACES_EvtNot();
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_TRACES_CHANNEL );
return;
}
__weak void HW_IPCC_TRACES_EvtNot( void ){};
/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/

View File

@ -1,169 +1,236 @@
/**
******************************************************************************
* @file mbox_def.h
* @author MCD Application Team
* @brief Mailbox definition
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MBOX_H
#define __MBOX_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* This file shall be identical between the CPU1 and the CPU2
*/
/**
*********************************************************************************
* TABLES
*********************************************************************************
*/
/**
* Version
* [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version
* [4:7] = branch - 0: Mass Market - x: ...
* [8:15] = Subversion
* [16:23] = Version minor
* [24:31] = Version major
*
* Memory Size
* [0:7] = Flash ( Number of 4k sector)
* [8:15] = Reserved ( Shall be set to 0 - may be used as flash extension )
* [16:23] = SRAM2b ( Number of 1k sector)
* [24:31] = SRAM2a ( Number of 1k sector)
*/
typedef struct
{
uint32_t Version;
} MB_SafeBootInfoTable_t;
typedef struct
{
uint32_t Version;
uint32_t MemorySize;
uint32_t RssInfo;
} MB_RssInfoTable_t;
typedef struct
{
uint32_t Version;
uint32_t MemorySize;
uint32_t ThreadInfo;
uint32_t BleInfo;
} MB_WirelessFwInfoTable_t;
typedef struct
{
MB_SafeBootInfoTable_t SafeBootInfoTable;
MB_RssInfoTable_t RssInfoTable;
MB_WirelessFwInfoTable_t WirelessFwIinfoTable;
} MB_DeviceInfoTable_t;
typedef struct
{
uint8_t *pcmd_buffer;
uint8_t *pcs_buffer;
uint8_t *pevt_queue;
uint8_t *phci_acl_data_buffer;
} MB_BleTable_t;
typedef struct
{
uint8_t *notack_buffer;
uint8_t *clicmdrsp_buffer;
uint8_t *otcmdrsp_buffer;
} MB_ThreadTable_t;
/**
* msg
* [0:7] = cmd/evt
* [8:31] = Reserved
*/
typedef struct
{
uint8_t *pcmd_buffer;
uint8_t *sys_queue;
} MB_SysTable_t;
typedef struct
{
uint8_t *spare_ble_buffer;
uint8_t *spare_sys_buffer;
uint8_t *blepool;
uint32_t blepoolsize;
uint8_t *pevt_free_buffer_queue;
uint8_t *traces_evt_pool;
uint32_t tracespoolsize;
} MB_MemManagerTable_t;
typedef struct
{
uint8_t *traces_queue;
} MB_TracesTable_t;
typedef struct
{
uint8_t *p_cmdrsp_buffer;
uint8_t *p_notack_buffer;
uint8_t *evt_queue;
} MB_Mac_802_15_4_t;
typedef struct
{
MB_DeviceInfoTable_t *p_device_info_table;
MB_BleTable_t *p_ble_table;
MB_ThreadTable_t *p_thread_table;
MB_SysTable_t *p_sys_table;
MB_MemManagerTable_t *p_mem_manager_table;
MB_TracesTable_t *p_traces_table;
MB_Mac_802_15_4_t *p_mac_802_15_4_table;
} MB_RefTable_t;
#ifdef __cplusplus
}
#endif
/**
*********************************************************************************
* IPCC CHANNELS
*********************************************************************************
*/
/** CPU1 */
#define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1
#define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2
#define HW_IPCC_THREAD_OT_CMD_RSP_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_HCI_ACL_DATA_CHANNEL LL_IPCC_CHANNEL_6
/** CPU2 */
#define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1
#define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2
#define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3
#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_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
#endif /*__MBOX_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file mbox_def.h
* @author MCD Application Team
* @brief Mailbox definition
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MBOX_H
#define __MBOX_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32_wpan_common.h"
/**
* This file shall be identical between the CPU1 and the CPU2
*/
/**
*********************************************************************************
* TABLES
*********************************************************************************
*/
/**
* Version
* [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version
* [4:7] = branch - 0: Mass Market - x: ...
* [8:15] = Subversion
* [16:23] = Version minor
* [24:31] = Version major
*
* Memory Size
* [0:7] = Flash ( Number of 4k sector)
* [8:15] = Reserved ( Shall be set to 0 - may be used as flash extension )
* [16:23] = SRAM2b ( Number of 1k sector)
* [24:31] = SRAM2a ( Number of 1k sector)
*/
typedef PACKED_STRUCT
{
uint32_t Version;
} MB_SafeBootInfoTable_t;
typedef PACKED_STRUCT
{
uint32_t Version;
uint32_t MemorySize;
uint32_t FusInfo;
} MB_FusInfoTable_t;
typedef PACKED_STRUCT
{
uint32_t Version;
uint32_t MemorySize;
uint32_t InfoStack;
uint32_t Reserved;
} MB_WirelessFwInfoTable_t;
typedef struct
{
MB_SafeBootInfoTable_t SafeBootInfoTable;
MB_FusInfoTable_t FusInfoTable;
MB_WirelessFwInfoTable_t WirelessFwInfoTable;
} MB_DeviceInfoTable_t;
typedef struct
{
uint8_t *pcmd_buffer;
uint8_t *pcs_buffer;
uint8_t *pevt_queue;
uint8_t *phci_acl_data_buffer;
} MB_BleTable_t;
typedef struct
{
uint8_t *notack_buffer;
uint8_t *clicmdrsp_buffer;
uint8_t *otcmdrsp_buffer;
} MB_ThreadTable_t;
typedef struct
{
uint8_t *notack_buffer;
uint8_t *clicmdrsp_buffer;
} MB_LldTestsTable_t;
typedef struct
{
uint8_t *notifM0toM4_buffer;
uint8_t *appliCmdM4toM0_buffer;
uint8_t *loggingM0toM4_buffer;
} MB_ZigbeeTable_t;
/**
* msg
* [0:7] = cmd/evt
* [8:31] = Reserved
*/
typedef struct
{
uint8_t *pcmd_buffer;
uint8_t *sys_queue;
} MB_SysTable_t;
typedef struct
{
uint8_t *spare_ble_buffer;
uint8_t *spare_sys_buffer;
uint8_t *blepool;
uint32_t blepoolsize;
uint8_t *pevt_free_buffer_queue;
uint8_t *traces_evt_pool;
uint32_t tracespoolsize;
} MB_MemManagerTable_t;
typedef struct
{
uint8_t *traces_queue;
} MB_TracesTable_t;
typedef struct
{
uint8_t *p_cmdrsp_buffer;
uint8_t *p_notack_buffer;
uint8_t *evt_queue;
} MB_Mac_802_15_4_t;
typedef struct
{
MB_DeviceInfoTable_t *p_device_info_table;
MB_BleTable_t *p_ble_table;
MB_ThreadTable_t *p_thread_table;
MB_SysTable_t *p_sys_table;
MB_MemManagerTable_t *p_mem_manager_table;
MB_TracesTable_t *p_traces_table;
MB_Mac_802_15_4_t *p_mac_802_15_4_table;
MB_ZigbeeTable_t *p_zigbee_table;
MB_LldTestsTable_t *p_lld_tests_table;
} MB_RefTable_t;
#ifdef __cplusplus
}
#endif
/**
*********************************************************************************
* IPCC CHANNELS
*********************************************************************************
*/
/* CPU1 CPU2
* | (SYSTEM) |
* |----HW_IPCC_SYSTEM_CMD_RSP_CHANNEL-------------->|
* | |
* |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------|
* | |
* | (ZIGBEE) |
* |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>|
* | |
* |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->|
* | |
* |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------|
* | |
* |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------|
* | |
* | (THREAD) |
* |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->|
* | |
* |----HW_IPCC_THREAD_CLI_CMD_CHANNEL-------------->|
* | |
* |<---HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL------|
* | |
* |<---HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL--|
* | |
* | (BLE) |
* |----HW_IPCC_BLE_CMD_CHANNEL--------------------->|
* | |
* |----HW_IPCC_HCI_ACL_DATA_CHANNEL---------------->|
* | |
* |<---HW_IPCC_BLE_EVENT_CHANNEL--------------------|
* | |
* | (MAC) |
* |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->|
* | |
* |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL|
* | |
* | (BUFFER) |
* |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>|
* | |
* | (TRACE) |
* |<----HW_IPCC_TRACES_CHANNEL----------------------|
* | |
*
*
*
*/
/** CPU1 */
#define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1
#define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2
#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_HCI_ACL_DATA_CHANNEL LL_IPCC_CHANNEL_6
/** CPU2 */
#define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1
#define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2
#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_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
#endif /*__MBOX_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,224 +1,526 @@
/**
******************************************************************************
* @file shci.c
* @author MCD Application Team
* @brief HCI command for the system channel
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"
#include "shci_tl.h"
#include "shci.h"
/* Private typedef -----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Global variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Local Functions Definition ------------------------------------------------------*/
/* Public Functions Definition ------------------------------------------------------*/
/**
* C2 COMMAND
*/
SHCI_CmdStatus_t SHCI_C2_FUS_Get_State( void )
{
/**
* Buffer is large enough to hold either a command with no parameter
* or a command complete without payload
*/
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
TL_CmdPacket_t * p_cmd;
TL_EvtPacket_t * p_rsp;
p_cmd = (TL_CmdPacket_t *)local_buffer;
p_rsp = (TL_EvtPacket_t *)local_buffer;
p_cmd->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_FUS_GET_STATE;
p_cmd->cmdserial.cmd.plen = 0 ;
shci_send( p_cmd, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket )
{
/**
* Buffer is large enough to hold a 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;
((TL_CmdPacket_t *)pCmdPacket)->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_BLE_INIT;
((TL_CmdPacket_t *)pCmdPacket)->cmdserial.cmd.plen = sizeof( SHCI_C2_Ble_Init_Cmd_Param_t ) ;
shci_send( (TL_CmdPacket_t *)pCmdPacket, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void )
{
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
TL_CmdPacket_t * p_cmd;
TL_EvtPacket_t * p_rsp;
p_cmd = (TL_CmdPacket_t *)local_buffer;
p_rsp = (TL_EvtPacket_t *)local_buffer;
p_cmd->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_THREAD_INIT;
p_cmd->cmdserial.cmd.plen = 0 ;
shci_send( p_cmd, p_rsp );
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 )
{
/**
* Buffer is large enough to hold a 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;
((TL_CmdPacket_t *)pCmdPacket)->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_DEBUG_INIT;
((TL_CmdPacket_t *)pCmdPacket)->cmdserial.cmd.plen = sizeof( SHCI_C2_DEBUG_Init_Cmd_Packet_t ) ;
shci_send( (TL_CmdPacket_t *)pCmdPacket, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FLASH_Erase_Activity( SHCI_C2_FLASH_Erase_Activity_Cmd_Packet_t *pCmdPacket )
{
/**
* Buffer is large enough to hold a 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;
((TL_CmdPacket_t *)pCmdPacket)->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY;
((TL_CmdPacket_t *)pCmdPacket)->cmdserial.cmd.plen = sizeof( SHCI_C2_FLASH_Erase_Activity_Cmd_Packet_t ) ;
shci_send( (TL_CmdPacket_t *)pCmdPacket, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode )
{
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
TL_CmdPacket_t * p_cmd;
TL_EvtPacket_t * p_rsp;
p_cmd = (TL_CmdPacket_t *)local_buffer;
p_rsp = (TL_EvtPacket_t *)local_buffer;
p_cmd->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_CONCURRENT_SET_MODE;
p_cmd->cmdserial.cmd.plen = 1;
p_cmd->cmdserial.cmd.payload[0] = Mode;
shci_send( p_cmd, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip )
{
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
TL_CmdPacket_t * p_cmd;
TL_EvtPacket_t * p_rsp;
p_cmd = (TL_CmdPacket_t *)local_buffer;
p_rsp = (TL_EvtPacket_t *)local_buffer;
p_cmd->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_FLASH_STORE_DATA;
p_cmd->cmdserial.cmd.plen = 1;
p_cmd->cmdserial.cmd.payload[0] = Ip;
shci_send( p_cmd, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip )
{
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
TL_CmdPacket_t * p_cmd;
TL_EvtPacket_t * p_rsp;
p_cmd = (TL_CmdPacket_t *)local_buffer;
p_rsp = (TL_EvtPacket_t *)local_buffer;
p_cmd->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_FLASH_ERASE_DATA;
p_cmd->cmdserial.cmd.plen = 1;
p_cmd->cmdserial.cmd.payload[0] = Ip;
shci_send( p_cmd, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn)
{
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
TL_CmdPacket_t * p_cmd;
TL_EvtPacket_t * p_rsp;
p_cmd = (TL_CmdPacket_t *)local_buffer;
p_rsp = (TL_EvtPacket_t *)local_buffer;
p_cmd->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER;
p_cmd->cmdserial.cmd.plen = 2;
p_cmd->cmdserial.cmd.payload[0] = Ip;
p_cmd->cmdserial.cmd.payload[1] = FlagRadioLowPowerOn;
shci_send( p_cmd, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void )
{
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE];
TL_CmdPacket_t * p_cmd;
TL_EvtPacket_t * p_rsp;
p_cmd = (TL_CmdPacket_t *)local_buffer;
p_rsp = (TL_EvtPacket_t *)local_buffer;
p_cmd->cmdserial.cmd.cmdcode = SHCI_OPCODE_C2_MAC_802_15_4_INIT;
p_cmd->cmdserial.cmd.plen = 0 ;
shci_send( p_cmd, p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file shci.c
* @author MCD Application Team
* @brief HCI command for the system channel
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"
#include "shci_tl.h"
#include "shci.h"
#include "stm32wbxx.h"
/* Private typedef -----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Global variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Local Functions Definition ------------------------------------------------------*/
/* Public Functions Definition ------------------------------------------------------*/
/**
* C2 COMMAND
* These commands are sent to the CPU2
*/
uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_error_code )
{
/**
* A command status event + payload has the same size than the expected command complete
*/
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1];
TL_EvtPacket_t * p_rsp;
p_rsp = (TL_EvtPacket_t *)local_buffer;
shci_send( SHCI_OPCODE_C2_FUS_GET_STATE,
0,
0,
p_rsp );
if(p_error_code != 0)
{
*p_error_code = (SHCI_FUS_GetState_ErrorCode_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]);
}
return (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_add )
{
/**
* 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;
uint32_t *p_cmd;
uint8_t cmd_length;
p_cmd = (uint32_t*)local_buffer;
cmd_length = 0;
if(fw_src_add != 0)
{
*p_cmd = fw_src_add;
cmd_length += 4;
}
if(fw_dest_add != 0)
{
*(p_cmd+1) = fw_dest_add;
cmd_length += 4;
}
p_rsp = (TL_EvtPacket_t *)local_buffer;
shci_send( SHCI_OPCODE_C2_FUS_FW_UPGRADE,
cmd_length,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void )
{
/**
* 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_send( SHCI_OPCODE_C2_FUS_FW_DELETE,
0,
0,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam )
{
/**
* 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_send( SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY,
sizeof( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t ),
(uint8_t*)pParam,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void )
{
/**
* 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_send( SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY,
0,
0,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index )
{
/**
* Buffer is large enough to hold command complete without payload
*/
uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1];
TL_EvtPacket_t * p_rsp;
uint8_t local_payload_len;
if(pParam->KeyType == KEYTYPE_ENCRYPTED)
{
/**
* When the key is encrypted, the 12 bytes IV Key is included in the payload as well
* The IV key is always 12 bytes
*/
local_payload_len = pParam->KeySize + 2 + 12;
}
else
{
local_payload_len = pParam->KeySize + 2;
}
p_rsp = (TL_EvtPacket_t *)local_buffer;
shci_send( SHCI_OPCODE_C2_FUS_STORE_USR_KEY,
local_payload_len ,
(uint8_t*)pParam,
p_rsp );
*p_key_index = (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]);
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index )
{
/**
* 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] = key_index;
shci_send( SHCI_OPCODE_C2_FUS_LOAD_USR_KEY,
1,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void )
{
/**
* 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_send( SHCI_OPCODE_C2_FUS_START_WS,
0,
0,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index )
{
/**
* 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] = key_index;
shci_send( SHCI_OPCODE_C2_FUS_LOCK_USR_KEY,
1,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket )
{
/**
* 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_send( SHCI_OPCODE_C2_BLE_INIT,
sizeof( SHCI_C2_Ble_Init_Cmd_Param_t ),
(uint8_t*)&pCmdPacket->Param,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void )
{
/**
* 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_send( SHCI_OPCODE_C2_THREAD_INIT,
0,
0,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param )
{
/**
* 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_send( SHCI_OPCODE_C2_LLD_TESTS_INIT,
param_size,
p_param,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void )
{
/**
* 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_send( SHCI_OPCODE_C2_ZIGBEE_INIT,
0,
0,
p_rsp );
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 )
{
/**
* 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_send( SHCI_OPCODE_C2_DEBUG_INIT,
sizeof( SHCI_C2_DEBUG_init_Cmd_Param_t ),
(uint8_t*)&pCmdPacket->Param,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activity )
{
/**
* 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] = erase_activity;
shci_send( SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY,
1,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode )
{
/**
* 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] = Mode;
shci_send( SHCI_OPCODE_C2_CONCURRENT_SET_MODE,
1,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip )
{
/**
* 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] = Ip;
shci_send( SHCI_OPCODE_C2_FLASH_STORE_DATA,
1,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip )
{
/**
* 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] = Ip;
shci_send( SHCI_OPCODE_C2_FLASH_ERASE_DATA,
1,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn)
{
/**
* 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] = Ip;
local_buffer[1] = FlagRadioLowPowerOn;
shci_send( SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER,
2,
local_buffer,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void )
{
/**
* 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_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT,
0,
0,
p_rsp );
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
SHCI_CmdStatus_t SHCI_C2_Reinit( void )
{
/**
* 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_send( SHCI_OPCODE_C2_REINIT,
0,
0,
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
*/
SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo )
{
uint32_t ipccdba = 0;
MB_RefTable_t * p_RefTable = NULL;
uint32_t version = 0;
uint32_t memorySize = 0;
uint32_t infoStack = 0;
ipccdba = READ_BIT( FLASH->IPCCBR, FLASH_IPCCBR_IPCCDBA );
p_RefTable = (MB_RefTable_t*)((ipccdba<<2) + SRAM2A_BASE);
/**
* Retrieve the WirelessFwInfoTable
* This table is stored in RAM at startup during the TL (transport layer) initialization
*/
version = p_RefTable->p_device_info_table->WirelessFwInfoTable.Version;
pWirelessInfo->VersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET);
pWirelessInfo->VersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET);
pWirelessInfo->VersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET);
pWirelessInfo->VersionBranch = ((version & INFO_VERSION_BRANCH_MASK) >> INFO_VERSION_BRANCH_OFFSET);
pWirelessInfo->VersionReleaseType = ((version & INFO_VERSION_TYPE_MASK) >> INFO_VERSION_TYPE_OFFSET);
memorySize = p_RefTable->p_device_info_table->WirelessFwInfoTable.MemorySize;
pWirelessInfo->MemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET);
pWirelessInfo->MemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET);
pWirelessInfo->MemorySizeSram1 = ((memorySize & INFO_SIZE_SRAM1_MASK) >> INFO_SIZE_SRAM1_OFFSET);
pWirelessInfo->MemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET);
infoStack = p_RefTable->p_device_info_table->WirelessFwInfoTable.InfoStack;
pWirelessInfo->StackType = ((infoStack & INFO_STACK_TYPE_MASK) >> INFO_STACK_TYPE_OFFSET);
/**
* Retrieve the FusInfoTable
* This table is stored in RAM at startup during the TL (transport layer) initialization
*/
version = p_RefTable->p_device_info_table->FusInfoTable.Version;
pWirelessInfo->FusVersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET);
pWirelessInfo->FusVersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET);
pWirelessInfo->FusVersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET);
memorySize = p_RefTable->p_device_info_table->FusInfoTable.MemorySize;
pWirelessInfo->FusMemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET);
pWirelessInfo->FusMemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET);
pWirelessInfo->FusMemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET);
return (SHCI_Success);
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load Diff

View File

@ -1,206 +1,225 @@
/**
******************************************************************************
* @file shci.c
* @author MCD Application Team
* @brief System HCI command implementation
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"
#include "stm_list.h"
#include "shci_tl.h"
/* Private typedef -----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/**
* The default System HCI layer timeout is set to 33s
*/
#define SHCI_TL_DEFAULT_TIMEOUT (33000)
/* Private macros ------------------------------------------------------------*/
/* Public variables ---------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/**
* START of Section SYSTEM_DRIVER_CONTEXT
*/
static tListNode SHciAsynchEventQueue;
static volatile SHCI_TL_CmdStatus_t SHCICmdStatus;
static TL_CmdPacket_t *pCmdBuffer;
SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow;
/**
* END of Section SYSTEM_DRIVER_CONTEXT
*/
static tSHciContext shciContext;
static void (* StatusNotCallBackFunction) (SHCI_TL_CmdStatus_t status);
/* Private function prototypes -----------------------------------------------*/
static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus);
static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt);
static void TlUserEvtReceived(TL_EvtPacket_t *shcievt);
static void TlInit( TL_CmdPacket_t * p_cmdbuffer );
/* Interface ------- ---------------------------------------------------------*/
void shci_init(void(* UserEvtRx)(void* pData), void* pConf)
{
StatusNotCallBackFunction = ((SHCI_TL_HciInitConf_t *)pConf)->StatusNotCallBack;
shciContext.UserEvtRx = UserEvtRx;
shci_register_io_bus (&shciContext.io);
TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer));
return;
}
void shci_user_evt_proc(void)
{
TL_EvtPacket_t *phcievtbuffer;
tSHCI_UserEvtRxParam UserEvtRxParam;
while((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable))
{
LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer );
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
if (shciContext.UserEvtRx != NULL)
{
UserEvtRxParam.pckt = phcievtbuffer;
shciContext.UserEvtRx((void *)&UserEvtRxParam);
SHCI_TL_UserEventFlow = UserEvtRxParam.status;
}
if(SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)
{
TL_MM_EvtDone( phcievtbuffer );
}
else
{
/**
* put back the event in the queue
*/
LST_insert_head ( &SHciAsynchEventQueue, (tListNode *)phcievtbuffer );
}
}
return;
}
void shci_resume_flow( void )
{
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
/**
* It is better to go through the background process as it is not sure from which context this API may
* be called
*/
shci_notify_asynch_evt((void*) &SHciAsynchEventQueue);
return;
}
void shci_send( TL_CmdPacket_t * p_cmd, TL_EvtPacket_t * p_rsp )
{
Cmd_SetStatus(SHCI_TL_CmdBusy);
memcpy(&(pCmdBuffer->cmdserial), &(p_cmd->cmdserial), p_cmd->cmdserial.cmd.plen + TL_CMD_HDR_SIZE );
shciContext.io.Send(0,0);
shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT);
memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE );
Cmd_SetStatus(SHCI_TL_CmdAvailable);
return;
}
/* Private functions ---------------------------------------------------------*/
static void TlInit( TL_CmdPacket_t * p_cmdbuffer )
{
TL_SYS_InitConf_t Conf;
pCmdBuffer = p_cmdbuffer;
LST_init_head (&SHciAsynchEventQueue);
Cmd_SetStatus(SHCI_TL_CmdAvailable);
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
/* Initialize low level driver */
if (shciContext.io.Init)
{
Conf.p_cmdbuffer = (uint8_t *)p_cmdbuffer;
Conf.IoBusCallBackCmdEvt = TlCmdEvtReceived;
Conf.IoBusCallBackUserEvt = TlUserEvtReceived;
shciContext.io.Init(&Conf);
}
return;
}
static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus)
{
if(shcicmdstatus == SHCI_TL_CmdBusy)
{
if(StatusNotCallBackFunction != 0)
{
StatusNotCallBackFunction( SHCI_TL_CmdBusy );
}
SHCICmdStatus = SHCI_TL_CmdBusy;
}
else
{
SHCICmdStatus = SHCI_TL_CmdAvailable;
if(StatusNotCallBackFunction != 0)
{
StatusNotCallBackFunction( SHCI_TL_CmdAvailable );
}
}
return;
}
static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt)
{
shci_cmd_resp_release(0); /**< Notify the application the Cmd response has been received */
return;
}
static void TlUserEvtReceived(TL_EvtPacket_t *shcievt)
{
LST_insert_tail(&SHciAsynchEventQueue, (tListNode *)shcievt);
shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */
return;
}
// void shci_register_io_bus(tSHciIO* fops)
// {
// /* Register IO bus services */
// fops->Init = TL_SYS_Init;
// fops->Send = TL_SYS_SendCmd;
//
// return;
// }
/**
******************************************************************************
* @file shci.c
* @author MCD Application Team
* @brief System HCI command implementation
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"
#include "stm_list.h"
#include "shci_tl.h"
/* Private typedef -----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/**
* The default System HCI layer timeout is set to 33s
*/
#define SHCI_TL_DEFAULT_TIMEOUT (33000)
/* Private macros ------------------------------------------------------------*/
/* Public variables ---------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/**
* START of Section SYSTEM_DRIVER_CONTEXT
*/
/* This section is unused and generates warning. Don't use. */
static tListNode SHciAsynchEventQueue;
static volatile SHCI_TL_CmdStatus_t SHCICmdStatus;
static TL_CmdPacket_t *pCmdBuffer;
SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow;
/**
* END of Section SYSTEM_DRIVER_CONTEXT
*/
static tSHciContext shciContext;
static void (* StatusNotCallBackFunction) (SHCI_TL_CmdStatus_t status);
/* Private function prototypes -----------------------------------------------*/
static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus);
static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt);
static void TlUserEvtReceived(TL_EvtPacket_t *shcievt);
static void TlInit( TL_CmdPacket_t * p_cmdbuffer );
/* Interface ------- ---------------------------------------------------------*/
void shci_init(void(* UserEvtRx)(void* pData), void* pConf)
{
StatusNotCallBackFunction = ((SHCI_TL_HciInitConf_t *)pConf)->StatusNotCallBack;
shciContext.UserEvtRx = UserEvtRx;
shci_register_io_bus (&shciContext.io);
TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer));
return;
}
void shci_user_evt_proc(void)
{
TL_EvtPacket_t *phcievtbuffer;
tSHCI_UserEvtRxParam UserEvtRxParam;
/**
* Up to release version v1.2.0, a while loop was implemented to read out events from the queue as long as
* it is not empty. However, in a bare metal implementation, this leads to calling in a "blocking" mode
* shci_user_evt_proc() as long as events are received without giving the opportunity to run other tasks
* in the background.
* From now, the events are reported one by one. When it is checked there is still an event pending in the queue,
* a request to the user is made to call again shci_user_evt_proc().
* This gives the opportunity to the application to run other background tasks between each event.
*/
/**
* It is more secure to use LST_remove_head()/LST_insert_head() compare to LST_get_next_node()/LST_remove_node()
* in case the user overwrite the header where the next/prev pointers are located
*/
if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable))
{
LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer );
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
if (shciContext.UserEvtRx != NULL)
{
UserEvtRxParam.pckt = phcievtbuffer;
shciContext.UserEvtRx((void *)&UserEvtRxParam);
SHCI_TL_UserEventFlow = UserEvtRxParam.status;
}
if(SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)
{
TL_MM_EvtDone( phcievtbuffer );
}
else
{
/**
* put back the event in the queue
*/
LST_insert_head ( &SHciAsynchEventQueue, (tListNode *)phcievtbuffer );
}
}
if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable))
{
shci_notify_asynch_evt((void*) &SHciAsynchEventQueue);
}
return;
}
void shci_resume_flow( void )
{
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
/**
* It is better to go through the background process as it is not sure from which context this API may
* be called
*/
shci_notify_asynch_evt((void*) &SHciAsynchEventQueue);
return;
}
void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp )
{
Cmd_SetStatus(SHCI_TL_CmdBusy);
pCmdBuffer->cmdserial.cmd.cmdcode = cmd_code;
pCmdBuffer->cmdserial.cmd.plen = len_cmd_payload;
memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload );
shciContext.io.Send(0,0);
shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT);
/**
* The command complete of a system command does not have the header
* It starts immediately with the evtserial field
*/
memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE );
Cmd_SetStatus(SHCI_TL_CmdAvailable);
return;
}
/* Private functions ---------------------------------------------------------*/
static void TlInit( TL_CmdPacket_t * p_cmdbuffer )
{
TL_SYS_InitConf_t Conf;
pCmdBuffer = p_cmdbuffer;
LST_init_head (&SHciAsynchEventQueue);
Cmd_SetStatus(SHCI_TL_CmdAvailable);
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
/* Initialize low level driver */
if (shciContext.io.Init)
{
Conf.p_cmdbuffer = (uint8_t *)p_cmdbuffer;
Conf.IoBusCallBackCmdEvt = TlCmdEvtReceived;
Conf.IoBusCallBackUserEvt = TlUserEvtReceived;
shciContext.io.Init(&Conf);
}
return;
}
static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus)
{
if(shcicmdstatus == SHCI_TL_CmdBusy)
{
if(StatusNotCallBackFunction != 0)
{
StatusNotCallBackFunction( SHCI_TL_CmdBusy );
}
SHCICmdStatus = SHCI_TL_CmdBusy;
}
else
{
SHCICmdStatus = SHCI_TL_CmdAvailable;
if(StatusNotCallBackFunction != 0)
{
StatusNotCallBackFunction( SHCI_TL_CmdAvailable );
}
}
return;
}
static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt)
{
shci_cmd_resp_release(0); /**< Notify the application the Cmd response has been received */
return;
}
static void TlUserEvtReceived(TL_EvtPacket_t *shcievt)
{
LST_insert_tail(&SHciAsynchEventQueue, (tListNode *)shcievt);
shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */
return;
}

View File

@ -1,167 +1,170 @@
/**
******************************************************************************
* @file shci_tl.h
* @author MCD Application Team
* @brief System HCI command header for the system channel
******************************************************************************
* @attention
*
* <h2><center>&copy; 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 __SHCI_TL_H_
#define __SHCI_TL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "tl.h"
/* Exported defines -----------------------------------------------------------*/
typedef enum
{
SHCI_TL_UserEventFlow_Disable,
SHCI_TL_UserEventFlow_Enable,
} SHCI_TL_UserEventFlowStatus_t;
typedef enum
{
SHCI_TL_CmdBusy,
SHCI_TL_CmdAvailable
} SHCI_TL_CmdStatus_t;
/**
* @brief Structure used to manage the BUS IO operations.
* All the structure fields will point to functions defined at user level.
* @{
*/
typedef struct
{
int32_t (* Init) (void* pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */
int32_t (* DeInit) (void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */
int32_t (* Reset) (void); /**< Pointer to SHCI TL function for the IO Bus reset */
int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */
int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */
int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */
int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */
} tSHciIO;
/**
* @}
*/
/**
* @brief Contain the SHCI context
* @{
*/
typedef struct
{
tSHciIO io; /**< Manage the BUS IO operations */
void (* UserEvtRx) (void * pData); /**< User System events callback function pointer */
} tSHciContext;
typedef struct
{
SHCI_TL_UserEventFlowStatus_t status;
TL_EvtPacket_t *pckt;
} tSHCI_UserEvtRxParam;
typedef struct
{
uint8_t *p_cmdbuffer;
void (* StatusNotCallBack) (SHCI_TL_CmdStatus_t status);
} SHCI_TL_HciInitConf_t;
/**
* shci_send
* @brief Send an System HCI Command
*
* @param : None
* @retval : None
*/
void shci_send( TL_CmdPacket_t * p_cmd, TL_EvtPacket_t * p_rsp );
/**
* @brief Register IO bus services.
* @param fops The SHCI IO structure managing the IO BUS
* @retval None
*/
void shci_register_io_bus(tSHciIO* fops);
/**
* @brief Interrupt service routine that must be called when the system channel
* reports a packet has been received
*
* @param pdata Packet or event pointer
* @retval None
*/
void shci_notify_asynch_evt(void* pdata);
/**
* @brief This function resume the User Event Flow which has been stopped on return
* from UserEvtRx() when the User Event has not been processed.
*
* @param None
* @retval None
*/
void shci_resume_flow(void);
/**
* @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().
* It is called from the same context the System HCI command has been sent.
*
* @param timeout: Waiting timeout
* @retval None
*/
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.
*
* @param flag: Release flag
* @retval None
*/
void shci_cmd_resp_release(uint32_t flag);
/**
* @brief This process shall be called each time the shci_notify_asynch_evt notification is received
*
* @param None
* @retval None
*/
void shci_user_evt_proc(void);
/**
* @brief Initialize the System Host Controller Interface.
* This function must be called before any communication on the System Channel
*
* @param pData: System events callback function pointer
* This callback is triggered when an user event is received on
* the System Channel from CPU2.
* @param pConf: Configuration structure pointer
* @retval None
*/
void shci_init(void(* UserEvtRx)(void* pData), void* pConf);
#ifdef __cplusplus
}
#endif
#endif /* __SHCI_TL_H_ */
/**
******************************************************************************
* @file shci_tl.h
* @author MCD Application Team
* @brief System HCI command header for the system channel
******************************************************************************
* @attention
*
* <h2><center>&copy; 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 __SHCI_TL_H_
#define __SHCI_TL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "tl.h"
/* Exported defines -----------------------------------------------------------*/
typedef enum
{
SHCI_TL_UserEventFlow_Disable,
SHCI_TL_UserEventFlow_Enable,
} SHCI_TL_UserEventFlowStatus_t;
typedef enum
{
SHCI_TL_CmdBusy,
SHCI_TL_CmdAvailable
} SHCI_TL_CmdStatus_t;
/**
* @brief Structure used to manage the BUS IO operations.
* All the structure fields will point to functions defined at user level.
* @{
*/
typedef struct
{
int32_t (* Init) (void* pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */
int32_t (* DeInit) (void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */
int32_t (* Reset) (void); /**< Pointer to SHCI TL function for the IO Bus reset */
int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */
int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */
int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */
int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */
} tSHciIO;
/**
* @}
*/
/**
* @brief Contain the SHCI context
* @{
*/
typedef struct
{
tSHciIO io; /**< Manage the BUS IO operations */
void (* UserEvtRx) (void * pData); /**< User System events callback function pointer */
} tSHciContext;
typedef struct
{
SHCI_TL_UserEventFlowStatus_t status;
TL_EvtPacket_t *pckt;
} tSHCI_UserEvtRxParam;
typedef struct
{
uint8_t *p_cmdbuffer;
void (* StatusNotCallBack) (SHCI_TL_CmdStatus_t status);
} SHCI_TL_HciInitConf_t;
/**
* shci_send
* @brief Send an System HCI Command
*
* @param : cmd_code = Opcode of the command
* @param : len_cmd_payload = Length of the command payload
* @param : p_cmd_payload = Address of the command payload
* @param : p_rsp_status = Address of the full buffer holding the command complete event
* @retval : None
*/
void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp_status );
/**
* @brief Register IO bus services.
* @param fops The SHCI IO structure managing the IO BUS
* @retval None
*/
void shci_register_io_bus(tSHciIO* fops);
/**
* @brief Interrupt service routine that must be called when the system channel
* reports a packet has been received
*
* @param pdata Packet or event pointer
* @retval None
*/
void shci_notify_asynch_evt(void* pdata);
/**
* @brief This function resume the User Event Flow which has been stopped on return
* from UserEvtRx() when the User Event has not been processed.
*
* @param None
* @retval None
*/
void shci_resume_flow(void);
/**
* @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().
* It is called from the same context the System HCI command has been sent.
*
* @param timeout: Waiting timeout
* @retval None
*/
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.
*
* @param flag: Release flag
* @retval None
*/
void shci_cmd_resp_release(uint32_t flag);
/**
* @brief This process shall be called each time the shci_notify_asynch_evt notification is received
*
* @param None
* @retval None
*/
void shci_user_evt_proc(void);
/**
* @brief Initialize the System Host Controller Interface.
* This function must be called before any communication on the System Channel
*
* @param pData: System events callback function pointer
* This callback is triggered when an user event is received on
* the System Channel from CPU2.
* @param pConf: Configuration structure pointer
* @retval None
*/
void shci_init(void(* UserEvtRx)(void* pData), void* pConf);
#ifdef __cplusplus
}
#endif
#endif /* __SHCI_TL_H_ */

View File

@ -1,170 +1,170 @@
/**
******************************************************************************
* @file stm32_wpan_common.h
* @author MCD Application Team
* @brief Common file to utilities
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32_WPAN_COMMON_H
#define __STM32_WPAN_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined ( __CC_ARM )
#define __ASM __asm /*!< asm keyword for ARM Compiler */
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
#define __STATIC_INLINE static __inline
#elif defined ( __ICCARM__ )
#define __ASM __asm /*!< asm keyword for IAR Compiler */
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
#define __STATIC_INLINE static inline
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
#define __INLINE inline /*!< inline keyword for GNU Compiler */
#define __STATIC_INLINE static inline
#endif
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
// #include "core_cmFunc.h"
/* -------------------------------- *
* Basic definitions *
* -------------------------------- */
#undef NULL
#define NULL 0
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE (!0)
/* -------------------------------- *
* Critical Section definition *
* -------------------------------- */
#undef BACKUP_PRIMASK
#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
#undef DISABLE_IRQ
#define DISABLE_IRQ() __disable_irq()
#undef RESTORE_PRIMASK
#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
/* -------------------------------- *
* Macro delimiters *
* -------------------------------- */
#undef M_BEGIN
#define M_BEGIN do {
#undef M_END
#define M_END } while(0)
/* -------------------------------- *
* Some useful macro definitions *
* -------------------------------- */
#undef MAX
#define MAX( x, y ) (((x)>(y))?(x):(y))
#undef MIN
#define MIN( x, y ) (((x)<(y))?(x):(y))
#undef MODINC
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
#undef MODDEC
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
#undef MODADD
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
#undef MODSUB
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
#undef ALIGN
#ifdef WIN32
#define ALIGN(n)
#else
#define ALIGN(n) __attribute__((aligned(n)))
#endif
#undef PAUSE
#define PAUSE( t ) M_BEGIN \
volatile int _i; \
for ( _i = t; _i > 0; _i -- ); \
M_END
#undef DIVF
#define DIVF( x, y ) ((x)/(y))
#undef DIVC
#define DIVC( x, y ) (((x)+(y)-1)/(y))
#undef DIVR
#define DIVR( x, y ) (((x)+((y)/2))/(y))
#undef SHRR
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
#undef BITN
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
#undef BITNSET
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
/* -------------------------------- *
* Section attribute *
* -------------------------------- */
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
/* ----------------------------------- *
* Packed usage (compiler dependent) *
* ----------------------------------- */
#undef PACKED__
#undef PACKED_STRUCT
#if defined ( __CC_ARM )
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#else
#define PACKED__(TYPE) __packed TYPE
#define PACKED_STRUCT PACKED__(struct)
#endif
#elif defined ( __GNUC__ )
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#elif defined (__ICCARM__)
#define PACKED_STRUCT __packed struct
#elif
#define PACKED_STRUCT __packed struct
#endif
#ifdef __cplusplus
}
#endif
#endif /*__STM32_WPAN_COMMON_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file stm32_wpan_common.h
* @author MCD Application Team
* @brief Common file to utilities
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32_WPAN_COMMON_H
#define __STM32_WPAN_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined ( __CC_ARM )
#define __ASM __asm /*!< asm keyword for ARM Compiler */
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
#define __STATIC_INLINE static __inline
#elif defined ( __ICCARM__ )
#define __ASM __asm /*!< asm keyword for IAR Compiler */
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
#define __STATIC_INLINE static inline
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
#define __INLINE inline /*!< inline keyword for GNU Compiler */
#define __STATIC_INLINE static inline
#endif
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "cmsis_compiler.h"
/* -------------------------------- *
* Basic definitions *
* -------------------------------- */
#undef NULL
#define NULL 0U
#undef FALSE
#define FALSE 0U
#undef TRUE
#define TRUE (!0U)
/* -------------------------------- *
* Critical Section definition *
* -------------------------------- */
#undef BACKUP_PRIMASK
#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
#undef DISABLE_IRQ
#define DISABLE_IRQ() __disable_irq()
#undef RESTORE_PRIMASK
#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
/* -------------------------------- *
* Macro delimiters *
* -------------------------------- */
#undef M_BEGIN
#define M_BEGIN do {
#undef M_END
#define M_END } while(0)
/* -------------------------------- *
* Some useful macro definitions *
* -------------------------------- */
#undef MAX
#define MAX( x, y ) (((x)>(y))?(x):(y))
#undef MIN
#define MIN( x, y ) (((x)<(y))?(x):(y))
#undef MODINC
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
#undef MODDEC
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
#undef MODADD
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
#undef MODSUB
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
#undef ALIGN
#ifdef WIN32
#define ALIGN(n)
#else
#define ALIGN(n) __attribute__((aligned(n)))
#endif
#undef PAUSE
#define PAUSE( t ) M_BEGIN \
volatile int _i; \
for ( _i = t; _i > 0; _i -- ); \
M_END
#undef DIVF
#define DIVF( x, y ) ((x)/(y))
#undef DIVC
#define DIVC( x, y ) (((x)+(y)-1)/(y))
#undef DIVR
#define DIVR( x, y ) (((x)+((y)/2))/(y))
#undef SHRR
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
#undef BITN
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
#undef BITNSET
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
/* -------------------------------- *
* Section attribute *
* -------------------------------- */
#undef PLACE_IN_SECTION
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
/* ----------------------------------- *
* Packed usage (compiler dependent) *
* ----------------------------------- */
#undef PACKED__
#undef PACKED_STRUCT
#if defined ( __CC_ARM )
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U)
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#else
#define PACKED__(TYPE) __packed TYPE
#define PACKED_STRUCT PACKED__(struct)
#endif
#elif defined ( __GNUC__ )
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#elif defined (__ICCARM__)
#define PACKED_STRUCT __packed struct
#elif
#define PACKED_STRUCT __packed struct
#endif
#ifdef __cplusplus
}
#endif
#endif /*__STM32_WPAN_COMMON_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,279 +1,312 @@
/**
******************************************************************************
* @file tl.h
* @author MCD Application Team
* @brief Header for tl module
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TL_H
#define __TL_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#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_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_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 */
typedef PACKED_STRUCT
{
uint32_t *next;
uint32_t *prev;
} TL_PacketHeader_t;
/*******************************************************************************
* Event type
*/
/**
* This the payload of TL_Evt_t for a command status event
*/
typedef PACKED_STRUCT
{
uint8_t status;
uint8_t numcmd;
uint16_t cmdcode;
} TL_CsEvt_t;
/**
* This the payload of TL_Evt_t for a command complete event
*/
typedef PACKED_STRUCT
{
uint8_t numcmd;
uint16_t cmdcode;
uint8_t payload[1];
} TL_CcEvt_t;
/**
* This the payload of TL_Evt_t for an asynchronous event
*/
typedef PACKED_STRUCT
{
uint16_t subevtcode;
uint8_t payload[1];
} TL_AsynchEvt_t;
typedef PACKED_STRUCT
{
uint8_t evtcode;
uint8_t plen;
uint8_t payload[1];
} TL_Evt_t;
typedef PACKED_STRUCT
{
uint8_t type;
TL_Evt_t evt;
} TL_EvtSerial_t;
/**
* This format shall be used for all events (asynchronous and command response) reported
* by the CPU2 except for the command response of a system command where the header is not there
* and the format to be used shall be TL_EvtSerial_t.
* Note: Be careful that the asynchronous events reported by the CPU2 on the system channel do
* include the header and shall use TL_EvtPacket_t format. Only the command response format on the
* system channel is different.
*/
typedef PACKED_STRUCT
{
TL_PacketHeader_t header;
TL_EvtSerial_t evtserial;
} TL_EvtPacket_t;
/*****************************************************************************************
* Command type
*/
typedef PACKED_STRUCT
{
uint16_t cmdcode;
uint8_t plen;
uint8_t payload[255];
} TL_Cmd_t;
typedef PACKED_STRUCT
{
uint8_t type;
TL_Cmd_t cmd;
} TL_CmdSerial_t;
typedef PACKED_STRUCT
{
TL_PacketHeader_t header;
TL_CmdSerial_t cmdserial;
} TL_CmdPacket_t;
/*****************************************************************************************
* HCI ACL DATA type
*/
typedef PACKED_STRUCT
{
uint8_t type;
uint16_t handle;
uint16_t length;
uint8_t acl_data[1];
} TL_AclDataSerial_t;
typedef PACKED_STRUCT
{
TL_PacketHeader_t header;
TL_AclDataSerial_t AclDataSerial;
} TL_AclDataPacket_t;
typedef struct
{
uint8_t *p_BleSpareEvtBuffer;
uint8_t *p_SystemSpareEvtBuffer;
uint8_t *p_AsynchEvtPool;
uint32_t AsynchEvtPoolSize;
uint8_t *p_TracesEvtPool;
uint32_t TracesEvtPoolSize;
} TL_MM_Config_t;
typedef struct
{
uint8_t *p_ThreadOtCmdRspBuffer;
uint8_t *p_ThreadCliRspBuffer;
uint8_t *p_ThreadNotAckBuffer;
} TL_TH_Config_t;
typedef struct
{
uint8_t *p_Mac_802_15_4_CmdRspBuffer;
uint8_t *p_Mac_802_15_4_NotAckBuffer;
} TL_MAC_802_15_4_Config_t;
/**
* @brief Contain the BLE HCI Init Configuration
* @{
*/
typedef struct
{
void (* IoBusEvtCallBack) ( TL_EvtPacket_t *phcievt );
void (* IoBusAclDataTxAck) ( void );
uint8_t *p_cmdbuffer;
uint8_t *p_AclDataBuffer;
} TL_BLE_InitConf_t;
/**
* @brief Contain the SYSTEM HCI Init Configuration
* @{
*/
typedef struct
{
void (* IoBusCallBackCmdEvt) (TL_EvtPacket_t *phcievt);
void (* IoBusCallBackUserEvt) (TL_EvtPacket_t *phcievt);
uint8_t *p_cmdbuffer;
} TL_SYS_InitConf_t;
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/******************************************************************************
* GENERAL
******************************************************************************/
void TL_Enable( void );
void TL_Init( void );
/******************************************************************************
* BLE
******************************************************************************/
int32_t TL_BLE_Init( void* pConf );
int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size );
int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size );
/******************************************************************************
* SYSTEM
******************************************************************************/
int32_t TL_SYS_Init( void* pConf );
int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size );
/******************************************************************************
* THREAD
******************************************************************************/
void TL_THREAD_Init( TL_TH_Config_t *p_Config );
void TL_OT_SendCmd( void );
void TL_CLI_SendCmd( void );
void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_THREAD_SendAck ( void );
void TL_THREAD_CliSendAck ( void );
void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer );
/******************************************************************************
* MEMORY MANAGER
******************************************************************************/
void TL_MM_Init( TL_MM_Config_t *p_Config );
void TL_MM_EvtDone( TL_EvtPacket_t * hcievt );
/******************************************************************************
* TRACES
******************************************************************************/
void TL_TRACES_Init( void );
void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt );
/******************************************************************************
* MAC 802.15.4
******************************************************************************/
void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config );
void TL_MAC_802_15_4_SendCmd( void );
void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_MAC_802_15_4_SendAck ( void );
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*__TL_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file tl.h
* @author MCD Application Team
* @brief Header for tl module
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TL_H
#define __TL_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#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_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_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 */
typedef PACKED_STRUCT
{
uint32_t *next;
uint32_t *prev;
} TL_PacketHeader_t;
/*******************************************************************************
* Event type
*/
/**
* This the payload of TL_Evt_t for a command status event
*/
typedef PACKED_STRUCT
{
uint8_t status;
uint8_t numcmd;
uint16_t cmdcode;
} TL_CsEvt_t;
/**
* This the payload of TL_Evt_t for a command complete event
*/
typedef PACKED_STRUCT
{
uint8_t numcmd;
uint16_t cmdcode;
uint8_t payload[1];
} TL_CcEvt_t;
/**
* This the payload of TL_Evt_t for an asynchronous event
*/
typedef PACKED_STRUCT
{
uint16_t subevtcode;
uint8_t payload[1];
} TL_AsynchEvt_t;
typedef PACKED_STRUCT
{
uint8_t evtcode;
uint8_t plen;
uint8_t payload[1];
} TL_Evt_t;
typedef PACKED_STRUCT
{
uint8_t type;
TL_Evt_t evt;
} TL_EvtSerial_t;
/**
* This format shall be used for all events (asynchronous and command response) reported
* by the CPU2 except for the command response of a system command where the header is not there
* and the format to be used shall be TL_EvtSerial_t.
* Note: Be careful that the asynchronous events reported by the CPU2 on the system channel do
* include the header and shall use TL_EvtPacket_t format. Only the command response format on the
* system channel is different.
*/
typedef PACKED_STRUCT
{
TL_PacketHeader_t header;
TL_EvtSerial_t evtserial;
} TL_EvtPacket_t;
/*****************************************************************************************
* Command type
*/
typedef PACKED_STRUCT
{
uint16_t cmdcode;
uint8_t plen;
uint8_t payload[255];
} TL_Cmd_t;
typedef PACKED_STRUCT
{
uint8_t type;
TL_Cmd_t cmd;
} TL_CmdSerial_t;
typedef PACKED_STRUCT
{
TL_PacketHeader_t header;
TL_CmdSerial_t cmdserial;
} TL_CmdPacket_t;
/*****************************************************************************************
* HCI ACL DATA type
*/
typedef PACKED_STRUCT
{
uint8_t type;
uint16_t handle;
uint16_t length;
uint8_t acl_data[1];
} TL_AclDataSerial_t;
typedef PACKED_STRUCT
{
TL_PacketHeader_t header;
TL_AclDataSerial_t AclDataSerial;
} TL_AclDataPacket_t;
typedef struct
{
uint8_t *p_BleSpareEvtBuffer;
uint8_t *p_SystemSpareEvtBuffer;
uint8_t *p_AsynchEvtPool;
uint32_t AsynchEvtPoolSize;
uint8_t *p_TracesEvtPool;
uint32_t TracesEvtPoolSize;
} TL_MM_Config_t;
typedef struct
{
uint8_t *p_ThreadOtCmdRspBuffer;
uint8_t *p_ThreadCliRspBuffer;
uint8_t *p_ThreadNotAckBuffer;
} TL_TH_Config_t;
typedef struct
{
uint8_t *p_LldTestsCliRspBuffer;
uint8_t *p_LldTestsNotAckBuffer;
} TL_LLD_tests_Config_t;
typedef struct
{
uint8_t *p_Mac_802_15_4_CmdRspBuffer;
uint8_t *p_Mac_802_15_4_NotAckBuffer;
} TL_MAC_802_15_4_Config_t;
typedef struct
{
uint8_t *p_ZigbeeOtCmdRspBuffer;
uint8_t *p_ZigbeeNotAckBuffer;
uint8_t *p_ZigbeeLoggingBuffer;
} TL_ZIGBEE_Config_t;
/**
* @brief Contain the BLE HCI Init Configuration
* @{
*/
typedef struct
{
void (* IoBusEvtCallBack) ( TL_EvtPacket_t *phcievt );
void (* IoBusAclDataTxAck) ( void );
uint8_t *p_cmdbuffer;
uint8_t *p_AclDataBuffer;
} TL_BLE_InitConf_t;
/**
* @brief Contain the SYSTEM HCI Init Configuration
* @{
*/
typedef struct
{
void (* IoBusCallBackCmdEvt) (TL_EvtPacket_t *phcievt);
void (* IoBusCallBackUserEvt) (TL_EvtPacket_t *phcievt);
uint8_t *p_cmdbuffer;
} TL_SYS_InitConf_t;
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/******************************************************************************
* GENERAL
******************************************************************************/
void TL_Enable( void );
void TL_Init( void );
/******************************************************************************
* BLE
******************************************************************************/
int32_t TL_BLE_Init( void* pConf );
int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size );
int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size );
/******************************************************************************
* SYSTEM
******************************************************************************/
int32_t TL_SYS_Init( void* pConf );
int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size );
/******************************************************************************
* THREAD
******************************************************************************/
void TL_THREAD_Init( TL_TH_Config_t *p_Config );
void TL_OT_SendCmd( void );
void TL_CLI_SendCmd( void );
void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_THREAD_SendAck ( void );
void TL_THREAD_CliSendAck ( void );
void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer );
/******************************************************************************
* 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 );
/******************************************************************************
* MEMORY MANAGER
******************************************************************************/
void TL_MM_Init( TL_MM_Config_t *p_Config );
void TL_MM_EvtDone( TL_EvtPacket_t * hcievt );
/******************************************************************************
* TRACES
******************************************************************************/
void TL_TRACES_Init( void );
void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt );
/******************************************************************************
* MAC 802.15.4
******************************************************************************/
void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config );
void TL_MAC_802_15_4_SendCmd( void );
void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_MAC_802_15_4_SendAck ( void );
/******************************************************************************
* ZIGBEE
******************************************************************************/
void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config );
void TL_ZIGBEE_SendAppliCmdToM0( void );
void TL_ZIGBEE_SendAckAfterAppliNotifFromM0 ( 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 );
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*__TL_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,44 +1,47 @@
/**
******************************************************************************
* @file tl_if.c
* @author MCD Application Team
* @brief Transport layer interface to BLE
******************************************************************************
* @attention
*
* <h2><center>&copy; 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 "hci_tl.h"
#include "shci_tl.h"
#include "tl.h"
void hci_register_io_bus(tHciIO* fops)
{
/* Register IO bus services */
fops->Init = TL_BLE_Init;
fops->Send = TL_BLE_SendCmd;
return;
}
void shci_register_io_bus(tSHciIO* fops)
{
/* Register IO bus services */
fops->Init = TL_SYS_Init;
fops->Send = TL_SYS_SendCmd;
return;
}
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file tl_if.c
* @author MCD Application Team
* @brief Transport layer interface to BLE
******************************************************************************
* @attention
*
* <h2><center>&copy; 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 "app_common.h"
#include "hci_tl.h"
#include "shci_tl.h"
#include "tl.h"
void hci_register_io_bus(tHciIO* fops)
{
/* Register IO bus services */
fops->Init = TL_BLE_Init;
fops->Send = TL_BLE_SendCmd;
return;
}
void shci_register_io_bus(tSHciIO* fops)
{
/* Register IO bus services */
fops->Init = TL_SYS_Init;
fops->Send = TL_SYS_SendCmd;
return;
}
/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/

View File

@ -1,416 +1,555 @@
/**
******************************************************************************
* @file tl_mbox.c
* @author MCD Application Team
* @brief Transport layer for the mailbox interface
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"
#include "hw.h"
#include "stm_list.h"
#include "tl.h"
#include "mbox_def.h"
/* Private typedef -----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/**< reference table */
PLACE_IN_SECTION("MAPPING_TABLE") static volatile MB_RefTable_t TL_RefTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_DeviceInfoTable_t TL_DeviceInfoTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleTable_t TL_BleTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ThreadTable_t TL_ThreadTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table;
/**< tables */
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)];
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue;
static tListNode LocalFreeBufQueue;
static void (* BLE_IoBusEvtCallBackFunction) (TL_EvtPacket_t *phcievt);
static void (* BLE_IoBusAclDataTxAck) ( void );
static void (* SYS_CMD_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt);
static void (* SYS_EVT_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt);
/* Global variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void SendFreeBuf( void );
/* Public Functions Definition ------------------------------------------------------*/
/******************************************************************************
* GENERAL
******************************************************************************/
void TL_Enable( void )
{
HW_IPCC_Enable();
return;
}
void TL_Init( void )
{
TL_RefTable.p_device_info_table = &TL_DeviceInfoTable;
TL_RefTable.p_ble_table = &TL_BleTable;
TL_RefTable.p_thread_table = &TL_ThreadTable;
TL_RefTable.p_sys_table = &TL_SysTable;
TL_RefTable.p_mem_manager_table = &TL_MemManagerTable;
TL_RefTable.p_traces_table = &TL_TracesTable;
TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table;
HW_IPCC_Init();
return;
}
/******************************************************************************
* BLE
******************************************************************************/
int32_t TL_BLE_Init( void* pConf )
{
MB_BleTable_t * p_bletable;
TL_BLE_InitConf_t *pInitHciConf = (TL_BLE_InitConf_t *) pConf;
LST_init_head (&EvtQueue);
p_bletable = TL_RefTable.p_ble_table;
p_bletable->pcmd_buffer = pInitHciConf->p_cmdbuffer;
p_bletable->phci_acl_data_buffer = pInitHciConf->p_AclDataBuffer;
p_bletable->pcs_buffer = (uint8_t*)CsBuffer;
p_bletable->pevt_queue = (uint8_t*)&EvtQueue;
HW_IPCC_BLE_Init();
BLE_IoBusEvtCallBackFunction = pInitHciConf->IoBusEvtCallBack;
BLE_IoBusAclDataTxAck = pInitHciConf->IoBusAclDataTxAck;
return 0;
}
int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size )
{
((TL_CmdPacket_t*)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE;
HW_IPCC_BLE_SendCmd();
return 0;
}
void HW_IPCC_BLE_RxEvtNot(void)
{
TL_EvtPacket_t *phcievt;
while(LST_is_empty(&EvtQueue) == FALSE)
{
LST_remove_head (&EvtQueue, (tListNode **)&phcievt);
BLE_IoBusEvtCallBackFunction(phcievt);
}
return;
}
int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size )
{
((TL_AclDataPacket_t *)(TL_RefTable.p_ble_table->phci_acl_data_buffer))->AclDataSerial.type = TL_ACL_DATA_PKT_TYPE;
HW_IPCC_BLE_SendAclData();
return 0;
}
void HW_IPCC_BLE_AclDataAckNot(void)
{
BLE_IoBusAclDataTxAck( );
return;
}
/******************************************************************************
* SYSTEM
******************************************************************************/
int32_t TL_SYS_Init( void* pConf )
{
MB_SysTable_t * p_systable;
TL_SYS_InitConf_t *pInitHciConf = (TL_SYS_InitConf_t *) pConf;
LST_init_head (&SystemEvtQueue);
p_systable = TL_RefTable.p_sys_table;
p_systable->pcmd_buffer = pInitHciConf->p_cmdbuffer;
p_systable->sys_queue = (uint8_t*)&SystemEvtQueue;
HW_IPCC_SYS_Init();
SYS_CMD_IoBusCallBackFunction = pInitHciConf->IoBusCallBackCmdEvt;
SYS_EVT_IoBusCallBackFunction = pInitHciConf->IoBusCallBackUserEvt;
return 0;
}
int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size )
{
((TL_CmdPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer))->cmdserial.type = TL_SYSCMD_PKT_TYPE;
HW_IPCC_SYS_SendCmd();
return 0;
}
void HW_IPCC_SYS_CmdEvtNot(void)
{
SYS_CMD_IoBusCallBackFunction( (TL_EvtPacket_t*)(TL_RefTable.p_sys_table->pcmd_buffer) );
return;
}
void HW_IPCC_SYS_EvtNot( void )
{
TL_EvtPacket_t *p_evt;
while(LST_is_empty(&SystemEvtQueue) == FALSE)
{
LST_remove_head (&SystemEvtQueue, (tListNode **)&p_evt);
SYS_EVT_IoBusCallBackFunction( p_evt );
}
return;
}
/******************************************************************************
* THREAD
******************************************************************************/
void TL_THREAD_Init( TL_TH_Config_t *p_Config )
{
MB_ThreadTable_t * p_thread_table;
p_thread_table = TL_RefTable.p_thread_table;
p_thread_table->clicmdrsp_buffer = p_Config->p_ThreadCliRspBuffer;
p_thread_table->otcmdrsp_buffer = p_Config->p_ThreadOtCmdRspBuffer;
p_thread_table->notack_buffer = p_Config->p_ThreadNotAckBuffer;
HW_IPCC_THREAD_Init();
return;
}
void TL_OT_SendCmd( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->otcmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE;
HW_IPCC_OT_SendCmd();
return;
}
void TL_CLI_SendCmd( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE;
HW_IPCC_CLI_SendCmd();
return;
}
void TL_THREAD_SendAck ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_THREAD_SendAck();
return;
}
void TL_THREAD_CliSendAck ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_THREAD_CliSendAck();
return;
}
void HW_IPCC_OT_CmdEvtNot(void)
{
TL_OT_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->otcmdrsp_buffer) );
return;
}
void HW_IPCC_THREAD_EvtNot( void )
{
TL_THREAD_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->notack_buffer) );
return;
}
void HW_IPCC_THREAD_CliEvtNot( void )
{
TL_THREAD_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->clicmdrsp_buffer) );
return;
}
__weak void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
__weak void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ){};
__weak void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ){};
#ifdef MAC_802_15_4_WB
/******************************************************************************
* MAC 802.15.4
******************************************************************************/
void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config )
{
MB_Mac_802_15_4_t * p_mac_802_15_4_table;
p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table;
p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer;
p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer;
HW_IPCC_MAC_802_15_4_Init();
return;
}
void TL_MAC_802_15_4_SendCmd( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE;
HW_IPCC_MAC_802_15_4_SendCmd();
return;
}
void TL_MAC_802_15_4_SendAck ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_MAC_802_15_4_SendAck();
return;
}
void HW_IPCC_MAC_802_15_4_CmdEvtNot(void)
{
TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) );
return;
}
void HW_IPCC_MAC_802_15_4_EvtNot( void )
{
TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) );
return;
}
__weak void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
__weak void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){};
#endif
/******************************************************************************
* MEMORY MANAGER
******************************************************************************/
void TL_MM_Init( TL_MM_Config_t *p_Config )
{
static MB_MemManagerTable_t * p_mem_manager_table;
LST_init_head (&FreeBufQueue);
LST_init_head (&LocalFreeBufQueue);
p_mem_manager_table = TL_RefTable.p_mem_manager_table;
p_mem_manager_table->blepool = p_Config->p_AsynchEvtPool;
p_mem_manager_table->blepoolsize = p_Config->AsynchEvtPoolSize;
p_mem_manager_table->pevt_free_buffer_queue = (uint8_t*)&FreeBufQueue;
p_mem_manager_table->spare_ble_buffer = p_Config->p_BleSpareEvtBuffer;
p_mem_manager_table->spare_sys_buffer = p_Config->p_SystemSpareEvtBuffer;
p_mem_manager_table->traces_evt_pool = p_Config->p_TracesEvtPool;
p_mem_manager_table->tracespoolsize = p_Config->TracesEvtPoolSize;
return;
}
void TL_MM_EvtDone(TL_EvtPacket_t * phcievt)
{
LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt);
HW_IPCC_MM_SendFreeBuf( SendFreeBuf );
return;
}
static void SendFreeBuf( void )
{
tListNode *p_node;
while ( FALSE == LST_is_empty (&LocalFreeBufQueue) )
{
LST_remove_head( &LocalFreeBufQueue, (tListNode **)&p_node );
LST_insert_tail( (tListNode*)(TL_RefTable.p_mem_manager_table->pevt_free_buffer_queue), p_node );
}
return;
}
/******************************************************************************
* TRACES
******************************************************************************/
void TL_TRACES_Init( void )
{
LST_init_head (&TracesEvtQueue);
TL_RefTable.p_traces_table->traces_queue = (uint8_t*)&TracesEvtQueue;
HW_IPCC_TRACES_Init();
return;
}
void HW_IPCC_TRACES_EvtNot(void)
{
TL_EvtPacket_t *phcievt;
while(LST_is_empty(&TracesEvtQueue) == FALSE)
{
LST_remove_head (&TracesEvtQueue, (tListNode **)&phcievt);
TL_TRACES_EvtReceived( phcievt );
}
return;
}
__weak void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ){};
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file tl_mbox.c
* @author MCD Application Team
* @brief Transport layer for the mailbox interface
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"
#include "hw.h"
#include "stm_list.h"
#include "tl.h"
#include "mbox_def.h"
/* Private typedef -----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/**< reference table */
PLACE_IN_SECTION("MAPPING_TABLE") static volatile MB_RefTable_t TL_RefTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_DeviceInfoTable_t TL_DeviceInfoTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleTable_t TL_BleTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ThreadTable_t TL_ThreadTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldTestsTable_t TL_LldTestsTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table;
/**< tables */
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)];
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue;
static tListNode LocalFreeBufQueue;
static void (* BLE_IoBusEvtCallBackFunction) (TL_EvtPacket_t *phcievt);
static void (* BLE_IoBusAclDataTxAck) ( void );
static void (* SYS_CMD_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt);
static void (* SYS_EVT_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt);
/* Global variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void SendFreeBuf( void );
/* Public Functions Definition ------------------------------------------------------*/
/******************************************************************************
* GENERAL
******************************************************************************/
void TL_Enable( void )
{
HW_IPCC_Enable();
return;
}
void TL_Init( void )
{
TL_RefTable.p_device_info_table = &TL_DeviceInfoTable;
TL_RefTable.p_ble_table = &TL_BleTable;
TL_RefTable.p_thread_table = &TL_ThreadTable;
TL_RefTable.p_lld_tests_table = &TL_LldTestsTable;
TL_RefTable.p_sys_table = &TL_SysTable;
TL_RefTable.p_mem_manager_table = &TL_MemManagerTable;
TL_RefTable.p_traces_table = &TL_TracesTable;
TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table;
TL_RefTable.p_zigbee_table = &TL_Zigbee_Table;
HW_IPCC_Init();
return;
}
/******************************************************************************
* BLE
******************************************************************************/
int32_t TL_BLE_Init( void* pConf )
{
MB_BleTable_t * p_bletable;
TL_BLE_InitConf_t *pInitHciConf = (TL_BLE_InitConf_t *) pConf;
LST_init_head (&EvtQueue);
p_bletable = TL_RefTable.p_ble_table;
p_bletable->pcmd_buffer = pInitHciConf->p_cmdbuffer;
p_bletable->phci_acl_data_buffer = pInitHciConf->p_AclDataBuffer;
p_bletable->pcs_buffer = (uint8_t*)CsBuffer;
p_bletable->pevt_queue = (uint8_t*)&EvtQueue;
HW_IPCC_BLE_Init();
BLE_IoBusEvtCallBackFunction = pInitHciConf->IoBusEvtCallBack;
BLE_IoBusAclDataTxAck = pInitHciConf->IoBusAclDataTxAck;
return 0;
}
int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size )
{
((TL_CmdPacket_t*)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE;
HW_IPCC_BLE_SendCmd();
return 0;
}
void HW_IPCC_BLE_RxEvtNot(void)
{
TL_EvtPacket_t *phcievt;
while(LST_is_empty(&EvtQueue) == FALSE)
{
LST_remove_head (&EvtQueue, (tListNode **)&phcievt);
BLE_IoBusEvtCallBackFunction(phcievt);
}
return;
}
int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size )
{
((TL_AclDataPacket_t *)(TL_RefTable.p_ble_table->phci_acl_data_buffer))->AclDataSerial.type = TL_ACL_DATA_PKT_TYPE;
HW_IPCC_BLE_SendAclData();
return 0;
}
void HW_IPCC_BLE_AclDataAckNot(void)
{
BLE_IoBusAclDataTxAck( );
return;
}
/******************************************************************************
* SYSTEM
******************************************************************************/
int32_t TL_SYS_Init( void* pConf )
{
MB_SysTable_t * p_systable;
TL_SYS_InitConf_t *pInitHciConf = (TL_SYS_InitConf_t *) pConf;
LST_init_head (&SystemEvtQueue);
p_systable = TL_RefTable.p_sys_table;
p_systable->pcmd_buffer = pInitHciConf->p_cmdbuffer;
p_systable->sys_queue = (uint8_t*)&SystemEvtQueue;
HW_IPCC_SYS_Init();
SYS_CMD_IoBusCallBackFunction = pInitHciConf->IoBusCallBackCmdEvt;
SYS_EVT_IoBusCallBackFunction = pInitHciConf->IoBusCallBackUserEvt;
return 0;
}
int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size )
{
((TL_CmdPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer))->cmdserial.type = TL_SYSCMD_PKT_TYPE;
HW_IPCC_SYS_SendCmd();
return 0;
}
void HW_IPCC_SYS_CmdEvtNot(void)
{
SYS_CMD_IoBusCallBackFunction( (TL_EvtPacket_t*)(TL_RefTable.p_sys_table->pcmd_buffer) );
return;
}
void HW_IPCC_SYS_EvtNot( void )
{
TL_EvtPacket_t *p_evt;
while(LST_is_empty(&SystemEvtQueue) == FALSE)
{
LST_remove_head (&SystemEvtQueue, (tListNode **)&p_evt);
SYS_EVT_IoBusCallBackFunction( p_evt );
}
return;
}
/******************************************************************************
* THREAD
******************************************************************************/
#ifdef THREAD_WB
void TL_THREAD_Init( TL_TH_Config_t *p_Config )
{
MB_ThreadTable_t * p_thread_table;
p_thread_table = TL_RefTable.p_thread_table;
p_thread_table->clicmdrsp_buffer = p_Config->p_ThreadCliRspBuffer;
p_thread_table->otcmdrsp_buffer = p_Config->p_ThreadOtCmdRspBuffer;
p_thread_table->notack_buffer = p_Config->p_ThreadNotAckBuffer;
HW_IPCC_THREAD_Init();
return;
}
void TL_OT_SendCmd( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->otcmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE;
HW_IPCC_OT_SendCmd();
return;
}
void TL_CLI_SendCmd( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE;
HW_IPCC_CLI_SendCmd();
return;
}
void TL_THREAD_SendAck ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_THREAD_SendAck();
return;
}
void TL_THREAD_CliSendAck ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_THREAD_CliSendAck();
return;
}
void HW_IPCC_OT_CmdEvtNot(void)
{
TL_OT_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->otcmdrsp_buffer) );
return;
}
void HW_IPCC_THREAD_EvtNot( void )
{
TL_THREAD_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->notack_buffer) );
return;
}
void HW_IPCC_THREAD_CliEvtNot( void )
{
TL_THREAD_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->clicmdrsp_buffer) );
return;
}
__WEAK void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
__WEAK void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ){};
__WEAK void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ){};
#endif /* THREAD_WB */
/******************************************************************************
* LLD 802.15.4
******************************************************************************/
#ifdef LLD_802_15_4_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;
HW_IPCC_LLDTESTS_Init();
return;
}
void TL_LLDTESTS_CliSendCmd( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE;
HW_IPCC_LLDTESTS_CliSendCmd();
return;
}
void TL_LLDTESTS_CliSendAck ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_LLDTESTS_CliSendAck();
return;
}
void HW_IPCC_LLDTESTS_EvtNot( void )
{
TL_LLDTESTS_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_lld_tests_table->notack_buffer) );
return;
}
void HW_IPCC_LLDTESTS_CliEvtNot( void )
{
TL_LLDTESTS_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_lld_tests_table->clicmdrsp_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 */
#ifdef MAC_802_15_4_WB
/******************************************************************************
* MAC 802.15.4
******************************************************************************/
void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config )
{
MB_Mac_802_15_4_t * p_mac_802_15_4_table;
p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table;
p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer;
p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer;
HW_IPCC_MAC_802_15_4_Init();
return;
}
void TL_MAC_802_15_4_SendCmd( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE;
HW_IPCC_MAC_802_15_4_SendCmd();
return;
}
void TL_MAC_802_15_4_SendAck ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_MAC_802_15_4_SendAck();
return;
}
void HW_IPCC_MAC_802_15_4_CmdEvtNot(void)
{
TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) );
return;
}
void HW_IPCC_MAC_802_15_4_EvtNot( void )
{
TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) );
return;
}
__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){};
#endif
#ifdef ZIGBEE_WB
/******************************************************************************
* ZIGBEE
******************************************************************************/
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;
HW_IPCC_ZIGBEE_Init();
return;
}
void TL_ZIGBEE_SendAppliCmdToM0( 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();
return;
}
/* Used to receive an ACK from the M0 */
void HW_IPCC_ZIGBEE_AppliCmdNotification(void)
{
TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) );
return;
}
/* Zigbee callback */
void HW_IPCC_ZIGBEE_AppliAsyncEvtNotification( void )
{
TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) );
return;
}
/* Zigbee logging */
void HW_IPCC_ZIGBEE_AppliAsyncLoggingNotification( void )
{
TL_ZIGBEE_LoggingReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->loggingM0toM4_buffer) );
return;
}
/* Send a Logging ACK to the M0 */
void TL_ZIGBEE_SendAckAfterAppliLoggingFromM0 ( void )
{
((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->loggingM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
HW_IPCC_ZIGBEE_SendLoggingAck();
return;
}
__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){};
#endif
/******************************************************************************
* MEMORY MANAGER
******************************************************************************/
void TL_MM_Init( TL_MM_Config_t *p_Config )
{
static MB_MemManagerTable_t * p_mem_manager_table;
LST_init_head (&FreeBufQueue);
LST_init_head (&LocalFreeBufQueue);
p_mem_manager_table = TL_RefTable.p_mem_manager_table;
p_mem_manager_table->blepool = p_Config->p_AsynchEvtPool;
p_mem_manager_table->blepoolsize = p_Config->AsynchEvtPoolSize;
p_mem_manager_table->pevt_free_buffer_queue = (uint8_t*)&FreeBufQueue;
p_mem_manager_table->spare_ble_buffer = p_Config->p_BleSpareEvtBuffer;
p_mem_manager_table->spare_sys_buffer = p_Config->p_SystemSpareEvtBuffer;
p_mem_manager_table->traces_evt_pool = p_Config->p_TracesEvtPool;
p_mem_manager_table->tracespoolsize = p_Config->TracesEvtPoolSize;
return;
}
void TL_MM_EvtDone(TL_EvtPacket_t * phcievt)
{
LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt);
HW_IPCC_MM_SendFreeBuf( SendFreeBuf );
return;
}
static void SendFreeBuf( void )
{
tListNode *p_node;
while ( FALSE == LST_is_empty (&LocalFreeBufQueue) )
{
LST_remove_head( &LocalFreeBufQueue, (tListNode **)&p_node );
LST_insert_tail( (tListNode*)(TL_RefTable.p_mem_manager_table->pevt_free_buffer_queue), p_node );
}
return;
}
/******************************************************************************
* TRACES
******************************************************************************/
void TL_TRACES_Init( void )
{
LST_init_head (&TracesEvtQueue);
TL_RefTable.p_traces_table->traces_queue = (uint8_t*)&TracesEvtQueue;
HW_IPCC_TRACES_Init();
return;
}
void HW_IPCC_TRACES_EvtNot(void)
{
TL_EvtPacket_t *phcievt;
while(LST_is_empty(&TracesEvtQueue) == FALSE)
{
LST_remove_head (&TracesEvtQueue, (tListNode **)&phcievt);
TL_TRACES_EvtReceived( phcievt );
}
return;
}
__WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ){};
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,156 +1,156 @@
/**
******************************************************************************
* @file utilities_common.h
* @author MCD Application Team
* @brief Common file to utilities
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __UTILITIES_COMMON_H
#define __UTILITIES_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "utilities_conf.h"
/* -------------------------------- *
* Basic definitions *
* -------------------------------- */
#undef NULL
#define NULL 0
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE (!0)
/* -------------------------------- *
* Critical Section definition *
* -------------------------------- */
#undef BACKUP_PRIMASK
#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
#undef DISABLE_IRQ
#define DISABLE_IRQ() __disable_irq()
#undef RESTORE_PRIMASK
#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
/* -------------------------------- *
* Macro delimiters *
* -------------------------------- */
#undef M_BEGIN
#define M_BEGIN do {
#undef M_END
#define M_END } while(0)
/* -------------------------------- *
* Some useful macro definitions *
* -------------------------------- */
#undef MAX
#define MAX( x, y ) (((x)>(y))?(x):(y))
#undef MIN
#define MIN( x, y ) (((x)<(y))?(x):(y))
#undef MODINC
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
#undef MODDEC
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
#undef MODADD
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
#undef MODSUB
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
#undef ALIGN
#ifdef WIN32
#define ALIGN(n)
#else
#define ALIGN(n) __attribute__((aligned(n)))
#endif
#undef PAUSE
#define PAUSE( t ) M_BEGIN \
volatile int _i; \
for ( _i = t; _i > 0; _i -- ); \
M_END
#undef DIVF
#define DIVF( x, y ) ((x)/(y))
#undef DIVC
#define DIVC( x, y ) (((x)+(y)-1)/(y))
#undef DIVR
#define DIVR( x, y ) (((x)+((y)/2))/(y))
#undef SHRR
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
#undef BITN
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
#undef BITNSET
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
/* -------------------------------- *
* Section attribute *
* -------------------------------- */
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
/* ----------------------------------- *
* Packed usage (compiler dependent) *
* ----------------------------------- */
#undef PACKED__
#undef PACKED_STRUCT
#if defined ( __CC_ARM )
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#else
#define PACKED__(TYPE) __packed TYPE
#define PACKED_STRUCT PACKED__(struct)
#endif
#elif defined ( __GNUC__ )
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#elif defined (__ICCARM__)
#define PACKED_STRUCT __packed struct
#elif
#define PACKED_STRUCT __packed struct
#endif
#ifdef __cplusplus
}
#endif
#endif /*__UTILITIES_COMMON_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file utilities_common.h
* @author MCD Application Team
* @brief Common file to utilities
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __UTILITIES_COMMON_H
#define __UTILITIES_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "app_conf.h"
/* -------------------------------- *
* Basic definitions *
* -------------------------------- */
#undef NULL
#define NULL 0
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE (!0)
/* -------------------------------- *
* Critical Section definition *
* -------------------------------- */
#undef BACKUP_PRIMASK
#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
#undef DISABLE_IRQ
#define DISABLE_IRQ() __disable_irq()
#undef RESTORE_PRIMASK
#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
/* -------------------------------- *
* Macro delimiters *
* -------------------------------- */
#undef M_BEGIN
#define M_BEGIN do {
#undef M_END
#define M_END } while(0)
/* -------------------------------- *
* Some useful macro definitions *
* -------------------------------- */
#undef MAX
#define MAX( x, y ) (((x)>(y))?(x):(y))
#undef MIN
#define MIN( x, y ) (((x)<(y))?(x):(y))
#undef MODINC
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
#undef MODDEC
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
#undef MODADD
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
#undef MODSUB
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
#undef ALIGN
#ifdef WIN32
#define ALIGN(n)
#else
#define ALIGN(n) __attribute__((aligned(n)))
#endif
#undef PAUSE
#define PAUSE( t ) M_BEGIN \
volatile int _i; \
for ( _i = t; _i > 0; _i -- ); \
M_END
#undef DIVF
#define DIVF( x, y ) ((x)/(y))
#undef DIVC
#define DIVC( x, y ) (((x)+(y)-1)/(y))
#undef DIVR
#define DIVR( x, y ) (((x)+((y)/2))/(y))
#undef SHRR
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
#undef BITN
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
#undef BITNSET
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
/* -------------------------------- *
* Section attribute *
* -------------------------------- */
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
/* ----------------------------------- *
* Packed usage (compiler dependent) *
* ----------------------------------- */
#undef PACKED__
#undef PACKED_STRUCT
#if defined ( __CC_ARM )
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#else
#define PACKED__(TYPE) __packed TYPE
#define PACKED_STRUCT PACKED__(struct)
#endif
#elif defined ( __GNUC__ )
#define PACKED__ __attribute__((packed))
#define PACKED_STRUCT struct PACKED__
#elif defined (__ICCARM__)
#define PACKED_STRUCT __packed struct
#elif
#define PACKED_STRUCT __packed struct
#endif
#ifdef __cplusplus
}
#endif
#endif /*__UTILITIES_COMMON_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,82 +1,68 @@
/**
******************************************************************************
* File Name : utilities_conf.h
* Description : Utilities configuration file for BLE
* middleWare.
******************************************************************************
* @attention
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef UTILITIES_CONF_H
#define UTILITIES_CONF_H
#include "app_conf.h"
/******************************************************************************
* OTP manager
******************************************************************************/
#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE
#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR
/******************************************************************************
* Scheduler
******************************************************************************/
#define SCH_CONF_TASK_NBR CFG_TASK_NBR
#define SCH_CONF_PRIO_NBR CFG_PRIO_NBR
/******************************************************************************
* Debug Trace
******************************************************************************/
/**
* When DBG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number
* When DBG_TRACE_LIGTH is set to 1, only the debug message is output
*
* When both are set to 0, no trace are output
* When both are set to 1, DBG_TRACE_FULL is selected
*/
#define DBG_TRACE_LIGTH 1
#define DBG_TRACE_FULL 0
#if (( CFG_DEBUG_TRACE != 0 ) && ( DBG_TRACE_LIGTH == 0 ) && (DBG_TRACE_FULL == 0))
#undef DBG_TRACE_FULL
#undef DBG_TRACE_LIGTH
#define DBG_TRACE_FULL 0
#define DBG_TRACE_LIGTH 1
#endif
#if ( CFG_DEBUG_TRACE == 0 )
#undef DBG_TRACE_FULL
#undef DBG_TRACE_LIGTH
#define DBG_TRACE_FULL 0
#define DBG_TRACE_LIGTH 0
#endif
/**
* When not set, the traces is looping on sending the trace over UART
*/
#define DBG_TRACE_USE_CIRCULAR_QUEUE 1
/**
* max buffer Size to queue data traces and max data trace allowed.
* Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined
*/
#define DBG_TRACE_MSG_QUEUE_SIZE 4096
#define MAX_DBG_TRACE_MSG_SIZE 1024
#endif /*UTILITIES_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/* USER CODE BEGIN Header */
/**
******************************************************************************
* File Name : utilities_conf.h
* Description : Configuration file for STM32 Utilities.
*
******************************************************************************
* @attention
*
* <h2><center>&copy; 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 UTILITIES_CONF_H
#define UTILITIES_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cmsis_compiler.h"
#include "string.h"
/******************************************************************************
* common
******************************************************************************/
#define UTILS_ENTER_CRITICAL_SECTION( ) uint32_t primask_bit = __get_PRIMASK( );\
__disable_irq( )
#define UTILS_EXIT_CRITICAL_SECTION( ) __set_PRIMASK( primask_bit )
#define UTILS_MEMSET8( dest, value, size ) memset( dest, value, size);
/******************************************************************************
* tiny low power manager
* (any macro that does not need to be modified can be removed)
******************************************************************************/
#define UTIL_LPM_INIT_CRITICAL_SECTION( )
#define UTIL_LPM_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION( )
#define UTIL_LPM_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION( )
/******************************************************************************
* sequencer
* (any macro that does not need to be modified can be removed)
******************************************************************************/
#define UTIL_SEQ_INIT_CRITICAL_SECTION( )
#define UTIL_SEQ_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION( )
#define UTIL_SEQ_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION( )
#define UTIL_SEQ_CONF_TASK_NBR (32)
#define UTIL_SEQ_CONF_PRIO_NBR (2)
#define UTIL_SEQ_MEMSET8( dest, value, size ) UTILS_MEMSET8( dest, value, size )
#ifdef __cplusplus
}
#endif
#endif /*UTILITIES_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/