mirror of https://github.com/ARMmbed/mbed-os.git
NUCLEO_WB55RG: add WB Cube files reused for BLE transport layer
parent
2b257fabad
commit
be1e80512e
|
@ -0,0 +1,114 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* File Name : app_common.h
|
||||||
|
* Description : App Common application configuration file for BLE
|
||||||
|
* middleWare.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef APP_COMMON_H
|
||||||
|
#define APP_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 *
|
||||||
|
* -------------------------------- */
|
||||||
|
#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
|
||||||
|
#define DISABLE_IRQ() __disable_irq()
|
||||||
|
#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
|
||||||
|
|
||||||
|
/* -------------------------------- *
|
||||||
|
* Macro delimiters *
|
||||||
|
* -------------------------------- */
|
||||||
|
|
||||||
|
#define M_BEGIN do {
|
||||||
|
|
||||||
|
#define M_END } while(0)
|
||||||
|
|
||||||
|
/* -------------------------------- *
|
||||||
|
* Some useful macro definitions *
|
||||||
|
* -------------------------------- */
|
||||||
|
|
||||||
|
#define MAX( x, y ) (((x)>(y))?(x):(y))
|
||||||
|
|
||||||
|
#define MIN( x, y ) (((x)<(y))?(x):(y))
|
||||||
|
|
||||||
|
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
|
||||||
|
|
||||||
|
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
|
||||||
|
|
||||||
|
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
|
||||||
|
|
||||||
|
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
|
||||||
|
|
||||||
|
#define PAUSE( t ) M_BEGIN \
|
||||||
|
__IO int _i; \
|
||||||
|
for ( _i = t; _i > 0; _i -- ); \
|
||||||
|
M_END
|
||||||
|
|
||||||
|
#define DIVF( x, y ) ((x)/(y))
|
||||||
|
|
||||||
|
#define DIVC( x, y ) (((x)+(y)-1)/(y))
|
||||||
|
|
||||||
|
#define DIVR( x, y ) (((x)+((y)/2))/(y))
|
||||||
|
|
||||||
|
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
|
||||||
|
|
||||||
|
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
|
||||||
|
|
||||||
|
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
|
||||||
|
|
||||||
|
/* -------------------------------- *
|
||||||
|
* Compiler *
|
||||||
|
* -------------------------------- */
|
||||||
|
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define ALIGN(n)
|
||||||
|
#else
|
||||||
|
#define ALIGN(n) __attribute__((aligned(n)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*APP_COMMON_H */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,436 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file app_conf.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Application configuration file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __APP_CONFIG_H
|
||||||
|
#define __APP_CONFIG_H
|
||||||
|
|
||||||
|
#include "hw.h"
|
||||||
|
#include "hw_conf.h"
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Transparent Mode 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 *//*****************************************************/
|
||||||
|
/******************************************************************************
|
||||||
|
* 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 0
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* 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 hw_lpuart1
|
||||||
|
#define CFG_CONSOLE_MENU
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* USB interface
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/Disable USB interface
|
||||||
|
*/
|
||||||
|
#define CFG_USB_INTERFACE_ENABLE 1
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* 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 0
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#define CFG_LED_SUPPORTED 1
|
||||||
|
#define CFG_BUTTON_SUPPORTED 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 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
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* 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,
|
||||||
|
|
||||||
|
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_VCP_SEND_DATA_ID,
|
||||||
|
CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID,
|
||||||
|
|
||||||
|
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_SCH_PRIO_1,
|
||||||
|
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****/
|
|
@ -0,0 +1,310 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file hw.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Hardware
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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****/
|
|
@ -0,0 +1,168 @@
|
||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* File Name : hw_conf.h
|
||||||
|
* Description : Hardware configuration file for BLE
|
||||||
|
* middleWare.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef HW_CONF_H
|
||||||
|
#define HW_CONF_H
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Semaphores
|
||||||
|
* THIS SHALL NO BE CHANGED AS THESE SEMAPHORES ARE USED AS WELL ON THE CM0+
|
||||||
|
*****************************************************************************/
|
||||||
|
/* Index of the semaphore used to manage the entry Stop Mode procedure */
|
||||||
|
#define CFG_HW_ENTRY_STOP_MODE_SEMID 4
|
||||||
|
|
||||||
|
/* Index of the semaphore used to access the RCC */
|
||||||
|
#define CFG_HW_RCC_SEMID 3
|
||||||
|
|
||||||
|
/* Index of the semaphore used to access the FLASH */
|
||||||
|
#define CFG_HW_FLASH_SEMID 2
|
||||||
|
|
||||||
|
/* Index of the semaphore used to access the PKA */
|
||||||
|
#define CFG_HW_PKA_SEMID 1
|
||||||
|
|
||||||
|
/* Index of the semaphore used to access the RNG */
|
||||||
|
#define CFG_HW_RNG_SEMID 0
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* HW TIMER SERVER
|
||||||
|
*****************************************************************************/
|
||||||
|
/**
|
||||||
|
* The user may define the maximum number of virtual timers supported.
|
||||||
|
* It shall not exceed 255
|
||||||
|
*/
|
||||||
|
#define CFG_HW_TS_MAX_NBR_CONCURRENT_TIMER 6
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user may define the priority in the NVIC of the RTC_WKUP interrupt handler that is used to manage the
|
||||||
|
* wakeup timer.
|
||||||
|
* This setting is the preemptpriority part of the NVIC.
|
||||||
|
*/
|
||||||
|
#define CFG_HW_TS_NVIC_RTC_WAKEUP_IT_PREEMPTPRIO 3
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user may define the priority in the NVIC of the RTC_WKUP interrupt handler that is used to manage the
|
||||||
|
* wakeup timer.
|
||||||
|
* This setting is the subpriority part of the NVIC. It does not exist on all processors. When it is not supported
|
||||||
|
* on the CPU, the setting is ignored
|
||||||
|
*/
|
||||||
|
#define CFG_HW_TS_NVIC_RTC_WAKEUP_IT_SUBPRIO 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define a critical section in the Timer server
|
||||||
|
* The Timer server does not support the API to be nested
|
||||||
|
* The Application shall either:
|
||||||
|
* a) Ensure this will never happen
|
||||||
|
* b) Define the critical section
|
||||||
|
* The default implementations is masking all interrupts using the PRIMASK bit
|
||||||
|
* The TimerServer driver uses critical sections to avoid context corruption. This is achieved with the macro
|
||||||
|
* TIMER_ENTER_CRITICAL_SECTION and TIMER_EXIT_CRITICAL_SECTION. When CFG_HW_TS_USE_PRIMASK_AS_CRITICAL_SECTION is set
|
||||||
|
* to 1, all STM32 interrupts are masked with the PRIMASK bit of the CortexM CPU. It is possible to use the BASEPRI
|
||||||
|
* register of the CortexM CPU to keep allowed some interrupts with high priority. In that case, the user shall
|
||||||
|
* re-implement TIMER_ENTER_CRITICAL_SECTION and TIMER_EXIT_CRITICAL_SECTION and shall make sure that no TimerServer
|
||||||
|
* API are called when the TIMER critical section is entered
|
||||||
|
*/
|
||||||
|
#define CFG_HW_TS_USE_PRIMASK_AS_CRITICAL_SECTION 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This value shall reflect the maximum delay there could be in the application between the time the RTC interrupt
|
||||||
|
* is generated by the Hardware and the time when the RTC interrupt handler is called. This time is measured in
|
||||||
|
* number of RTCCLK ticks.
|
||||||
|
* A relaxed timing would be 10ms
|
||||||
|
* When the value is too short, the timerserver will not be able to count properly and all timeout may be random.
|
||||||
|
* When the value is too long, the device may wake up more often than the most optimal configuration. However, the
|
||||||
|
* impact on power consumption would be marginal (unless the value selected is extremely too long). It is strongly
|
||||||
|
* recommended to select a value large enough to make sure it is not too short to ensure reliability of the system
|
||||||
|
* as this will have marginal impact on low power mode
|
||||||
|
*/
|
||||||
|
#define CFG_HW_TS_RTC_HANDLER_MAX_DELAY ( 10 * (LSI_VALUE/1000) )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interrupt ID in the NVIC of the RTC Wakeup interrupt handler
|
||||||
|
* It shall be type of IRQn_Type
|
||||||
|
*/
|
||||||
|
#define CFG_HW_TS_RTC_WAKEUP_HANDLER_ID RTC_WKUP_IRQn
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* HW UART
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#define CFG_HW_LPUART1_ENABLED 0
|
||||||
|
#define CFG_HW_LPUART1_DMA_TX_SUPPORTED 0
|
||||||
|
|
||||||
|
#define CFG_HW_USART1_ENABLED 1
|
||||||
|
#define CFG_HW_USART1_DMA_TX_SUPPORTED 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UART1
|
||||||
|
*/
|
||||||
|
#define CFG_HW_USART1_PREEMPTPRIORITY 0x0F
|
||||||
|
#define CFG_HW_USART1_SUBPRIORITY 0
|
||||||
|
|
||||||
|
/** < The application shall check the selected source clock is enable */
|
||||||
|
#define CFG_HW_USART1_SOURCE_CLOCK RCC_USART1CLKSOURCE_SYSCLK
|
||||||
|
|
||||||
|
#define CFG_HW_USART1_BAUDRATE 115200
|
||||||
|
#define CFG_HW_USART1_WORDLENGTH UART_WORDLENGTH_8B
|
||||||
|
#define CFG_HW_USART1_STOPBITS UART_STOPBITS_1
|
||||||
|
#define CFG_HW_USART1_PARITY UART_PARITY_NONE
|
||||||
|
#define CFG_HW_USART1_HWFLOWCTL UART_HWCONTROL_NONE
|
||||||
|
#define CFG_HW_USART1_MODE UART_MODE_TX_RX
|
||||||
|
#define CFG_HW_USART1_ADVFEATUREINIT UART_ADVFEATURE_NO_INIT
|
||||||
|
#define CFG_HW_USART1_OVERSAMPLING UART_OVERSAMPLING_8
|
||||||
|
|
||||||
|
#define CFG_HW_USART1_TX_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
|
||||||
|
#define CFG_HW_USART1_TX_PORT GPIOB
|
||||||
|
#define CFG_HW_USART1_TX_PIN GPIO_PIN_6
|
||||||
|
#define CFG_HW_USART1_TX_MODE GPIO_MODE_AF_PP
|
||||||
|
#define CFG_HW_USART1_TX_PULL GPIO_NOPULL
|
||||||
|
#define CFG_HW_USART1_TX_SPEED GPIO_SPEED_FREQ_VERY_HIGH
|
||||||
|
#define CFG_HW_USART1_TX_ALTERNATE GPIO_AF7_USART1
|
||||||
|
|
||||||
|
#define CFG_HW_USART1_RX_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
|
||||||
|
#define CFG_HW_USART1_RX_PORT GPIOB
|
||||||
|
#define CFG_HW_USART1_RX_PIN GPIO_PIN_7
|
||||||
|
#define CFG_HW_USART1_RX_MODE GPIO_MODE_AF_PP
|
||||||
|
#define CFG_HW_USART1_RX_PULL GPIO_NOPULL
|
||||||
|
#define CFG_HW_USART1_RX_SPEED GPIO_SPEED_FREQ_VERY_HIGH
|
||||||
|
#define CFG_HW_USART1_RX_ALTERNATE GPIO_AF7_USART1
|
||||||
|
|
||||||
|
#define CFG_HW_USART1_CTS_PORT_CLK_ENABLE __HAL_RCC_GPIOA_CLK_ENABLE
|
||||||
|
#define CFG_HW_USART1_CTS_PORT GPIOA
|
||||||
|
#define CFG_HW_USART1_CTS_PIN GPIO_PIN_11
|
||||||
|
#define CFG_HW_USART1_CTS_MODE GPIO_MODE_AF_PP
|
||||||
|
#define CFG_HW_USART1_CTS_PULL GPIO_PULLDOWN
|
||||||
|
#define CFG_HW_USART1_CTS_SPEED GPIO_SPEED_FREQ_VERY_HIGH
|
||||||
|
#define CFG_HW_USART1_CTS_ALTERNATE GPIO_AF7_USART1
|
||||||
|
|
||||||
|
#define CFG_HW_USART1_DMA_TX_PREEMPTPRIORITY 0x0F
|
||||||
|
#define CFG_HW_USART1_DMA_TX_SUBPRIORITY 0
|
||||||
|
|
||||||
|
#define CFG_HW_USART1_DMAMUX_CLK_ENABLE __HAL_RCC_DMAMUX1_CLK_ENABLE
|
||||||
|
#define CFG_HW_USART1_DMA_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
|
||||||
|
#define CFG_HW_USART1_TX_DMA_REQ DMA_REQUEST_USART1_TX
|
||||||
|
#define CFG_HW_USART1_TX_DMA_CHANNEL DMA2_CHANNEL_4
|
||||||
|
#define CFG_HW_USART1_TX_DMA_IRQn DMA2_CHANNEL_4_IRQn
|
||||||
|
#define CFG_HW_USART1_DMA_TX_IRQHandler DMA2_CHANNEL_4_IRQHandler
|
||||||
|
|
||||||
|
#endif /*HW_CONF_H */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,329 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* File Name : Target/hw_ipcc.c
|
||||||
|
* Description : Hardware IPCC source file for BLE
|
||||||
|
* middleWare.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 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****/
|
|
@ -0,0 +1,171 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file mbox_def.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Mailbox definition
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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 RssInfo;
|
||||||
|
} MB_RssInfoTable_t;
|
||||||
|
|
||||||
|
typedef PACKED_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****/
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file otp.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief OTP manager
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "utilities_common.h"
|
||||||
|
|
||||||
|
#include "otp.h"
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private defines -----------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Global variables ----------------------------------------------------------*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* Functions Definition ------------------------------------------------------*/
|
||||||
|
|
||||||
|
uint8_t * OTP_Read( uint8_t id )
|
||||||
|
{
|
||||||
|
uint8_t *p_id;
|
||||||
|
|
||||||
|
p_id = (uint8_t*)(CFG_OTP_END_ADRESS - 7) ;
|
||||||
|
|
||||||
|
while( ((*( p_id + 7 )) != id) && ( p_id != (uint8_t*)CFG_OTP_BASE_ADDRESS) )
|
||||||
|
{
|
||||||
|
p_id -= 8 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((*( p_id + 7 )) != id)
|
||||||
|
{
|
||||||
|
p_id = 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p_id ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file otp.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief OTP manager interface
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __OTP_H
|
||||||
|
#define __OTP_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "utilities_common.h"
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
typedef PACKED_STRUCT
|
||||||
|
{
|
||||||
|
uint8_t bd_address[6];
|
||||||
|
uint8_t hse_tuning;
|
||||||
|
uint8_t id;
|
||||||
|
} OTP_ID0_t;
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* External variables --------------------------------------------------------*/
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This API return the address (64 bits aligned) of the ID parameter in the OTP
|
||||||
|
* It returns the first ID declaration found from the higher address down to the base address
|
||||||
|
* The user shall fill the OTP from the base address to the top of the OTP so that the more recent
|
||||||
|
* declaration is returned by the API
|
||||||
|
* The OTP manager handles only 64bits parameter
|
||||||
|
* | Id | Parameter |
|
||||||
|
* | 8bits | 58bits |
|
||||||
|
* | MSB | LSB |
|
||||||
|
*
|
||||||
|
* @param id: ID of the parameter to read from OTP
|
||||||
|
* @retval Address of the ID in the OTP - returns 0 when no ID found
|
||||||
|
*/
|
||||||
|
uint8_t * OTP_Read( uint8_t id );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*__OTP_H */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,224 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file shci.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief HCI command for the system channel
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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****/
|
|
@ -0,0 +1,394 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file shci.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief HCI command for the system channel
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __SHCI_H
|
||||||
|
#define __SHCI_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* SYSTEM EVENT */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
WIRELESS_FW_RUNNING = 0x00,
|
||||||
|
RSS_FW_RUNNING = 0x01,
|
||||||
|
} SHCI_SysEvt_Ready_Rsp_t;
|
||||||
|
|
||||||
|
#define SHCI_EVTCODE ( 0xFF )
|
||||||
|
#define SHCI_SUB_EVT_CODE_BASE ( 0x9200 )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU1 DEFINITION
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SHCI_SUB_EVT_CODE_READY = SHCI_SUB_EVT_CODE_BASE,
|
||||||
|
} SHCI_SUB_EVT_CODE_t;
|
||||||
|
|
||||||
|
typedef PACKED_STRUCT{
|
||||||
|
SHCI_SysEvt_Ready_Rsp_t sysevt_ready_rsp;
|
||||||
|
} SHCI_C2_Ready_Evt_t;
|
||||||
|
|
||||||
|
/* SYSTEM COMMAND */
|
||||||
|
typedef PACKED_STRUCT
|
||||||
|
{
|
||||||
|
uint32_t MetaData[3];
|
||||||
|
} SHCI_Header_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SHCI_Success = 0x00,
|
||||||
|
SHCI_Unknown_Command = 0x01,
|
||||||
|
SHCI_ERR_UNSUPPORTED_FEATURE = 0x11,
|
||||||
|
SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12,
|
||||||
|
SHCI_FUS_Command_Not_Supported = 0xFF,
|
||||||
|
} SHCI_CmdStatus_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SHCI_8bits = 0x01,
|
||||||
|
SHCI_16bits = 0x02,
|
||||||
|
SHCI_32bits = 0x04,
|
||||||
|
} SHCI_Busw_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
erase_activity_OFF = 0x00,
|
||||||
|
erase_activity_ON = 0x01,
|
||||||
|
} SHCI_Erase_Activity_t;
|
||||||
|
|
||||||
|
#define SHCI_OGF ( 0x3F )
|
||||||
|
#define SHCI_OCF_BASE ( 0x50 )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU2 DEFINITION
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SHCI_OCF_C2_RESERVED1 = SHCI_OCF_BASE,
|
||||||
|
SHCI_OCF_C2_RESERVED2,
|
||||||
|
SHCI_OCF_C2_FUS_GET_STATE,
|
||||||
|
SHCI_OCF_C2_FUS_GET_UUID64,
|
||||||
|
SHCI_OCF_C2_FUS_FIRMWARE_UPGRADE,
|
||||||
|
SHCI_OCF_C2_FUS_REMOVE_WIRELESS_STACK,
|
||||||
|
SHCI_OCF_C2_FUS_UPDATE_AUTHENTICATION_KEY,
|
||||||
|
SHCI_OCF_C2_FUS_LOCK_AUTHENTICATION_KEY,
|
||||||
|
SHCI_OCF_C2_FUS_WRITE_USER_KEY_IN_MEMORY,
|
||||||
|
SHCI_OCF_C2_FUS_WRITE_USER_KEY_IN_AES,
|
||||||
|
SHCI_OCF_C2_FUS_START_WIRELESS_STACK,
|
||||||
|
SHCI_OCF_C2_FUS_UPGRADE,
|
||||||
|
SHCI_OCF_C2_FUS_ABORT,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED1,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED2,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED3,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED4,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED5,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED6,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED7,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED8,
|
||||||
|
SHCI_OCF_C2_FUS_RESERVED9,
|
||||||
|
SHCI_OCF_C2_BLE_init,
|
||||||
|
SHCI_OCF_C2_Thread_init,
|
||||||
|
SHCI_OCF_C2_Debug_init,
|
||||||
|
SHCI_OCF_C2_FLASH_erase_activity,
|
||||||
|
SHCI_OCF_C2_Concurrent_Set_Mode,
|
||||||
|
SHCI_OCF_C2_FLASH_store_data,
|
||||||
|
SHCI_OCF_C2_FLASH_erase_data,
|
||||||
|
SHCI_OCF_C2_RADIO_Allow_Low_Power,
|
||||||
|
SHCI_OCF_C2_Mac_802_15_4_init,
|
||||||
|
} SHCI_OCF_t;
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_GET_STATE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_GET_UUID64 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_UUID64)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_FIRMWARE_UPGRADE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FIRMWARE_UPGRADE)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_REMOVE_WIRELESS_STACK (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_REMOVE_WIRELESS_STACK)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_UPDATE_AUTHENTICATION_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UPDATE_AUTHENTICATION_KEY)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_LOCK_AUTHENTICATION_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_AUTHENTICATION_KEY)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_WRITE_USER_KEY_IN_MEMORY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_WRITE_USER_KEY_IN_MEMORY)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_WRITE_USER_KEY_IN_AES (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_WRITE_USER_KEY_IN_AES)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_START_WIRELESS_STACK (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_START_WIRELESS_STACK)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_UPGRADE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UPGRADE)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_ABORT (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_ABORT)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED1 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED1)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED2 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED2)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED3 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED3)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED4 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED4)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED5 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED5)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED6 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED6)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED7 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED7)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED8 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED8)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FUS_RESERVED9 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED9)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_init)
|
||||||
|
/** THE ORDER SHALL NOT BE CHANGED */
|
||||||
|
typedef PACKED_STRUCT{
|
||||||
|
uint8_t* pBleBufferAddress; /**< NOT USED CURRENTLY */
|
||||||
|
uint32_t BleBufferSize; /**< Size of the Buffer allocated in pBleBufferAddress */
|
||||||
|
uint16_t NumAttrRecord;
|
||||||
|
uint16_t NumAttrServ;
|
||||||
|
uint16_t AttrValueArrSize;
|
||||||
|
uint8_t NumOfLinks;
|
||||||
|
uint8_t ExtendedPacketLengthEnable;
|
||||||
|
uint8_t PrWriteListSize;
|
||||||
|
uint8_t MblockCount;
|
||||||
|
uint16_t AttMtu;
|
||||||
|
uint16_t SlaveSca;
|
||||||
|
uint8_t MasterSca;
|
||||||
|
uint8_t LsSource;
|
||||||
|
uint32_t MaxConnEventLength;
|
||||||
|
uint16_t HsStartupTime;
|
||||||
|
uint8_t ViterbiEnable;
|
||||||
|
uint8_t LlOnly;
|
||||||
|
uint8_t HwVersion;
|
||||||
|
} SHCI_C2_Ble_Init_Cmd_Param_t;
|
||||||
|
|
||||||
|
typedef PACKED_STRUCT{
|
||||||
|
SHCI_Header_t Header; /** Does not need to be initialized by the user */
|
||||||
|
SHCI_C2_Ble_Init_Cmd_Param_t Param;
|
||||||
|
} SHCI_C2_Ble_Init_Cmd_Packet_t;
|
||||||
|
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_THREAD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_Thread_init)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_DEBUG_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_Debug_init)
|
||||||
|
/** Command parameters */
|
||||||
|
typedef PACKED_STRUCT{
|
||||||
|
uint8_t *pGpioConfig;
|
||||||
|
uint8_t *pTracesConfig;
|
||||||
|
uint8_t *pGeneralConfig;
|
||||||
|
uint8_t GpioConfigSize;
|
||||||
|
uint8_t TracesConfigSize;
|
||||||
|
uint8_t GeneralConfigSize;
|
||||||
|
} SHCI_C2_DEBUG_init_Cmd_Param_t;
|
||||||
|
|
||||||
|
typedef PACKED_STRUCT{
|
||||||
|
SHCI_Header_t Header; /** Does not need to be initialized by the user */
|
||||||
|
SHCI_C2_DEBUG_init_Cmd_Param_t Param;
|
||||||
|
} SHCI_C2_DEBUG_Init_Cmd_Packet_t;
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_erase_activity)
|
||||||
|
/** Command parameters */
|
||||||
|
typedef PACKED_STRUCT{
|
||||||
|
SHCI_Erase_Activity_t EraseActivity;
|
||||||
|
} SHCI_C2_FLASH_Erase_Activity_Cmd_Param_t;
|
||||||
|
|
||||||
|
typedef PACKED_STRUCT{
|
||||||
|
SHCI_Header_t Header; /** Does not need to be initialized by the user */
|
||||||
|
SHCI_C2_FLASH_Erase_Activity_Cmd_Param_t Param;
|
||||||
|
} SHCI_C2_FLASH_Erase_Activity_Cmd_Packet_t;
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_CONCURRENT_SET_MODE (( SHCI_OGF << 10) + SHCI_OCF_C2_Concurrent_Set_Mode)
|
||||||
|
/** command parameters */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
BLE_ENABLE,
|
||||||
|
THREAD_ENABLE,
|
||||||
|
} SHCI_C2_CONCURRENT_Mode_Param_t;
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_FLASH_STORE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_store_data)
|
||||||
|
#define SHCI_OPCODE_C2_FLASH_ERASE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_erase_data)
|
||||||
|
/** command parameters */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
BLE_IP,
|
||||||
|
THREAD_IP,
|
||||||
|
} SHCI_C2_FLASH_Ip_t;
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_Allow_Low_Power)
|
||||||
|
|
||||||
|
#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_Mac_802_15_4_init)
|
||||||
|
/** No command parameters */
|
||||||
|
/** No response parameters*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* External variables --------------------------------------------------------*/
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* SHCI_C2_FUS_Get_State
|
||||||
|
* @brief Read the RSS
|
||||||
|
* When the wireless FW is running on the CPU2, the command returns SHCI_FUS_Command_Not_Supported
|
||||||
|
* When any RSS command is sent after the SHCI_FUS_Command_Not_Supported has been returned after sending one RSS command,
|
||||||
|
* the CPU2 switches on the RSS ( This reboots automatically the device )
|
||||||
|
*
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_FUS_Get_State( void );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_BLE_Init
|
||||||
|
* @brief Provides parameters and starts the BLE Stack
|
||||||
|
*
|
||||||
|
* @param pCmdPacket : Parameters to be provided to the BLE Stack
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_THREAD_Init
|
||||||
|
* @brief Starts the THREAD Stack
|
||||||
|
*
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_DEBUG_Init
|
||||||
|
* @brief Starts the Traces
|
||||||
|
*
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_FLASH_Erase_Activity
|
||||||
|
* @brief Provides the information of the start and the end of a flash erase window on the CPU1
|
||||||
|
*
|
||||||
|
* @param pCmdPacket: Start/End of erase activity
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_FLASH_Erase_Activity( SHCI_C2_FLASH_Erase_Activity_Cmd_Packet_t *pCmdPacket );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_CONCURRENT_SetMode
|
||||||
|
* @brief Enable/Disable Thread on CPU2 (M0+)
|
||||||
|
*
|
||||||
|
* @param Mode: BLE or Thread enable flag
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_FLASH_StoreData
|
||||||
|
* @brief Store Data in Flash
|
||||||
|
*
|
||||||
|
* @param Ip: BLE or THREAD
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_FLASH_EraseData
|
||||||
|
* @brief Erase Data in Flash
|
||||||
|
*
|
||||||
|
* @param Ip: BLE or THREAD
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_RADIO_AllowLowPower
|
||||||
|
* @brief Allow or forbid IP_radio (802_15_4 or BLE) to enter in low power mode.
|
||||||
|
*
|
||||||
|
* @param Ip: BLE or 802_15_5
|
||||||
|
* @param FlagRadioLowPowerOn: True or false
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHCI_C2_MAC_802_15_4_Init
|
||||||
|
* @brief Starts the MAC 802.15.4 on M0
|
||||||
|
*
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*__SHCI_H */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,196 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file shci.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief System HCI command implementation
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
*/
|
||||||
|
PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static tListNode SHciAsynchEventQueue;
|
||||||
|
PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static volatile SHCI_TL_CmdStatus_t SHCICmdStatus;
|
||||||
|
PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static TL_CmdPacket_t *pCmdBuffer;
|
||||||
|
PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow;
|
||||||
|
/**
|
||||||
|
* END of Section SYSTEM_DRIVER_CONTEXT
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,167 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file shci_tl.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief System HCI command header for the system channel
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#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_ */
|
|
@ -0,0 +1,168 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32_wpan_common.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Common file to utilities
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2018 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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>
|
||||||
|
|
||||||
|
/* -------------------------------- *
|
||||||
|
* 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 *
|
||||||
|
* -------------------------------- */
|
||||||
|
#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****/
|
|
@ -0,0 +1,208 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm_list.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief TCircular Linked List Implementation.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Include Files
|
||||||
|
******************************************************************************/
|
||||||
|
#include "utilities_common.h"
|
||||||
|
|
||||||
|
#include "stm_list.h"
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Function Definitions
|
||||||
|
******************************************************************************/
|
||||||
|
void LST_init_head (tListNode * listHead)
|
||||||
|
{
|
||||||
|
listHead->next = listHead;
|
||||||
|
listHead->prev = listHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t LST_is_empty (tListNode * listHead)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
uint8_t return_value;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
if(listHead->next == listHead)
|
||||||
|
{
|
||||||
|
return_value = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return_value = FALSE;
|
||||||
|
}
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LST_insert_head (tListNode * listHead, tListNode * node)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
node->next = listHead->next;
|
||||||
|
node->prev = listHead;
|
||||||
|
listHead->next = node;
|
||||||
|
(node->next)->prev = node;
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LST_insert_tail (tListNode * listHead, tListNode * node)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
node->next = listHead;
|
||||||
|
node->prev = listHead->prev;
|
||||||
|
listHead->prev = node;
|
||||||
|
(node->prev)->next = node;
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LST_remove_node (tListNode * node)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
(node->prev)->next = node->next;
|
||||||
|
(node->next)->prev = node->prev;
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LST_remove_head (tListNode * listHead, tListNode ** node )
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
*node = listHead->next;
|
||||||
|
LST_remove_node (listHead->next);
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LST_remove_tail (tListNode * listHead, tListNode ** node )
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
*node = listHead->prev;
|
||||||
|
LST_remove_node (listHead->prev);
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LST_insert_node_after (tListNode * node, tListNode * ref_node)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
node->next = ref_node->next;
|
||||||
|
node->prev = ref_node;
|
||||||
|
ref_node->next = node;
|
||||||
|
(node->next)->prev = node;
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LST_insert_node_before (tListNode * node, tListNode * ref_node)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
node->next = ref_node;
|
||||||
|
node->prev = ref_node->prev;
|
||||||
|
ref_node->prev = node;
|
||||||
|
(node->prev)->next = node;
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int LST_get_size (tListNode * listHead)
|
||||||
|
{
|
||||||
|
int size = 0;
|
||||||
|
tListNode * temp;
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
temp = listHead->next;
|
||||||
|
while (temp != listHead)
|
||||||
|
{
|
||||||
|
size++;
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
|
||||||
|
return (size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LST_get_next_node (tListNode * ref_node, tListNode ** node)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
*node = ref_node->next;
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LST_get_prev_node (tListNode * ref_node, tListNode ** node)
|
||||||
|
{
|
||||||
|
uint32_t primask_bit;
|
||||||
|
|
||||||
|
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
|
||||||
|
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||||
|
|
||||||
|
*node = ref_node->prev;
|
||||||
|
|
||||||
|
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm_list.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file for linked list library.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _STM_LIST_H_
|
||||||
|
#define _STM_LIST_H_
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
typedef struct _tListNode {
|
||||||
|
struct _tListNode * next;
|
||||||
|
struct _tListNode * prev;
|
||||||
|
} tListNode;
|
||||||
|
|
||||||
|
void LST_init_head (tListNode * listHead);
|
||||||
|
|
||||||
|
uint8_t LST_is_empty (tListNode * listHead);
|
||||||
|
|
||||||
|
void LST_insert_head (tListNode * listHead, tListNode * node);
|
||||||
|
|
||||||
|
void LST_insert_tail (tListNode * listHead, tListNode * node);
|
||||||
|
|
||||||
|
void LST_remove_node (tListNode * node);
|
||||||
|
|
||||||
|
void LST_remove_head (tListNode * listHead, tListNode ** node );
|
||||||
|
|
||||||
|
void LST_remove_tail (tListNode * listHead, tListNode ** node );
|
||||||
|
|
||||||
|
void LST_insert_node_after (tListNode * node, tListNode * ref_node);
|
||||||
|
|
||||||
|
void LST_insert_node_before (tListNode * node, tListNode * ref_node);
|
||||||
|
|
||||||
|
int LST_get_size (tListNode * listHead);
|
||||||
|
|
||||||
|
void LST_get_next_node (tListNode * ref_node, tListNode ** node);
|
||||||
|
|
||||||
|
void LST_get_prev_node (tListNode * ref_node, tListNode ** node);
|
||||||
|
|
||||||
|
#endif /* _STM_LIST_H_ */
|
|
@ -0,0 +1,279 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tl.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header for tl module
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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****/
|
|
@ -0,0 +1,416 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tl_mbox.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Transport layer for the mailbox interface
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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****/
|
|
@ -0,0 +1,156 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file utilities_common.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Common file to utilities
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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****/
|
|
@ -0,0 +1,83 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file utilities_conf.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Configuration of utilities
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* This software component is licensed by ST under Ultimate Liberty license
|
||||||
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at:
|
||||||
|
* www.st.com/SLA0044
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 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****/
|
Loading…
Reference in New Issue