Trinity Devboard PCB V1.0 Firmware. FreeRTOS is setup and the MCU reads IMU data over SPI fand Magnetometer data over I2C, each with a seperate task. Sensordata is then run though MadgwickAHRS and send over USB as serial packet data to use in trinity visualizer. Bare minimum functionality works and is replicated from the first prototype.
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_cdc.h
|
||||
* @author MCD Application Team
|
||||
* @brief header file for the usbd_cdc.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_CDC_H
|
||||
#define __USB_CDC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_ioreq.h"
|
||||
|
||||
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_cdc
|
||||
* @brief This file is the Header file for usbd_cdc.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_cdc_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#ifndef CDC_IN_EP
|
||||
#define CDC_IN_EP 0x81U /* EP1 for data IN */
|
||||
#endif /* CDC_IN_EP */
|
||||
#ifndef CDC_OUT_EP
|
||||
#define CDC_OUT_EP 0x01U /* EP1 for data OUT */
|
||||
#endif /* CDC_OUT_EP */
|
||||
#ifndef CDC_CMD_EP
|
||||
#define CDC_CMD_EP 0x82U /* EP2 for CDC commands */
|
||||
#endif /* CDC_CMD_EP */
|
||||
|
||||
#ifndef CDC_HS_BINTERVAL
|
||||
#define CDC_HS_BINTERVAL 0x10U
|
||||
#endif /* CDC_HS_BINTERVAL */
|
||||
|
||||
#ifndef CDC_FS_BINTERVAL
|
||||
#define CDC_FS_BINTERVAL 0x10U
|
||||
#endif /* CDC_FS_BINTERVAL */
|
||||
|
||||
#ifndef CDC_CMD_PACKET_SIZE
|
||||
#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
||||
#endif /* CDC_CMD_PACKET_SIZE */
|
||||
|
||||
/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
||||
#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
||||
#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
||||
|
||||
#define USB_CDC_CONFIG_DESC_SIZ 67U
|
||||
#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
|
||||
#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
|
||||
|
||||
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
||||
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
||||
|
||||
#define CDC_REQ_MAX_DATA_SIZE 0x7U
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* CDC definitions */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U
|
||||
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U
|
||||
#define CDC_SET_COMM_FEATURE 0x02U
|
||||
#define CDC_GET_COMM_FEATURE 0x03U
|
||||
#define CDC_CLEAR_COMM_FEATURE 0x04U
|
||||
#define CDC_SET_LINE_CODING 0x20U
|
||||
#define CDC_GET_LINE_CODING 0x21U
|
||||
#define CDC_SET_CONTROL_LINE_STATE 0x22U
|
||||
#define CDC_SEND_BREAK 0x23U
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t bitrate;
|
||||
uint8_t format;
|
||||
uint8_t paritytype;
|
||||
uint8_t datatype;
|
||||
} USBD_CDC_LineCodingTypeDef;
|
||||
|
||||
typedef struct _USBD_CDC_Itf
|
||||
{
|
||||
int8_t (* Init)(void);
|
||||
int8_t (* DeInit)(void);
|
||||
int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length);
|
||||
int8_t (* Receive)(uint8_t *Buf, uint32_t *Len);
|
||||
int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum);
|
||||
} USBD_CDC_ItfTypeDef;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */
|
||||
uint8_t CmdOpCode;
|
||||
uint8_t CmdLength;
|
||||
uint8_t *RxBuffer;
|
||||
uint8_t *TxBuffer;
|
||||
uint32_t RxLength;
|
||||
uint32_t TxLength;
|
||||
|
||||
__IO uint32_t TxState;
|
||||
__IO uint32_t RxState;
|
||||
} USBD_CDC_HandleTypeDef;
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern USBD_ClassTypeDef USBD_CDC;
|
||||
#define USBD_CDC_CLASS &USBD_CDC
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||
USBD_CDC_ItfTypeDef *fops);
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
||||
uint32_t length, uint8_t ClassId);
|
||||
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
|
||||
#else
|
||||
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
||||
uint32_t length);
|
||||
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
||||
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USB_CDC_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,896 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_cdc.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides the high layer firmware functions to manage the
|
||||
* following functionalities of the USB CDC Class:
|
||||
* - Initialization and Configuration of high and low layer
|
||||
* - Enumeration as CDC Device (and enumeration for each implemented memory interface)
|
||||
* - OUT/IN data transfer
|
||||
* - Command IN transfer (class requests management)
|
||||
* - Error management
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
* @verbatim
|
||||
*
|
||||
* ===================================================================
|
||||
* CDC Class Driver Description
|
||||
* ===================================================================
|
||||
* This driver manages the "Universal Serial Bus Class Definitions for Communications Devices
|
||||
* Revision 1.2 November 16, 2007" and the sub-protocol specification of "Universal Serial Bus
|
||||
* Communications Class Subclass Specification for PSTN Devices Revision 1.2 February 9, 2007"
|
||||
* This driver implements the following aspects of the specification:
|
||||
* - Device descriptor management
|
||||
* - Configuration descriptor management
|
||||
* - Enumeration as CDC device with 2 data endpoints (IN and OUT) and 1 command endpoint (IN)
|
||||
* - Requests management (as described in section 6.2 in specification)
|
||||
* - Abstract Control Model compliant
|
||||
* - Union Functional collection (using 1 IN endpoint for control)
|
||||
* - Data interface class
|
||||
*
|
||||
* These aspects may be enriched or modified for a specific user application.
|
||||
*
|
||||
* This driver doesn't implement the following aspects of the specification
|
||||
* (but it is possible to manage these features with some modifications on this driver):
|
||||
* - Any class-specific aspect relative to communication classes should be managed by user application.
|
||||
* - All communication classes other than PSTN are not managed
|
||||
*
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* BSPDependencies
|
||||
- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
|
||||
- "stm32xxxxx_{eval}{discovery}_io.c"
|
||||
EndBSPDependencies */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_cdc.h"
|
||||
#include "usbd_ctlreq.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CDC
|
||||
* @brief usbd core module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CDC_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CDC_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CDC_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CDC_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
|
||||
static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
|
||||
static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev);
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
static uint8_t *USBD_CDC_GetFSCfgDesc(uint16_t *length);
|
||||
static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length);
|
||||
static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length);
|
||||
uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/* USB Standard Device Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_CDC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
|
||||
{
|
||||
USB_LEN_DEV_QUALIFIER_DESC,
|
||||
USB_DESC_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
};
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CDC_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* CDC interface class callbacks structure */
|
||||
USBD_ClassTypeDef USBD_CDC =
|
||||
{
|
||||
USBD_CDC_Init,
|
||||
USBD_CDC_DeInit,
|
||||
USBD_CDC_Setup,
|
||||
NULL, /* EP0_TxSent */
|
||||
USBD_CDC_EP0_RxReady,
|
||||
USBD_CDC_DataIn,
|
||||
USBD_CDC_DataOut,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#else
|
||||
USBD_CDC_GetHSCfgDesc,
|
||||
USBD_CDC_GetFSCfgDesc,
|
||||
USBD_CDC_GetOtherSpeedCfgDesc,
|
||||
USBD_CDC_GetDeviceQualifierDescriptor,
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||
NULL,
|
||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||
};
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/* USB CDC device Configuration Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_CDC_CfgDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
/* Configuration Descriptor */
|
||||
0x09, /* bLength: Configuration Descriptor size */
|
||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||
USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength */
|
||||
0x00,
|
||||
0x02, /* bNumInterfaces: 2 interfaces */
|
||||
0x01, /* bConfigurationValue: Configuration value */
|
||||
0x00, /* iConfiguration: Index of string descriptor
|
||||
describing the configuration */
|
||||
#if (USBD_SELF_POWERED == 1U)
|
||||
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||
#else
|
||||
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||
#endif /* USBD_SELF_POWERED */
|
||||
USBD_MAX_POWER, /* MaxPower (mA) */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Interface Descriptor */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
|
||||
/* Interface descriptor type */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x01, /* bNumEndpoints: One endpoint used */
|
||||
0x02, /* bInterfaceClass: Communication Interface Class */
|
||||
0x02, /* bInterfaceSubClass: Abstract Control Model */
|
||||
0x01, /* bInterfaceProtocol: Common AT commands */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/* Header Functional Descriptor */
|
||||
0x05, /* bLength: Endpoint Descriptor size */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x00, /* bDescriptorSubtype: Header Func Desc */
|
||||
0x10, /* bcdCDC: spec release number */
|
||||
0x01,
|
||||
|
||||
/* Call Management Functional Descriptor */
|
||||
0x05, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x01, /* bDescriptorSubtype: Call Management Func Desc */
|
||||
0x00, /* bmCapabilities: D0+D1 */
|
||||
0x01, /* bDataInterface */
|
||||
|
||||
/* ACM Functional Descriptor */
|
||||
0x04, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x02, /* bDescriptorSubtype: Abstract Control Management desc */
|
||||
0x02, /* bmCapabilities */
|
||||
|
||||
/* Union Functional Descriptor */
|
||||
0x05, /* bFunctionLength */
|
||||
0x24, /* bDescriptorType: CS_INTERFACE */
|
||||
0x06, /* bDescriptorSubtype: Union func desc */
|
||||
0x00, /* bMasterInterface: Communication class interface */
|
||||
0x01, /* bSlaveInterface0: Data Class Interface */
|
||||
|
||||
/* Endpoint 2 Descriptor */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
|
||||
CDC_CMD_EP, /* bEndpointAddress */
|
||||
0x03, /* bmAttributes: Interrupt */
|
||||
LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */
|
||||
HIBYTE(CDC_CMD_PACKET_SIZE),
|
||||
CDC_FS_BINTERVAL, /* bInterval */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Data class interface descriptor */
|
||||
0x09, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */
|
||||
0x01, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints: Two endpoints used */
|
||||
0x0A, /* bInterfaceClass: CDC */
|
||||
0x00, /* bInterfaceSubClass */
|
||||
0x00, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/* Endpoint OUT Descriptor */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
|
||||
CDC_OUT_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */
|
||||
HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),
|
||||
0x00, /* bInterval */
|
||||
|
||||
/* Endpoint IN Descriptor */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
|
||||
CDC_IN_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */
|
||||
HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),
|
||||
0x00 /* bInterval */
|
||||
};
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
static uint8_t CDCInEpAdd = CDC_IN_EP;
|
||||
static uint8_t CDCOutEpAdd = CDC_OUT_EP;
|
||||
static uint8_t CDCCmdEpAdd = CDC_CMD_EP;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CDC_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_Init
|
||||
* Initialize the CDC interface
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
{
|
||||
UNUSED(cfgidx);
|
||||
USBD_CDC_HandleTypeDef *hcdc;
|
||||
|
||||
hcdc = (USBD_CDC_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));
|
||||
|
||||
if (hcdc == NULL)
|
||||
{
|
||||
pdev->pClassDataCmsit[pdev->classId] = NULL;
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
(void)USBD_memset(hcdc, 0, sizeof(USBD_CDC_HandleTypeDef));
|
||||
|
||||
pdev->pClassDataCmsit[pdev->classId] = (void *)hcdc;
|
||||
pdev->pClassData = pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||
CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
/* Open EP IN */
|
||||
(void)USBD_LL_OpenEP(pdev, CDCInEpAdd, USBD_EP_TYPE_BULK,
|
||||
CDC_DATA_HS_IN_PACKET_SIZE);
|
||||
|
||||
pdev->ep_in[CDCInEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
/* Open EP OUT */
|
||||
(void)USBD_LL_OpenEP(pdev, CDCOutEpAdd, USBD_EP_TYPE_BULK,
|
||||
CDC_DATA_HS_OUT_PACKET_SIZE);
|
||||
|
||||
pdev->ep_out[CDCOutEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
/* Set bInterval for CDC CMD Endpoint */
|
||||
pdev->ep_in[CDCCmdEpAdd & 0xFU].bInterval = CDC_HS_BINTERVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Open EP IN */
|
||||
(void)USBD_LL_OpenEP(pdev, CDCInEpAdd, USBD_EP_TYPE_BULK,
|
||||
CDC_DATA_FS_IN_PACKET_SIZE);
|
||||
|
||||
pdev->ep_in[CDCInEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
/* Open EP OUT */
|
||||
(void)USBD_LL_OpenEP(pdev, CDCOutEpAdd, USBD_EP_TYPE_BULK,
|
||||
CDC_DATA_FS_OUT_PACKET_SIZE);
|
||||
|
||||
pdev->ep_out[CDCOutEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
/* Set bInterval for CMD Endpoint */
|
||||
pdev->ep_in[CDCCmdEpAdd & 0xFU].bInterval = CDC_FS_BINTERVAL;
|
||||
}
|
||||
|
||||
/* Open Command IN EP */
|
||||
(void)USBD_LL_OpenEP(pdev, CDCCmdEpAdd, USBD_EP_TYPE_INTR, CDC_CMD_PACKET_SIZE);
|
||||
pdev->ep_in[CDCCmdEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
hcdc->RxBuffer = NULL;
|
||||
|
||||
/* Init physical Interface components */
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init();
|
||||
|
||||
/* Init Xfer states */
|
||||
hcdc->TxState = 0U;
|
||||
hcdc->RxState = 0U;
|
||||
|
||||
if (hcdc->RxBuffer == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
|
||||
CDC_DATA_HS_OUT_PACKET_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
|
||||
CDC_DATA_FS_OUT_PACKET_SIZE);
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_Init
|
||||
* DeInitialize the CDC layer
|
||||
* @param pdev: device instance
|
||||
* @param cfgidx: Configuration index
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
{
|
||||
UNUSED(cfgidx);
|
||||
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this CDC class instance */
|
||||
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||
CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/* Close EP IN */
|
||||
(void)USBD_LL_CloseEP(pdev, CDCInEpAdd);
|
||||
pdev->ep_in[CDCInEpAdd & 0xFU].is_used = 0U;
|
||||
|
||||
/* Close EP OUT */
|
||||
(void)USBD_LL_CloseEP(pdev, CDCOutEpAdd);
|
||||
pdev->ep_out[CDCOutEpAdd & 0xFU].is_used = 0U;
|
||||
|
||||
/* Close Command IN EP */
|
||||
(void)USBD_LL_CloseEP(pdev, CDCCmdEpAdd);
|
||||
pdev->ep_in[CDCCmdEpAdd & 0xFU].is_used = 0U;
|
||||
pdev->ep_in[CDCCmdEpAdd & 0xFU].bInterval = 0U;
|
||||
|
||||
/* DeInit physical Interface components */
|
||||
if (pdev->pClassDataCmsit[pdev->classId] != NULL)
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->DeInit();
|
||||
(void)USBD_free(pdev->pClassDataCmsit[pdev->classId]);
|
||||
pdev->pClassDataCmsit[pdev->classId] = NULL;
|
||||
pdev->pClassData = NULL;
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_Setup
|
||||
* Handle the CDC specific requests
|
||||
* @param pdev: instance
|
||||
* @param req: usb requests
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
|
||||
USBD_SetupReqTypedef *req)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
uint16_t len;
|
||||
uint8_t ifalt = 0U;
|
||||
uint16_t status_info = 0U;
|
||||
USBD_StatusTypeDef ret = USBD_OK;
|
||||
|
||||
if (hcdc == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||
{
|
||||
case USB_REQ_TYPE_CLASS:
|
||||
if (req->wLength != 0U)
|
||||
{
|
||||
if ((req->bmRequest & 0x80U) != 0U)
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Control(req->bRequest,
|
||||
(uint8_t *)hcdc->data,
|
||||
req->wLength);
|
||||
|
||||
len = MIN(CDC_REQ_MAX_DATA_SIZE, req->wLength);
|
||||
(void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
hcdc->CmdOpCode = req->bRequest;
|
||||
hcdc->CmdLength = (uint8_t)MIN(req->wLength, USB_MAX_EP0_SIZE);
|
||||
|
||||
(void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, hcdc->CmdLength);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Control(req->bRequest,
|
||||
(uint8_t *)req, 0U);
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest)
|
||||
{
|
||||
case USB_REQ_GET_STATUS:
|
||||
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||
{
|
||||
(void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U);
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_CtlError(pdev, req);
|
||||
ret = USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_REQ_GET_INTERFACE:
|
||||
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||
{
|
||||
(void)USBD_CtlSendData(pdev, &ifalt, 1U);
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_CtlError(pdev, req);
|
||||
ret = USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_REQ_SET_INTERFACE:
|
||||
if (pdev->dev_state != USBD_STATE_CONFIGURED)
|
||||
{
|
||||
USBD_CtlError(pdev, req);
|
||||
ret = USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_CtlError(pdev, req);
|
||||
ret = USBD_FAIL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_CtlError(pdev, req);
|
||||
ret = USBD_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
return (uint8_t)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_DataIn
|
||||
* Data sent on non-control IN endpoint
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc;
|
||||
PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *)pdev->pData;
|
||||
|
||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if ((pdev->ep_in[epnum & 0xFU].total_length > 0U) &&
|
||||
((pdev->ep_in[epnum & 0xFU].total_length % hpcd->IN_ep[epnum & 0xFU].maxpacket) == 0U))
|
||||
{
|
||||
/* Update the packet total length */
|
||||
pdev->ep_in[epnum & 0xFU].total_length = 0U;
|
||||
|
||||
/* Send ZLP */
|
||||
(void)USBD_LL_Transmit(pdev, epnum, NULL, 0U);
|
||||
}
|
||||
else
|
||||
{
|
||||
hcdc->TxState = 0U;
|
||||
|
||||
if (((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt != NULL)
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
||||
}
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_DataOut
|
||||
* Data received on non-control Out endpoint
|
||||
* @param pdev: device instance
|
||||
* @param epnum: endpoint number
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
/* Get the received data length */
|
||||
hcdc->RxLength = USBD_LL_GetRxDataSize(pdev, epnum);
|
||||
|
||||
/* USB data will be immediately processed, this allow next USB traffic being
|
||||
NAKed till the end of the application Xfer */
|
||||
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Receive(hcdc->RxBuffer, &hcdc->RxLength);
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_EP0_RxReady
|
||||
* Handle EP0 Rx Ready event
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (hcdc == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
if ((pdev->pUserData[pdev->classId] != NULL) && (hcdc->CmdOpCode != 0xFFU))
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Control(hcdc->CmdOpCode,
|
||||
(uint8_t *)hcdc->data,
|
||||
(uint16_t)hcdc->CmdLength);
|
||||
hcdc->CmdOpCode = 0xFFU;
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/**
|
||||
* @brief USBD_CDC_GetFSCfgDesc
|
||||
* Return configuration descriptor
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_CDC_GetFSCfgDesc(uint16_t *length)
|
||||
{
|
||||
USBD_EpDescTypeDef *pEpCmdDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_CMD_EP);
|
||||
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_OUT_EP);
|
||||
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_IN_EP);
|
||||
|
||||
if (pEpCmdDesc != NULL)
|
||||
{
|
||||
pEpCmdDesc->bInterval = CDC_FS_BINTERVAL;
|
||||
}
|
||||
|
||||
if (pEpOutDesc != NULL)
|
||||
{
|
||||
pEpOutDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
|
||||
}
|
||||
|
||||
if (pEpInDesc != NULL)
|
||||
{
|
||||
pEpInDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
|
||||
}
|
||||
|
||||
*length = (uint16_t)sizeof(USBD_CDC_CfgDesc);
|
||||
return USBD_CDC_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_GetHSCfgDesc
|
||||
* Return configuration descriptor
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length)
|
||||
{
|
||||
USBD_EpDescTypeDef *pEpCmdDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_CMD_EP);
|
||||
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_OUT_EP);
|
||||
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_IN_EP);
|
||||
|
||||
if (pEpCmdDesc != NULL)
|
||||
{
|
||||
pEpCmdDesc->bInterval = CDC_HS_BINTERVAL;
|
||||
}
|
||||
|
||||
if (pEpOutDesc != NULL)
|
||||
{
|
||||
pEpOutDesc->wMaxPacketSize = CDC_DATA_HS_MAX_PACKET_SIZE;
|
||||
}
|
||||
|
||||
if (pEpInDesc != NULL)
|
||||
{
|
||||
pEpInDesc->wMaxPacketSize = CDC_DATA_HS_MAX_PACKET_SIZE;
|
||||
}
|
||||
|
||||
*length = (uint16_t)sizeof(USBD_CDC_CfgDesc);
|
||||
return USBD_CDC_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_GetOtherSpeedCfgDesc
|
||||
* Return configuration descriptor
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length)
|
||||
{
|
||||
USBD_EpDescTypeDef *pEpCmdDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_CMD_EP);
|
||||
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_OUT_EP);
|
||||
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_IN_EP);
|
||||
|
||||
if (pEpCmdDesc != NULL)
|
||||
{
|
||||
pEpCmdDesc->bInterval = CDC_FS_BINTERVAL;
|
||||
}
|
||||
|
||||
if (pEpOutDesc != NULL)
|
||||
{
|
||||
pEpOutDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
|
||||
}
|
||||
|
||||
if (pEpInDesc != NULL)
|
||||
{
|
||||
pEpInDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
|
||||
}
|
||||
|
||||
*length = (uint16_t)sizeof(USBD_CDC_CfgDesc);
|
||||
return USBD_CDC_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_GetDeviceQualifierDescriptor
|
||||
* return Device Qualifier descriptor
|
||||
* @param length : pointer data length
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length)
|
||||
{
|
||||
*length = (uint16_t)sizeof(USBD_CDC_DeviceQualifierDesc);
|
||||
|
||||
return USBD_CDC_DeviceQualifierDesc;
|
||||
}
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
/**
|
||||
* @brief USBD_CDC_RegisterInterface
|
||||
* @param pdev: device instance
|
||||
* @param fops: CD Interface callback
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||
USBD_CDC_ItfTypeDef *fops)
|
||||
{
|
||||
if (fops == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
pdev->pUserData[pdev->classId] = fops;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_SetTxBuffer
|
||||
* @param pdev: device instance
|
||||
* @param pbuff: Tx Buffer
|
||||
* @param length: length of data to be sent
|
||||
* @param ClassId: The Class ID
|
||||
* @retval status
|
||||
*/
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuff, uint32_t length, uint8_t ClassId)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||
#else
|
||||
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuff, uint32_t length)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
if (hcdc == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
hcdc->TxBuffer = pbuff;
|
||||
hcdc->TxLength = length;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_SetRxBuffer
|
||||
* @param pdev: device instance
|
||||
* @param pbuff: Rx Buffer
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (hcdc == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
hcdc->RxBuffer = pbuff;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_TransmitPacket
|
||||
* Transmit packet on IN endpoint
|
||||
* @param pdev: device instance
|
||||
* @param ClassId: The Class ID
|
||||
* @retval status
|
||||
*/
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||
#else
|
||||
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
USBD_StatusTypeDef ret = USBD_BUSY;
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, ClassId);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
if (hcdc == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
if (hcdc->TxState == 0U)
|
||||
{
|
||||
/* Tx Transfer in progress */
|
||||
hcdc->TxState = 1U;
|
||||
|
||||
/* Update the packet total length */
|
||||
pdev->ep_in[CDCInEpAdd & 0xFU].total_length = hcdc->TxLength;
|
||||
|
||||
/* Transmit next packet */
|
||||
(void)USBD_LL_Transmit(pdev, CDCInEpAdd, hcdc->TxBuffer, hcdc->TxLength);
|
||||
|
||||
ret = USBD_OK;
|
||||
}
|
||||
|
||||
return (uint8_t)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CDC_ReceivePacket
|
||||
* prepare OUT Endpoint for reception
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
|
||||
CDC_DATA_HS_OUT_PACKET_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
|
||||
CDC_DATA_FS_OUT_PACKET_SIZE);
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_core.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header file for usbd_core.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_CORE_H
|
||||
#define __USBD_CORE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_conf.h"
|
||||
#include "usbd_def.h"
|
||||
#include "usbd_ioreq.h"
|
||||
#include "usbd_ctlreq.h"
|
||||
|
||||
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE
|
||||
* @brief This file is the Header file for usbd_core.c file
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#ifndef USBD_DEBUG_LEVEL
|
||||
#define USBD_DEBUG_LEVEL 0U
|
||||
#endif /* USBD_DEBUG_LEVEL */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
#define USBD_SOF USBD_LL_SOF
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id);
|
||||
USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
|
||||
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||
USBD_StatusTypeDef USBD_RegisterDevStateCallback(USBD_HandleTypeDef *pdev, USBD_DevStateCallbackTypeDef pUserCallback);
|
||||
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
|
||||
USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr);
|
||||
|
||||
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev);
|
||||
uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type, uint8_t ClassId);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index);
|
||||
uint8_t USBD_CoreFindEP(USBD_HandleTypeDef *pdev, uint8_t index);
|
||||
|
||||
USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
|
||||
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup);
|
||||
USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
|
||||
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
|
||||
USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
|
||||
|
||||
/* USBD Low Level Driver */
|
||||
USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
|
||||
uint8_t ep_type, uint16_t ep_mps);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
|
||||
USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
|
||||
USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
|
||||
USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
|
||||
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
|
||||
uint8_t *pbuf, uint32_t size);
|
||||
|
||||
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
|
||||
uint8_t *pbuf, uint32_t size);
|
||||
|
||||
#ifdef USBD_HS_TESTMODE_ENABLE
|
||||
USBD_StatusTypeDef USBD_LL_SetTestMode(USBD_HandleTypeDef *pdev, uint8_t testmode);
|
||||
#endif /* USBD_HS_TESTMODE_ENABLE */
|
||||
|
||||
uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
|
||||
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
|
||||
|
||||
void USBD_LL_Delay(uint32_t Delay);
|
||||
|
||||
void *USBD_GetEpDesc(uint8_t *pConfDesc, uint8_t EpAddr);
|
||||
USBD_DescHeaderTypeDef *USBD_GetNextDesc(uint8_t *pbuf, uint16_t *ptr);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USBD_CORE_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_req.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header file for the usbd_req.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_REQUEST_H
|
||||
#define __USB_REQUEST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_def.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_REQ
|
||||
* @brief header file for the usbd_req.c file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_REQ_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_REQ_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_REQ_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_REQ_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_REQ_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
|
||||
USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
|
||||
void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata);
|
||||
void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USB_REQUEST_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,524 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_def.h
|
||||
* @author MCD Application Team
|
||||
* @brief General defines for the usb device library
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_DEF_H
|
||||
#define __USBD_DEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_conf.h"
|
||||
|
||||
/** @addtogroup STM32_USBD_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_DEF
|
||||
* @brief general defines for the usb device library file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_DEF_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0U
|
||||
#endif /* NULL */
|
||||
|
||||
#ifndef USBD_MAX_NUM_INTERFACES
|
||||
#define USBD_MAX_NUM_INTERFACES 1U
|
||||
#endif /* USBD_MAX_NUM_CONFIGURATION */
|
||||
|
||||
#ifndef USBD_MAX_NUM_CONFIGURATION
|
||||
#define USBD_MAX_NUM_CONFIGURATION 1U
|
||||
#endif /* USBD_MAX_NUM_CONFIGURATION */
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
#ifndef USBD_MAX_SUPPORTED_CLASS
|
||||
#define USBD_MAX_SUPPORTED_CLASS 4U
|
||||
#endif /* USBD_MAX_SUPPORTED_CLASS */
|
||||
#else
|
||||
#ifndef USBD_MAX_SUPPORTED_CLASS
|
||||
#define USBD_MAX_SUPPORTED_CLASS 1U
|
||||
#endif /* USBD_MAX_SUPPORTED_CLASS */
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
#ifndef USBD_MAX_CLASS_ENDPOINTS
|
||||
#define USBD_MAX_CLASS_ENDPOINTS 5U
|
||||
#endif /* USBD_MAX_CLASS_ENDPOINTS */
|
||||
|
||||
#ifndef USBD_MAX_CLASS_INTERFACES
|
||||
#define USBD_MAX_CLASS_INTERFACES 5U
|
||||
#endif /* USBD_MAX_CLASS_INTERFACES */
|
||||
|
||||
#ifndef USBD_LPM_ENABLED
|
||||
#define USBD_LPM_ENABLED 0U
|
||||
#endif /* USBD_LPM_ENABLED */
|
||||
|
||||
#ifndef USBD_SELF_POWERED
|
||||
#define USBD_SELF_POWERED 1U
|
||||
#endif /*USBD_SELF_POWERED */
|
||||
|
||||
#ifndef USBD_MAX_POWER
|
||||
#define USBD_MAX_POWER 0x32U /* 100 mA */
|
||||
#endif /* USBD_MAX_POWER */
|
||||
|
||||
#ifndef USBD_SUPPORT_USER_STRING_DESC
|
||||
#define USBD_SUPPORT_USER_STRING_DESC 0U
|
||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||
|
||||
#ifndef USBD_CLASS_USER_STRING_DESC
|
||||
#define USBD_CLASS_USER_STRING_DESC 0U
|
||||
#endif /* USBD_CLASS_USER_STRING_DESC */
|
||||
|
||||
#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU
|
||||
#define USB_LEN_DEV_DESC 0x12U
|
||||
#define USB_LEN_CFG_DESC 0x09U
|
||||
#define USB_LEN_IF_DESC 0x09U
|
||||
#define USB_LEN_EP_DESC 0x07U
|
||||
#define USB_LEN_OTG_DESC 0x03U
|
||||
#define USB_LEN_LANGID_STR_DESC 0x04U
|
||||
#define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U
|
||||
|
||||
#define USBD_IDX_LANGID_STR 0x00U
|
||||
#define USBD_IDX_MFC_STR 0x01U
|
||||
#define USBD_IDX_PRODUCT_STR 0x02U
|
||||
#define USBD_IDX_SERIAL_STR 0x03U
|
||||
#define USBD_IDX_CONFIG_STR 0x04U
|
||||
#define USBD_IDX_INTERFACE_STR 0x05U
|
||||
|
||||
#define USB_REQ_TYPE_STANDARD 0x00U
|
||||
#define USB_REQ_TYPE_CLASS 0x20U
|
||||
#define USB_REQ_TYPE_VENDOR 0x40U
|
||||
#define USB_REQ_TYPE_MASK 0x60U
|
||||
|
||||
#define USB_REQ_RECIPIENT_DEVICE 0x00U
|
||||
#define USB_REQ_RECIPIENT_INTERFACE 0x01U
|
||||
#define USB_REQ_RECIPIENT_ENDPOINT 0x02U
|
||||
#define USB_REQ_RECIPIENT_MASK 0x03U
|
||||
|
||||
#define USB_REQ_GET_STATUS 0x00U
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01U
|
||||
#define USB_REQ_SET_FEATURE 0x03U
|
||||
#define USB_REQ_SET_ADDRESS 0x05U
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06U
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07U
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08U
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09U
|
||||
#define USB_REQ_GET_INTERFACE 0x0AU
|
||||
#define USB_REQ_SET_INTERFACE 0x0BU
|
||||
#define USB_REQ_SYNCH_FRAME 0x0CU
|
||||
|
||||
#define USB_DESC_TYPE_DEVICE 0x01U
|
||||
#define USB_DESC_TYPE_CONFIGURATION 0x02U
|
||||
#define USB_DESC_TYPE_STRING 0x03U
|
||||
#define USB_DESC_TYPE_INTERFACE 0x04U
|
||||
#define USB_DESC_TYPE_ENDPOINT 0x05U
|
||||
#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U
|
||||
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
|
||||
#define USB_DESC_TYPE_IAD 0x0BU
|
||||
#define USB_DESC_TYPE_BOS 0x0FU
|
||||
|
||||
#define USB_CONFIG_REMOTE_WAKEUP 0x02U
|
||||
#define USB_CONFIG_SELF_POWERED 0x01U
|
||||
|
||||
#define USB_FEATURE_EP_HALT 0x00U
|
||||
#define USB_FEATURE_REMOTE_WAKEUP 0x01U
|
||||
#define USB_FEATURE_TEST_MODE 0x02U
|
||||
|
||||
#define USB_DEVICE_CAPABITY_TYPE 0x10U
|
||||
|
||||
#define USB_CONF_DESC_SIZE 0x09U
|
||||
#define USB_IF_DESC_SIZE 0x09U
|
||||
#define USB_EP_DESC_SIZE 0x07U
|
||||
#define USB_IAD_DESC_SIZE 0x08U
|
||||
|
||||
#define USB_HS_MAX_PACKET_SIZE 512U
|
||||
#define USB_FS_MAX_PACKET_SIZE 64U
|
||||
#define USB_MAX_EP0_SIZE 64U
|
||||
|
||||
/* Device Status */
|
||||
#define USBD_STATE_DEFAULT 0x01U
|
||||
#define USBD_STATE_ADDRESSED 0x02U
|
||||
#define USBD_STATE_CONFIGURED 0x03U
|
||||
#define USBD_STATE_SUSPENDED 0x04U
|
||||
|
||||
|
||||
/* EP0 State */
|
||||
#define USBD_EP0_IDLE 0x00U
|
||||
#define USBD_EP0_SETUP 0x01U
|
||||
#define USBD_EP0_DATA_IN 0x02U
|
||||
#define USBD_EP0_DATA_OUT 0x03U
|
||||
#define USBD_EP0_STATUS_IN 0x04U
|
||||
#define USBD_EP0_STATUS_OUT 0x05U
|
||||
#define USBD_EP0_STALL 0x06U
|
||||
|
||||
#define USBD_EP_TYPE_CTRL 0x00U
|
||||
#define USBD_EP_TYPE_ISOC 0x01U
|
||||
#define USBD_EP_TYPE_BULK 0x02U
|
||||
#define USBD_EP_TYPE_INTR 0x03U
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
#define USBD_EP_IN 0x80U
|
||||
#define USBD_EP_OUT 0x00U
|
||||
#define USBD_FUNC_DESCRIPTOR_TYPE 0x24U
|
||||
#define USBD_DESC_SUBTYPE_ACM 0x0FU
|
||||
#define USBD_DESC_ECM_BCD_LOW 0x00U
|
||||
#define USBD_DESC_ECM_BCD_HIGH 0x10U
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_DEF_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct usb_setup_req
|
||||
{
|
||||
uint8_t bmRequest;
|
||||
uint8_t bRequest;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} USBD_SetupReqTypedef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bNumInterfaces;
|
||||
uint8_t bConfigurationValue;
|
||||
uint8_t iConfiguration;
|
||||
uint8_t bmAttributes;
|
||||
uint8_t bMaxPower;
|
||||
} __PACKED USBD_ConfigDescTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bNumDeviceCaps;
|
||||
} USBD_BosDescTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmAttributes;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
} __PACKED USBD_EpDescTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
} USBD_DescHeaderTypeDef;
|
||||
|
||||
struct _USBD_HandleTypeDef;
|
||||
|
||||
typedef struct _Device_cb
|
||||
{
|
||||
uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
|
||||
uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
|
||||
/* Control Endpoints*/
|
||||
uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev);
|
||||
uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev);
|
||||
/* Class Specific Endpoints*/
|
||||
uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev);
|
||||
uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
|
||||
uint8_t *(*GetHSConfigDescriptor)(uint16_t *length);
|
||||
uint8_t *(*GetFSConfigDescriptor)(uint16_t *length);
|
||||
uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length);
|
||||
uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length);
|
||||
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||
uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length);
|
||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||
|
||||
} USBD_ClassTypeDef;
|
||||
|
||||
/* Following USB Device Speed */
|
||||
typedef enum
|
||||
{
|
||||
USBD_SPEED_HIGH = 0U,
|
||||
USBD_SPEED_FULL = 1U,
|
||||
USBD_SPEED_LOW = 2U,
|
||||
} USBD_SpeedTypeDef;
|
||||
|
||||
/* Following USB Device status */
|
||||
typedef enum
|
||||
{
|
||||
USBD_OK = 0U,
|
||||
USBD_BUSY,
|
||||
USBD_EMEM,
|
||||
USBD_FAIL,
|
||||
} USBD_StatusTypeDef;
|
||||
|
||||
/* USB Device descriptors structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
#if (USBD_CLASS_USER_STRING_DESC == 1)
|
||||
uint8_t *(*GetUserStrDescriptor)(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length);
|
||||
#endif /* USBD_CLASS_USER_STRING_DESC */
|
||||
#if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1))
|
||||
uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
|
||||
#endif /* (USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1) */
|
||||
} USBD_DescriptorsTypeDef;
|
||||
|
||||
/* USB Device handle structure */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t total_length;
|
||||
uint32_t rem_length;
|
||||
uint32_t bInterval;
|
||||
uint16_t maxpacket;
|
||||
uint8_t status;
|
||||
uint8_t is_used;
|
||||
uint8_t *pbuffer;
|
||||
} USBD_EndpointTypeDef;
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
typedef enum
|
||||
{
|
||||
CLASS_TYPE_NONE = 0,
|
||||
CLASS_TYPE_HID = 1,
|
||||
CLASS_TYPE_CDC = 2,
|
||||
CLASS_TYPE_MSC = 3,
|
||||
CLASS_TYPE_DFU = 4,
|
||||
CLASS_TYPE_CHID = 5,
|
||||
CLASS_TYPE_AUDIO = 6,
|
||||
CLASS_TYPE_ECM = 7,
|
||||
CLASS_TYPE_RNDIS = 8,
|
||||
CLASS_TYPE_MTP = 9,
|
||||
CLASS_TYPE_VIDEO = 10,
|
||||
CLASS_TYPE_PRINTER = 11,
|
||||
CLASS_TYPE_CCID = 12,
|
||||
} USBD_CompositeClassTypeDef;
|
||||
|
||||
|
||||
/* USB Device handle structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t add;
|
||||
uint8_t type;
|
||||
uint8_t size;
|
||||
uint8_t is_used;
|
||||
} USBD_EPTypeDef;
|
||||
|
||||
/* USB Device handle structure */
|
||||
typedef struct
|
||||
{
|
||||
USBD_CompositeClassTypeDef ClassType;
|
||||
uint32_t ClassId;
|
||||
uint32_t Active;
|
||||
uint32_t NumEps;
|
||||
USBD_EPTypeDef Eps[USBD_MAX_CLASS_ENDPOINTS];
|
||||
uint8_t *EpAdd;
|
||||
uint32_t NumIf;
|
||||
uint8_t Ifs[USBD_MAX_CLASS_INTERFACES];
|
||||
uint32_t CurrPcktSze;
|
||||
} USBD_CompositeElementTypeDef;
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/* USB Device handle structure */
|
||||
typedef struct _USBD_HandleTypeDef
|
||||
{
|
||||
uint8_t id;
|
||||
uint32_t dev_config;
|
||||
uint32_t dev_default_config;
|
||||
uint32_t dev_config_status;
|
||||
USBD_SpeedTypeDef dev_speed;
|
||||
USBD_EndpointTypeDef ep_in[16];
|
||||
USBD_EndpointTypeDef ep_out[16];
|
||||
__IO uint32_t ep0_state;
|
||||
uint32_t ep0_data_len;
|
||||
__IO uint8_t dev_state;
|
||||
__IO uint8_t dev_old_state;
|
||||
uint8_t dev_address;
|
||||
uint8_t dev_connection_status;
|
||||
uint8_t dev_test_mode;
|
||||
uint32_t dev_remote_wakeup;
|
||||
uint8_t ConfIdx;
|
||||
|
||||
USBD_SetupReqTypedef request;
|
||||
USBD_DescriptorsTypeDef *pDesc;
|
||||
USBD_ClassTypeDef *pClass[USBD_MAX_SUPPORTED_CLASS];
|
||||
void *pClassData;
|
||||
void *pClassDataCmsit[USBD_MAX_SUPPORTED_CLASS];
|
||||
void *pUserData[USBD_MAX_SUPPORTED_CLASS];
|
||||
void *pData;
|
||||
void *pBosDesc;
|
||||
void *pConfDesc;
|
||||
uint32_t classId;
|
||||
uint32_t NumClasses;
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS];
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||
void (* DevStateCallback)(uint8_t dev_state, uint8_t cfgidx); /*!< User Notification callback */
|
||||
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||
} USBD_HandleTypeDef;
|
||||
|
||||
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||
typedef void (*USBD_DevStateCallbackTypeDef)(uint8_t dev_state, uint8_t cfgidx); /*!< pointer to User callback function */
|
||||
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||
|
||||
/* USB Device endpoint direction */
|
||||
typedef enum
|
||||
{
|
||||
OUT = 0x00,
|
||||
IN = 0x80,
|
||||
} USBD_EPDirectionTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NETWORK_CONNECTION = 0x00,
|
||||
RESPONSE_AVAILABLE = 0x01,
|
||||
CONNECTION_SPEED_CHANGE = 0x2A
|
||||
} USBD_CDC_NotifCodeTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_DEF_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
__STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
|
||||
{
|
||||
uint16_t _SwapVal;
|
||||
uint16_t _Byte1;
|
||||
uint16_t _Byte2;
|
||||
uint8_t *_pbuff = addr;
|
||||
|
||||
_Byte1 = *(uint8_t *)_pbuff;
|
||||
_pbuff++;
|
||||
_Byte2 = *(uint8_t *)_pbuff;
|
||||
|
||||
_SwapVal = (_Byte2 << 8) | _Byte1;
|
||||
|
||||
return _SwapVal;
|
||||
}
|
||||
|
||||
#ifndef LOBYTE
|
||||
#define LOBYTE(x) ((uint8_t)((x) & 0x00FFU))
|
||||
#endif /* LOBYTE */
|
||||
|
||||
#ifndef HIBYTE
|
||||
#define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U))
|
||||
#endif /* HIBYTE */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif /* MIN */
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif /* MAX */
|
||||
|
||||
#if defined ( __GNUC__ )
|
||||
#ifndef __weak
|
||||
#define __weak __attribute__((weak))
|
||||
#endif /* __weak */
|
||||
#ifndef __packed
|
||||
#define __packed __attribute__((__packed__))
|
||||
#endif /* __packed */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
/* In HS mode and when the DMA is used, all variables and data structures dealing
|
||||
with the DMA during the transaction process should be 4-bytes aligned */
|
||||
|
||||
#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
|
||||
#ifndef __ALIGN_END
|
||||
#define __ALIGN_END __attribute__ ((aligned (4U)))
|
||||
#endif /* __ALIGN_END */
|
||||
#ifndef __ALIGN_BEGIN
|
||||
#define __ALIGN_BEGIN
|
||||
#endif /* __ALIGN_BEGIN */
|
||||
#else
|
||||
#ifndef __ALIGN_END
|
||||
#define __ALIGN_END
|
||||
#endif /* __ALIGN_END */
|
||||
#ifndef __ALIGN_BEGIN
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __ALIGN_BEGIN __align(4U)
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __ALIGN_BEGIN
|
||||
#endif /* __CC_ARM */
|
||||
#endif /* __ALIGN_BEGIN */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_DEF_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_DEF_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USBD_DEF_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_ioreq.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header file for the usbd_ioreq.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_IOREQ_H
|
||||
#define __USBD_IOREQ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_def.h"
|
||||
#include "usbd_core.h"
|
||||
|
||||
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_IOREQ
|
||||
* @brief header file for the usbd_ioreq.c file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_IOREQ_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_IOREQ_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
|
||||
USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len);
|
||||
|
||||
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len);
|
||||
|
||||
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len);
|
||||
|
||||
USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len);
|
||||
|
||||
USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
|
||||
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev);
|
||||
|
||||
uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USBD_IOREQ_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_ioreq.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides the IO requests APIs for control endpoints.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_ioreq.h"
|
||||
|
||||
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ
|
||||
* @brief control I/O requests module
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_IOREQ_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_IOREQ_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief USBD_CtlSendData
|
||||
* send data on the ctl pipe
|
||||
* @param pdev: device instance
|
||||
* @param buff: pointer to data buffer
|
||||
* @param len: length of data to be sent
|
||||
* @retval status
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len)
|
||||
{
|
||||
/* Set EP0 State */
|
||||
pdev->ep0_state = USBD_EP0_DATA_IN;
|
||||
pdev->ep_in[0].total_length = len;
|
||||
pdev->ep_in[0].pbuffer = pbuf;
|
||||
|
||||
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
||||
pdev->ep_in[0].rem_length = 0U;
|
||||
#else
|
||||
pdev->ep_in[0].rem_length = len;
|
||||
#endif /* USBD_AVOID_PACKET_SPLIT_MPS */
|
||||
|
||||
/* Start the transfer */
|
||||
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CtlContinueSendData
|
||||
* continue sending data on the ctl pipe
|
||||
* @param pdev: device instance
|
||||
* @param buff: pointer to data buffer
|
||||
* @param len: length of data to be sent
|
||||
* @retval status
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len)
|
||||
{
|
||||
/* Start the next transfer */
|
||||
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CtlPrepareRx
|
||||
* receive data on the ctl pipe
|
||||
* @param pdev: device instance
|
||||
* @param buff: pointer to data buffer
|
||||
* @param len: length of data to be received
|
||||
* @retval status
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len)
|
||||
{
|
||||
/* Set EP0 State */
|
||||
pdev->ep0_state = USBD_EP0_DATA_OUT;
|
||||
pdev->ep_out[0].total_length = len;
|
||||
pdev->ep_out[0].pbuffer = pbuf;
|
||||
|
||||
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
|
||||
pdev->ep_out[0].rem_length = 0U;
|
||||
#else
|
||||
pdev->ep_out[0].rem_length = len;
|
||||
#endif /* USBD_AVOID_PACKET_SPLIT_MPS */
|
||||
|
||||
/* Start the transfer */
|
||||
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CtlContinueRx
|
||||
* continue receive data on the ctl pipe
|
||||
* @param pdev: device instance
|
||||
* @param buff: pointer to data buffer
|
||||
* @param len: length of data to be received
|
||||
* @retval status
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuf, uint32_t len)
|
||||
{
|
||||
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CtlSendStatus
|
||||
* send zero lzngth packet on the ctl pipe
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
/* Set EP0 State */
|
||||
pdev->ep0_state = USBD_EP0_STATUS_IN;
|
||||
|
||||
/* Start the transfer */
|
||||
(void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_CtlReceiveStatus
|
||||
* receive zero lzngth packet on the ctl pipe
|
||||
* @param pdev: device instance
|
||||
* @retval status
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
/* Set EP0 State */
|
||||
pdev->ep0_state = USBD_EP0_STATUS_OUT;
|
||||
|
||||
/* Start the transfer */
|
||||
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USBD_GetRxCount
|
||||
* returns the received data length
|
||||
* @param pdev: device instance
|
||||
* @param ep_addr: endpoint address
|
||||
* @retval Rx Data blength
|
||||
*/
|
||||
uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
||||
{
|
||||
return USBD_LL_GetRxDataSize(pdev, ep_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
This software component is provided to you as part of a software package and
|
||||
applicable license terms are in the Package_license file. If you received this
|
||||
software component outside of a package or without applicable license terms,
|
||||
the terms of the SLA0044 license shall apply and are fully reproduced below:
|
||||
|
||||
SLA0044 Rev6/October 2025
|
||||
|
||||
Software license agreement
|
||||
|
||||
ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT
|
||||
|
||||
BY CLICKING ON THE "I ACCEPT" BUTTON OR BY UNZIPPING, INSTALLING, COPYING,
|
||||
DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE OR ANY PART THEREOF,
|
||||
INCLUDING ANY RELATED DOCUMENTATION (collectively the “SOFTWARE”)
|
||||
FROM STMICROELECTRONICS INTERNATIONAL N.V, SWISS BRANCH AND/OR
|
||||
ITS AFFILIATED COMPANIES (collectively “STMICROELECTRONICS”),
|
||||
YOU (hereinafter referred also to as “THE RECIPIENT”), ON BEHALF OF YOURSELF,
|
||||
OR ON BEHALF OF ANY ENTITY BY WHICH YOU ARE EMPLOYED AND/OR ENGAGED,
|
||||
AGREE TO BE BOUND BY THIS AGREEMENT.
|
||||
|
||||
Under STMICROELECTRONICS’ intellectual property rights, the redistribution,
|
||||
reproduction and use in source and binary forms of the SOFTWARE or any part
|
||||
thereof, with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
1. Redistribution of source code (modified or not) must retain any copyright
|
||||
notice accompanying the SOFTWARE, this list of conditions and the disclaimer below.
|
||||
|
||||
2. Redistributions in binary form, except as embedded into a processing unit device
|
||||
manufactured by or for STMicroelectronics or a software update for any such device,
|
||||
must reproduce the accompanying copyright notice, this list of conditions,
|
||||
and the below disclaimer in capital type, in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of STMicroelectronics nor the names of other contributors
|
||||
to the SOFTWARE may be used to endorse or promote products derived
|
||||
from the SOFTWARE or part thereof without specific written permission.
|
||||
|
||||
4. The SOFTWARE or any part thereof, including modifications and/or
|
||||
derivative works of the SOFTWARE, must be used and execute solely
|
||||
and exclusively on or in combination with a processing unit device
|
||||
manufactured by or for STMicroelectronics.
|
||||
|
||||
5. No use, reproduction or redistribution of the SOFTWARE partially
|
||||
or totally may be done in any manner that would subject the SOFTWARE
|
||||
to any Open Source Terms. “Open Source Terms” shall mean
|
||||
any open source license which requires as part of distribution
|
||||
of software that the source code of such software is distributed
|
||||
therewith or otherwise made available, or open source license
|
||||
that substantially complies with the Open Source definition specified
|
||||
at www.opensource.org and any other comparable open source license
|
||||
such as for example GNU General Public License (GPL),
|
||||
Eclipse Public License (EPL), Apache Software License, BSD license
|
||||
or MIT license.
|
||||
|
||||
6. STMicroelectronics has no obligation to provide any maintenance,
|
||||
support or updates for the SOFTWARE.
|
||||
|
||||
7. The SOFTWARE is and will remain the exclusive property of
|
||||
STMicroelectronics and its licensors. The RECIPIENT will not take
|
||||
any action that jeopardizes STMicroelectronics and its
|
||||
licensors' proprietary rights or acquire any rights in the SOFTWARE,
|
||||
except the limited rights specified hereunder.
|
||||
|
||||
8. The RECIPIENT shall comply with all applicable laws and regulations
|
||||
affecting the use of the SOFTWARE or any part thereof including
|
||||
any applicable export control law or regulation.
|
||||
|
||||
9. Redistribution and use of the SOFTWARE or any part thereof other
|
||||
than as permitted under this AGREEMENT is void and will automatically
|
||||
terminate RECIPIENT’s rights under this AGREEMENT.
|
||||
|
||||
10. The RECIPIENT shall be solely liable to determine and verify that
|
||||
the SOFTWARE is fit for the RECIPIENT intended use, environment or
|
||||
application and comply with all regulatory, safety and security
|
||||
related requirements concerning any use.
|
||||
|
||||
DISCLAIMER:
|
||||
|
||||
THE SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING,BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
||||
AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, ARE
|
||||
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS,
|
||||
WHETHER EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL
|
||||
PROPERTY RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ble.h
|
||||
* @author MCD Application Team
|
||||
* @brief BLE interface
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __BLE_H
|
||||
#define __BLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ble_conf.h"
|
||||
#include "ble_dbg_conf.h"
|
||||
|
||||
/**< core */
|
||||
#include "core/ble_core.h"
|
||||
#include "core/ble_bufsize.h"
|
||||
#include "core/ble_defs.h"
|
||||
#include "core/auto/ble_vs_codes.h"
|
||||
#include "core/ble_legacy.h"
|
||||
#include "core/ble_std.h"
|
||||
|
||||
/**< blesvc */
|
||||
#include "svc/Inc/bas.h"
|
||||
#include "svc/Inc/bls.h"
|
||||
#include "svc/Inc/crs_stm.h"
|
||||
#include "svc/Inc/dis.h"
|
||||
#include "svc/Inc/eds_stm.h"
|
||||
#include "svc/Inc/hids.h"
|
||||
#include "svc/Inc/hrs.h"
|
||||
#include "svc/Inc/hts.h"
|
||||
#include "svc/Inc/ias.h"
|
||||
#include "svc/Inc/lls.h"
|
||||
#include "svc/Inc/tps.h"
|
||||
#include "svc/Inc/motenv_stm.h"
|
||||
#include "svc/Inc/p2p_stm.h"
|
||||
#include "svc/Inc/zdd_stm.h"
|
||||
#include "svc/Inc/otas_stm.h"
|
||||
#include "svc/Inc/mesh.h"
|
||||
#include "svc/Inc/template_stm.h"
|
||||
|
||||
#include "svc/Inc/svc_ctl.h"
|
||||
|
||||
#include "svc/Inc/uuid.h"
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* -------------------------------- *
|
||||
* [retrieved from ble_legacy file]
|
||||
* Macro to get RSSI from advertising report #0.
|
||||
* "p" must be a pointer to the event parameters buffer
|
||||
* -------------------------------- */
|
||||
#define HCI_LE_ADVERTISING_REPORT_RSSI_0(p) \
|
||||
(*(int8_t*)((&((hci_le_advertising_report_event_rp0*)(p))-> \
|
||||
Advertising_Report[0].Length_Data) + 1 + \
|
||||
((hci_le_advertising_report_event_rp0*)(p))-> \
|
||||
Advertising_Report[0].Length_Data))
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__BLE_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ble_common.h
|
||||
* @author MCD Application Team
|
||||
* @brief Common file to BLE Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __BLE_COMMON_H
|
||||
#define __BLE_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "ble_conf.h"
|
||||
#include "ble_dbg_conf.h"
|
||||
|
||||
/* Event types copied from MW Legacy file*/
|
||||
#include "tl.h"
|
||||
|
||||
/* -------------------------------- *
|
||||
* Basic definitions *
|
||||
* -------------------------------- */
|
||||
|
||||
#undef NULL
|
||||
#define NULL 0
|
||||
|
||||
#undef FALSE
|
||||
#define FALSE 0
|
||||
|
||||
#undef TRUE
|
||||
#define TRUE (!0)
|
||||
|
||||
|
||||
/* -------------------------------- *
|
||||
* Macro delimiters *
|
||||
* -------------------------------- */
|
||||
|
||||
#define M_BEGIN do {
|
||||
|
||||
#define M_END } while(0)
|
||||
|
||||
|
||||
/* -------------------------------- *
|
||||
* Some useful macro definitions *
|
||||
* -------------------------------- */
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX( a, b ) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN( a, b ) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#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 )
|
||||
|
||||
#ifdef WIN32
|
||||
#define ALIGN(n)
|
||||
#else
|
||||
#define ALIGN(n) __attribute__((aligned(n)))
|
||||
#endif
|
||||
|
||||
#define PAUSE( t ) M_BEGIN \
|
||||
volatile 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 __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__BLE_COMMON_H */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,142 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_gen_aci.h
|
||||
* @brief STM32WB BLE API (GEN_ACI)
|
||||
* Auto-generated file: do not edit!
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_GEN_ACI_H__
|
||||
#define BLE_GEN_ACI_H__
|
||||
|
||||
|
||||
#include "auto/ble_types.h"
|
||||
|
||||
/**
|
||||
* @brief ACI_RESET
|
||||
* This command resets the BLE stack (Host and LE Controller).
|
||||
*
|
||||
* @param Mode ACI reset mode.
|
||||
* Values:
|
||||
* - 0x00: Reset without BLE stack options change
|
||||
* - 0x01: Reset with BLE stack option changes
|
||||
* @param Options New BLE stack options to set at ACI reset (a bit set to 1
|
||||
* means that the corresponding optional feature is activated).
|
||||
* Flags:
|
||||
* - 0x00000001: LL only mode
|
||||
* - 0x00000002: No service change description
|
||||
* - 0x00000004: Device Name is read-only
|
||||
* - 0x00000008: Support of Extended Advertising
|
||||
* - 0x00000010: Support of Channel Selection Algorithm #2
|
||||
* - 0x00000020: Reduced GATT database in NVM
|
||||
* - 0x00000040: Support of GATT caching
|
||||
* - 0x00000080: Support of LE Power Class 1 (flag not available in RCP
|
||||
* mode)
|
||||
* - 0x00000100: Appearance is writable
|
||||
* - 0x00000200: Support of Enhanced ATT
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_reset( uint8_t Mode,
|
||||
uint32_t Options );
|
||||
|
||||
/**
|
||||
* @brief ACI_GET_INFORMATION
|
||||
* This command reads the local ACI information.
|
||||
*
|
||||
* @param[out] Version BLE stack version.
|
||||
* @param[out] Options Current BLE stack options (a bit set to 1 means that the
|
||||
* corresponding optional feature is activated).
|
||||
* Flags:
|
||||
* - 0x00000001: LL only mode
|
||||
* - 0x00000002: No service change description
|
||||
* - 0x00000004: Device Name is read-only
|
||||
* - 0x00000008: Support of Extended Advertising
|
||||
* - 0x00000010: Support of Channel Selection Algorithm #2
|
||||
* - 0x00000020: Reduced GATT database in NVM
|
||||
* - 0x00000040: Support of GATT caching
|
||||
* - 0x00000080: Support of LE Power Class 1 (flag not available in RCP
|
||||
* mode)
|
||||
* - 0x00000100: Appearance is writable
|
||||
* - 0x00000200: Support of Enhanced ATT
|
||||
* @param[out] Debug_Info BLE stack debug information.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_get_information( uint32_t* Version,
|
||||
uint32_t* Options,
|
||||
uint32_t* Debug_Info );
|
||||
|
||||
/**
|
||||
* @brief ACI_WRITE_CONFIG_DATA
|
||||
* This command writes a value to a configure data structure. It is useful to
|
||||
* setup directly some parameters for the BLE stack.
|
||||
* Refer to Annex for details on the different parameters that can be
|
||||
* configured.
|
||||
*
|
||||
* @param Offset Offset of the element in the configuration data structure
|
||||
* which has to be written.
|
||||
* Values:
|
||||
* - 0x00: CONFIG_DATA_PUBLIC_ADDRESS_OFFSET;
|
||||
* Bluetooth public address; 6 bytes
|
||||
* - 0x08: CONFIG_DATA_ER_OFFSET;
|
||||
* Encryption root key; 16 bytes
|
||||
* - 0x18: CONFIG_DATA_IR_OFFSET;
|
||||
* Identity root key; 16 bytes
|
||||
* - 0x2E: CONFIG_DATA_RANDOM_ADDRESS_OFFSET;
|
||||
* Static Random Address; 6 bytes
|
||||
* - 0x34: CONFIG_DATA_GAP_ADD_REC_NBR_OFFSET;
|
||||
* GAP service additional record number; 1 byte
|
||||
* - 0x35: CONFIG_DATA_SC_KEY_TYPE_OFFSET;
|
||||
* Secure Connections key type; 1 byte
|
||||
* - 0xB0: CONFIG_DATA_SMP_MODE_OFFSET;
|
||||
* SMP mode; 1 byte
|
||||
* - 0xC0: CONFIG_DATA_LL_SCAN_CHAN_MAP_OFFSET;
|
||||
* LL scan channel map; 1 byte
|
||||
* - 0xC1: CONFIG_DATA_LL_BG_SCAN_MODE_OFFSET;
|
||||
* LL background scan mode; 1 byte
|
||||
* - 0xC3: CONFIG_DATA_LL_RPA_MODE_OFFSET;
|
||||
* LL RPA mode; 1 byte
|
||||
* - 0xD1: CONFIG_DATA_LL_MAX_DATA_EXT_OFFSET [only for full stack];
|
||||
* LL maximum data length extension; 8 bytes
|
||||
* @param Length Length of data to be written
|
||||
* @param Value Data to be written
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_write_config_data( uint8_t Offset,
|
||||
uint8_t Length,
|
||||
const uint8_t* Value );
|
||||
|
||||
/**
|
||||
* @brief ACI_READ_CONFIG_DATA
|
||||
* This command requests the value in the configure data structure. The number
|
||||
* of read bytes changes for different Offset.
|
||||
*
|
||||
* @param Offset Offset of the element in the configuration data structure
|
||||
* which has to be read.
|
||||
* Values:
|
||||
* - 0x00: CONFIG_DATA_PUBLIC_ADDRESS_OFFSET;
|
||||
* Bluetooth public address; 6 bytes
|
||||
* - 0x08: CONFIG_DATA_ER_OFFSET;
|
||||
* Encryption root key used to derive LTK (legacy) and CSRK; 16 bytes
|
||||
* - 0x18: CONFIG_DATA_IR_OFFSET
|
||||
* Identity root key used to derive DHK (legacy) and IRK; 16 bytes
|
||||
* - 0x2E: CONFIG_DATA_RANDOM_ADDRESS_OFFSET;
|
||||
* Static Random Address; 6 bytes
|
||||
* @param[out] Data_Length Length of Data in octets
|
||||
* @param[out] Data Data field associated with Offset parameter
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_read_config_data( uint8_t Offset,
|
||||
uint8_t* Data_Length,
|
||||
uint8_t* Data );
|
||||
|
||||
|
||||
#endif /* BLE_GEN_ACI_H__ */
|
||||
@@ -0,0 +1,418 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_hal_aci.c
|
||||
* @brief STM32WB BLE API (hal_aci)
|
||||
* Auto-generated file: do not edit!
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#include "auto/ble_hal_aci.h"
|
||||
|
||||
tBleStatus aci_hal_write_config_data( uint8_t Offset,
|
||||
uint8_t Length,
|
||||
const uint8_t* Value )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_write_config_data_cp0 *cp0 = (aci_hal_write_config_data_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Offset = Offset;
|
||||
index_input += 1;
|
||||
cp0->Length = Length;
|
||||
index_input += 1;
|
||||
Osal_MemCpy( (void*)&cp0->Value, (const void*)Value, Length );
|
||||
index_input += Length;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x00c;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_read_config_data( uint8_t Offset,
|
||||
uint8_t* Data_Length,
|
||||
uint8_t* Data )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_read_config_data_cp0 *cp0 = (aci_hal_read_config_data_cp0*)(cmd_buffer);
|
||||
aci_hal_read_config_data_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
int index_input = 0;
|
||||
cp0->Offset = Offset;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x00d;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
*Data_Length = resp.Data_Length;
|
||||
Osal_MemCpy( (void*)Data, (const void*)resp.Data, *Data_Length);
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_set_tx_power_level( uint8_t En_High_Power,
|
||||
uint8_t PA_Level )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_set_tx_power_level_cp0 *cp0 = (aci_hal_set_tx_power_level_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->En_High_Power = En_High_Power;
|
||||
index_input += 1;
|
||||
cp0->PA_Level = PA_Level;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x00f;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_le_tx_test_packet_number( uint32_t* Number_Of_Packets )
|
||||
{
|
||||
struct hci_request rq;
|
||||
aci_hal_le_tx_test_packet_number_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x014;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
*Number_Of_Packets = resp.Number_Of_Packets;
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_tone_start( uint8_t RF_Channel,
|
||||
uint8_t Freq_offset )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_tone_start_cp0 *cp0 = (aci_hal_tone_start_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->RF_Channel = RF_Channel;
|
||||
index_input += 1;
|
||||
cp0->Freq_offset = Freq_offset;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x015;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_tone_stop( void )
|
||||
{
|
||||
struct hci_request rq;
|
||||
tBleStatus status = 0;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x016;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_get_link_status( uint8_t* Link_Status,
|
||||
uint16_t* Link_Connection_Handle )
|
||||
{
|
||||
struct hci_request rq;
|
||||
aci_hal_get_link_status_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x017;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
Osal_MemCpy( (void*)Link_Status, (const void*)resp.Link_Status, 8 );
|
||||
Osal_MemCpy( (void*)Link_Connection_Handle, (const void*)resp.Link_Connection_Handle, 16 );
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_set_radio_activity_mask( uint16_t Radio_Activity_Mask )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_set_radio_activity_mask_cp0 *cp0 = (aci_hal_set_radio_activity_mask_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Radio_Activity_Mask = Radio_Activity_Mask;
|
||||
index_input += 2;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x018;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_get_anchor_period( uint32_t* Anchor_Period,
|
||||
uint32_t* Max_Free_Slot )
|
||||
{
|
||||
struct hci_request rq;
|
||||
aci_hal_get_anchor_period_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x019;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
*Anchor_Period = resp.Anchor_Period;
|
||||
*Max_Free_Slot = resp.Max_Free_Slot;
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_set_event_mask( uint32_t Event_Mask )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_set_event_mask_cp0 *cp0 = (aci_hal_set_event_mask_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Event_Mask = Event_Mask;
|
||||
index_input += 4;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x01a;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_set_peripheral_latency( uint8_t Enable )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_set_peripheral_latency_cp0 *cp0 = (aci_hal_set_peripheral_latency_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Enable = Enable;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x020;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_read_rssi( uint8_t* RSSI )
|
||||
{
|
||||
struct hci_request rq;
|
||||
aci_hal_read_rssi_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x022;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
*RSSI = resp.RSSI;
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_ead_encrypt_decrypt( uint8_t Mode,
|
||||
const uint8_t* Key,
|
||||
const uint8_t* IV,
|
||||
uint16_t In_Data_Length,
|
||||
const uint8_t* In_Data,
|
||||
uint16_t* Out_Data_Length,
|
||||
uint8_t* Out_Data )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_ead_encrypt_decrypt_cp0 *cp0 = (aci_hal_ead_encrypt_decrypt_cp0*)(cmd_buffer);
|
||||
aci_hal_ead_encrypt_decrypt_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
int index_input = 0;
|
||||
cp0->Mode = Mode;
|
||||
index_input += 1;
|
||||
Osal_MemCpy( (void*)&cp0->Key, (const void*)Key, 16 );
|
||||
index_input += 16;
|
||||
Osal_MemCpy( (void*)&cp0->IV, (const void*)IV, 8 );
|
||||
index_input += 8;
|
||||
cp0->In_Data_Length = In_Data_Length;
|
||||
index_input += 2;
|
||||
Osal_MemCpy( (void*)&cp0->In_Data, (const void*)In_Data, In_Data_Length );
|
||||
index_input += In_Data_Length;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x02f;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
*Out_Data_Length = resp.Out_Data_Length;
|
||||
Osal_MemCpy( (void*)Out_Data, (const void*)resp.Out_Data, *Out_Data_Length);
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_read_radio_reg( uint8_t Register_Address,
|
||||
uint8_t* reg_val )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_read_radio_reg_cp0 *cp0 = (aci_hal_read_radio_reg_cp0*)(cmd_buffer);
|
||||
aci_hal_read_radio_reg_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
int index_input = 0;
|
||||
cp0->Register_Address = Register_Address;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x030;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
*reg_val = resp.reg_val;
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_write_radio_reg( uint8_t Register_Address,
|
||||
uint8_t Register_Value )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_write_radio_reg_cp0 *cp0 = (aci_hal_write_radio_reg_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Register_Address = Register_Address;
|
||||
index_input += 1;
|
||||
cp0->Register_Value = Register_Value;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x031;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_read_raw_rssi( uint8_t* Value )
|
||||
{
|
||||
struct hci_request rq;
|
||||
aci_hal_read_raw_rssi_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x032;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
Osal_MemCpy( (void*)Value, (const void*)resp.Value, 3 );
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_rx_start( uint8_t RF_Channel )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_hal_rx_start_cp0 *cp0 = (aci_hal_rx_start_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->RF_Channel = RF_Channel;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x033;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_hal_rx_stop( void )
|
||||
{
|
||||
struct hci_request rq;
|
||||
tBleStatus status = 0;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x034;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_hal_aci.h
|
||||
* @brief STM32WB BLE API (HAL_ACI)
|
||||
* Auto-generated file: do not edit!
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_HAL_ACI_H__
|
||||
#define BLE_HAL_ACI_H__
|
||||
|
||||
|
||||
#include "auto/ble_types.h"
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_WRITE_CONFIG_DATA
|
||||
* This command writes a value to a configure data structure. It is useful to
|
||||
* setup directly some parameters for the BLE stack.
|
||||
* Refer to Annex for details on the different parameters that can be
|
||||
* configured.
|
||||
* Note: this command is an alias of ACI_WRITE_CONFIG_DATA.
|
||||
*
|
||||
* @param Offset Offset of the element in the configuration data structure
|
||||
* which has to be written.
|
||||
* Values:
|
||||
* - 0x00: CONFIG_DATA_PUBLIC_ADDRESS_OFFSET;
|
||||
* Bluetooth public address; 6 bytes
|
||||
* - 0x08: CONFIG_DATA_ER_OFFSET;
|
||||
* Encryption root key; 16 bytes
|
||||
* - 0x18: CONFIG_DATA_IR_OFFSET;
|
||||
* Identity root key; 16 bytes
|
||||
* - 0x2E: CONFIG_DATA_RANDOM_ADDRESS_OFFSET;
|
||||
* Static Random Address; 6 bytes
|
||||
* - 0x34: CONFIG_DATA_GAP_ADD_REC_NBR_OFFSET;
|
||||
* GAP service additional record number; 1 byte
|
||||
* - 0x35: CONFIG_DATA_SC_KEY_TYPE_OFFSET;
|
||||
* Secure Connections key type; 1 byte
|
||||
* - 0xB0: CONFIG_DATA_SMP_MODE_OFFSET;
|
||||
* SMP mode; 1 byte
|
||||
* - 0xC0: CONFIG_DATA_LL_SCAN_CHAN_MAP_OFFSET;
|
||||
* LL scan channel map; 1 byte
|
||||
* - 0xC1: CONFIG_DATA_LL_BG_SCAN_MODE_OFFSET;
|
||||
* LL background scan mode; 1 byte
|
||||
* - 0xC3: CONFIG_DATA_LL_RPA_MODE_OFFSET;
|
||||
* LL RPA mode; 1 byte
|
||||
* - 0xD1: CONFIG_DATA_LL_MAX_DATA_EXT_OFFSET [only for full stack];
|
||||
* LL maximum data length extension; 8 bytes
|
||||
* @param Length Length of data to be written
|
||||
* @param Value Data to be written
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_write_config_data( uint8_t Offset,
|
||||
uint8_t Length,
|
||||
const uint8_t* Value );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_READ_CONFIG_DATA
|
||||
* This command requests the value in the configure data structure. The number
|
||||
* of read bytes changes for different Offset.
|
||||
* Note: this command is an alias of ACI_READ_CONFIG_DATA.
|
||||
*
|
||||
* @param Offset Offset of the element in the configuration data structure
|
||||
* which has to be read.
|
||||
* Values:
|
||||
* - 0x00: CONFIG_DATA_PUBLIC_ADDRESS_OFFSET;
|
||||
* Bluetooth public address; 6 bytes
|
||||
* - 0x08: CONFIG_DATA_ER_OFFSET;
|
||||
* Encryption root key used to derive LTK (legacy) and CSRK; 16 bytes
|
||||
* - 0x18: CONFIG_DATA_IR_OFFSET
|
||||
* Identity root key used to derive DHK (legacy) and IRK; 16 bytes
|
||||
* - 0x2E: CONFIG_DATA_RANDOM_ADDRESS_OFFSET;
|
||||
* Static Random Address; 6 bytes
|
||||
* @param[out] Data_Length Length of Data in octets
|
||||
* @param[out] Data Data field associated with Offset parameter
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_read_config_data( uint8_t Offset,
|
||||
uint8_t* Data_Length,
|
||||
uint8_t* Data );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_SET_TX_POWER_LEVEL
|
||||
* This command sets the TX power level of the device. By controlling the PA
|
||||
* level, that determines the output power level (dBm) at the IC pin.
|
||||
* When the system starts up or reboots, the default TX power level is used,
|
||||
* which is the maximum value. Once this command is given, the output power
|
||||
* changes instantly, regardless if there is BLE communication going on or not.
|
||||
* For example, for debugging purpose, the device can be set to advertise all
|
||||
* the time. By using this command, one can then observe the evolution of the
|
||||
* TX signal strength.
|
||||
* The system keeps the last received TX power level from the command, i.e. the
|
||||
* 2nd command overwrites the previous TX power level. The new TX power level
|
||||
* remains until another ACI_HAL_SET_TX_POWER_LEVEL command, or the system
|
||||
* reboots. However, note that the advertising extensions commands allow, per
|
||||
* advertising set, to override the value of TX power determined by
|
||||
* ACI_HAL_SET_TX_POWER_LEVEL command (e.g. see ACI_GAP_ADV_SET_CONFIGURATION).
|
||||
* Refer to Annex for the dBm corresponding values of PA_Level parameter.
|
||||
*
|
||||
* @param En_High_Power Enable High Power mode - Deprecated and ignored
|
||||
* Values:
|
||||
* - 0x00: Standard Power
|
||||
* - 0x01: High Power
|
||||
* @param PA_Level Power amplifier output level.
|
||||
* Values:
|
||||
* - 0x00 ... 0x23
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_set_tx_power_level( uint8_t En_High_Power,
|
||||
uint8_t PA_Level );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_LE_TX_TEST_PACKET_NUMBER
|
||||
* This command returns the number of packets sent in Direct Test Mode.
|
||||
* When the Direct TX test is started, a 16-bit counter is used to count how
|
||||
* many packets have been transmitted.
|
||||
* This command can be used to check how many packets have been sent during the
|
||||
* Direct TX test.
|
||||
* The counter starts from 0 and counts upwards. The counter can wrap and start
|
||||
* from 0 again. The counter is not cleared until the next Direct TX test
|
||||
* starts.
|
||||
*
|
||||
* @param[out] Number_Of_Packets Number of packets sent during the last Direct
|
||||
* TX test.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_le_tx_test_packet_number( uint32_t* Number_Of_Packets );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_TONE_START
|
||||
* This command starts a carrier frequency, i.e. a tone, on a specific channel.
|
||||
* The frequency sine wave at the specific channel may be used for debugging
|
||||
* purpose only. The channel ID is a parameter from 0x00 to 0x27 for the 40 BLE
|
||||
* channels, e.g. 0x00 for 2.402 GHz, 0x01 for 2.404 GHz etc.
|
||||
* This command should not be used when normal BLE activities are ongoing.
|
||||
* The tone should be stopped by ACI_HAL_TONE_STOP command.
|
||||
*
|
||||
* @param RF_Channel BLE Channel ID, from 0x00 to 0x27 meaning (2.402 +
|
||||
* 0.002*0xXX) GHz
|
||||
* Device will continuously emit 0s, that means that the tone will be at
|
||||
* the channel center frequency minus the maximum frequency deviation
|
||||
* (250 kHz).
|
||||
* Values:
|
||||
* - 0x00 ... 0x27
|
||||
* @param Freq_offset Frequency Offset for tone channel
|
||||
* Values:
|
||||
* - 0x00 ... 0xFF
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_tone_start( uint8_t RF_Channel,
|
||||
uint8_t Freq_offset );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_TONE_STOP
|
||||
* This command is used to stop the previously started ACI_HAL_TONE_START
|
||||
* command.
|
||||
*
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_tone_stop( void );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_GET_LINK_STATUS
|
||||
* This command returns the status of the 8 BLE links managed by the device.
|
||||
*
|
||||
* @param[out] Link_Status Array of link status (8 links). Each link status is
|
||||
* 1 byte.
|
||||
* Values:
|
||||
* - 0x00: Idle
|
||||
* - 0x01: Advertising
|
||||
* - 0x02: Connected in Peripheral role
|
||||
* - 0x03: Scanning
|
||||
* - 0x04: Reserved
|
||||
* - 0x05: Connected in Central role
|
||||
* - 0x06: TX test mode
|
||||
* - 0x07: RX test mode
|
||||
* - 0x81: Advertising with Additional Beacon
|
||||
* @param[out] Link_Connection_Handle Array of connection handles (2 bytes) for
|
||||
* 8 links. Valid only if the link status is "connected" (0x02 or 0x05)
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_get_link_status( uint8_t* Link_Status,
|
||||
uint16_t* Link_Connection_Handle );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_SET_RADIO_ACTIVITY_MASK
|
||||
* This command set the bitmask associated to
|
||||
* ACI_HAL_END_OF_RADIO_ACTIVITY_EVENT.
|
||||
* Only the radio activities enabled in the mask will be reported to
|
||||
* application by ACI_HAL_END_OF_RADIO_ACTIVITY_EVENT
|
||||
*
|
||||
* @param Radio_Activity_Mask Bitmask of radio events
|
||||
* Flags:
|
||||
* - 0x0001: Idle
|
||||
* - 0x0002: Advertising
|
||||
* - 0x0004: Peripheral connection
|
||||
* - 0x0008: Scanning
|
||||
* - 0x0020: Central connection
|
||||
* - 0x0040: TX test mode
|
||||
* - 0x0080: RX test mode
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_set_radio_activity_mask( uint16_t Radio_Activity_Mask );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_GET_ANCHOR_PERIOD
|
||||
* This command returns information about the Anchor Period to help application
|
||||
* in selecting slot timings when operating in multi-link scenarios.
|
||||
*
|
||||
* @param[out] Anchor_Period Current anchor period.
|
||||
* T = N * 0.625 ms.
|
||||
* @param[out] Max_Free_Slot Maximum available time that can be allocated for a
|
||||
* new slot.
|
||||
* T = N * 0.625 ms.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_get_anchor_period( uint32_t* Anchor_Period,
|
||||
uint32_t* Max_Free_Slot );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_SET_EVENT_MASK
|
||||
* This command is used to enable/disable the generation of HAL events. If the
|
||||
* bit in the Event_Mask is set to a one, then the event associated with that
|
||||
* bit will be enabled.
|
||||
*
|
||||
* @param Event_Mask ACI HAL event mask. Default: 0x00000000.
|
||||
* Flags:
|
||||
* - 0x00000000: No events specified (Default)
|
||||
* - 0x00000001: ACI_HAL_SCAN_REQ_REPORT_EVENT
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_set_event_mask( uint32_t Event_Mask );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_SET_PERIPHERAL_LATENCY
|
||||
* This command is used to disable/enable the Peripheral latency feature during
|
||||
* a connection. Note that, by default, the Peripheral latency is enabled at
|
||||
* connection time.
|
||||
*
|
||||
* @param Enable Enable/disable Peripheral latency.
|
||||
* Values:
|
||||
* - 0x00: Peripheral latency is disabled
|
||||
* - 0x01: Peripheral latency is enabled
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_set_peripheral_latency( uint8_t Enable );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_READ_RSSI
|
||||
* This command returns the value of the RSSI.
|
||||
*
|
||||
* @param[out] RSSI RSSI (signed integer).
|
||||
* Units: dBm.
|
||||
* Values:
|
||||
* - 127: RSSI not available
|
||||
* - -127 ... 20
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_read_rssi( uint8_t* RSSI );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_EAD_ENCRYPT_DECRYPT
|
||||
* This command encrypts or decrypts data following the Encrypted Advertising
|
||||
* Data scheme.
|
||||
* When encryption mode is selected, In_Data shall only contain the Payload
|
||||
* field to encrypt. The command adds the Randomizer and MIC fields in the
|
||||
* result. The result data length (Out_Data_Length) is equal to the input
|
||||
* length plus 9.
|
||||
* When decryption mode is selected, In_Data shall contain the full Encrypted
|
||||
* Data (Randomizer + Payload + MIC). The result data length (Out_Data_Length)
|
||||
* is equal to the input length minus 9.
|
||||
* If the decryption fails, the returned status is BLE_STATUS_FAILED, otherwise
|
||||
* it is BLE_STATUS_SUCCESS.
|
||||
* Note: the In_Data_Length value must not exceed (BLE_CMD_MAX_PARAM_LEN - 27)
|
||||
* i.e. 228 for BLE_CMD_MAX_PARAM_LEN default value.
|
||||
*
|
||||
* @param Mode EAD operation mode: encryption or decryption.
|
||||
* Values:
|
||||
* - 0x00: Encryption
|
||||
* - 0x01: Decryption
|
||||
* @param Key Session key used for EAD operation (in Little Endian format).
|
||||
* @param IV Initialization vector used for EAD operation (in Little Endian
|
||||
* format).
|
||||
* @param In_Data_Length Length of input data
|
||||
* @param In_Data Input data
|
||||
* @param[out] Out_Data_Length Length of result data
|
||||
* @param[out] Out_Data Result data
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_ead_encrypt_decrypt( uint8_t Mode,
|
||||
const uint8_t* Key,
|
||||
const uint8_t* IV,
|
||||
uint16_t In_Data_Length,
|
||||
const uint8_t* In_Data,
|
||||
uint16_t* Out_Data_Length,
|
||||
uint8_t* Out_Data );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_READ_RADIO_REG
|
||||
* This command Reads Register value from the RF module.
|
||||
*
|
||||
* @param Register_Address Address of the register to be read
|
||||
* @param[out] reg_val Register value
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_read_radio_reg( uint8_t Register_Address,
|
||||
uint8_t* reg_val );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_WRITE_RADIO_REG
|
||||
* This command writes Register value to the RF module.
|
||||
*
|
||||
* @param Register_Address Address of the register to be written
|
||||
* @param Register_Value Value to be written
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_write_radio_reg( uint8_t Register_Address,
|
||||
uint8_t Register_Value );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_READ_RAW_RSSI
|
||||
* This command returns the raw value of the RSSI.
|
||||
*
|
||||
* @param[out] Value RAW RSSI value
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_read_raw_rssi( uint8_t* Value );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_RX_START
|
||||
* This command does set up the RF to listen to a specific RF channel.
|
||||
*
|
||||
* @param RF_Channel BLE Channel ID, from 0x00 to 0x27 meaning (2.402 +
|
||||
* 0.002*0xXX) GHz
|
||||
* Device will continuously emit 0s, that means that the tone will be at
|
||||
* the channel center frequency minus the maximum frequency deviation
|
||||
* (250 kHz).
|
||||
* Values:
|
||||
* - 0x00 ... 0x27
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_rx_start( uint8_t RF_Channel );
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_RX_STOP
|
||||
* This command stops a previous ACI_HAL_RX_START command.
|
||||
*
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_hal_rx_stop( void );
|
||||
|
||||
|
||||
#endif /* BLE_HAL_ACI_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,306 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_l2cap_aci.c
|
||||
* @brief STM32WB BLE API (l2cap_aci)
|
||||
* Auto-generated file: do not edit!
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#include "auto/ble_l2cap_aci.h"
|
||||
|
||||
tBleStatus aci_l2cap_connection_parameter_update_req( uint16_t Connection_Handle,
|
||||
uint16_t Conn_Interval_Min,
|
||||
uint16_t Conn_Interval_Max,
|
||||
uint16_t Latency,
|
||||
uint16_t Timeout_Multiplier )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_connection_parameter_update_req_cp0 *cp0 = (aci_l2cap_connection_parameter_update_req_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Connection_Handle = Connection_Handle;
|
||||
index_input += 2;
|
||||
cp0->Conn_Interval_Min = Conn_Interval_Min;
|
||||
index_input += 2;
|
||||
cp0->Conn_Interval_Max = Conn_Interval_Max;
|
||||
index_input += 2;
|
||||
cp0->Latency = Latency;
|
||||
index_input += 2;
|
||||
cp0->Timeout_Multiplier = Timeout_Multiplier;
|
||||
index_input += 2;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x181;
|
||||
rq.event = 0x0F;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_connection_parameter_update_resp( uint16_t Connection_Handle,
|
||||
uint16_t Conn_Interval_Min,
|
||||
uint16_t Conn_Interval_Max,
|
||||
uint16_t Latency,
|
||||
uint16_t Timeout_Multiplier,
|
||||
uint16_t Minimum_CE_Length,
|
||||
uint16_t Maximum_CE_Length,
|
||||
uint8_t Identifier,
|
||||
uint8_t Accept )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_connection_parameter_update_resp_cp0 *cp0 = (aci_l2cap_connection_parameter_update_resp_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Connection_Handle = Connection_Handle;
|
||||
index_input += 2;
|
||||
cp0->Conn_Interval_Min = Conn_Interval_Min;
|
||||
index_input += 2;
|
||||
cp0->Conn_Interval_Max = Conn_Interval_Max;
|
||||
index_input += 2;
|
||||
cp0->Latency = Latency;
|
||||
index_input += 2;
|
||||
cp0->Timeout_Multiplier = Timeout_Multiplier;
|
||||
index_input += 2;
|
||||
cp0->Minimum_CE_Length = Minimum_CE_Length;
|
||||
index_input += 2;
|
||||
cp0->Maximum_CE_Length = Maximum_CE_Length;
|
||||
index_input += 2;
|
||||
cp0->Identifier = Identifier;
|
||||
index_input += 1;
|
||||
cp0->Accept = Accept;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x182;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_coc_connect( uint16_t Connection_Handle,
|
||||
uint16_t SPSM,
|
||||
uint16_t MTU,
|
||||
uint16_t MPS,
|
||||
uint16_t Initial_Credits,
|
||||
uint8_t Channel_Number )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_coc_connect_cp0 *cp0 = (aci_l2cap_coc_connect_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Connection_Handle = Connection_Handle;
|
||||
index_input += 2;
|
||||
cp0->SPSM = SPSM;
|
||||
index_input += 2;
|
||||
cp0->MTU = MTU;
|
||||
index_input += 2;
|
||||
cp0->MPS = MPS;
|
||||
index_input += 2;
|
||||
cp0->Initial_Credits = Initial_Credits;
|
||||
index_input += 2;
|
||||
cp0->Channel_Number = Channel_Number;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x188;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_coc_connect_confirm( uint16_t Connection_Handle,
|
||||
uint16_t MTU,
|
||||
uint16_t MPS,
|
||||
uint16_t Initial_Credits,
|
||||
uint16_t Result,
|
||||
uint8_t Max_Channel_Number,
|
||||
uint8_t* Channel_Number,
|
||||
uint8_t* Channel_Index_List )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_coc_connect_confirm_cp0 *cp0 = (aci_l2cap_coc_connect_confirm_cp0*)(cmd_buffer);
|
||||
aci_l2cap_coc_connect_confirm_rp0 resp;
|
||||
Osal_MemSet( &resp, 0, sizeof(resp) );
|
||||
int index_input = 0;
|
||||
cp0->Connection_Handle = Connection_Handle;
|
||||
index_input += 2;
|
||||
cp0->MTU = MTU;
|
||||
index_input += 2;
|
||||
cp0->MPS = MPS;
|
||||
index_input += 2;
|
||||
cp0->Initial_Credits = Initial_Credits;
|
||||
index_input += 2;
|
||||
cp0->Result = Result;
|
||||
index_input += 2;
|
||||
cp0->Max_Channel_Number = Max_Channel_Number;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x189;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &resp;
|
||||
rq.rlen = sizeof(resp);
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
if ( resp.Status )
|
||||
return resp.Status;
|
||||
*Channel_Number = resp.Channel_Number;
|
||||
Osal_MemCpy( (void*)Channel_Index_List, (const void*)resp.Channel_Index_List, *Channel_Number);
|
||||
return BLE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_coc_reconf( uint16_t Connection_Handle,
|
||||
uint16_t MTU,
|
||||
uint16_t MPS,
|
||||
uint8_t Channel_Number,
|
||||
const uint8_t* Channel_Index_List )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_coc_reconf_cp0 *cp0 = (aci_l2cap_coc_reconf_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Connection_Handle = Connection_Handle;
|
||||
index_input += 2;
|
||||
cp0->MTU = MTU;
|
||||
index_input += 2;
|
||||
cp0->MPS = MPS;
|
||||
index_input += 2;
|
||||
cp0->Channel_Number = Channel_Number;
|
||||
index_input += 1;
|
||||
Osal_MemCpy( (void*)&cp0->Channel_Index_List, (const void*)Channel_Index_List, Channel_Number );
|
||||
index_input += Channel_Number;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x18a;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_coc_reconf_confirm( uint16_t Connection_Handle,
|
||||
uint16_t Result )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_coc_reconf_confirm_cp0 *cp0 = (aci_l2cap_coc_reconf_confirm_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Connection_Handle = Connection_Handle;
|
||||
index_input += 2;
|
||||
cp0->Result = Result;
|
||||
index_input += 2;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x18b;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_coc_disconnect( uint8_t Channel_Index )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_coc_disconnect_cp0 *cp0 = (aci_l2cap_coc_disconnect_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Channel_Index = Channel_Index;
|
||||
index_input += 1;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x18c;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_coc_flow_control( uint8_t Channel_Index,
|
||||
uint16_t Credits )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_coc_flow_control_cp0 *cp0 = (aci_l2cap_coc_flow_control_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Channel_Index = Channel_Index;
|
||||
index_input += 1;
|
||||
cp0->Credits = Credits;
|
||||
index_input += 2;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x18d;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
tBleStatus aci_l2cap_coc_tx_data( uint8_t Channel_Index,
|
||||
uint16_t Length,
|
||||
const uint8_t* Data )
|
||||
{
|
||||
struct hci_request rq;
|
||||
uint8_t cmd_buffer[BLE_CMD_MAX_PARAM_LEN];
|
||||
aci_l2cap_coc_tx_data_cp0 *cp0 = (aci_l2cap_coc_tx_data_cp0*)(cmd_buffer);
|
||||
tBleStatus status = 0;
|
||||
int index_input = 0;
|
||||
cp0->Channel_Index = Channel_Index;
|
||||
index_input += 1;
|
||||
cp0->Length = Length;
|
||||
index_input += 2;
|
||||
Osal_MemCpy( (void*)&cp0->Data, (const void*)Data, Length );
|
||||
index_input += Length;
|
||||
Osal_MemSet( &rq, 0, sizeof(rq) );
|
||||
rq.ogf = 0x3f;
|
||||
rq.ocf = 0x18e;
|
||||
rq.cparam = cmd_buffer;
|
||||
rq.clen = index_input;
|
||||
rq.rparam = &status;
|
||||
rq.rlen = 1;
|
||||
if ( hci_send_req(&rq, FALSE) < 0 )
|
||||
return BLE_STATUS_TIMEOUT;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_l2cap_aci.h
|
||||
* @brief STM32WB BLE API (L2CAP_ACI)
|
||||
* Auto-generated file: do not edit!
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_L2CAP_ACI_H__
|
||||
#define BLE_L2CAP_ACI_H__
|
||||
|
||||
|
||||
#include "auto/ble_types.h"
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_REQ
|
||||
* Sends an L2CAP connection parameter update request from the Peripheral to
|
||||
* the Central.
|
||||
* An ACI_L2CAP_CONNECTION_UPDATE_RESP_EVENT event is raised when the Central
|
||||
* responds to the request (accepts or rejects).
|
||||
*
|
||||
* @param Connection_Handle Connection handle for which the command applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF
|
||||
* @param Conn_Interval_Min Minimum value for the connection event interval.
|
||||
* Time = N * 1.25 ms.
|
||||
* Values:
|
||||
* - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms)
|
||||
* @param Conn_Interval_Max Maximum value for the connection event interval.
|
||||
* Time = N * 1.25 ms.
|
||||
* Values:
|
||||
* - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms)
|
||||
* @param Latency Maximum Peripheral latency for the connection in number of
|
||||
* connection events.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x01F3
|
||||
* @param Timeout_Multiplier Defines connection timeout parameter in the
|
||||
* following manner: Timeout Multiplier * 10ms.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_connection_parameter_update_req( uint16_t Connection_Handle,
|
||||
uint16_t Conn_Interval_Min,
|
||||
uint16_t Conn_Interval_Max,
|
||||
uint16_t Latency,
|
||||
uint16_t Timeout_Multiplier );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_CONNECTION_PARAMETER_UPDATE_RESP
|
||||
* Accepts or rejects a connection update. This command should be sent in
|
||||
* response to an ACI_L2CAP_CONNECTION_UPDATE_REQ_EVENT event from the
|
||||
* controller. The accept parameter has to be set if the connection parameters
|
||||
* given in the event are acceptable.
|
||||
*
|
||||
* @param Connection_Handle Connection handle for which the command applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF
|
||||
* @param Conn_Interval_Min Minimum value for the connection event interval.
|
||||
* Time = N * 1.25 ms.
|
||||
* Values:
|
||||
* - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms)
|
||||
* @param Conn_Interval_Max Maximum value for the connection event interval.
|
||||
* Time = N * 1.25 ms.
|
||||
* Values:
|
||||
* - 0x0006 (7.50 ms) ... 0x0C80 (4000.00 ms)
|
||||
* @param Latency Maximum Peripheral latency for the connection in number of
|
||||
* connection events.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x01F3
|
||||
* @param Timeout_Multiplier Defines connection timeout parameter in the
|
||||
* following manner: Timeout Multiplier * 10ms.
|
||||
* @param Minimum_CE_Length Information parameter about the minimum length of
|
||||
* connection needed for this LE connection.
|
||||
* Time = N * 0.625 ms.
|
||||
* Values:
|
||||
* - 0x0000 (0.000 ms) ... 0xFFFF (40959.375 ms)
|
||||
* @param Maximum_CE_Length Information parameter about the maximum length of
|
||||
* connection needed for this LE connection.
|
||||
* Time = N * 0.625 ms.
|
||||
* Values:
|
||||
* - 0x0000 (0.000 ms) ... 0xFFFF (40959.375 ms)
|
||||
* @param Identifier Received identifier.
|
||||
* @param Accept Specify if connection update parameters are acceptable or not.
|
||||
* Values:
|
||||
* - 0x00: Reject
|
||||
* - 0x01: Accept
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_connection_parameter_update_resp( uint16_t Connection_Handle,
|
||||
uint16_t Conn_Interval_Min,
|
||||
uint16_t Conn_Interval_Max,
|
||||
uint16_t Latency,
|
||||
uint16_t Timeout_Multiplier,
|
||||
uint16_t Minimum_CE_Length,
|
||||
uint16_t Maximum_CE_Length,
|
||||
uint8_t Identifier,
|
||||
uint8_t Accept );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_COC_CONNECT
|
||||
* This command sends a Credit Based Connection Request packet on the specified
|
||||
* connection. See Core Specification [Vol 3, Part A].
|
||||
*
|
||||
* @param Connection_Handle Connection handle for which the command applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF
|
||||
* @param SPSM Simplified Protocol/Service Multiplexer.
|
||||
* Values:
|
||||
* - 0x0001 ... 0x00FF
|
||||
* @param MTU Maximum Transmission Unit.
|
||||
* Values:
|
||||
* - 23 ... 65535
|
||||
* - 64 ... 246: for Enhanced ATT
|
||||
* @param MPS Maximum payload size (in octets).
|
||||
* Values:
|
||||
* - 23 ... 248
|
||||
* - 64 ... 248: for Enhanced ATT
|
||||
* @param Initial_Credits Number of K-frames that can be received on the
|
||||
* created channel(s) by the L2CAP layer entity sending this packet.
|
||||
* Values:
|
||||
* - 0 ... 65535
|
||||
* @param Channel_Number Number of channels to be created. If this parameter is
|
||||
* set to 0, it requests the creation of one LE credit based connection-
|
||||
* oriented channel. Otherwise, it requests the creation of one or more
|
||||
* enhanced credit based connection-oriented channels.
|
||||
* Values:
|
||||
* - 0 ... 5
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_coc_connect( uint16_t Connection_Handle,
|
||||
uint16_t SPSM,
|
||||
uint16_t MTU,
|
||||
uint16_t MPS,
|
||||
uint16_t Initial_Credits,
|
||||
uint8_t Channel_Number );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_COC_CONNECT_CONFIRM
|
||||
* This command sends a Credit Based Connection Response packet. It must be
|
||||
* used upon receipt of a connection request through an
|
||||
* ACI_L2CAP_COC_CONNECT_EVENT event.
|
||||
* By setting the Result parameter to 0x0000, the application can accept all
|
||||
* connections or only some. In this case, the number of accepted connections
|
||||
* depends on the Max_Channel_Number parameter. Note that if some connections
|
||||
* are refused, the Result parameter is automatically modified by the BLE
|
||||
* stack.
|
||||
* By setting the Result parameter to a non-zero value, the application can
|
||||
* refuse all connections. The Result value shall then be one of the
|
||||
* "Connection refused" or "All connections refused" values.
|
||||
* See Core Specification [Vol 3, Part A].
|
||||
*
|
||||
* @param Connection_Handle Connection handle for which the command applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF
|
||||
* @param MTU Maximum Transmission Unit.
|
||||
* Values:
|
||||
* - 23 ... 65535
|
||||
* - 64 ... 246: for Enhanced ATT
|
||||
* @param MPS Maximum payload size (in octets).
|
||||
* Values:
|
||||
* - 23 ... 248
|
||||
* - 64 ... 248: for Enhanced ATT
|
||||
* @param Initial_Credits Number of K-frames that can be received on the
|
||||
* created channel(s) by the L2CAP layer entity sending this packet.
|
||||
* Values:
|
||||
* - 0 ... 65535
|
||||
* @param Result Indicates the outcome of the request. See Core Specification
|
||||
* [Vol 3, Part A, Table 4.16] for LE credit based connection-oriented
|
||||
* channels, or [Vol 3, Part A, Table 4.17] for enhanced credit based
|
||||
* connection-oriented channels.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x000F
|
||||
* @param Max_Channel_Number Indicates the maximum number of channels that can
|
||||
* be created.
|
||||
* Values:
|
||||
* - 0x01 ... 0x05
|
||||
* @param[out] Channel_Number Number of created channels. It is the length of
|
||||
* Channel_Index_List.
|
||||
* Values:
|
||||
* - 0 ... 5
|
||||
* @param[out] Channel_Index_List List of channel indexes for which the
|
||||
* primitive applies.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_coc_connect_confirm( uint16_t Connection_Handle,
|
||||
uint16_t MTU,
|
||||
uint16_t MPS,
|
||||
uint16_t Initial_Credits,
|
||||
uint16_t Result,
|
||||
uint8_t Max_Channel_Number,
|
||||
uint8_t* Channel_Number,
|
||||
uint8_t* Channel_Index_List );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_COC_RECONF
|
||||
* This command sends a Credit Based Reconfigure Request packet on the
|
||||
* specified connection. See Core Specification [Vol 3, Part A].
|
||||
*
|
||||
* @param Connection_Handle Connection handle for which the command applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF
|
||||
* @param MTU Maximum Transmission Unit.
|
||||
* Values:
|
||||
* - 23 ... 65535
|
||||
* - 64 ... 246: for Enhanced ATT
|
||||
* @param MPS Maximum payload size (in octets).
|
||||
* Values:
|
||||
* - 23 ... 248
|
||||
* - 64 ... 248: for Enhanced ATT
|
||||
* @param Channel_Number Number of created channels. It is the length of
|
||||
* Channel_Index_List.
|
||||
* Values:
|
||||
* - 1 ... 5
|
||||
* @param Channel_Index_List List of channel indexes for which the primitive
|
||||
* applies.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_coc_reconf( uint16_t Connection_Handle,
|
||||
uint16_t MTU,
|
||||
uint16_t MPS,
|
||||
uint8_t Channel_Number,
|
||||
const uint8_t* Channel_Index_List );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_COC_RECONF_CONFIRM
|
||||
* This command sends a Credit Based Reconfigure Response packet. It must be
|
||||
* used upon receipt of a Credit Based Reconfigure Request through an
|
||||
* ACI_L2CAP_COC_RECONF_EVENT event. A Result value of 0x0000 indicates success
|
||||
* while a non-zero value indicates the request is refused.
|
||||
* See Core Specification [Vol 3, Part A].
|
||||
*
|
||||
* @param Connection_Handle Connection handle for which the command applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF
|
||||
* @param Result Indicates the outcome of the request. See Core Specification
|
||||
* [Vol 3, Part A, Table 4.18].
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0004
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_coc_reconf_confirm( uint16_t Connection_Handle,
|
||||
uint16_t Result );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_COC_DISCONNECT
|
||||
* This command sends a Disconnection Request signaling packet on the specified
|
||||
* connection-oriented channel. See Core Specification [Vol 3, Part A].
|
||||
* The ACI_L2CAP_COC_DISCONNECT_EVENT event is received when the disconnection
|
||||
* of the channel is effective.
|
||||
*
|
||||
* @param Channel_Index Index of the connection-oriented channel for which the
|
||||
* primitive applies.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_coc_disconnect( uint8_t Channel_Index );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_COC_FLOW_CONTROL
|
||||
* This command sends a Flow Control Credit signaling packet on the specified
|
||||
* connection-oriented channel. See Core Specification [Vol 3, Part A].
|
||||
*
|
||||
* @param Channel_Index Index of the connection-oriented channel for which the
|
||||
* primitive applies.
|
||||
* @param Credits Number of credits the receiving device can increment,
|
||||
* corresponding to the number of K-frames that can be sent to the peer
|
||||
* device sending the Flow Control Credit packet.
|
||||
* Values:
|
||||
* - 1 ... 65535
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_coc_flow_control( uint8_t Channel_Index,
|
||||
uint16_t Credits );
|
||||
|
||||
/**
|
||||
* @brief ACI_L2CAP_COC_TX_DATA
|
||||
* This command sends a K-frame packet on the specified connection-oriented
|
||||
* channel. See Core Specification [Vol 3, Part A].
|
||||
* Note: for the first K-frame of the SDU, the Information data shall contain
|
||||
* the L2CAP SDU Length coded on two octets followed by the K-frame information
|
||||
* payload. For the next K-frames of the SDU, the Information data shall only
|
||||
* contain the K-frame information payload.
|
||||
* The Length value must not exceed (BLE_CMD_MAX_PARAM_LEN - 3) i.e. 252 for
|
||||
* BLE_CMD_MAX_PARAM_LEN default value.
|
||||
*
|
||||
* @param Channel_Index Index of the connection-oriented channel for which the
|
||||
* primitive applies.
|
||||
* @param Length Length of Data (in octets)
|
||||
* @param Data Information data
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
tBleStatus aci_l2cap_coc_tx_data( uint8_t Channel_Index,
|
||||
uint16_t Length,
|
||||
const uint8_t* Data );
|
||||
|
||||
|
||||
#endif /* BLE_L2CAP_ACI_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,200 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_vs_codes.h
|
||||
* @brief STM32WB BLE API (vendor specific event codes)
|
||||
* Auto-generated file: do not edit!
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_VS_CODES_H__
|
||||
#define BLE_VS_CODES_H__
|
||||
|
||||
|
||||
/* Vendor specific codes of ACI General events
|
||||
*/
|
||||
|
||||
/* ACI_WARNING_EVENT code */
|
||||
#define ACI_WARNING_VSEVT_CODE 0x0006U
|
||||
|
||||
/* Vendor specific codes of ACI GAP events
|
||||
*/
|
||||
|
||||
/* ACI_GAP_LIMITED_DISCOVERABLE_EVENT code */
|
||||
#define ACI_GAP_LIMITED_DISCOVERABLE_VSEVT_CODE 0x0400U
|
||||
|
||||
/* ACI_GAP_PAIRING_COMPLETE_EVENT code */
|
||||
#define ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE 0x0401U
|
||||
|
||||
/* ACI_GAP_PASS_KEY_REQ_EVENT code */
|
||||
#define ACI_GAP_PASS_KEY_REQ_VSEVT_CODE 0x0402U
|
||||
|
||||
/* ACI_GAP_AUTHORIZATION_REQ_EVENT code */
|
||||
#define ACI_GAP_AUTHORIZATION_REQ_VSEVT_CODE 0x0403U
|
||||
|
||||
/* ACI_GAP_BOND_LOST_EVENT code */
|
||||
#define ACI_GAP_BOND_LOST_VSEVT_CODE 0x0405U
|
||||
|
||||
/* ACI_GAP_PROC_COMPLETE_EVENT code */
|
||||
#define ACI_GAP_PROC_COMPLETE_VSEVT_CODE 0x0407U
|
||||
|
||||
/* ACI_GAP_ADDR_NOT_RESOLVED_EVENT code */
|
||||
#define ACI_GAP_ADDR_NOT_RESOLVED_VSEVT_CODE 0x0408U
|
||||
|
||||
/* ACI_GAP_NUMERIC_COMPARISON_VALUE_EVENT code */
|
||||
#define ACI_GAP_NUMERIC_COMPARISON_VALUE_VSEVT_CODE 0x0409U
|
||||
|
||||
/* ACI_GAP_KEYPRESS_NOTIFICATION_EVENT code */
|
||||
#define ACI_GAP_KEYPRESS_NOTIFICATION_VSEVT_CODE 0x040AU
|
||||
|
||||
/* ACI_GAP_PAIRING_REQUEST_EVENT code */
|
||||
#define ACI_GAP_PAIRING_REQUEST_VSEVT_CODE 0x040BU
|
||||
|
||||
/* Vendor specific codes of ACI GATT/ATT events
|
||||
*/
|
||||
|
||||
/* ACI_GATT_ATTRIBUTE_MODIFIED_EVENT code */
|
||||
#define ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE 0x0C01U
|
||||
|
||||
/* ACI_GATT_PROC_TIMEOUT_EVENT code */
|
||||
#define ACI_GATT_PROC_TIMEOUT_VSEVT_CODE 0x0C02U
|
||||
|
||||
/* ACI_ATT_EXCHANGE_MTU_RESP_EVENT code */
|
||||
#define ACI_ATT_EXCHANGE_MTU_RESP_VSEVT_CODE 0x0C03U
|
||||
|
||||
/* ACI_ATT_FIND_INFO_RESP_EVENT code */
|
||||
#define ACI_ATT_FIND_INFO_RESP_VSEVT_CODE 0x0C04U
|
||||
|
||||
/* ACI_ATT_FIND_BY_TYPE_VALUE_RESP_EVENT code */
|
||||
#define ACI_ATT_FIND_BY_TYPE_VALUE_RESP_VSEVT_CODE 0x0C05U
|
||||
|
||||
/* ACI_ATT_READ_BY_TYPE_RESP_EVENT code */
|
||||
#define ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE 0x0C06U
|
||||
|
||||
/* ACI_ATT_READ_RESP_EVENT code */
|
||||
#define ACI_ATT_READ_RESP_VSEVT_CODE 0x0C07U
|
||||
|
||||
/* ACI_ATT_READ_BLOB_RESP_EVENT code */
|
||||
#define ACI_ATT_READ_BLOB_RESP_VSEVT_CODE 0x0C08U
|
||||
|
||||
/* ACI_ATT_READ_MULTIPLE_RESP_EVENT code */
|
||||
#define ACI_ATT_READ_MULTIPLE_RESP_VSEVT_CODE 0x0C09U
|
||||
|
||||
/* ACI_ATT_READ_BY_GROUP_TYPE_RESP_EVENT code */
|
||||
#define ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE 0x0C0AU
|
||||
|
||||
/* ACI_ATT_PREPARE_WRITE_RESP_EVENT code */
|
||||
#define ACI_ATT_PREPARE_WRITE_RESP_VSEVT_CODE 0x0C0CU
|
||||
|
||||
/* ACI_ATT_EXEC_WRITE_RESP_EVENT code */
|
||||
#define ACI_ATT_EXEC_WRITE_RESP_VSEVT_CODE 0x0C0DU
|
||||
|
||||
/* ACI_GATT_INDICATION_EVENT code */
|
||||
#define ACI_GATT_INDICATION_VSEVT_CODE 0x0C0EU
|
||||
|
||||
/* ACI_GATT_NOTIFICATION_EVENT code */
|
||||
#define ACI_GATT_NOTIFICATION_VSEVT_CODE 0x0C0FU
|
||||
|
||||
/* ACI_GATT_PROC_COMPLETE_EVENT code */
|
||||
#define ACI_GATT_PROC_COMPLETE_VSEVT_CODE 0x0C10U
|
||||
|
||||
/* ACI_GATT_ERROR_RESP_EVENT code */
|
||||
#define ACI_GATT_ERROR_RESP_VSEVT_CODE 0x0C11U
|
||||
|
||||
/* ACI_GATT_DISC_READ_CHAR_BY_UUID_RESP_EVENT code */
|
||||
#define ACI_GATT_DISC_READ_CHAR_BY_UUID_RESP_VSEVT_CODE 0x0C12U
|
||||
|
||||
/* ACI_GATT_WRITE_PERMIT_REQ_EVENT code */
|
||||
#define ACI_GATT_WRITE_PERMIT_REQ_VSEVT_CODE 0x0C13U
|
||||
|
||||
/* ACI_GATT_READ_PERMIT_REQ_EVENT code */
|
||||
#define ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE 0x0C14U
|
||||
|
||||
/* ACI_GATT_READ_MULTI_PERMIT_REQ_EVENT code */
|
||||
#define ACI_GATT_READ_MULTI_PERMIT_REQ_VSEVT_CODE 0x0C15U
|
||||
|
||||
/* ACI_GATT_TX_POOL_AVAILABLE_EVENT code */
|
||||
#define ACI_GATT_TX_POOL_AVAILABLE_VSEVT_CODE 0x0C16U
|
||||
|
||||
/* ACI_GATT_SERVER_CONFIRMATION_EVENT code */
|
||||
#define ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE 0x0C17U
|
||||
|
||||
/* ACI_GATT_PREPARE_WRITE_PERMIT_REQ_EVENT code */
|
||||
#define ACI_GATT_PREPARE_WRITE_PERMIT_REQ_VSEVT_CODE 0x0C18U
|
||||
|
||||
/* ACI_GATT_EATT_BEARER_EVENT code */
|
||||
#define ACI_GATT_EATT_BEARER_VSEVT_CODE 0x0C19U
|
||||
|
||||
/* ACI_GATT_MULT_NOTIFICATION_EVENT code */
|
||||
#define ACI_GATT_MULT_NOTIFICATION_VSEVT_CODE 0x0C1AU
|
||||
|
||||
/* ACI_GATT_NOTIFICATION_COMPLETE_EVENT code */
|
||||
#define ACI_GATT_NOTIFICATION_COMPLETE_VSEVT_CODE 0x0C1BU
|
||||
|
||||
/* ACI_GATT_READ_EXT_EVENT code */
|
||||
#define ACI_GATT_READ_EXT_VSEVT_CODE 0x0C1DU
|
||||
|
||||
/* ACI_GATT_INDICATION_EXT_EVENT code */
|
||||
#define ACI_GATT_INDICATION_EXT_VSEVT_CODE 0x0C1EU
|
||||
|
||||
/* ACI_GATT_NOTIFICATION_EXT_EVENT code */
|
||||
#define ACI_GATT_NOTIFICATION_EXT_VSEVT_CODE 0x0C1FU
|
||||
|
||||
/* Vendor specific codes of ACI L2CAP events
|
||||
*/
|
||||
|
||||
/* ACI_L2CAP_CONNECTION_UPDATE_RESP_EVENT code */
|
||||
#define ACI_L2CAP_CONNECTION_UPDATE_RESP_VSEVT_CODE 0x0800U
|
||||
|
||||
/* ACI_L2CAP_PROC_TIMEOUT_EVENT code */
|
||||
#define ACI_L2CAP_PROC_TIMEOUT_VSEVT_CODE 0x0801U
|
||||
|
||||
/* ACI_L2CAP_CONNECTION_UPDATE_REQ_EVENT code */
|
||||
#define ACI_L2CAP_CONNECTION_UPDATE_REQ_VSEVT_CODE 0x0802U
|
||||
|
||||
/* ACI_L2CAP_COMMAND_REJECT_EVENT code */
|
||||
#define ACI_L2CAP_COMMAND_REJECT_VSEVT_CODE 0x080AU
|
||||
|
||||
/* ACI_L2CAP_COC_CONNECT_EVENT code */
|
||||
#define ACI_L2CAP_COC_CONNECT_VSEVT_CODE 0x0810U
|
||||
|
||||
/* ACI_L2CAP_COC_CONNECT_CONFIRM_EVENT code */
|
||||
#define ACI_L2CAP_COC_CONNECT_CONFIRM_VSEVT_CODE 0x0811U
|
||||
|
||||
/* ACI_L2CAP_COC_RECONF_EVENT code */
|
||||
#define ACI_L2CAP_COC_RECONF_VSEVT_CODE 0x0812U
|
||||
|
||||
/* ACI_L2CAP_COC_RECONF_CONFIRM_EVENT code */
|
||||
#define ACI_L2CAP_COC_RECONF_CONFIRM_VSEVT_CODE 0x0813U
|
||||
|
||||
/* ACI_L2CAP_COC_DISCONNECT_EVENT code */
|
||||
#define ACI_L2CAP_COC_DISCONNECT_VSEVT_CODE 0x0814U
|
||||
|
||||
/* ACI_L2CAP_COC_FLOW_CONTROL_EVENT code */
|
||||
#define ACI_L2CAP_COC_FLOW_CONTROL_VSEVT_CODE 0x0815U
|
||||
|
||||
/* ACI_L2CAP_COC_RX_DATA_EVENT code */
|
||||
#define ACI_L2CAP_COC_RX_DATA_VSEVT_CODE 0x0816U
|
||||
|
||||
/* ACI_L2CAP_COC_TX_POOL_AVAILABLE_EVENT code */
|
||||
#define ACI_L2CAP_COC_TX_POOL_AVAILABLE_VSEVT_CODE 0x0817U
|
||||
|
||||
/* Vendor specific codes of ACI HAL events
|
||||
*/
|
||||
|
||||
/* ACI_HAL_END_OF_RADIO_ACTIVITY_EVENT code */
|
||||
#define ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE 0x1804U
|
||||
|
||||
/* ACI_HAL_SCAN_REQ_REPORT_EVENT code */
|
||||
#define ACI_HAL_SCAN_REQ_REPORT_VSEVT_CODE 0x1805U
|
||||
|
||||
|
||||
#endif /* BLE_VS_CODES_H__ */
|
||||
@@ -0,0 +1,182 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_bufsize.h
|
||||
*
|
||||
* @brief Definition of BLE stack buffers size
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_BUFSIZE_H__
|
||||
#define BLE_BUFSIZE_H__
|
||||
|
||||
|
||||
/*
|
||||
* BLE_DEFAULT_ATT_MTU: minimum MTU value that GATT must support.
|
||||
*/
|
||||
#define BLE_DEFAULT_ATT_MTU 23
|
||||
|
||||
/*
|
||||
* BLE_DEFAULT_MAX_ATT_SIZE: maximum attribute size.
|
||||
*/
|
||||
#define BLE_DEFAULT_MAX_ATT_SIZE 512
|
||||
|
||||
/*
|
||||
* BLE_PREP_WRITE_X_ATT: compute how many Prepare Write Request are needed to
|
||||
* write a characteristic with size 'max_att' when the used ATT_MTU value is
|
||||
* equal to BLE_DEFAULT_ATT_MTU (23).
|
||||
*/
|
||||
#define BLE_PREP_WRITE_X_ATT(max_att) \
|
||||
(DIVC(max_att, BLE_DEFAULT_ATT_MTU - 5) * 2)
|
||||
|
||||
/*
|
||||
* BLE_DEFAULT_PREP_WRITE_LIST_SIZE: default minimum Prepare Write List size.
|
||||
*/
|
||||
#define BLE_DEFAULT_PREP_WRITE_LIST_SIZE \
|
||||
BLE_PREP_WRITE_X_ATT(BLE_DEFAULT_MAX_ATT_SIZE)
|
||||
|
||||
/*
|
||||
* BLE_MEM_BLOCK_X_MTU: compute how many memory blocks are needed to compose
|
||||
* an ATT packet with ATT_MTU=mtu.
|
||||
*/
|
||||
#define BLE_MEM_BLOCK_SIZE 32
|
||||
|
||||
#if (SLAVE_ONLY != 0) || (BASIC_FEATURES != 0)
|
||||
#define BLE_MEM_BLOCK_X_PTX(n_link) 0
|
||||
#else
|
||||
#define BLE_MEM_BLOCK_X_PTX(n_link) (n_link)
|
||||
#endif
|
||||
|
||||
#define BLE_MEM_BLOCK_X_TX(mtu) \
|
||||
(DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 1)
|
||||
|
||||
#define BLE_MEM_BLOCK_X_RX(mtu, n_link) \
|
||||
((DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 2U) * (n_link) + 1)
|
||||
|
||||
#define BLE_MEM_BLOCK_X_MTU(mtu, n_link) \
|
||||
(BLE_MEM_BLOCK_X_TX(mtu) + BLE_MEM_BLOCK_X_PTX(n_link) + \
|
||||
BLE_MEM_BLOCK_X_RX(mtu, n_link))
|
||||
|
||||
/*
|
||||
* BLE_MBLOCKS_SECURE_CONNECTIONS: minimum number of blocks required for
|
||||
* secure connections
|
||||
*/
|
||||
#define BLE_MBLOCKS_SECURE_CONNECTIONS 4
|
||||
|
||||
/*
|
||||
* BLE_MBLOCKS_CALC: minimum number of buffers needed by the stack.
|
||||
* This is the minimum racomanded value and depends on:
|
||||
* - pw: size of Prepare Write List
|
||||
* - mtu: ATT_MTU size
|
||||
* - n_link: maximum number of simultaneous connections
|
||||
*/
|
||||
#define BLE_MBLOCKS_CALC(pw, mtu, n_link) \
|
||||
((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \
|
||||
BLE_MBLOCKS_SECURE_CONNECTIONS))
|
||||
|
||||
/*
|
||||
* BLE_FIXED_BUFFER_SIZE_BYTES:
|
||||
* A part of the RAM, is dynamically allocated by initializing all the pointers
|
||||
* defined in a global context variable "mem_alloc_ctx_p".
|
||||
* This initialization is made in the Dynamic_allocator functions, which
|
||||
* assign a portion of RAM given by the external application to the above
|
||||
* mentioned "global pointers".
|
||||
*
|
||||
* The size of this Dynamic RAM is made of 2 main components:
|
||||
* - a part that is parameters-dependent (num of links, GATT buffers, ...),
|
||||
* and which value is made explicit by the following macro;
|
||||
* - a part, that may be considered "fixed", i.e. independent from the above
|
||||
* mentioned parameters.
|
||||
*/
|
||||
#if (BEACON_ONLY != 0)
|
||||
#define BLE_FIXED_BUFFER_SIZE_BYTES 4200 /* Beacon only */
|
||||
#elif (LL_ONLY_BASIC != 0)
|
||||
#define BLE_FIXED_BUFFER_SIZE_BYTES 5960 /* LL only Basic*/
|
||||
#elif (LL_ONLY != 0)
|
||||
#define BLE_FIXED_BUFFER_SIZE_BYTES 6288 /* LL only Full */
|
||||
#elif (SLAVE_ONLY != 0)
|
||||
#define BLE_FIXED_BUFFER_SIZE_BYTES 6408 /* Peripheral only */
|
||||
#elif (BASIC_FEATURES != 0)
|
||||
#define BLE_FIXED_BUFFER_SIZE_BYTES 6928 /* Basic Features */
|
||||
#else
|
||||
#define BLE_FIXED_BUFFER_SIZE_BYTES 7212 /* Full stack */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* BLE_PER_LINK_SIZE_BYTES: additional memory size used per link
|
||||
*/
|
||||
#if (BEACON_ONLY != 0)
|
||||
#define BLE_PER_LINK_SIZE_BYTES 76 /* Beacon only */
|
||||
#elif (LL_ONLY_BASIC != 0)
|
||||
#define BLE_PER_LINK_SIZE_BYTES 244 /* LL only Basic */
|
||||
#elif (LL_ONLY != 0)
|
||||
#define BLE_PER_LINK_SIZE_BYTES 244 /* LL only Full */
|
||||
#elif (SLAVE_ONLY != 0)
|
||||
#define BLE_PER_LINK_SIZE_BYTES 392 /* Peripheral only */
|
||||
#elif (BASIC_FEATURES != 0)
|
||||
#define BLE_PER_LINK_SIZE_BYTES 420 /* Basic Features */
|
||||
#else
|
||||
#define BLE_PER_LINK_SIZE_BYTES 432 /* Full stack */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* BLE_TOTAL_BUFFER_SIZE: this macro returns the amount of memory, in bytes,
|
||||
* needed for the storage of data structures (except GATT database elements)
|
||||
* whose size depends on the number of supported connections.
|
||||
*
|
||||
* @param n_link: Maximum number of simultaneous connections that the device
|
||||
* will support. Valid values are from 1 to 8.
|
||||
*
|
||||
* @param mblocks_count: Number of memory blocks allocated for packets.
|
||||
*/
|
||||
#define BLE_TOTAL_BUFFER_SIZE(n_link, mblocks_count) \
|
||||
(16 + BLE_FIXED_BUFFER_SIZE_BYTES + \
|
||||
(BLE_PER_LINK_SIZE_BYTES * (n_link)) + \
|
||||
((BLE_MEM_BLOCK_SIZE + 8) * (mblocks_count)))
|
||||
|
||||
/*
|
||||
* BLE_EXT_ADV_BUFFER_SIZE
|
||||
* additional memory size used for Extended advertising;
|
||||
* It has to be added to BLE_TOTAL_BUFFER_SIZE() if the Extended advertising
|
||||
* feature is used.
|
||||
*
|
||||
* @param set_nbr: Maximum number of advertising sets.
|
||||
* Valid values are from 1 to 8.
|
||||
*
|
||||
* @param data_len: Maximum size of advertising data.
|
||||
* Valid values are from 31 to 1650.
|
||||
*/
|
||||
#define BLE_EXT_ADV_BUFFER_SIZE(set_nbr, data_len) \
|
||||
(2512 + ((892 + (DIVC(data_len, 207) * 244)) * (set_nbr)))
|
||||
|
||||
/*
|
||||
* BLE_TOTAL_BUFFER_SIZE_GATT: this macro returns the amount of memory,
|
||||
* in bytes, needed for the storage of GATT database elements.
|
||||
*
|
||||
* @param num_gatt_attributes: 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
|
||||
*
|
||||
* @param num_gatt_services: 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
|
||||
*
|
||||
* @param att_value_array_size: Size of the storage area for Attribute values.
|
||||
*/
|
||||
#define BLE_TOTAL_BUFFER_SIZE_GATT(num_gatt_attributes, num_gatt_services, att_value_array_size) \
|
||||
(((((att_value_array_size) - 1) | 3) + 1) + \
|
||||
(40 * (num_gatt_attributes)) + (48 * (num_gatt_services)))
|
||||
|
||||
|
||||
#endif /* BLE_BUFSIZE_H__ */
|
||||
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_core.h
|
||||
*
|
||||
* @brief This file contains the definitions for BLE stack
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_CORE_H__
|
||||
#define BLE_CORE_H__
|
||||
|
||||
|
||||
/* BLE standard definitions */
|
||||
#include "ble_std.h"
|
||||
|
||||
/* BLE stack API definitions */
|
||||
#include "ble_defs.h"
|
||||
#include "auto/ble_vs_codes.h"
|
||||
#include "auto/ble_gen_aci.h"
|
||||
#include "auto/ble_gap_aci.h"
|
||||
#include "auto/ble_gatt_aci.h"
|
||||
#include "auto/ble_l2cap_aci.h"
|
||||
#include "auto/ble_hal_aci.h"
|
||||
#include "auto/ble_hci_le.h"
|
||||
#include "auto/ble_events.h"
|
||||
|
||||
/* BLE stack buffer size definitions */
|
||||
#include "ble_bufsize.h"
|
||||
|
||||
/* BLE stack legacy definitions */
|
||||
#include "ble_legacy.h"
|
||||
|
||||
|
||||
#endif /* BLE_CORE_H__ */
|
||||
@@ -0,0 +1,510 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_defs.h
|
||||
*
|
||||
* @brief This file contains definitions used for BLE Stack interface.
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_DEFS_H__
|
||||
#define BLE_DEFS_H__
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Status codes */
|
||||
|
||||
/* Returned when the command has completed with success
|
||||
*/
|
||||
#define BLE_STATUS_SUCCESS 0x00U
|
||||
|
||||
/* The remote device in in the Blacklist and the pairing operation it requested
|
||||
* cannot be performed.
|
||||
*/
|
||||
#define BLE_STATUS_DEV_IN_BLACKLIST 0x59U
|
||||
|
||||
/* CSRK not found during validation of an incoming signed packet
|
||||
*/
|
||||
#define BLE_STATUS_CSRK_NOT_FOUND 0x5AU
|
||||
|
||||
/* IRK not found (Currently not used)
|
||||
*/
|
||||
#define BLE_STATUS_IRK_NOT_FOUND 0x5BU
|
||||
|
||||
/* A search for a specific remote device was unsuccessful because no entry
|
||||
* exists either into NVM Database or in volatile database.
|
||||
*/
|
||||
#define BLE_STATUS_DEV_NOT_FOUND 0x5CU
|
||||
|
||||
/* The remote device is not bonded, and no operations related to bonded devices
|
||||
* may be performed (e.g. writing Gatt Client data).
|
||||
*/
|
||||
#define BLE_STATUS_DEV_NOT_BONDED 0x5EU
|
||||
|
||||
/* The attribute handle is invalid.
|
||||
*/
|
||||
#define BLE_STATUS_INVALID_HANDLE 0x60U
|
||||
|
||||
/* There aren't sufficient Attributes handles available for allocation during
|
||||
* creation of Services, Characteristics or Descriptors.
|
||||
*/
|
||||
#define BLE_STATUS_OUT_OF_HANDLE 0x61U
|
||||
|
||||
/* The requested GATT operation is not allowed in this context/status or using
|
||||
* the provided parameters.
|
||||
* This is a specific GATT error, different from generic Not Allowed error,
|
||||
* because it refers to specific GATT specifications/rules.
|
||||
*/
|
||||
#define BLE_STATUS_INVALID_OPERATION 0x62U
|
||||
|
||||
/* The requested operation failed for a temporary lack of resources
|
||||
* (e.g. packet pool or timers), but it may be retried later when resources may
|
||||
* become available (packets or timers may have been released by other
|
||||
* consumers).
|
||||
*/
|
||||
#define BLE_STATUS_INSUFFICIENT_RESOURCES 0x64U
|
||||
|
||||
/* Notification/Indication can't be sent to the requested remote device because
|
||||
* it doesn't satisfy the needed security permission.
|
||||
*/
|
||||
#define BLE_STATUS_SEC_PERMISSION_ERROR 0x65U
|
||||
|
||||
/* The address of the device could not be resolved using the IRK stored\n
|
||||
*/
|
||||
#define BLE_STATUS_ADDRESS_NOT_RESOLVED 0x70U
|
||||
|
||||
/* Returned when no valid slots are available
|
||||
* (e.g. when there are no available state machines).
|
||||
*/
|
||||
#define BLE_STATUS_NO_VALID_SLOT 0x82U
|
||||
|
||||
/* The only slot available is not long enough to satisfy scan window request.
|
||||
*/
|
||||
#define BLE_STATUS_SCAN_WINDOW_SHORT 0x83U
|
||||
|
||||
/* Returned when the maximum requested interval to be allocated is shorter
|
||||
* then the current anchor period and there is no submultiple for the
|
||||
* current anchor period that is between the minimum and the maximum requested
|
||||
* intervals.
|
||||
*/
|
||||
#define BLE_STATUS_NEW_INTERVAL_FAILED 0x84U
|
||||
|
||||
/* Returned when the maximum requested interval to be allocated is greater
|
||||
* than the current anchor period and there is no multiple of the anchor
|
||||
* period that is between the minimum and the maximum requested intervals.
|
||||
*/
|
||||
#define BLE_STATUS_INTERVAL_TOO_LARGE 0x85U
|
||||
|
||||
/* Returned when the current anchor period or a new one can be found that
|
||||
* is compatible to the interval range requested by the new slot but the
|
||||
* maximum available length that can be allocated is less than the minimum
|
||||
* requested slot length.
|
||||
*/
|
||||
#define BLE_STATUS_LENGTH_FAILED 0x86U
|
||||
|
||||
/* The Host failed while performing the requested operation.
|
||||
*/
|
||||
#define BLE_STATUS_FAILED 0x91U
|
||||
|
||||
/* Invalid parameters in Host commands
|
||||
*/
|
||||
#define BLE_STATUS_INVALID_PARAMS 0x92U
|
||||
|
||||
/* The Host is already processing another request received in advance.
|
||||
*/
|
||||
#define BLE_STATUS_BUSY 0x93U
|
||||
|
||||
/* The operation requested cannot be completed immediately by the Host
|
||||
* (usually because of lack of resources).
|
||||
* The operation is generally put on hold by the caller and it's usually
|
||||
* retried on later time.
|
||||
*/
|
||||
#define BLE_STATUS_PENDING 0x95U
|
||||
|
||||
/* The requested operation violates the logic of the called layer/function or
|
||||
* the format of the data to be processed during the operation.
|
||||
*/
|
||||
#define BLE_STATUS_ERROR 0x97U
|
||||
|
||||
/* The requested operation failed because of lack of memory.
|
||||
* Out of memory shall be returned for situations where memory will never
|
||||
* become available again (e.g. ATT database)
|
||||
*/
|
||||
#define BLE_STATUS_OUT_OF_MEMORY 0x98U
|
||||
|
||||
/* Returned when a timeout occurs at BLE application interface
|
||||
*/
|
||||
#define BLE_STATUS_TIMEOUT 0xFFU
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* BLE stack options (Options)
|
||||
* (ACI_RESET)
|
||||
*/
|
||||
#define BLE_OPTIONS_LL_ONLY 0x00000001UL
|
||||
#define BLE_OPTIONS_NO_SVC_CHANGE_DESC 0x00000002UL
|
||||
#define BLE_OPTIONS_DEV_NAME_READ_ONLY 0x00000004UL
|
||||
#define BLE_OPTIONS_EXTENDED_ADV 0x00000008UL
|
||||
#define BLE_OPTIONS_CS_ALGO_2 0x00000010UL
|
||||
#define BLE_OPTIONS_REDUCED_DB_IN_NVM 0x00000020UL
|
||||
#define BLE_OPTIONS_GATT_CACHING 0x00000040UL
|
||||
#define BLE_OPTIONS_POWER_CLASS_1 0x00000080UL
|
||||
#define BLE_OPTIONS_APPEARANCE_WRITABLE 0x00000100UL
|
||||
#define BLE_OPTIONS_ENHANCED_ATT 0x00000200UL
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Characteristic value lengths
|
||||
*/
|
||||
#define DEVICE_NAME_CHARACTERISTIC_LEN 8
|
||||
#define APPEARANCE_CHARACTERISTIC_LEN 2
|
||||
#define PERIPHERAL_PRIVACY_CHARACTERISTIC_LEN 1
|
||||
#define RECONNECTION_ADDR_CHARACTERISTIC_LEN 6
|
||||
#define PERIPHERAL_PREF_CONN_PARAMS_CHARACTERISTIC_LEN 8
|
||||
|
||||
/* Adv. lengths
|
||||
*/
|
||||
#define MAX_ADV_DATA_LEN 31
|
||||
#define BD_ADDR_SIZE 6
|
||||
|
||||
/* Privacy flag values
|
||||
*/
|
||||
#define PRIVACY_DISABLED 0x00
|
||||
#define PRIVACY_ENABLED 0x02
|
||||
|
||||
/* Intervals in terms of 625 micro sec
|
||||
*/
|
||||
#define DIR_CONN_ADV_INT_MIN 0x190U /* 250 ms */
|
||||
#define DIR_CONN_ADV_INT_MAX 0x320U /* 500 ms */
|
||||
#define UNDIR_CONN_ADV_INT_MIN 0x800U /* 1.28 s */
|
||||
#define UNDIR_CONN_ADV_INT_MAX 0x1000U /* 2.56 s */
|
||||
#define LIM_DISC_ADV_INT_MIN 0x190U /* 250 ms */
|
||||
#define LIM_DISC_ADV_INT_MAX 0x320U /* 500 ms */
|
||||
#define GEN_DISC_ADV_INT_MIN 0x800U /* 1.28 s */
|
||||
#define GEN_DISC_ADV_INT_MAX 0x1000U /* 2.56 s */
|
||||
|
||||
/* GAP Roles
|
||||
*/
|
||||
#define GAP_PERIPHERAL_ROLE 0x01U
|
||||
#define GAP_BROADCASTER_ROLE 0x02U
|
||||
#define GAP_CENTRAL_ROLE 0x04U
|
||||
#define GAP_OBSERVER_ROLE 0x08U
|
||||
|
||||
/* GAP procedure codes
|
||||
* Procedure codes for ACI_GAP_PROC_COMPLETE_EVENT event
|
||||
* and ACI_GAP_TERMINATE_GAP_PROC command.
|
||||
*/
|
||||
#define GAP_LIMITED_DISCOVERY_PROC 0x01U
|
||||
#define GAP_GENERAL_DISCOVERY_PROC 0x02U
|
||||
#define GAP_PERIODIC_ADVERTISING_CONNECTION_PROC 0x04U
|
||||
#define GAP_AUTO_CONNECTION_ESTABLISHMENT_PROC 0x08U
|
||||
#define GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC 0x10U
|
||||
#define GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC 0x20U
|
||||
#define GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC 0x40U
|
||||
#define GAP_OBSERVATION_PROC 0x80U
|
||||
|
||||
/* GAP Address Type
|
||||
*/
|
||||
#define GAP_PUBLIC_ADDR 0x00U
|
||||
#define GAP_STATIC_RANDOM_ADDR 0x01U
|
||||
#define GAP_RESOLVABLE_PRIVATE_ADDR 0x02U
|
||||
#define GAP_NON_RESOLVABLE_PRIVATE_ADDR 0x03U
|
||||
|
||||
/* Bitmap definitions for Mode of ACI_GAP_ADD_DEVICES_TO_LIST
|
||||
*/
|
||||
#define GAP_ADD_DEV_MODE_RESOLVING_LIST_ONLY 0x00U
|
||||
#define GAP_ADD_DEV_MODE_CLEAR 0x01U
|
||||
#define GAP_ADD_DEV_MODE_FILTER_ACC_LIST_ONLY 0x02U
|
||||
#define GAP_ADD_DEV_MODE_BOTH_LISTS 0x04U
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* IO capabilities
|
||||
* (ACI_GAP_SET_IO_CAPABILITY)
|
||||
*/
|
||||
#define IO_CAP_DISPLAY_ONLY 0x00U
|
||||
#define IO_CAP_DISPLAY_YES_NO 0x01U
|
||||
#define IO_CAP_KEYBOARD_ONLY 0x02U
|
||||
#define IO_CAP_NO_INPUT_NO_OUTPUT 0x03U
|
||||
#define IO_CAP_KEYBOARD_DISPLAY 0x04U
|
||||
|
||||
/* Bonding mode
|
||||
* (ACI_GAP_SET_AUTHENTICATION_REQUIREMENT)
|
||||
*/
|
||||
#define NO_BONDING 0x00U
|
||||
#define BONDING 0x01U
|
||||
|
||||
/* MITM protection
|
||||
* (ACI_GAP_SET_AUTHENTICATION_REQUIREMENT)
|
||||
*/
|
||||
#define MITM_PROTECTION_NOT_REQUIRED 0x00U
|
||||
#define MITM_PROTECTION_REQUIRED_AS_MANDATORY 0x01U
|
||||
#define MITM_PROTECTION_REQUIRED_AS_OPTIONAL 0x02U
|
||||
|
||||
/* LE Secure Connections support
|
||||
* (ACI_GAP_SET_AUTHENTICATION_REQUIREMENT)
|
||||
*/
|
||||
#define SC_PAIRING_UNSUPPORTED 0x00U
|
||||
#define SC_PAIRING_OPTIONAL 0x01U
|
||||
#define SC_PAIRING_ONLY 0x02U
|
||||
|
||||
/* Keypress notification support
|
||||
* (ACI_GAP_SET_AUTHENTICATION_REQUIREMENT)
|
||||
*/
|
||||
#define KEYPRESS_NOT_SUPPORTED 0x00U
|
||||
#define KEYPRESS_SUPPORTED 0x01U
|
||||
|
||||
/* Use fixed pin
|
||||
* (ACI_GAP_SET_AUTHENTICATION_REQUIREMENT)
|
||||
*/
|
||||
#define USE_FIXED_PIN_FOR_PAIRING_ALLOWED 0x00U
|
||||
#define USE_FIXED_PIN_FOR_PAIRING_FORBIDDEN 0x01U
|
||||
|
||||
/* Authorization requirements
|
||||
* (ACI_GAP_SET_AUTHORIZATION_REQUIREMENT)
|
||||
*/
|
||||
#define AUTHORIZATION_NOT_REQUIRED 0x00U
|
||||
#define AUTHORIZATION_REQUIRED 0x01U
|
||||
|
||||
/* Connection authorization response
|
||||
* (ACI_GAP_AUTHORIZATION_RESP)
|
||||
*/
|
||||
#define CONNECTION_AUTHORIZED 0x01U
|
||||
#define CONNECTION_REJECTED 0x02U
|
||||
|
||||
/* SMP pairing status
|
||||
* (ACI_GAP_PAIRING_COMPLETE_EVENT)
|
||||
*/
|
||||
#define SMP_PAIRING_STATUS_SUCCESS 0x00U
|
||||
#define SMP_PAIRING_STATUS_SMP_TIMEOUT 0x01U
|
||||
#define SMP_PAIRING_STATUS_PAIRING_FAILED 0x02U
|
||||
#define SMP_PAIRING_STATUS_ENCRYPT_FAILED 0x03U
|
||||
|
||||
/* SMP pairing failed reason code
|
||||
* (ACI_GAP_PAIRING_COMPLETE_EVENT)
|
||||
*/
|
||||
#define REASON_PASSKEY_ENTRY_FAILED 0x01U
|
||||
#define REASON_OOB_NOT_AVAILABLE 0x02U
|
||||
#define REASON_AUTHENTICATION_REQ 0x03U
|
||||
#define REASON_CONFIRM_VALUE_FAILED 0x04U
|
||||
#define REASON_PAIRING_NOT_SUPPORTED 0x05U
|
||||
#define REASON_ENCRYPTION_KEY_SIZE 0x06U
|
||||
#define REASON_COMMAND_NOT_SUPPORTED 0x07U
|
||||
#define REASON_UNSPECIFIED_REASON 0x08U
|
||||
#define REASON_REPEATED_ATTEMPTS 0x09U
|
||||
#define REASON_INVALID_PARAMETERS 0x0AU
|
||||
#define REASON_DHKEY_CHECK_FAILED 0x0BU
|
||||
#define REASON_NUM_COMPARISON_FAILED 0x0CU
|
||||
#define REASON_KEY_REJECTED 0x0FU
|
||||
#define REASON_BUSY 0x10U
|
||||
|
||||
/* Passkey input type detected
|
||||
* (ACI_GAP_PASSKEY_INPUT)
|
||||
*/
|
||||
#define PASSKEY_ENTRY_STARTED 0x00U
|
||||
#define PASSKEY_DIGIT_ENTERED 0x01U
|
||||
#define PASSKEY_DIGIT_ERASED 0x02U
|
||||
#define PASSKEY_CLEARED 0x03U
|
||||
#define PASSKEY_ENTRY_COMPLETED 0x04U
|
||||
|
||||
/* Numeric Comparison Confirm Value
|
||||
* (ACI_GAP_NUMERIC_COMPARISON_VALUE_CONFIRM_YESNO)
|
||||
*/
|
||||
#define NUMERIC_COMPARISON_CONFIRM_NO 0x00U
|
||||
#define NUMERIC_COMPARISON_CONFIRM_YES 0x01U
|
||||
|
||||
/* OOB Device Type
|
||||
* (ACI_GAP_SET_OOB_DATA)
|
||||
*/
|
||||
#define OOB_DEVICE_TYPE_LOCAL 0x00U
|
||||
#define OOB_DEVICE_TYPE_REMOTE 0x01U
|
||||
|
||||
/* OOB Data Type
|
||||
* (ACI_GAP_GET_OOB_DATA, ACI_GAP_SET_OOB_DATA)
|
||||
*/
|
||||
#define OOB_DATA_TYPE_LP_TK 0x00U
|
||||
#define OOB_DATA_TYPE_SC_RANDOM 0x01U
|
||||
#define OOB_DATA_TYPE_SC_CONFIRM 0x02U
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Access permissions for an attribute
|
||||
*/
|
||||
#define ATTR_NO_ACCESS 0x00U
|
||||
#define ATTR_ACCESS_READ_ONLY 0x01U
|
||||
#define ATTR_ACCESS_WRITE_REQ_ONLY 0x02U
|
||||
#define ATTR_ACCESS_READ_WRITE 0x03U
|
||||
#define ATTR_ACCESS_WRITE_WITHOUT_RESPONSE 0x04U
|
||||
#define ATTR_ACCESS_SIGNED_WRITE_ALLOWED 0x08U
|
||||
#define ATTR_ACCESS_WRITE_ANY 0x0EU
|
||||
#define ATTR_ACCESS_ANY 0x0FU
|
||||
|
||||
/* Characteristic properties
|
||||
*/
|
||||
#define CHAR_PROP_NONE 0x00U
|
||||
#define CHAR_PROP_BROADCAST 0x01U
|
||||
#define CHAR_PROP_READ 0x02U
|
||||
#define CHAR_PROP_WRITE_WITHOUT_RESP 0x04U
|
||||
#define CHAR_PROP_WRITE 0x08U
|
||||
#define CHAR_PROP_NOTIFY 0x10u
|
||||
#define CHAR_PROP_INDICATE 0x20U
|
||||
#define CHAR_PROP_SIGNED_WRITE 0x40U
|
||||
#define CHAR_PROP_EXT 0x80U
|
||||
|
||||
/* Security permissions for an attribute
|
||||
*/
|
||||
#define ATTR_PERMISSION_NONE 0x00U /* No security. */
|
||||
#define ATTR_PERMISSION_AUTHEN_READ 0x01U /* Need authentication to read */
|
||||
#define ATTR_PERMISSION_AUTHOR_READ 0x02U /* Need authorization to read */
|
||||
#define ATTR_PERMISSION_ENCRY_READ 0x04U /* Need encryption to read */
|
||||
#define ATTR_PERMISSION_AUTHEN_WRITE 0x08U /* Need authentication to write */
|
||||
#define ATTR_PERMISSION_AUTHOR_WRITE 0x10U /* Need authorization to write */
|
||||
#define ATTR_PERMISSION_ENCRY_WRITE 0x20U /* Need encryption to write */
|
||||
#define ATTR_PERMISSION_SC_READ 0x40U /* Need SC to read */
|
||||
#define ATTR_PERMISSION_SC_WRITE 0x80U /* Need SC tto write */
|
||||
|
||||
/* Type of UUID (16 bit or 128 bit)
|
||||
*/
|
||||
#define UUID_TYPE_16 0x01U
|
||||
#define UUID_TYPE_128 0x02U
|
||||
|
||||
/* Type of service (primary or secondary)
|
||||
*/
|
||||
#define PRIMARY_SERVICE 0x01U
|
||||
#define SECONDARY_SERVICE 0x02U
|
||||
|
||||
/* Gatt Event Mask
|
||||
* Type of event generated by GATT server
|
||||
* See aci_gatt_add_char.
|
||||
*/
|
||||
#define GATT_DONT_NOTIFY_EVENTS 0x00U
|
||||
#define GATT_NOTIFY_ATTRIBUTE_WRITE 0x01U
|
||||
#define GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP 0x02U
|
||||
#define GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP 0x04U
|
||||
#define GATT_NOTIFY_NOTIFICATION_COMPLETION 0x08U
|
||||
|
||||
/* Type of characteristic length (see ACI_GATT_ADD_CHAR)
|
||||
*/
|
||||
#define CHAR_VALUE_LEN_CONSTANT 0x00
|
||||
#define CHAR_VALUE_LEN_VARIABLE 0x01
|
||||
|
||||
/* Encryption key size
|
||||
*/
|
||||
#define MIN_ENCRY_KEY_SIZE 7
|
||||
#define MAX_ENCRY_KEY_SIZE 16
|
||||
|
||||
/* Format
|
||||
*/
|
||||
#define FORMAT_UINT8 0x04U
|
||||
#define FORMAT_UINT16 0x06U
|
||||
#define FORMAT_SINT16 0x0EU
|
||||
#define FORMAT_SINT24 0x0FU
|
||||
|
||||
/* Unit
|
||||
*/
|
||||
#define UNIT_UNITLESS 0x2700
|
||||
#define UNIT_TEMP_CELSIUS 0x272F
|
||||
#define UNIT_PRESSURE_BAR 0x2780
|
||||
|
||||
/* Update_Type definitions for ACI_GATT_UPDATE_CHAR_VALUE_EXT
|
||||
*/
|
||||
#define GATT_CHAR_UPDATE_LOCAL_ONLY 0x00U
|
||||
#define GATT_CHAR_UPDATE_SEND_NOTIFICATION 0x01U
|
||||
#define GATT_CHAR_UPDATE_SEND_INDICATION 0x02U
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Advertising Type
|
||||
*/
|
||||
#define ADV_IND 0
|
||||
#define ADV_DIRECT_IND 1
|
||||
#define ADV_SCAN_IND 2
|
||||
#define ADV_NONCONN_IND 3
|
||||
#define ADV_DIRECT_IND_LDC 4
|
||||
#define SCAN_RSP 4
|
||||
|
||||
/* Advertising channels
|
||||
*/
|
||||
#define ADV_CH_37 0x01
|
||||
#define ADV_CH_38 0x02
|
||||
#define ADV_CH_39 0x04
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Definitions for Radio_Activity_Mask
|
||||
* (ACI_HAL_SET_RADIO_ACTIVITY_MASK)
|
||||
*/
|
||||
#define RADIO_ACT_MASK_IDLE 0x0001U
|
||||
#define RADIO_ACT_MASK_ADVERTISING 0x0002U
|
||||
#define RADIO_ACT_MASK_PERIPH_CONNECT 0x0004U
|
||||
#define RADIO_ACT_MASK_SCANNING 0x0008U
|
||||
#define RADIO_ACT_MASK_CENTR_CONNECT 0x0020U
|
||||
#define RADIO_ACT_MASK_TX_TEST 0x0040U
|
||||
#define RADIO_ACT_MASK_RX_TEST 0x0080U
|
||||
#define RADIO_ACT_MASK_PERIOD_ADVERTISING 0x0200U
|
||||
#define RADIO_ACT_MASK_PERIOD_SYNC 0x0400U
|
||||
#define RADIO_ACT_MASK_ISO_BROADCAST 0x0800U
|
||||
#define RADIO_ACT_MASK_ISO_SYNC 0x1000U
|
||||
#define RADIO_ACT_MASK_ISO_PERIPH_CONNECT 0x2000U
|
||||
#define RADIO_ACT_MASK_ISO_CENTR_CONNECT 0x4000U
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Definitions for Warning_Type
|
||||
* (ACI_WARNING_EVENT)
|
||||
*/
|
||||
#define WARNING_L2CAP_RECOMBINATION_FAILURE 0x01U
|
||||
#define WARNING_GATT_UNEXPECTED_PEER_MESSAGE 0x02U
|
||||
#define WARNING_NVM_ALMOST_FULL 0x03U
|
||||
#define WARNING_COC_RX_DATA_LENGTH_TOO_LARGE 0x04U
|
||||
#define WARNING_COC_ALREADY_ASSIGNED_DCID 0x05U
|
||||
#define WARNING_SMP_UNEXPECTED_LTK_REQUEST 0x06U
|
||||
#define WARNING_GATT_BEARER_NOT_ALLOCATED 0x07U
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Offset for configuration values (see ACI_HAL_WRITE_CONFIG_DATA)
|
||||
*/
|
||||
#define CONFIG_DATA_PUBLIC_ADDRESS_OFFSET 0x00U
|
||||
#define CONFIG_DATA_ER_OFFSET 0x08U
|
||||
#define CONFIG_DATA_IR_OFFSET 0x18U
|
||||
#define CONFIG_DATA_RANDOM_ADDRESS_OFFSET 0x2EU
|
||||
#define CONFIG_DATA_GAP_ADD_REC_NBR_OFFSET 0x34U
|
||||
#define CONFIG_DATA_SC_KEY_TYPE_OFFSET 0x35U
|
||||
#define CONFIG_DATA_SMP_MODE_OFFSET 0xB0U
|
||||
#define CONFIG_DATA_LL_SCAN_CHAN_MAP_OFFSET 0xC0U
|
||||
#define CONFIG_DATA_LL_BG_SCAN_MODE_OFFSET 0xC1U
|
||||
#define CONFIG_DATA_LL_RSSI_GOLDEN_RANGE_OFFSET 0xC2U
|
||||
#define CONFIG_DATA_LL_RPA_MODE_OFFSET 0xC3U
|
||||
#define CONFIG_DATA_LL_RX_ACL_CTRL_OFFSET 0xC4U
|
||||
#define CONFIG_DATA_LL_MAX_DATA_EXT_OFFSET 0xD1U
|
||||
|
||||
/* Length for configuration values (see ACI_HAL_WRITE_CONFIG_DATA)
|
||||
*/
|
||||
#define CONFIG_DATA_PUBLIC_ADDRESS_LEN 6
|
||||
#define CONFIG_DATA_ER_LEN 16
|
||||
#define CONFIG_DATA_IR_LEN 16
|
||||
#define CONFIG_DATA_RANDOM_ADDRESS_LEN 6
|
||||
#define CONFIG_DATA_GAP_ADD_REC_NBR_LEN 1
|
||||
#define CONFIG_DATA_SC_KEY_TYPE_LEN 1
|
||||
#define CONFIG_DATA_SMP_MODE_LEN 1
|
||||
#define CONFIG_DATA_LL_SCAN_CHAN_MAP_LEN 1
|
||||
#define CONFIG_DATA_LL_BG_SCAN_MODE_LEN 1
|
||||
#define CONFIG_DATA_LL_RSSI_GOLDEN_RANGE_LEN 2
|
||||
#define CONFIG_DATA_LL_RPA_MODE_LEN 1
|
||||
#define CONFIG_DATA_LL_RX_ACL_CTRL_LEN 2
|
||||
#define CONFIG_DATA_LL_MAX_DATA_EXT_LEN 8
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#endif /* BLE_DEFS_H__ */
|
||||
@@ -0,0 +1,363 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_legacy.h
|
||||
*
|
||||
* @brief This file contains legacy definitions used for BLE.
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_LEGACY_H__
|
||||
#define BLE_LEGACY_H__
|
||||
|
||||
|
||||
/* Various obsolete definitions
|
||||
*/
|
||||
|
||||
#define PERIPHERAL_PRIVACY_FLAG_UUID 0x2A02U
|
||||
#define RECONNECTION_ADDR_UUID 0x2A03U
|
||||
|
||||
#define OOB_AUTH_DATA_ABSENT 0x00U
|
||||
#define OOB_AUTH_DATA_PRESENT 0x01U
|
||||
|
||||
#define BLE_STATUS_SEC_DB_FULL 0x5DU
|
||||
#define BLE_STATUS_INSUFFICIENT_ENC_KEYSIZE 0x5FU
|
||||
#define BLE_STATUS_CHARAC_ALREADY_EXISTS 0x63U
|
||||
|
||||
#define GAP_NAME_DISCOVERY_PROC 0x04U
|
||||
|
||||
#define MITM_PROTECTION_REQUIRED 0x01U
|
||||
|
||||
#define HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE 0xFFU
|
||||
|
||||
/* Deprecated names for ACI/HCI commands and events
|
||||
*/
|
||||
|
||||
#define hci_le_read_local_supported_features \
|
||||
hci_le_read_local_supported_features_page_0
|
||||
#define hci_le_read_remote_features \
|
||||
hci_le_read_remote_features_page_0
|
||||
|
||||
#define aci_gap_configure_whitelist \
|
||||
aci_gap_configure_filter_accept_list
|
||||
#define aci_gap_slave_security_req \
|
||||
aci_gap_peripheral_security_req
|
||||
#define aci_hal_set_slave_latency \
|
||||
aci_hal_set_peripheral_latency
|
||||
#define aci_gap_slave_security_initiated_event \
|
||||
aci_gap_peripheral_security_initiated_event
|
||||
|
||||
typedef __PACKED_STRUCT
|
||||
{
|
||||
/**
|
||||
* Identity address type
|
||||
* Values:
|
||||
* - 0x00: Public Identity Address
|
||||
* - 0x01: Random (static) Identity Address
|
||||
*/
|
||||
uint8_t Peer_Identity_Address_Type;
|
||||
/**
|
||||
* Public or Random (static) Identity Address of the peer device
|
||||
*/
|
||||
uint8_t Peer_Identity_Address[6];
|
||||
} Identity_Entry_t;
|
||||
|
||||
#define Whitelist_Entry_t \
|
||||
Peer_Entry_t
|
||||
#define Whitelist_Identity_Entry_t \
|
||||
Identity_Entry_t
|
||||
|
||||
#define HCI_LE_READ_REMOTE_FEATURES_COMPLETE_SUBEVT_CODE \
|
||||
HCI_LE_READ_REMOTE_FEATURES_PAGE_0_COMPLETE_SUBEVT_CODE
|
||||
|
||||
#define hci_le_read_remote_features_complete_event_rp0 \
|
||||
hci_le_read_remote_features_page_0_complete_event_rp0
|
||||
|
||||
#define ACI_GAP_SLAVE_SECURITY_INITIATED_VSEVT_CODE \
|
||||
ACI_GAP_PERIPHERAL_SECURITY_INITIATED_VSEVT_CODE
|
||||
|
||||
#define ACI_HAL_FW_ERROR_VSEVT_CODE \
|
||||
ACI_WARNING_VSEVT_CODE
|
||||
|
||||
#define ACI_HAL_WARNING_VSEVT_CODE \
|
||||
ACI_WARNING_VSEVT_CODE
|
||||
|
||||
typedef __PACKED_STRUCT
|
||||
{
|
||||
uint8_t FW_Error_Type;
|
||||
uint8_t Data_Length;
|
||||
uint8_t Data[(BLE_EVT_MAX_PARAM_LEN - 2) - 2];
|
||||
} aci_hal_fw_error_event_rp0;
|
||||
|
||||
#define aci_hal_warning_event_rp0 \
|
||||
aci_warning_event_rp0
|
||||
|
||||
#define aci_hal_warning_event \
|
||||
aci_warning_event
|
||||
|
||||
/* Other deprecated names
|
||||
*/
|
||||
|
||||
#define HCI_ADV_FILTER_WHITELIST_SCAN \
|
||||
HCI_ADV_FILTER_ACC_LIST_USED_FOR_SCAN
|
||||
#define HCI_ADV_FILTER_WHITELIST_CONNECT \
|
||||
HCI_ADV_FILTER_ACC_LIST_USED_FOR_CONNECT
|
||||
#define HCI_ADV_FILTER_WHITELIST_SCAN_CONNECT \
|
||||
HCI_ADV_FILTER_ACC_LIST_USED_FOR_ALL
|
||||
#define NO_WHITE_LIST_USE \
|
||||
HCI_ADV_FILTER_NO
|
||||
#define WHITE_LIST_FOR_ONLY_SCAN \
|
||||
HCI_ADV_FILTER_ACC_LIST_USED_FOR_SCAN
|
||||
#define WHITE_LIST_FOR_ONLY_CONN \
|
||||
HCI_ADV_FILTER_ACC_LIST_USED_FOR_CONNECT
|
||||
#define WHITE_LIST_FOR_ALL \
|
||||
HCI_ADV_FILTER_ACC_LIST_USED_FOR_ALL
|
||||
|
||||
#define HCI_SCAN_FILTER_WHITELIST \
|
||||
HCI_SCAN_FILTER_ACC_LIST_USED
|
||||
#define HCI_SCAN_FILTER_NO_EVEN_RPA \
|
||||
HCI_SCAN_FILTER_NO_EXT
|
||||
#define HCI_SCAN_FILTER_WHITELIST_BUT_RPA \
|
||||
HCI_SCAN_FILTER_ACC_LIST_USED_EXT
|
||||
|
||||
#define HCI_INIT_FILTER_WHITELIST \
|
||||
HCI_INIT_FILTER_ACC_LIST_USED
|
||||
|
||||
#define AD_TYPE_SLAVE_CONN_INTERVAL \
|
||||
AD_TYPE_PERIPHERAL_CONN_INTERVAL
|
||||
|
||||
#define OOB_NOT_AVAILABLE REASON_OOB_NOT_AVAILABLE
|
||||
#define AUTH_REQ_CANNOT_BE_MET REASON_AUTHENTICATION_REQ
|
||||
#define CONFIRM_VALUE_FAILED REASON_CONFIRM_VALUE_FAILED
|
||||
#define PAIRING_NOT_SUPPORTED REASON_PAIRING_NOT_SUPPORTED
|
||||
#define INSUFF_ENCRYPTION_KEY_SIZE REASON_ENCRYPTION_KEY_SIZE
|
||||
#define CMD_NOT_SUPPORTED REASON_COMMAND_NOT_SUPPORTED
|
||||
#define UNSPECIFIED_REASON REASON_UNSPECIFIED_REASON
|
||||
#define VERY_EARLY_NEXT_ATTEMPT REASON_REPEATED_ATTEMPTS
|
||||
#define SM_INVALID_PARAMS REASON_INVALID_PARAMETERS
|
||||
#define SMP_SC_DHKEY_CHECK_FAILED REASON_DHKEY_CHECK_FAILED
|
||||
#define SMP_SC_NUMCOMPARISON_FAILED REASON_NUM_COMPARISON_FAILED
|
||||
|
||||
#define CONFIG_DATA_PUBADDR_OFFSET CONFIG_DATA_PUBLIC_ADDRESS_OFFSET
|
||||
#define CONFIG_DATA_PUBADDR_LEN CONFIG_DATA_PUBLIC_ADDRESS_LEN
|
||||
|
||||
#define FW_L2CAP_RECOMBINATION_ERROR 0x01U
|
||||
#define FW_GATT_UNEXPECTED_PEER_MESSAGE 0x02U
|
||||
#define FW_NVM_LEVEL_WARNING 0x03U
|
||||
#define FW_COC_RX_DATA_LENGTH_TOO_LARGE 0x04U
|
||||
#define FW_ECOC_CONN_RSP_ALREADY_ASSIGNED_DCID 0x05U
|
||||
|
||||
/* Deprecated commands
|
||||
*/
|
||||
|
||||
#define aci_gatt_read_long_char_desc\
|
||||
aci_gatt_read_long_char_value
|
||||
|
||||
#define aci_gatt_read_char_desc \
|
||||
aci_gatt_read_char_value
|
||||
|
||||
#define aci_gatt_write_long_char_desc \
|
||||
aci_gatt_write_long_char_value
|
||||
|
||||
#define aci_gatt_write_char_desc \
|
||||
aci_gatt_write_char_value
|
||||
|
||||
#define aci_gatt_write_resp \
|
||||
aci_gatt_permit_write
|
||||
|
||||
/**
|
||||
* @brief ACI_GAP_RESOLVE_PRIVATE_ADDR
|
||||
* This command tries to resolve the address provided with the IRKs present in
|
||||
* its database. If the address is resolved successfully with any one of the
|
||||
* IRKs present in the database, it returns success and also the corresponding
|
||||
* public/static random address stored with the IRK in the database.
|
||||
*
|
||||
* @param Address Address to be resolved
|
||||
* @param[out] Actual_Address The public or static random address of the peer
|
||||
* device, distributed during pairing phase.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_gap_resolve_private_addr( const uint8_t* Address,
|
||||
uint8_t* Actual_Address )
|
||||
{
|
||||
uint8_t type;
|
||||
return aci_gap_check_bonded_device( 1, Address, &type, Actual_Address );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACI_GAP_IS_DEVICE_BONDED
|
||||
* The command finds whether the device, whose address is specified in the
|
||||
* command, is present in the bonding table. If the device is found, the
|
||||
* command returns "Success".
|
||||
* Note: the specified address can be a RPA. In this case, even if privacy is
|
||||
* not enabled, this address is resolved to check the presence of the peer
|
||||
* device in the bonding table.
|
||||
*
|
||||
* @param Peer_Address_Type The address type of the peer device.
|
||||
* Values:
|
||||
* - 0x00: Public Device Address
|
||||
* - 0x01: Random Device Address
|
||||
* @param Peer_Address Public Device Address or Random Device Address of the
|
||||
* peer device
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_gap_is_device_bonded( uint8_t Peer_Address_Type,
|
||||
const uint8_t* Peer_Address )
|
||||
{
|
||||
uint8_t type, address[6];
|
||||
return aci_gap_check_bonded_device( Peer_Address_Type, Peer_Address,
|
||||
&type, address );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACI_GAP_ADD_DEVICES_TO_RESOLVING_LIST
|
||||
* This command is used to add devices to the list of address translations
|
||||
* used to resolve Resolvable Private Addresses in the Controller.
|
||||
*
|
||||
* @param Num_of_Resolving_list_Entries Number of devices that have to be added
|
||||
* to the list.
|
||||
* @param Identity_Entry See @ref Identity_Entry_t
|
||||
* @param Clear_Resolving_List Clear the resolving list
|
||||
* Values:
|
||||
* - 0x00: Do not clear
|
||||
* - 0x01: Clear before adding
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_gap_add_devices_to_resolving_list( uint8_t Num_of_Resolving_list_Entries,
|
||||
const Identity_Entry_t* Identity_Entry,
|
||||
uint8_t Clear_Resolving_List )
|
||||
{
|
||||
return aci_gap_add_devices_to_list( Num_of_Resolving_list_Entries,
|
||||
(const List_Entry_t*)Identity_Entry,
|
||||
Clear_Resolving_List );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_GET_FW_BUILD_NUMBER
|
||||
* This command returns the build number associated with the firmware version
|
||||
* currently running
|
||||
*
|
||||
* @param[out] Build_Number Build number of the firmware.
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_hal_get_fw_build_number( uint16_t* Build_Number )
|
||||
{
|
||||
uint32_t version[2], options[1], debug_info[3];
|
||||
tBleStatus status = aci_get_information( version, options, debug_info );
|
||||
*Build_Number = (uint16_t)(version[1] >> 16);
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_GET_PM_DEBUG_INFO
|
||||
* This command is used to retrieve TX, RX and total buffer count allocated for
|
||||
* ACL packets.
|
||||
*
|
||||
* @param[out] Allocated_For_TX MBlocks allocated for TXing
|
||||
* @param[out] Allocated_For_RX MBlocks allocated for RXing
|
||||
* @param[out] Allocated_MBlocks Overall allocated MBlocks
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_hal_get_pm_debug_info( uint8_t* Allocated_For_TX,
|
||||
uint8_t* Allocated_For_RX,
|
||||
uint8_t* Allocated_MBlocks )
|
||||
{
|
||||
uint32_t version[2], options[1], debug_info[3];
|
||||
tBleStatus status = aci_get_information( version, options, debug_info );
|
||||
*Allocated_For_TX = ((uint8_t)(((uint16_t*)debug_info)[2]) +
|
||||
(uint8_t)(((uint16_t*)debug_info)[3]));
|
||||
*Allocated_For_RX = (uint8_t)(((uint16_t*)debug_info)[1]);
|
||||
*Allocated_MBlocks = (*Allocated_For_TX) + (*Allocated_For_RX);
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACI_HAL_STACK_RESET
|
||||
* This command is equivalent to HCI_RESET but ensures the sleep mode is
|
||||
* entered immediately after its completion.
|
||||
*
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_hal_stack_reset( void )
|
||||
{
|
||||
return aci_reset( 0, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACI_GATT_ALLOW_READ
|
||||
* Allow the GATT server to send a response to a read request from a client.
|
||||
* The application has to send this command when it receives the
|
||||
* ACI_GATT_READ_PERMIT_REQ_EVENT or ACI_GATT_READ_MULTI_PERMIT_REQ_EVENT. This
|
||||
* command indicates to the stack that the response can be sent to the client.
|
||||
* So if the application wishes to update any of the attributes before they are
|
||||
* read by the client, it must update the characteristic values using the
|
||||
* ACI_GATT_UPDATE_CHAR_VALUE and then give this command. The application
|
||||
* should perform the required operations within 30 seconds. Otherwise the GATT
|
||||
* procedure will be timeout.
|
||||
*
|
||||
* @param Connection_Handle Specifies the ATT bearer for which the command
|
||||
* applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
|
||||
* connection handle)
|
||||
* - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
|
||||
* parameter is the connection-oriented channel index)
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_gatt_allow_read( uint16_t Connection_Handle )
|
||||
{
|
||||
return aci_gatt_permit_read( Connection_Handle, 0, 0, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACI_GATT_DENY_READ
|
||||
* This command is used to deny the GATT server to send a response to a read
|
||||
* request from a client.
|
||||
* The application may send this command when it receives the
|
||||
* ACI_GATT_READ_PERMIT_REQ_EVENT or ACI_GATT_READ_MULTI_PERMIT_REQ_EVENT.
|
||||
* This command indicates to the stack that the client is not allowed to read
|
||||
* the requested characteristic due to e.g. application restrictions.
|
||||
* The Error code shall be either 0x08 (Insufficient Authorization) or a value
|
||||
* in the range 0x80-0x9F (Application Error).
|
||||
* The application should issue the ACI_GATT_DENY_READ or ACI_GATT_ALLOW_READ
|
||||
* command within 30 seconds from the reception of the
|
||||
* ACI_GATT_READ_PERMIT_REQ_EVENT or ACI_GATT_READ_MULTI_PERMIT_REQ_EVENT
|
||||
* events; otherwise the GATT procedure issues a timeout.
|
||||
*
|
||||
* @param Connection_Handle Specifies the ATT bearer for which the command
|
||||
* applies.
|
||||
* Values:
|
||||
* - 0x0000 ... 0x0EFF: Unenhanced ATT bearer (the parameter is the
|
||||
* connection handle)
|
||||
* - 0xEA00 ... 0xEA3F: Enhanced ATT bearer (the LSB-byte of the
|
||||
* parameter is the connection-oriented channel index)
|
||||
* @param Error_Code Error code for the command
|
||||
* Values:
|
||||
* - 0x08: Insufficient Authorization
|
||||
* - 0x80 ... 0x9F: Application Error
|
||||
* @return Value indicating success or error code.
|
||||
*/
|
||||
__STATIC_INLINE
|
||||
tBleStatus aci_gatt_deny_read( uint16_t Connection_Handle,
|
||||
uint8_t Error_Code )
|
||||
{
|
||||
return aci_gatt_permit_read( Connection_Handle, 1, Error_Code, 0 );
|
||||
}
|
||||
|
||||
|
||||
#endif /* BLE_LEGACY_H__ */
|
||||
@@ -0,0 +1,387 @@
|
||||
/******************************************************************************
|
||||
* @file ble_std.h
|
||||
*
|
||||
* @brief BLE standard definitions
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_STD_H__
|
||||
#define BLE_STD_H__
|
||||
|
||||
|
||||
/* HCI packet type */
|
||||
#define HCI_COMMAND_PKT_TYPE 0x01U
|
||||
#define HCI_ACLDATA_PKT_TYPE 0x02U
|
||||
#define HCI_EVENT_PKT_TYPE 0x04U
|
||||
#define HCI_ISODATA_PKT_TYPE 0x05U
|
||||
|
||||
/* HCI packet header size */
|
||||
#define HCI_COMMAND_HDR_SIZE 4
|
||||
#define HCI_ACLDATA_HDR_SIZE 5
|
||||
#define HCI_EVENT_HDR_SIZE 3
|
||||
#define HCI_ISODATA_HDR_SIZE 5
|
||||
|
||||
/* HCI parameters length */
|
||||
#define HCI_COMMAND_MAX_PARAM_LEN 255
|
||||
#define HCI_ACLDATA_MAX_DATA_LEN 251 /* LE_ACL_Data_Packet_Length */
|
||||
#define HCI_EVENT_MAX_PARAM_LEN 255
|
||||
#define HCI_ISODATA_MAX_DATA_LEN 300 /* ISO_Data_Packet_Length */
|
||||
|
||||
/* HCI packet maximum size */
|
||||
#define HCI_COMMAND_PKT_MAX_SIZE \
|
||||
(HCI_COMMAND_HDR_SIZE + HCI_COMMAND_MAX_PARAM_LEN)
|
||||
#define HCI_ACLDATA_PKT_MAX_SIZE \
|
||||
(HCI_ACLDATA_HDR_SIZE + HCI_ACLDATA_MAX_DATA_LEN)
|
||||
#define HCI_EVENT_PKT_MAX_SIZE \
|
||||
(HCI_EVENT_HDR_SIZE + HCI_EVENT_MAX_PARAM_LEN)
|
||||
#define HCI_ISODATA_PKT_MAX_SIZE \
|
||||
(HCI_ISODATA_HDR_SIZE + HCI_ISODATA_MAX_DATA_LEN)
|
||||
|
||||
/* HCI event code */
|
||||
#define HCI_DISCONNECTION_COMPLETE_EVT_CODE 0x05U
|
||||
#define HCI_ENCRYPTION_CHANGE_EVT_CODE 0x08U
|
||||
#define HCI_READ_REMOTE_VERSION_INFORMATION_COMPLETE_EVT_CODE 0x0CU
|
||||
#define HCI_COMMAND_COMPLETE_EVT_CODE 0x0EU
|
||||
#define HCI_COMMAND_STATUS_EVT_CODE 0x0FU
|
||||
#define HCI_HARDWARE_ERROR_EVT_CODE 0x10U
|
||||
#define HCI_NUMBER_OF_COMPLETED_PACKETS_EVT_CODE 0x13U
|
||||
#define HCI_DATA_BUFFER_OVERFLOW_EVT_CODE 0x1AU
|
||||
#define HCI_ENCRYPTION_KEY_REFRESH_COMPLETE_EVT_CODE 0x30U
|
||||
#define HCI_LE_META_EVT_CODE 0x3EU
|
||||
#define HCI_AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_EVT_CODE 0x57U
|
||||
#define HCI_VENDOR_SPECIFIC_EVT_CODE 0xFFU
|
||||
|
||||
/* HCI LE subevent code */
|
||||
#define HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE 0x01U
|
||||
#define HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE 0x02U
|
||||
#define HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE 0x03U
|
||||
#define HCI_LE_READ_REMOTE_FEATURES_PAGE_0_COMPLETE_SUBEVT_CODE 0x04U
|
||||
#define HCI_LE_LONG_TERM_KEY_REQUEST_SUBEVT_CODE 0x05U
|
||||
#define HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_SUBEVT_CODE 0x06U
|
||||
#define HCI_LE_DATA_LENGTH_CHANGE_SUBEVT_CODE 0x07U
|
||||
#define HCI_LE_READ_LOCAL_P256_PUBLIC_KEY_COMPLETE_SUBEVT_CODE 0x08U
|
||||
#define HCI_LE_GENERATE_DHKEY_COMPLETE_SUBEVT_CODE 0x09U
|
||||
#define HCI_LE_ENHANCED_CONNECTION_COMPLETE_SUBEVT_CODE 0x0AU
|
||||
#define HCI_LE_DIRECTED_ADVERTISING_REPORT_SUBEVT_CODE 0x0BU
|
||||
#define HCI_LE_PHY_UPDATE_COMPLETE_SUBEVT_CODE 0x0CU
|
||||
#define HCI_LE_EXTENDED_ADVERTISING_REPORT_SUBEVT_CODE 0x0DU
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_SYNC_ESTABLISHED_SUBEVT_CODE 0x0EU
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_REPORT_SUBEVT_CODE 0x0FU
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_SYNC_LOST_SUBEVT_CODE 0x10U
|
||||
#define HCI_LE_SCAN_TIMEOUT_SUBEVT_CODE 0x11U
|
||||
#define HCI_LE_ADVERTISING_SET_TERMINATED_SUBEVT_CODE 0x12U
|
||||
#define HCI_LE_SCAN_REQUEST_RECEIVED_SUBEVT_CODE 0x13U
|
||||
#define HCI_LE_CHANNEL_SELECTION_ALGORITHM_SUBEVT_CODE 0x14U
|
||||
#define HCI_LE_CONNECTIONLESS_IQ_REPORT_SUBEVT_CODE 0x15U
|
||||
#define HCI_LE_CONNECTION_IQ_REPORT_SUBEVT_CODE 0x16U
|
||||
#define HCI_LE_CTE_REQUEST_FAILED_SUBEVT_CODE 0x17U
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED_SUBEVT_CODE 0x18U
|
||||
#define HCI_LE_CIS_ESTABLISHED_SUBEVT_CODE 0x19U
|
||||
#define HCI_LE_CIS_REQUEST_SUBEVT_CODE 0x1AU
|
||||
#define HCI_LE_CREATE_BIG_COMPLETE_SUBEVT_CODE 0x1BU
|
||||
#define HCI_LE_TERMINATE_BIG_COMPLETE_SUBEVT_CODE 0x1CU
|
||||
#define HCI_LE_BIG_SYNC_ESTABLISHED_SUBEVT_CODE 0x1DU
|
||||
#define HCI_LE_BIG_SYNC_LOST_SUBEVT_CODE 0x1EU
|
||||
#define HCI_LE_REQUEST_PEER_SCA_COMPLETE_SUBEVT_CODE 0x1FU
|
||||
#define HCI_LE_PATH_LOSS_THRESHOLD_SUBEVT_CODE 0x20U
|
||||
#define HCI_LE_TRANSMIT_POWER_REPORTING_SUBEVT_CODE 0x21U
|
||||
#define HCI_LE_BIGINFO_ADVERTISING_REPORT_SUBEVT_CODE 0x22U
|
||||
#define HCI_LE_SUBRATE_CHANGE_SUBEVT_CODE 0x23U
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_SYNC_ESTABLISHED_V2_SUBEVT_CODE 0x24U
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_REPORT_V2_SUBEVT_CODE 0x25U
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED_V2_SUBEVT_CODE 0x26U
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_SUBEVENT_DATA_REQUEST_SUBEVT_CODE 0x27U
|
||||
#define HCI_LE_PERIODIC_ADVERTISING_RESPONSE_REPORT_SUBEVT_CODE 0x28U
|
||||
#define HCI_LE_ENHANCED_CONNECTION_COMPLETE_V2_SUBEVT_CODE 0x29U
|
||||
#define HCI_LE_CIS_ESTABLISHED_V2_SUBEVT_CODE 0x2AU
|
||||
#define HCI_LE_READ_ALL_REMOTE_FEATURES_COMPLETE_SUBEVT_CODE 0x2BU
|
||||
#define HCI_LE_CS_READ_REMOTE_SUPPORTED_CAPABILITIES_COMPLETE_SUBEVT_CODE 0x2CU
|
||||
#define HCI_LE_CS_READ_REMOTE_FAE_TABLE_COMPLETE_SUBEVT_CODE 0x2DU
|
||||
#define HCI_LE_CS_SECURITY_ENABLE_COMPLETE_SUBEVT_CODE 0x2EU
|
||||
#define HCI_LE_CS_CONFIG_COMPLETE_SUBEVT_CODE 0x2FU
|
||||
#define HCI_LE_CS_PROCEDURE_ENABLE_COMPLETE_SUBEVT_CODE 0x30U
|
||||
#define HCI_LE_CS_SUBEVENT_RESULT_SUBEVT_CODE 0x31U
|
||||
#define HCI_LE_CS_SUBEVENT_RESULT_CONTINUE_SUBEVT_CODE 0x32U
|
||||
#define HCI_LE_CS_TEST_END_COMPLETE_SUBEVT_CODE 0x33U
|
||||
#define HCI_LE_MONITORED_ADVERTISERS_REPORT_SUBEVT_CODE 0x34U
|
||||
#define HCI_LE_FRAME_SPACE_UPDATE_COMPLETE_SUBEVT_CODE 0x35U
|
||||
|
||||
/* HCI error code */
|
||||
#define HCI_SUCCESS_ERR_CODE 0x00U
|
||||
#define HCI_UNKNOWN_HCI_COMMAND_ERR_CODE 0x01U
|
||||
#define HCI_UNKNOWN_CONNECTION_IDENTIFIER_ERR_CODE 0x02U
|
||||
#define HCI_HARDWARE_FAILURE_ERR_CODE 0x03U
|
||||
#define HCI_AUTHENTICATION_FAILURE_ERR_CODE 0x05U
|
||||
#define HCI_PIN_OR_KEY_MISSING_ERR_CODE 0x06U
|
||||
#define HCI_MEMORY_CAPACITY_EXCEEDED_ERR_CODE 0x07U
|
||||
#define HCI_CONNECTION_TIMEOUT_ERR_CODE 0x08U
|
||||
#define HCI_CONNECTION_LIMIT_EXCEEDED_ERR_CODE 0x09U
|
||||
#define HCI_CONNECTION_ALREADY_EXISTS_ERR_CODE 0x0BU
|
||||
#define HCI_COMMAND_DISALLOWED_ERR_CODE 0x0CU
|
||||
#define HCI_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE_ERR_CODE 0x11U
|
||||
#define HCI_INVALID_HCI_COMMAND_PARAMETERS_ERR_CODE 0x12U
|
||||
#define HCI_REMOTE_USER_TERMINATED_CONNECTION_ERR_CODE 0x13U
|
||||
#define HCI_REMOTE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES_ERR_CODE 0x14U
|
||||
#define HCI_REMOTE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF_ERR_CODE 0x15U
|
||||
#define HCI_CONNECTION_TERMINATED_BY_LOCAL_HOST_ERR_CODE 0x16U
|
||||
#define HCI_UNSUPPORTED_REMOTE_FEATURE_ERR_CODE 0x1AU
|
||||
#define HCI_INVALID_LL_PARAMETERS_ERR_CODE 0x1EU
|
||||
#define HCI_UNSPECIFIED_ERROR_ERR_CODE 0x1FU
|
||||
#define HCI_UNSUPPORTED_LL_PARAMETER_VALUE_ERR_CODE 0x20U
|
||||
#define HCI_LL_RESPONSE_TIMEOUT_ERR_CODE 0x22U
|
||||
#define HCI_LL_PROCEDURE_COLLISION_ERR_CODE 0x23U
|
||||
#define HCI_LMP_PDU_NOT_ALLOWED_ERR_CODE 0x24U
|
||||
#define HCI_INSTANT_PASSED_ERR_CODE 0x28U
|
||||
#define HCI_DIFFERENT_TRANSACTION_COLLISION_ERR_CODE 0x2AU
|
||||
#define HCI_PARAMETER_OUT_OF_MANDATORY_RANGE_ERR_CODE 0x30U
|
||||
#define HCI_HOST_BUSY_PAIRING_ERR_CODE 0x38U
|
||||
#define HCI_CONTROLLER_BUSY_ERR_CODE 0x3AU
|
||||
#define HCI_UNACCEPTABLE_CONNECTION_PARAMETERS_ERR_CODE 0x3BU
|
||||
#define HCI_ADVERTISING_TIMEOUT_ERR_CODE 0x3CU
|
||||
#define HCI_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE_ERR_CODE 0x3DU
|
||||
#define HCI_CONNECTION_FAILED_TO_BE_ESTABLISHED_ERR_CODE 0x3EU
|
||||
#define HCI_UNKNOWN_ADVERTISING_IDENTIFIER_ERR_CODE 0x42U
|
||||
#define HCI_ADVERTISING_LIMIT_REACHED_ERR_CODE 0x43U
|
||||
#define HCI_PACKET_TOO_LONG_ERR_CODE 0x45U
|
||||
|
||||
/* HCI_LE_Set_Advertising_Parameters: Advertising_Type */
|
||||
#define HCI_ADV_TYPE_ADV_IND 0x00U
|
||||
#define HCI_ADV_TYPE_ADV_DIRECT_IND_HDC 0x01U
|
||||
#define HCI_ADV_TYPE_ADV_SCAN_IND 0x02U
|
||||
#define HCI_ADV_TYPE_ADV_NONCONN_IND 0x03U
|
||||
#define HCI_ADV_TYPE_ADV_DIRECT_IND_LDC 0x04U
|
||||
|
||||
/* HCI_LE_Set_Advertising_Parameters: Advertising_Filter_Policy */
|
||||
#define HCI_ADV_FILTER_NO 0x00U
|
||||
#define HCI_ADV_FILTER_ACC_LIST_USED_FOR_SCAN 0x01U
|
||||
#define HCI_ADV_FILTER_ACC_LIST_USED_FOR_CONNECT 0x02U
|
||||
#define HCI_ADV_FILTER_ACC_LIST_USED_FOR_ALL 0x03U
|
||||
|
||||
/* HCI_LE_Set_[Advertising/Scan]_Parameters: Own_Address_Type */
|
||||
#define HCI_OWN_ADDR_TYPE_PUBLIC 0x00U
|
||||
#define HCI_OWN_ADDR_TYPE_RANDOM 0x01U
|
||||
#define HCI_OWN_ADDR_TYPE_RP_OR_PUBLIC 0x02U
|
||||
#define HCI_OWN_ADDR_TYPE_RP_OR_RANDOM 0x03U
|
||||
|
||||
/* HCI_LE_Set_Scan_Parameters: LE_Scan_Type */
|
||||
#define HCI_SCAN_TYPE_PASSIVE 0x00U
|
||||
#define HCI_SCAN_TYPE_ACTIVE 0x01U
|
||||
|
||||
/* HCI_LE_Set_Scan_Parameters: Scanning_Filter_Policy */
|
||||
#define HCI_SCAN_FILTER_NO 0x00U
|
||||
#define HCI_SCAN_FILTER_ACC_LIST_USED 0x01U
|
||||
#define HCI_SCAN_FILTER_NO_EXT 0x02U
|
||||
#define HCI_SCAN_FILTER_ACC_LIST_USED_EXT 0x03U
|
||||
|
||||
/* HCI_LE_Create_Connection: Initiator_Filter_Policy */
|
||||
#define HCI_INIT_FILTER_NO 0x00U
|
||||
#define HCI_INIT_FILTER_ACC_LIST_USED 0x01U
|
||||
|
||||
/* HCI_LE_Read_PHY: TX_PHY */
|
||||
#define HCI_TX_PHY_LE_1M 0x01U
|
||||
#define HCI_TX_PHY_LE_2M 0x02U
|
||||
#define HCI_TX_PHY_LE_CODED 0x03U
|
||||
|
||||
/* HCI_LE_Read_PHY: RX_PHY */
|
||||
#define HCI_RX_PHY_LE_1M 0x01U
|
||||
#define HCI_RX_PHY_LE_2M 0x02U
|
||||
#define HCI_RX_PHY_LE_CODED 0x03U
|
||||
|
||||
/* HCI_LE_Set_PHY: ALL_PHYS */
|
||||
#define HCI_ALL_PHYS_TX_NO_PREF 0x01U
|
||||
#define HCI_ALL_PHYS_RX_NO_PREF 0x02U
|
||||
|
||||
/* HCI_LE_Set_PHY: TX_PHYS */
|
||||
#define HCI_TX_PHYS_LE_1M_PREF 0x01U
|
||||
#define HCI_TX_PHYS_LE_2M_PREF 0x02U
|
||||
#define HCI_TX_PHYS_LE_CODED_PREF 0x04U
|
||||
|
||||
/* HCI_LE_Set_PHY: RX_PHYS */
|
||||
#define HCI_RX_PHYS_LE_1M_PREF 0x01U
|
||||
#define HCI_RX_PHYS_LE_2M_PREF 0x02U
|
||||
#define HCI_RX_PHYS_LE_CODED_PREF 0x04U
|
||||
|
||||
/* HCI_LE_Set_Extended_Advertising_Parameters: Advertising_Event_Properties */
|
||||
#define HCI_ADV_EVENT_PROP_CONNECTABLE 0x0001U
|
||||
#define HCI_ADV_EVENT_PROP_SCANNABLE 0x0002U
|
||||
#define HCI_ADV_EVENT_PROP_DIRECTED 0x0004U
|
||||
#define HCI_ADV_EVENT_PROP_HDC_DIRECTED 0x0008U
|
||||
#define HCI_ADV_EVENT_PROP_LEGACY 0x0010U
|
||||
#define HCI_ADV_EVENT_PROP_ANONYMOUS 0x0020U
|
||||
#define HCI_ADV_EVENT_PROP_TXPOWER_INC 0x0040U
|
||||
|
||||
/* HCI_LE_Set_Extended_Advertising_Parameters: Primary_Advertising_PHY */
|
||||
#define HCI_PRIMARY_ADV_PHY_LE_1M 0x01U
|
||||
#define HCI_PRIMARY_ADV_PHY_LE_CODED 0x03U
|
||||
|
||||
/* HCI_LE_Set_Extended_Advertising_Data: Operation */
|
||||
#define HCI_SET_ADV_DATA_OPERATION_INTERMEDIATE 0x00U
|
||||
#define HCI_SET_ADV_DATA_OPERATION_FIRST 0x01U
|
||||
#define HCI_SET_ADV_DATA_OPERATION_LAST 0x02U
|
||||
#define HCI_SET_ADV_DATA_OPERATION_COMPLETE 0x03U
|
||||
#define HCI_SET_ADV_DATA_OPERATION_UNCHANGED 0x04U
|
||||
|
||||
/* HCI_LE_Advertising_Report: Event_Type */
|
||||
#define HCI_ADV_EVT_TYPE_ADV_IND 0x00U
|
||||
#define HCI_ADV_EVT_TYPE_ADV_DIRECT_IND 0x01U
|
||||
#define HCI_ADV_EVT_TYPE_ADV_SCAN_IND 0x02U
|
||||
#define HCI_ADV_EVT_TYPE_ADV_NONCONN_IND 0x03U
|
||||
#define HCI_ADV_EVT_TYPE_SCAN_RSP 0x04U
|
||||
|
||||
/* HCI_LE_Set_Extended_Scan_Parameters: Scanning_PHYs */
|
||||
#define HCI_SCANNING_PHYS_LE_1M 0x01U
|
||||
#define HCI_SCANNING_PHYS_LE_CODED 0x04U
|
||||
|
||||
/* HCI_LE_Extended_Create_Connection: Initiating_PHYs */
|
||||
#define HCI_INIT_PHYS_SCAN_CONN_LE_1M 0x01U
|
||||
#define HCI_INIT_PHYS_CONN_LE_2M 0x02U
|
||||
#define HCI_INIT_PHYS_SCAN_CONN_LE_CODED 0x04U
|
||||
|
||||
/* HCI_LE_Receiver_Test/HCI_LE_Transmitter_Test [v2]: PHY */
|
||||
#define HCI_TEST_PHY_LE_1M 0x01U
|
||||
#define HCI_TEST_PHY_LE_2M 0x02U
|
||||
|
||||
/* HCI_LE_Connection_Complete/HCI_LE_Enhanced_Connection_Complete: Role */
|
||||
#define HCI_ROLE_CENTRAL 0x00U
|
||||
#define HCI_ROLE_PERIPHERAL 0x01U
|
||||
|
||||
/* HCI_LE_Set_Privacy_Mode: Privacy_Mode */
|
||||
#define HCI_PRIV_MODE_NETWORK 0x00U
|
||||
#define HCI_PRIV_MODE_DEVICE 0x01U
|
||||
|
||||
/* Bluetooth Core Specification versions
|
||||
*/
|
||||
#define BLE_CORE_5_2 11
|
||||
#define BLE_CORE_5_3 12
|
||||
#define BLE_CORE_5_4 13
|
||||
#define BLE_CORE_6_0 14
|
||||
#define BLE_CORE_6_1 15
|
||||
|
||||
/* AD types for advertising data and scan response data
|
||||
*/
|
||||
#define AD_TYPE_FLAGS 0x01U
|
||||
#define AD_TYPE_16_BIT_SERV_UUID 0x02U
|
||||
#define AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST 0x03U
|
||||
#define AD_TYPE_32_BIT_SERV_UUID 0x04U
|
||||
#define AD_TYPE_32_BIT_SERV_UUID_CMPLT_LIST 0x05U
|
||||
#define AD_TYPE_128_BIT_SERV_UUID 0x06U
|
||||
#define AD_TYPE_128_BIT_SERV_UUID_CMPLT_LIST 0x07U
|
||||
#define AD_TYPE_SHORTENED_LOCAL_NAME 0x08U
|
||||
#define AD_TYPE_COMPLETE_LOCAL_NAME 0x09U
|
||||
#define AD_TYPE_TX_POWER_LEVEL 0x0AU
|
||||
#define AD_TYPE_CLASS_OF_DEVICE 0x0DU
|
||||
#define AD_TYPE_SEC_MGR_TK_VALUE 0x10U
|
||||
#define AD_TYPE_SEC_MGR_OOB_FLAGS 0x11U
|
||||
#define AD_TYPE_PERIPHERAL_CONN_INTERVAL 0x12U
|
||||
#define AD_TYPE_SERV_SOLICIT_16_BIT_UUID_LIST 0x14U
|
||||
#define AD_TYPE_SERV_SOLICIT_128_BIT_UUID_LIST 0x15U
|
||||
#define AD_TYPE_SERVICE_DATA 0x16U
|
||||
#define AD_TYPE_APPEARANCE 0x19U
|
||||
#define AD_TYPE_ADVERTISING_INTERVAL 0x1AU
|
||||
#define AD_TYPE_LE_ROLE 0x1CU
|
||||
#define AD_TYPE_SERV_SOLICIT_32_BIT_UUID_LIST 0x1FU
|
||||
#define AD_TYPE_URI 0x24U
|
||||
#define AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFFU
|
||||
|
||||
/* Flag bits for Flags AD Type
|
||||
*/
|
||||
#define FLAG_BIT_LE_LIMITED_DISCOVERABLE_MODE 0x01U
|
||||
#define FLAG_BIT_LE_GENERAL_DISCOVERABLE_MODE 0x02U
|
||||
#define FLAG_BIT_BR_EDR_NOT_SUPPORTED 0x04U
|
||||
#define FLAG_BIT_LE_BR_EDR_CONTROLLER 0x08U
|
||||
#define FLAG_BIT_LE_BR_EDR_HOST 0x10U
|
||||
|
||||
/* Appearance values
|
||||
*/
|
||||
#define GAP_APPEARANCE_UNKNOWN 0x0000
|
||||
#define GAP_APPEARANCE_GENERIC_PHONE 0x0040
|
||||
#define GAP_APPEARANCE_GENERIC_COMPUTER 0x0080
|
||||
#define GAP_APPEARANCE_GENERIC_WATCH 0x00C0
|
||||
#define GAP_APPEARANCE_WATCH_SPORT_WATCH 0x00C1
|
||||
#define GAP_APPEARANCE_GENERIC_CLOCK 0x0100
|
||||
#define GAP_APPEARANCE_GENERIC_DISPLAY 0x0140
|
||||
#define GAP_APPEARANCE_GENERIC_REMOTE_CONTROL 0x0180
|
||||
#define GAP_APPEARANCE_GENERIC_EYE_GLASSES 0x01C0
|
||||
#define GAP_APPEARANCE_GENERIC_TAG 0x0200
|
||||
#define GAP_APPEARANCE_GENERIC_KEYRING 0x0240
|
||||
#define GAP_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280
|
||||
#define GAP_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0
|
||||
#define GAP_APPEARANCE_GENERIC_THERMOMETER 0x0300
|
||||
#define GAP_APPEARANCE_THERMOMETER_EAR 0x0301
|
||||
#define GAP_APPEARANCE_GENERIC_HEART_RATE_SENSOR 0x0340
|
||||
#define GAP_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 0x0341
|
||||
#define GAP_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380
|
||||
#define GAP_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381
|
||||
#define GAP_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382
|
||||
#define GAP_APPEARANCE_HUMAN_INTERFACE_DEVICE 0x03C0
|
||||
#define GAP_APPEARANCE_KEYBOARD 0x03C1
|
||||
#define GAP_APPEARANCE_MOUSE 0x03C2
|
||||
#define GAP_APPEARANCE_JOYSTICK 0x03C3
|
||||
#define GAP_APPEARANCE_GAMEPAD 0x03C4
|
||||
#define GAP_APPEARANCE_DIGITIZER_TABLET 0x03C5
|
||||
#define GAP_APPEARANCE_CARD_READER 0x03C6
|
||||
#define GAP_APPEARANCE_DIGITAL_PEN 0x03C7
|
||||
#define GAP_APPEARANCE_BARCODE_SCANNER 0x03C8
|
||||
#define GAP_APPEARANCE_GENERIC_GLUCOSE_METER 0x0400
|
||||
#define GAP_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 0x0440
|
||||
#define GAP_APPEARANCE_RUNNING_WALKING_IN_SHOE 0x0441
|
||||
#define GAP_APPEARANCE_RUNNING_WALKING_ON_SHOE 0x0442
|
||||
#define GAP_APPEARANCE_RUNNING_WALKING_ON_HIP 0x0443
|
||||
#define GAP_APPEARANCE_GENERIC_CYCLING 0x0480
|
||||
#define GAP_APPEARANCE_CYCLING_CYCLING_COMPUTER 0x0481
|
||||
#define GAP_APPEARANCE_CYCLING_SPEED_SENSOR 0x0482
|
||||
#define GAP_APPEARANCE_CYCLING_CADENCE_SENSOR 0x0483
|
||||
#define GAP_APPEARANCE_CYCLING_POWER_SENSOR 0x0484
|
||||
#define GAP_APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR 0x0485
|
||||
#define GAP_APPEARANCE_GENERIC_PULSE_OXYMETER 0x0C40
|
||||
#define GAP_APPEARANCE_FINGERTIP 0x0C41
|
||||
#define GAP_APPEARANCE_WRIST_WORN 0x0C42
|
||||
#define GAP_APPEARANCE_GENERIC_WEIGHT_SCALE 0x0C80
|
||||
#define GAP_APPEARANCE_GENERIC_OUTDOOR_SPORT_ACTIVITY 0x1440
|
||||
#define GAP_APPEARANCE_LOCATION_DISPLAY_DEVICE 0x1441
|
||||
#define GAP_APPEARANCE_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE 0x1442
|
||||
#define GAP_APPEARANCE_LOCATION_POD 0x1443
|
||||
#define GAP_APPEARANCE_LOCATION_AND_NAVIGATION_POD 0x1444
|
||||
#define GAP_APPEARANCE_GENERIC_ENVIRONMENTAL_SENSOR 0x1640
|
||||
|
||||
/* GATT UUIDs
|
||||
*/
|
||||
#define GATT_SERVICE_UUID 0x1801U
|
||||
#define PRIMARY_SERVICE_UUID 0x2800U
|
||||
#define SECONDARY_SERVICE_UUID 0x2801U
|
||||
#define INCLUDE_SERVICE_UUID 0x2802U
|
||||
#define CHARACTERISTIC_UUID 0x2803U
|
||||
#define CHAR_EXTENDED_PROP_DESC_UUID 0x2900U
|
||||
#define CHAR_USER_DESC_UUID 0x2901U
|
||||
#define CHAR_CLIENT_CONFIG_DESC_UUID 0x2902U
|
||||
#define CHAR_SERVER_CONFIG_DESC_UUID 0x2903U
|
||||
#define CHAR_FORMAT_DESC_UUID 0x2904U
|
||||
#define CHAR_AGGR_FMT_DESC_UUID 0x2905U
|
||||
#define SERVICE_CHANGED_UUID 0x2A05U
|
||||
#define CLIENT_SUPPORTED_FEATURES_UUID 0X2B29U
|
||||
#define DATABASE_HASH_UUID 0X2B2AU
|
||||
#define SERVER_SUPPORTED_FEATURES_UUID 0X2B3AU
|
||||
|
||||
/* GAP UUIDs
|
||||
*/
|
||||
#define GAP_SERVICE_UUID 0x1800U
|
||||
#define DEVICE_NAME_UUID 0x2A00U
|
||||
#define APPEARANCE_UUID 0x2A01U
|
||||
#define PERIPHERAL_PREFERRED_CONN_PARAMS_UUID 0x2A04U
|
||||
#define CENTRAL_ADDRESS_RESOLUTION_UUID 0x2AA6U
|
||||
#define RESOLVABLE_PRIVATE_ADDRESS_ONLY_UUID 0x2AC9U
|
||||
#define ENCRYPTED_DATA_KEY_MATERIAL_UUID 0x2B88U
|
||||
#define LE_GATT_SECURITY_LEVELS_UUID 0x2BF5U
|
||||
|
||||
|
||||
#endif /* BLE_STD_H__ */
|
||||
@@ -0,0 +1,129 @@
|
||||
/*****************************************************************************
|
||||
* @file ble_const.h
|
||||
*
|
||||
* @brief This file contains the definitions which are compiler dependent.
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BLE_CONST_H__
|
||||
#define BLE_CONST_H__
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "ble_std.h"
|
||||
#include "ble_defs.h"
|
||||
#include "osal.h"
|
||||
#include "compiler.h"
|
||||
|
||||
|
||||
/* Default BLE variant */
|
||||
#ifndef BASIC_FEATURES
|
||||
#define BASIC_FEATURES 0
|
||||
#endif
|
||||
#ifndef SLAVE_ONLY
|
||||
#define SLAVE_ONLY 0
|
||||
#endif
|
||||
#ifndef LL_ONLY
|
||||
#define LL_ONLY 0
|
||||
#endif
|
||||
#ifndef LL_ONLY_BASIC
|
||||
#define LL_ONLY_BASIC 0
|
||||
#endif
|
||||
#ifndef BEACON_ONLY
|
||||
#define BEACON_ONLY 0
|
||||
#endif
|
||||
|
||||
/* Definition to determine BLE Host stack presence */
|
||||
#define BLE_HOST_PRESENT (!(LL_ONLY || LL_ONLY_BASIC || BEACON_ONLY))
|
||||
|
||||
|
||||
/* Size of command/events buffers:
|
||||
*
|
||||
* To change the size of commands and events parameters used in the
|
||||
* auto-generated files, you need to update 2 defines:
|
||||
*
|
||||
* - BLE_CMD_MAX_PARAM_LEN
|
||||
* - BLE_EVT_MAX_PARAM_LEN
|
||||
*
|
||||
* These 2 defines are set below with default values and can be changed.
|
||||
*
|
||||
* To compute the value to support a characteristic of 512 bytes for a specific
|
||||
* command or an event, you need to look in "ble_types.h".
|
||||
*
|
||||
* Here are 2 examples, one with a command and one with an event:
|
||||
*
|
||||
* - aci_gatt_update_char_value_ext_cp0
|
||||
* ----------------------------------
|
||||
*
|
||||
* we have in the structure:
|
||||
*
|
||||
* uint8_t Value[(BLE_CMD_MAX_PARAM_LEN- 12)/sizeof(uint8_t)];
|
||||
*
|
||||
* so to support a 512 byte value, we need to have
|
||||
*
|
||||
* BLE_CMD_MAX_PARAM_LEN at least equal to: 512 + 12 = 524
|
||||
*
|
||||
* - aci_gatt_read_handle_value_rp0
|
||||
* ------------------------------
|
||||
*
|
||||
* we have in the structure:
|
||||
*
|
||||
* uint8_t Value[((BLE_EVT_MAX_PARAM_LEN - 3) - 5)/sizeof(uint8_t)];
|
||||
*
|
||||
* so to support a 512 byte value, we need to have
|
||||
*
|
||||
* BLE_EVT_MAX_PARAM_LEN at least equal to: 512 + 3 + 5 = 520
|
||||
*
|
||||
* If you need several events or commands with 512-size values, you need to
|
||||
* take the maximum values for BLE_EVT_MAX_PARAM_LEN and BLE_CMD_MAX_PARAM_LEN.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Maximum parameter size of BLE commands.
|
||||
* Change this value if needed. */
|
||||
#define BLE_CMD_MAX_PARAM_LEN HCI_COMMAND_MAX_PARAM_LEN
|
||||
|
||||
/* Maximum parameter size of BLE responses/events.
|
||||
* Change this value if needed. */
|
||||
#define BLE_EVT_MAX_PARAM_LEN HCI_EVENT_MAX_PARAM_LEN
|
||||
|
||||
|
||||
/* Callback function to send command and receive response */
|
||||
struct hci_request
|
||||
{
|
||||
uint16_t ogf;
|
||||
uint16_t ocf;
|
||||
int event;
|
||||
void* cparam;
|
||||
int clen;
|
||||
void* rparam;
|
||||
int rlen;
|
||||
};
|
||||
extern int hci_send_req( struct hci_request* req, uint8_t async );
|
||||
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN( a, b ) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX( a, b ) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* BLE_CONST_H__ */
|
||||
@@ -0,0 +1,160 @@
|
||||
/*****************************************************************************
|
||||
* @file compiler.h
|
||||
*
|
||||
* @brief This file contains the definitions which are compiler dependent.
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef COMPILER_H__
|
||||
#define COMPILER_H__
|
||||
|
||||
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT PACKED(struct)
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION PACKED(union)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This is the section dedicated to IAR toolchain
|
||||
*/
|
||||
#if defined(__ICCARM__) || defined(__IAR_SYSTEMS_ASM__)
|
||||
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
|
||||
#define QUOTE_(a) #a
|
||||
|
||||
/**
|
||||
* @brief PACKED
|
||||
* Use the PACKED macro for variables that needs to be packed.
|
||||
* Usage: PACKED(struct) myStruct_s
|
||||
* PACKED(union) myStruct_s
|
||||
*/
|
||||
#define PACKED(decl) __packed decl
|
||||
|
||||
/**
|
||||
* @brief SECTION
|
||||
* Use the SECTION macro to assign data or code in a specific section.
|
||||
* Usage: SECTION(".my_section")
|
||||
*/
|
||||
#define SECTION(name) _Pragma(QUOTE_(location=name))
|
||||
|
||||
/**
|
||||
* @brief ALIGN_DEF
|
||||
* Use the ALIGN_DEF macro to specify the alignment of a variable.
|
||||
* Usage: ALIGN_DEF(4)
|
||||
*/
|
||||
#define ALIGN_DEF(v) _Pragma(QUOTE_(data_alignment=v))
|
||||
|
||||
/**
|
||||
* @brief NO_INIT
|
||||
* Use the NO_INIT macro to declare a not initialized variable.
|
||||
* Usage: NO_INIT(int my_no_init_var)
|
||||
* Usage: NO_INIT(uint16_t my_no_init_array[10])
|
||||
*/
|
||||
#define NO_INIT(var) __no_init var
|
||||
|
||||
/**
|
||||
* @brief This is the section dedicated to GNU toolchain
|
||||
*/
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PACKED
|
||||
* Use the PACKED macro for variables that needs to be packed.
|
||||
* Usage: PACKED(struct) myStruct_s
|
||||
* PACKED(union) myStruct_s
|
||||
*/
|
||||
#define PACKED(decl) decl __attribute__((packed))
|
||||
|
||||
/**
|
||||
* @brief SECTION
|
||||
* Use the SECTION macro to assign data or code in a specific section.
|
||||
* Usage: SECTION(".my_section")
|
||||
*/
|
||||
#define SECTION(name) __attribute__((section(name)))
|
||||
|
||||
/**
|
||||
* @brief ALIGN_DEF
|
||||
* Use the ALIGN_DEF macro to specify the alignment of a variable.
|
||||
* Usage: ALIGN_DEF(4)
|
||||
*/
|
||||
#define ALIGN_DEF(N) __attribute__((aligned(N)))
|
||||
|
||||
/**
|
||||
* @brief NO_INIT
|
||||
* Use the NO_INIT macro to declare a not initialized variable.
|
||||
* Usage: NO_INIT(int my_no_init_var)
|
||||
* Usage: NO_INIT(uint16_t my_no_init_array[10])
|
||||
*/
|
||||
#define NO_INIT(var) var __attribute__((section(".noinit")))
|
||||
|
||||
/**
|
||||
* @brief This is the section dedicated to Keil toolchain
|
||||
*/
|
||||
#else
|
||||
#ifdef __CC_ARM
|
||||
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PACKED
|
||||
* Use the PACKED macro for variables that needs to be packed.
|
||||
* Usage: PACKED(struct) myStruct_s
|
||||
* PACKED(union) myStruct_s
|
||||
*/
|
||||
#define PACKED(decl) decl __attribute__((packed))
|
||||
|
||||
/**
|
||||
* @brief SECTION
|
||||
* Use the SECTION macro to assign data or code in a specific section.
|
||||
* Usage: SECTION(".my_section")
|
||||
*/
|
||||
#define SECTION(name) __attribute__((section(name)))
|
||||
|
||||
/**
|
||||
* @brief ALIGN_DEF
|
||||
* Use the ALIGN_DEF macro to specify the alignment of a variable.
|
||||
* Usage: ALIGN_DEF(4)
|
||||
*/
|
||||
#define ALIGN_DEF(N) __attribute__((aligned(N)))
|
||||
|
||||
/**
|
||||
* @brief NO_INIT
|
||||
* Use the NO_INIT macro to declare a not initialized variable.
|
||||
* Usage: NO_INIT(int my_no_init_var)
|
||||
* Usage: NO_INIT(uint16_t my_no_init_array[10])
|
||||
*/
|
||||
#define NO_INIT(var) var __attribute__((section("NoInit")))
|
||||
|
||||
#else
|
||||
|
||||
#error Neither ICCARM, CC ARM nor GNUC C detected. Define your macros.
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* COMPILER_H__ */
|
||||
@@ -0,0 +1,50 @@
|
||||
/*****************************************************************************
|
||||
* @file osal.c
|
||||
*
|
||||
* @brief Implements the interface defined in "osal.h" needed by the stack.
|
||||
* Actually, only memset, memcpy and memcmp wrappers are implemented.
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "osal.h"
|
||||
|
||||
|
||||
/**
|
||||
* Osal_MemCpy
|
||||
*
|
||||
*/
|
||||
|
||||
void* Osal_MemCpy( void *dest, const void *src, unsigned int size )
|
||||
{
|
||||
return memcpy( dest, src, size );
|
||||
}
|
||||
|
||||
/**
|
||||
* Osal_MemSet
|
||||
*
|
||||
*/
|
||||
|
||||
void* Osal_MemSet( void *ptr, int value, unsigned int size )
|
||||
{
|
||||
return memset( ptr, value, size );
|
||||
}
|
||||
|
||||
/**
|
||||
* Osal_MemCmp
|
||||
*
|
||||
*/
|
||||
int Osal_MemCmp( const void *s1, const void *s2, unsigned int size )
|
||||
{
|
||||
return memcmp( s1, s2, size );
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************
|
||||
* @file osal.h
|
||||
*
|
||||
* @brief This header file defines the OS abstraction layer used by
|
||||
* the BLE stack. OSAL defines the set of functions which needs to be
|
||||
* ported to target operating system and target platform.
|
||||
* Actually, only memset, memcpy and memcmp wrappers are defined.
|
||||
*****************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef OSAL_H__
|
||||
#define OSAL_H__
|
||||
|
||||
|
||||
/**
|
||||
* This function copies size number of bytes from a
|
||||
* memory location pointed by src to a destination
|
||||
* memory location pointed by dest
|
||||
*
|
||||
* @param[in] dest Destination address
|
||||
* @param[in] src Source address
|
||||
* @param[in] size size in the bytes
|
||||
*
|
||||
* @return Address of the destination
|
||||
*/
|
||||
|
||||
extern void* Osal_MemCpy( void *dest, const void *src, unsigned int size );
|
||||
|
||||
/**
|
||||
* This function sets first number of bytes, specified
|
||||
* by size, to the destination memory pointed by ptr
|
||||
* to the specified value
|
||||
*
|
||||
* @param[in] ptr Destination address
|
||||
* @param[in] value Value to be set
|
||||
* @param[in] size Size in the bytes
|
||||
*
|
||||
* @return Address of the destination
|
||||
*/
|
||||
|
||||
extern void* Osal_MemSet( void *ptr, int value, unsigned int size );
|
||||
|
||||
/**
|
||||
* This function compares n bytes of two regions of memory
|
||||
*
|
||||
* @param[in] s1 First buffer to compare.
|
||||
* @param[in] s2 Second buffer to compare.
|
||||
* @param[in] size Number of bytes to compare.
|
||||
*
|
||||
* @return 0 if the two buffers are equal, 1 otherwise
|
||||
*/
|
||||
extern int Osal_MemCmp( const void *s1, const void *s2, unsigned int size );
|
||||
|
||||
|
||||
#endif /* OSAL_H__ */
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file bas.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for bas.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __BAS_H
|
||||
#define __BAS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
BAS_LEVEL_NOT_ENABLED_EVT,
|
||||
BAS_LEVEL_NOT_DISABLED_EVT,
|
||||
BAS_LEVEL_READ_EVT
|
||||
} BAS_Opcode_Notification_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BAS_Opcode_Notification_evt_t BAS_Evt_Opcode;
|
||||
uint8_t ServiceInstance;
|
||||
}BAS_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
#define BAS_LEVEL_NOTIFICATION_OPTION 1
|
||||
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void BAS_Init(void);
|
||||
void BAS_Update_Char(uint16_t UUID, uint8_t service_instance, uint8_t *pPayload);
|
||||
void BAS_Notification(BAS_Notification_evt_t * pNotification);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__BAS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file bls.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for bls.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __BLS_H
|
||||
#define __BLS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
NO_FLAG = 0,
|
||||
VALUE_UNIT_KILO_PASCAL = (1<<0), /*0 -> Blood pressure systolic, diastolic & Mean values in units of mmHg - if 1 -> in units of kPa*/
|
||||
TIME_STAMP_PRESENT = (1<<1),
|
||||
PULSE_RATE_PRESENT = (1<<2),
|
||||
USER_ID_PRESENT = (1<<3),
|
||||
MEASUREMENT_STATUS_PRESENT = (1<<4)
|
||||
} BLS_Measurement_Flags_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BLS_MEASUREMENT_IND_ENABLED_EVT,
|
||||
BLS_MEASUREMENT_IND_DISABLED_EVT,
|
||||
#if (BLE_CFG_BLS_INTERMEDIATE_CUFF_PRESSURE != 0)
|
||||
BLS_INTERMEDIATE_CUFF_PRESSURE_NOTIF_ENABLED_EVT,
|
||||
BLS_INTERMEDIATE_CUFF_PRESSURE_NOTIF_DISABLED_EVT,
|
||||
#endif
|
||||
} BLS_App_Opcode_Notification_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BLS_App_Opcode_Notification_evt_t BLS_Evt_Opcode;
|
||||
}BLS_App_Notification_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t Day;
|
||||
uint8_t Hours;
|
||||
uint8_t Minutes;
|
||||
uint8_t Seconds;
|
||||
}BLS_TimeStamp_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t MeasurementValue_Systolic;
|
||||
uint16_t MeasurementValue_Diastolic;
|
||||
uint16_t MeasurementValue_Mean;
|
||||
#if (BLE_CFG_BLS_TIME_STAMP_FLAG != 0)
|
||||
BLS_TimeStamp_t TimeStamp;
|
||||
#endif
|
||||
#if (BLE_CFG_BLS_PULSE_RATE_FLAG != 0)
|
||||
uint16_t PulseRate;
|
||||
#endif
|
||||
#if (BLE_CFG_BLS_USER_ID_FLAG != 0)
|
||||
uint8_t UserID;
|
||||
#endif
|
||||
#if (BLE_CFG_BLS_MEASUREMENT_STATUS_FLAG != 0)
|
||||
uint16_t MeasurementStatus;
|
||||
#endif
|
||||
uint8_t Flags;
|
||||
}BLS_Value_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void BLS_Init(void);
|
||||
void BLS_Update_Char(uint16_t UUID, uint8_t *pPayload);
|
||||
void BLS_App_Notification(BLS_App_Notification_evt_t * pNotification);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__BLS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file crs_stm.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for crs_stm.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32XX_CRS_H
|
||||
#define __STM32XX_CRS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
CRS_NOTIFY_ENABLED_EVT,
|
||||
CRS_NOTIFY_DISABLED_EVT,
|
||||
CRS_READ_EVT,
|
||||
CRS_WRITE_EVT,
|
||||
} CRS_Opcode_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * pPayload;
|
||||
uint8_t Length;
|
||||
}CRS_Data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CRS_Opcode_evt_t CRS_Evt_Opcode;
|
||||
CRS_Data_t DataTransfered;
|
||||
uint16_t ConnectionHandle;
|
||||
uint8_t ServiceInstance;
|
||||
}CRS_STM_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define CRS_MAX_DATA_LEN (BLE_DEFAULT_ATT_MTU - 3) /**< Maximum length of data (in bytes) that can be transmitted to the peer. */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void CRS_STM_Init(void);
|
||||
void CRS_STM_Notification(CRS_STM_Notification_evt_t *p_Notification);
|
||||
tBleStatus CRS_STM_Update_Char(uint16_t UUID, uint8_t *p_Payload);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__STM32XX_CRS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dis.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for dis.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DIS_H
|
||||
#define __DIS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *pPayload;
|
||||
uint8_t Length;
|
||||
}DIS_Data_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void DIS_Init(void);
|
||||
tBleStatus DIS_UpdateChar(uint16_t uuid, DIS_Data_t *p_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__DIS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file eds_stm.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for stm32xx_enddevicemanagement.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __EDS_STM_H
|
||||
#define __EDS_STM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
EDS_STM_NOTIFY_DISABLED_EVT,
|
||||
EDS_STM_NOTIFY_ENABLED_EVT,
|
||||
} EDS_STM_Opcode_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Device1_Status;
|
||||
uint8_t Device2_Status;
|
||||
uint8_t Device3_Status;
|
||||
uint8_t Device4_Status;
|
||||
uint8_t Device5_Status;
|
||||
uint8_t Device6_Status;
|
||||
}EDS_STM_Status_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * pPayload;
|
||||
uint8_t Length;
|
||||
}EDS_STM_Data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
EDS_STM_Opcode_evt_t EDS_Evt_Opcode;
|
||||
EDS_STM_Data_t DataTransfered;
|
||||
uint16_t ConnectionHandle;
|
||||
}EDS_STM_App_Notification_evt_t;
|
||||
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void EDS_STM_Init( void );
|
||||
void EDS_STM_App_Notification(EDS_STM_App_Notification_evt_t * pNotification);
|
||||
tBleStatus EDS_STM_Update_Char(uint16_t UUID, uint8_t *pPayload);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__EDS_STM_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file hids.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for hids.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __HIDS_H
|
||||
#define __HIDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
HIDS_REPORT_NOTIFICATION_ENABLED,
|
||||
HIDS_REPORT_NOTIFICATION_DISABLED,
|
||||
HIDS_KEYB_INPUT_NOTIFY_ENABLED,
|
||||
HIDS_KEYB_INPUT_NOTIFY_DISABLED,
|
||||
HIDS_MOUSE_INPUT_NOTIFY_ENABLED,
|
||||
HIDS_MOUSE_INPUT_NOTIFY_DISABLED,
|
||||
HIDS_OUTPUT_REPORT,
|
||||
HIDS_KEYBOARD_INPUT_REPORT,
|
||||
HIDS_KEYBOARD_OUTPUT_REPORT,
|
||||
HIDS_MOUSE_INPUT_REPORT,
|
||||
HIDS_CONN_HANDLE_EVT,
|
||||
HIDS_DISCON_HANDLE_EVT
|
||||
} HIDS_Opcode_Notification_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HIDS_Opcode_Notification_evt_t HIDS_Evt_Opcode;
|
||||
uint8_t Instance;
|
||||
uint8_t Index;
|
||||
uint8_t ReportLength;
|
||||
uint8_t *pReport;
|
||||
} HIDS_App_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void HIDS_Init(void);
|
||||
tBleStatus HIDS_Update_Char(uint16_t UUID,
|
||||
uint8_t service_instance,
|
||||
uint8_t Report_Index,
|
||||
uint8_t report_size,
|
||||
uint8_t *pPayload);
|
||||
void HIDS_Notification(HIDS_App_Notification_evt_t *pNotification);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__HIDS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file hrs.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for stm32xx_heartrate.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __HRS_H
|
||||
#define __HRS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
HRS_HRM_VALUE_FORMAT_UINT16 = 1,
|
||||
HRS_HRM_SENSOR_CONTACTS_PRESENT = 2,
|
||||
HRS_HRM_SENSOR_CONTACTS_SUPPORTED = 4,
|
||||
HRS_HRM_ENERGY_EXPENDED_PRESENT = 8,
|
||||
HRS_HRM_RR_INTERVAL_PRESENT = 0x10
|
||||
} HRS_HrmFlags_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HRS_BODY_SENSOR_LOCATION_OTHER = 0,
|
||||
HRS_BODY_SENSOR_LOCATION_CHEST = 1,
|
||||
HRS_BODY_SENSOR_LOCATION_WRIST = 2,
|
||||
HRS_BODY_SENSOR_LOCATION_FINGER = 3,
|
||||
HRS_BODY_SENSOR_LOCATION_HAND = 4,
|
||||
HRS_BODY_SENSOR_LOCATION_EAR_LOBE = 5,
|
||||
HRS_BODY_SENSOR_LOCATION_FOOT = 6
|
||||
} HRS_BodySensorLocation_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HRS_RESET_ENERGY_EXPENDED_EVT,
|
||||
HRS_NOTIFICATION_ENABLED,
|
||||
HRS_NOTIFICATION_DISABLED,
|
||||
HRS_STM_BOOT_REQUEST_EVT,
|
||||
} HRS_NotCode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * pPayload;
|
||||
uint8_t Length;
|
||||
}HRS_Data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HRS_NotCode_t HRS_Evt_Opcode;
|
||||
HRS_Data_t DataTransfered;
|
||||
uint16_t ConnectionHandle;
|
||||
uint8_t ServiceInstance;
|
||||
}HRS_App_Notification_evt_t;
|
||||
|
||||
typedef struct{
|
||||
uint16_t MeasurementValue;
|
||||
#if (BLE_CFG_HRS_ENERGY_EXPENDED_INFO_FLAG == 1)
|
||||
uint16_t EnergyExpended;
|
||||
#endif
|
||||
#if (BLE_CFG_HRS_ENERGY_RR_INTERVAL_FLAG != 0)
|
||||
uint16_t aRRIntervalValues[BLE_CFG_HRS_ENERGY_RR_INTERVAL_FLAG + BLE_CFG_HRS_ENERGY_EXPENDED_INFO_FLAG];
|
||||
uint8_t NbreOfValidRRIntervalValues;
|
||||
#endif
|
||||
uint8_t Flags;
|
||||
}HRS_MeasVal_t;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void HRS_Init(void);
|
||||
tBleStatus HRS_UpdateChar(uint16_t uuid, uint8_t *p_payload);
|
||||
void HRS_Notification(HRS_App_Notification_evt_t *pNotification);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__HRS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file hts.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for shst.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __HTS_H
|
||||
#define __HTS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
NO_FLAGS = 0,
|
||||
VALUE_UNIT_FAHRENHEIT = (1<<0),
|
||||
SENSOR_TIME_STAMP_PRESENT = (1<<1),
|
||||
SENSOR_TEMPERATURE_TYPE_PRESENT = (1<<2),
|
||||
} HTS_TM_Flags_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TT_Armpit = 1,
|
||||
TT_Body = 2,
|
||||
TT_Ear = 3,
|
||||
TT_Finger = 4,
|
||||
TT_Gastro_intestinal_Tract = 5,
|
||||
TT_Mouth = 6,
|
||||
TT_Rectum = 7,
|
||||
TT_Toe = 8,
|
||||
TT_Tympanum = 9
|
||||
} HTS_Temperature_Type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HTS_MEASUREMENT_INTERVAL_RECEIVED_EVT,
|
||||
HTS_MEASUREMENT_IND_ENABLED_EVT,
|
||||
HTS_MEASUREMENT_IND_DISABLED_EVT,
|
||||
HTS_MEASUREMENT_INTERVAL_IND_ENABLED_EVT,
|
||||
HTS_MEASUREMENT_INTERVAL_IND_DISABLED_EVT,
|
||||
HTS_INTERMEDIATE_TEMPERATURE_NOT_ENABLED_EVT,
|
||||
HTS_INTERMEDIATE_TEMPERATURE_NOT_DISABLED_EVT,
|
||||
} HTS_App_Opcode_Notification_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HTS_App_Opcode_Notification_evt_t HTS_Evt_Opcode;
|
||||
#if (BLE_CFG_HTS_MEASUREMENT_INTERVAL != 0)
|
||||
uint16_t RangeInterval;
|
||||
#endif
|
||||
}HTS_App_Notification_evt_t;
|
||||
|
||||
#if (BLE_CFG_HTS_TIME_STAMP_FLAG != 0)
|
||||
typedef struct
|
||||
{
|
||||
uint16_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t Day;
|
||||
uint8_t Hours;
|
||||
uint8_t Minutes;
|
||||
uint8_t Seconds;
|
||||
}HTS_TimeStamp_t;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t MeasurementValue;
|
||||
#if (BLE_CFG_HTS_TIME_STAMP_FLAG != 0)
|
||||
HTS_TimeStamp_t TimeStamp;
|
||||
#endif
|
||||
#if (BLE_CFG_HTS_TEMPERATURE_TYPE_VALUE_STATIC == 0)
|
||||
HTS_Temperature_Type_t TemperatureType;
|
||||
#endif
|
||||
uint8_t Flags;
|
||||
}HTS_TemperatureValue_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void HTS_Init(void);
|
||||
tBleStatus HTS_Update_Char(uint16_t UUID,
|
||||
uint8_t *pPayload);
|
||||
void HTS_App_Notification(HTS_App_Notification_evt_t * pNotification);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__HTS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ias.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for ias.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __IAS_H
|
||||
#define __IAS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
IAS_NO_ALERT_EVT,
|
||||
IAS_MID_ALERT_EVT,
|
||||
IAS_HIGH_ALERT_EVT
|
||||
} IAS_App_Opcode_Notification_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IAS_App_Opcode_Notification_evt_t IAS_Evt_Opcode;
|
||||
}IAS_App_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void IAS_Init(void);
|
||||
tBleStatus IAS_Update_Char(uint16_t UUID, uint8_t *pPayload);
|
||||
void IAS_App_Notification(IAS_App_Notification_evt_t *pNotification);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__IAS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lls.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for lls.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __LLS_H
|
||||
#define __LLS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
LLS_NO_ALERT_EVT,
|
||||
LLS_MID_ALERT_EVT,
|
||||
LLS_HIGH_ALERT_EVT,
|
||||
LLS_DISCONNECT_EVT,
|
||||
LLS_CONNECT_EVT
|
||||
} LLS_App_Opcode_Notification_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LLS_App_Opcode_Notification_evt_t LLS_Evt_Opcode;
|
||||
}LLS_App_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void LLS_Init(void);
|
||||
tBleStatus LLS_Update_Char(uint16_t UUID, uint8_t *pPayload);
|
||||
void LLS_App_Notification(LLS_App_Notification_evt_t *pNotification);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__LLS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mesh.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for mesh.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MESH_H
|
||||
#define __MESH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void MESH_Init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MESH_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file motenv_stm.h
|
||||
* @author SRA/AST
|
||||
* @brief Header for motenv_stm.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef MOTENV_STM_H
|
||||
#define MOTENV_STM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief MOTENV Event Opcode definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* HW Service Chars related events */
|
||||
HW_MOTION_NOTIFY_ENABLED_EVT,
|
||||
HW_MOTION_NOTIFY_DISABLED_EVT,
|
||||
HW_ENV_NOTIFY_ENABLED_EVT,
|
||||
HW_ENV_NOTIFY_DISABLED_EVT,
|
||||
HW_ENV_READ_EVT,
|
||||
HW_ACC_EVENT_NOTIFY_ENABLED_EVT,
|
||||
HW_ACC_EVENT_NOTIFY_DISABLED_EVT,
|
||||
HW_ACC_EVENT_READ_EVT,
|
||||
HW_TOF_NOTIFY_ENABLED_EVT,
|
||||
HW_TOF_NOTIFY_DISABLED_EVT,
|
||||
HW_TOF_WRITE_EVT,
|
||||
/* SW Service Chars related events */
|
||||
SW_MOTIONFX_NOTIFY_ENABLED_EVT,
|
||||
SW_MOTIONFX_NOTIFY_DISABLED_EVT,
|
||||
SW_ECOMPASS_NOTIFY_ENABLED_EVT,
|
||||
SW_ECOMPASS_NOTIFY_DISABLED_EVT,
|
||||
SW_ACTIVITY_REC_NOTIFY_ENABLED_EVT,
|
||||
SW_ACTIVITY_REC_NOTIFY_DISABLED_EVT,
|
||||
SW_ACTIVITY_REC_READ_EVT,
|
||||
SW_CARRY_POSITION_NOTIFY_ENABLED_EVT,
|
||||
SW_CARRY_POSITION_NOTIFY_DISABLED_EVT,
|
||||
SW_CARRY_POSITION_READ_EVT,
|
||||
SW_GESTURE_REC_NOTIFY_ENABLED_EVT,
|
||||
SW_GESTURE_REC_NOTIFY_DISABLED_EVT,
|
||||
SW_GESTURE_REC_READ_EVT,
|
||||
SW_PEDOMETER_NOTIFY_ENABLED_EVT,
|
||||
SW_PEDOMETER_NOTIFY_DISABLED_EVT,
|
||||
SW_PEDOMETER_READ_EVT,
|
||||
SW_INTENSITY_DET_NOTIFY_ENABLED_EVT,
|
||||
SW_INTENSITY_DET_NOTIFY_DISABLED_EVT,
|
||||
MOTENV_STM_BOOT_REQUEST_EVT,
|
||||
/* Config Service Chars related events */
|
||||
CONFIG_NOTIFY_ENABLED_EVT,
|
||||
CONFIG_NOTIFY_DISABLED_EVT,
|
||||
CONFIG_WRITE_EVT,
|
||||
/* Console Service Chars related events */
|
||||
CONSOLE_TERM_NOTIFY_ENABLED_EVT,
|
||||
CONSOLE_TERM_NOTIFY_DISABLED_EVT,
|
||||
CONSOLE_STDERR_NOTIFY_ENABLED_EVT,
|
||||
CONSOLE_STDERR_NOTIFY_DISABLED_EVT,
|
||||
CONSOLE_TERM_READ_EVT,
|
||||
CONSOLE_STDERR_READ_EVT
|
||||
} MOTENV_STM_Opcode_evt_t;
|
||||
|
||||
/**
|
||||
* @brief MOTENV Event data structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *pPayload;
|
||||
uint8_t Length;
|
||||
} MOTENV_STM_Data_t;
|
||||
|
||||
/**
|
||||
* @brief MOTENV Notification structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
MOTENV_STM_Opcode_evt_t Motenv_Evt_Opcode;
|
||||
MOTENV_STM_Data_t DataTransfered;
|
||||
uint16_t ConnectionHandle;
|
||||
uint8_t ServiceInstance;
|
||||
} MOTENV_STM_App_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported Variables ------------------------------------------------------- */
|
||||
extern uint8_t ToF_BoardPresent;
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Motion (Acc-Gyro-Magneto) Char shortened UUID
|
||||
*/
|
||||
#define MOTION_CHAR_UUID (0xE000)
|
||||
/**
|
||||
* @brief Environmental (Temp-Humidity-Pressure) Char shortened UUID
|
||||
*/
|
||||
#define ENV_CHAR_UUID (0x1D00)
|
||||
/**
|
||||
* @brief ToF Char shortened UUID
|
||||
*/
|
||||
#define TOF_CHAR_UUID (0x0000)
|
||||
/**
|
||||
* @brief Acceleration event Char shortened UUID
|
||||
*/
|
||||
#define ACC_EVENT_CHAR_UUID (0x0004)
|
||||
/**
|
||||
* @brief Sensor Fusion Char shortened UUID
|
||||
*/
|
||||
#define MOTION_FX_CHAR_UUID (0x0100)
|
||||
/**
|
||||
* @brief E-Compass event Char shortened UUID
|
||||
*/
|
||||
#define ECOMPASS_CHAR_UUID (0x0040)
|
||||
/**
|
||||
* @brief Activity Recognition Char event Char shortened UUID
|
||||
*/
|
||||
#define ACTIVITY_REC_CHAR_UUID (0x0010)
|
||||
/**
|
||||
* @brief Carry Position event Char shortened UUID
|
||||
*/
|
||||
#define CARRY_POSITION_CHAR_UUID (0x0008)
|
||||
/**
|
||||
* @brief Gesture Recognition event Char shortened UUID
|
||||
*/
|
||||
#define GESTURE_REC_CHAR_UUID (0x0200)
|
||||
/**
|
||||
* @brief Pedometer Char shortened UUID
|
||||
*/
|
||||
#define PEDOMETER_CHAR_UUID (0x0001)
|
||||
/**
|
||||
* @brief Intensity Detection Char shortened UUID
|
||||
*/
|
||||
#define INTENSITY_DET_CHAR_UUID (0x0020)
|
||||
/**
|
||||
* @brief Config Char shortened UUID
|
||||
*/
|
||||
#define CONFIG_CHAR_UUID (0x0002)
|
||||
/**
|
||||
* @brief Console Terminal Char shortened UUID
|
||||
*/
|
||||
#define CONSOLE_TERM_CHAR_UUID (0x010E)
|
||||
/**
|
||||
* @brief Cosnole Stderr Char shortened UUID
|
||||
*/
|
||||
#define CONSOLE_STDERR_CHAR_UUID (0x020E)
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void MOTENV_STM_Init(void);
|
||||
void MOTENV_STM_App_Notification(MOTENV_STM_App_Notification_evt_t *pNotification);
|
||||
tBleStatus MOTENV_STM_App_Update_Char(uint16_t UUID, uint8_t payloadLen, uint8_t *pPayload);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MOTENV_STM_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file otas_stm.h
|
||||
* @author MCD Application Team
|
||||
* @brief Interface to OTA BLE service
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __OTAS_STM_H
|
||||
#define __OTAS_STM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_wpan_common.h"
|
||||
|
||||
/* Exported defines -----------------------------------------------------------*/
|
||||
#define OTAS_STM_RAW_DATA_SIZE (248)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
OTAS_STM_BASE_ADDR_ID,
|
||||
OTAS_STM_RAW_DATA_ID,
|
||||
OTAS_STM_CONF_ID,
|
||||
OTAS_STM_CONF_EVENT_ID,
|
||||
} OTAS_STM_ChardId_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OTAS_STM_STOP_ALL_UPLOAD = 0x00,
|
||||
OTAS_STM_WIRELESS_FW_UPLOAD = 0x01,
|
||||
OTAS_STM_APPLICATION_UPLOAD = 0x02,
|
||||
OTAS_STM_UPLOAD_FINISHED = 0x07,
|
||||
OTAS_STM_CANCEL_UPLOAD = 0x08,
|
||||
} OTAS_STM_Command_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OTAS_STM_REBOOT_CONFIRMED = 0x01,
|
||||
} OTAS_STM_Indication_Msg_t;
|
||||
|
||||
typedef struct{
|
||||
uint8_t *pPayload;
|
||||
OTAS_STM_ChardId_t ChardId;
|
||||
uint8_t ValueLength;
|
||||
} OTA_STM_Notification_t;
|
||||
|
||||
typedef PACKED_STRUCT{
|
||||
OTAS_STM_Command_t Command; /**< [0:7] */
|
||||
uint8_t Base_Addr[3]; /**< [8:31] */
|
||||
} OTA_STM_Base_Addr_Event_Format_t;
|
||||
|
||||
typedef PACKED_STRUCT{
|
||||
uint8_t Raw_Data[OTAS_STM_RAW_DATA_SIZE];
|
||||
} OTA_STM_Raw_Data_Event_Format_t;
|
||||
|
||||
typedef PACKED_STRUCT{
|
||||
aci_gatt_server_confirmation_event_rp0 Conf_Event;
|
||||
} OTA_STM_Conf_Event_Format_t;
|
||||
|
||||
typedef PACKED_STRUCT{
|
||||
OTAS_STM_Indication_Msg_t Conf_Msg;
|
||||
} OTA_STM_Conf_Char_Format_t;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void OTAS_STM_Notification( OTA_STM_Notification_t *p_notification );
|
||||
|
||||
/**
|
||||
* @brief Service initialization
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void OTAS_STM_Init(void);
|
||||
|
||||
/**
|
||||
* @brief Characteristic update
|
||||
* @param ChardId: Id of the characteristic to be written
|
||||
* @param p_payload: The new value to be written
|
||||
* @retval Command status
|
||||
*/
|
||||
tBleStatus OTAS_STM_UpdateChar(OTAS_STM_ChardId_t ChardId, uint8_t *p_payload);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__OTAS_STM_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file p2p_stm.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for p2p_stm.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __P2PS_STM_H
|
||||
#define __P2PS_STM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
P2PS_STM__NOTIFY_ENABLED_EVT,
|
||||
P2PS_STM_NOTIFY_DISABLED_EVT,
|
||||
P2PS_STM_READ_EVT,
|
||||
P2PS_STM_WRITE_EVT,
|
||||
P2PS_STM_BOOT_REQUEST_EVT,
|
||||
} P2PS_STM_Opcode_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * pPayload;
|
||||
uint8_t Length;
|
||||
}P2PS_STM_Data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
P2PS_STM_Opcode_evt_t P2P_Evt_Opcode;
|
||||
P2PS_STM_Data_t DataTransfered;
|
||||
uint16_t ConnectionHandle;
|
||||
uint8_t ServiceInstance;
|
||||
}P2PS_STM_App_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void P2PS_STM_Init( void );
|
||||
void P2PS_STM_App_Notification(P2PS_STM_App_Notification_evt_t *pNotification);
|
||||
tBleStatus P2PS_STM_App_Update_Char(uint16_t UUID, uint8_t *pPayload);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__P2PS_STM_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file svc_ctl.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for ble_controller.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The BLE Controller supports the application to handle services and clients.
|
||||
* It provides an API to initialize the BLE core Device and a handler mechanism to rout the GATT/GAP events to the
|
||||
* application. When the ble_controller is used (recommended), the application shall register a callback for each
|
||||
* Service and each Client implemented. This is already done with the Services and Clients provided in that delivery.
|
||||
* + A GATT event is relevant to only one Service and/or one Client. When a GATT event is received, it is notified to
|
||||
* the registered handlers to the BLE controller. When no registered handler acknowledges positively the GATT event,
|
||||
* it is reported to the application.
|
||||
* + A GAP event is not relevant to either a Service or a Client. It is sent to the application
|
||||
* + In case the application does not want to take benefit from the ble_controller, it could bypass it. In that case,
|
||||
* the application shall:
|
||||
* - call SVCCTL_Init() to initialize the BLE core device (or implement on its own what is inside that function
|
||||
* - implement TLHCI_UserEvtRx() which is the notification from the HCI layer to report all events (GATT/GAP).
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __SVCCTL_H
|
||||
#define __SVCCTL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
SVCCTL_EvtNotAck,
|
||||
SVCCTL_EvtAckFlowEnable,
|
||||
SVCCTL_EvtAckFlowDisable,
|
||||
} SVCCTL_EvtAckStatus_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SVCCTL_UserEvtFlowDisable,
|
||||
SVCCTL_UserEvtFlowEnable,
|
||||
} SVCCTL_UserEvtFlowStatus_t;
|
||||
|
||||
typedef SVCCTL_EvtAckStatus_t (*SVC_CTL_p_EvtHandler_t)(void *p_evt);
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
/**
|
||||
* @brief It initializes the BLE core Driver and sends some commands to initialize the BLE core device
|
||||
* It shall be called before any BLE operation
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_Init( void );
|
||||
|
||||
/**
|
||||
* @brief This API registers a handler to be called when a GATT user event is received from the BLE core device. When
|
||||
* a Service is created, it shall register a callback to be notified when a GATT event is received from the
|
||||
* BLE core device. When a GATT event is received, it shall be checked in the handler if the GATT events belongs
|
||||
* to the Service or not. The handler shall return the correct status depending on the result. As soon as one
|
||||
* Service handler registered acknowledges positively the GATT event, the ble_controller stops calling the
|
||||
* registered Service handlers.
|
||||
* This handler is called in the TL_BLE_HCI_UserEvtProc() context
|
||||
*
|
||||
* @param pfBLE_SVC_Service_Event_Handler: This is the Service handler that the ble_controller calls to report a GATT
|
||||
* event received. If the GATT event belongs to that Service, the callback shall return positively with
|
||||
* SVCCTL_EvtAckFlowEnable.
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_RegisterSvcHandler( SVC_CTL_p_EvtHandler_t pfBLE_SVC_Service_Event_Handler );
|
||||
|
||||
/**
|
||||
* @brief This API registers a handler to be called when a GATT user event is received from the BLE core device. When
|
||||
* a Client is created, it shall register a callback to be notified when a GATT event is received from the
|
||||
* BLE core device. When a GATT event is received, it shall be checked in the handler if the GATT events belongs
|
||||
* to the Client or not. The handler shall return the correct status depending on the result. As soon as one
|
||||
* Client handler registered acknowledges positively the GATT event, the ble_controller stops calling the
|
||||
* registered Client handlers.
|
||||
* This handler is called in the TL_BLE_HCI_UserEvtProc() context
|
||||
*
|
||||
* @param pfBLE_SVC_Client_Event_Handler: This is the Client handler that the ble_controller calls to report a GATT
|
||||
* event received. If the GATT event belongs to that Client, the callback shall return positively with
|
||||
* SVCCTL_EvtAckFlowEnable.
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_RegisterCltHandler( SVC_CTL_p_EvtHandler_t pfBLE_SVC_Client_Event_Handler );
|
||||
|
||||
/**
|
||||
* @brief This API is used to resume the User Event Flow that has been stopped in return of SVCCTL_UserEvtRx()
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_ResumeUserEventFlow( void );
|
||||
|
||||
|
||||
/**
|
||||
* @brief This callback is triggered when either
|
||||
* + a GAP event is received from the BLE core device.
|
||||
* + a GATT event that has not been positively acknowledged by the registered handler is received from the
|
||||
* BLE core device.
|
||||
* The event is returned in a HCI packet. The full HCI packet is stored in a single buffer and is available when
|
||||
* this callback is triggered. However, an ACI event may be longer than a HCI packet and could be fragmented over
|
||||
* several HCI packets. The HCI layer only handles HCI packets so when an ACI packet is split over several HCI
|
||||
* packets, this callback is triggered for each HCI fragment. It is the responsibility of the application to
|
||||
* reassemble the ACI event.
|
||||
* This callback is triggered in the TL_BLE_HCI_UserEvtProc() context
|
||||
*
|
||||
* @param pckt: The user event received from the BLE core device
|
||||
* @retval None
|
||||
*/
|
||||
SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt );
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*
|
||||
* @param pckt: The user event received from the BLE core device
|
||||
* @retval SVCCTL_UserEvtFlowStatus_t: SVCCTL_UserEvtFlowEnable when the packet has been processed
|
||||
* SVCCTL_UserEvtFlowDisable otherwise (the packet is kept in the queue)
|
||||
*/
|
||||
SVCCTL_UserEvtFlowStatus_t SVCCTL_UserEvtRx( void *pckt );
|
||||
|
||||
/**
|
||||
* @brief This API may be used by the application when the Service Controller is used to add a custom service
|
||||
*
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_InitCustomSvc( void );
|
||||
|
||||
/**
|
||||
* @brief This API may be overloaded by the application to select a limited list of ble services to initialize.
|
||||
* It is called by SVCCTL_Init()
|
||||
* By default, SVCCTL_SvcInit() is implemented to initialize all BLE services which are included in the
|
||||
* application at build time
|
||||
* If it is required to initialize only limited part of the BLE service available in the application,
|
||||
* this API may be used to call the initialization API of the subset of needed services at run time.
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_SvcInit( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__SVCCTL_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file template_stm.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for template_stm.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TEMPLATE_STM_H
|
||||
#define __TEMPLATE_STM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
TEMPLATE_STM_NOTIFY_ENABLED_EVT,
|
||||
TEMPLATE_STM_NOTIFY_DISABLED_EVT,
|
||||
TEMPLATE_STM_READ_EVT,
|
||||
TEMPLATE_STM_WRITE_EVT,
|
||||
TEMPLATE_STM_BOOT_REQUEST_EVT,
|
||||
} TEMPLATE_STM_Opcode_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * pPayload;
|
||||
uint8_t Length;
|
||||
}TEMPLATE_STM_Data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TEMPLATE_STM_Opcode_evt_t Template_Evt_Opcode;
|
||||
TEMPLATE_STM_Data_t DataTransfered;
|
||||
uint16_t ConnectionHandle;
|
||||
uint8_t ServiceInstance;
|
||||
}TEMPLATE_STM_App_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void TEMPLATE_STM_Init( void );
|
||||
void TEMPLATE_STM_App_Notification(TEMPLATE_STM_App_Notification_evt_t *pNotification);
|
||||
tBleStatus TEMPLATE_STM_App_Update_Char(uint16_t UUID, uint8_t *pPayload);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__TEMPLATE_STM_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file tps.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for tps.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TPS_H
|
||||
#define __TPS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void TPS_Init(void);
|
||||
tBleStatus TPS_Update_Char(uint16_t UUID, uint8_t *pPayload);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__TPS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file uuid.h.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header containing the UUIDs of all the services and caharcteristics
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _UUID_H_
|
||||
#define _UUID_H_
|
||||
|
||||
/* Descriptor UUIDs */
|
||||
#define CHAR_EXTENDED_PROPERTIES_DESCRIPTOR_UUID (0x2900)
|
||||
#define CHAR_USER_DESCRIPTION_DESCRIPTOR_UUID (0x2901)
|
||||
#define CLIENT_CHAR_CONFIG_DESCRIPTOR_UUID (0x2902)
|
||||
#define SERVER_CHAR_CONFIG_DESCRIPTOR_UUID (0x2903)
|
||||
#define CHAR_PRESENTATION_FORMAT_DESCRIPTOR_UUID (0x2904)
|
||||
#define CHAR_AGGREGATE_FORMAT_DESCRIPTOR_UUID (0x2905)
|
||||
#define VALID_RANGE_DESCRIPTOR_UUID (0x2906)
|
||||
#define EXTERNAL_REPORT_REFERENCE_DESCRIPTOR_UUID (0x2907)
|
||||
#define REPORT_REFERENCE_DESCRIPTOR_UUID (0x2908)
|
||||
#define NUMBER_OF_DIGITALS_DESCRIPTOR_UUID (0x2909)
|
||||
#define VALUE_TRIGGER_SETTING_DESCRIPTOR_UUID (0x290A)
|
||||
#define ES_CONFIGURATION_DESCRIPTOR_UUID (0x290B)
|
||||
#define ES_MEASUREMENT_DESCRIPTOR_UUID (0x290C)
|
||||
#define ES_TRIGGER_SETTING_DESCRIPTOR_UUID (0x290D)
|
||||
#define TIME_TRIGGER_SETTING_DESCRIPTOR_UUID (0x290E)
|
||||
|
||||
/* UUIDs of Generic Attribute service */
|
||||
#define GENERIC_ATTRIBUTE_SERVICE_UUID (0x1801)
|
||||
#define SERVICE_CHANGED_CHARACTERISTIC_UUID (0x2A05)
|
||||
|
||||
/* UUIDs of immediate alert service */
|
||||
#define IMMEDIATE_ALERT_SERVICE_UUID (0x1802)
|
||||
#define ALERT_LEVEL_CHARACTERISTIC_UUID (0x2A06)
|
||||
|
||||
/* UUIDs for Link Loss service */
|
||||
#define LINK_LOSS_SERVICE_UUID (0x1803)
|
||||
#define LINK_LOSS_ALERT_LEVEL_CHARACTERISTIC_UUID (0x2A06)
|
||||
|
||||
/* UUIDs for TX Power service */
|
||||
#define TX_POWER_SERVICE_UUID (0x1804)
|
||||
#define TX_POWER_LEVEL_CHARACTERISTIC_UUID (0x2A07)
|
||||
|
||||
/* UUIDs for Time service */
|
||||
#define CURRENT_TIME_SERVICE_UUID (0x1805)
|
||||
#define CURRENT_TIME_CHAR_UUID (0x2A2B)
|
||||
#define LOCAL_TIME_INFORMATION_CHAR_UUID (0x2A0F)
|
||||
#define REFERENCE_TIME_INFORMATION_CHAR_UUID (0x2A14)
|
||||
|
||||
/* UUIDs for Reference Time Update service */
|
||||
#define REFERENCE_UPDATE_TIME_SERVICE_UUID (0x1806)
|
||||
#define TIME_UPDATE_CONTROL_POINT_CHAR_UUID (0x2A16)
|
||||
#define TIME_UPDATE_STATE_CHAR_UUID (0x2A17)
|
||||
|
||||
/* UUIDs for Next DST Change service */
|
||||
#define NEXT_DST_CHANGE_SERVICE_UUID (0x1807)
|
||||
#define TIME_WITH_DST_CHAR_UUID (0x2A11)
|
||||
|
||||
/* UUIDs for glucose profile */
|
||||
#define GLUCOSE_SERVICE_UUID (0x1808)
|
||||
#define GLUCOSE_MEASUREMENT_CHAR_UUID (0x2A18)
|
||||
#define GLUCOSE_MEASUREMENT_CONTEXT_CHAR_UUID (0x2A34)
|
||||
#define GLUCOSE_FEATURE_CHAR_UUID (0x2A51)
|
||||
/* Record Access Control Point (RACP) */
|
||||
#define GLUCOSE_RACP_CHAR_UUID (0x2A52)
|
||||
|
||||
/* UUIDs for health thermometer profile */
|
||||
#define HEALTH_THERMOMETER_SERVICE_UUID (0x1809)
|
||||
#define TEMPERATURE_MEASUREMENT_CHAR_UUID (0x2A1C)
|
||||
#define TEMPERATURE_TYPE_CHAR_UUID (0x2A1D)
|
||||
#define INTERMEDIATE_TEMPERATURE_CHAR_UUID (0x2A1E)
|
||||
#define MEASUREMENT_INTERVAL_CHAR_UUID (0x2A21)
|
||||
|
||||
/* UUIDs for Device Information Service */
|
||||
#define DEVICE_INFORMATION_SERVICE_UUID (0x180A)
|
||||
#define SYSTEM_ID_UUID (0x2A23)
|
||||
#define MODEL_NUMBER_UUID (0x2A24)
|
||||
#define SERIAL_NUMBER_UUID (0x2A25)
|
||||
#define FIRMWARE_REVISION_UUID (0x2A26)
|
||||
#define HARDWARE_REVISION_UUID (0x2A27)
|
||||
#define SOFTWARE_REVISION_UUID (0x2A28)
|
||||
#define MANUFACTURER_NAME_UUID (0x2A29)
|
||||
#define IEEE_CERTIFICATION_UUID (0x2A2A)
|
||||
#define PNP_ID_UUID (0x2A50)
|
||||
|
||||
/* UUIDs for Heart Rate Service */
|
||||
#define HEART_RATE_SERVICE_UUID (0x180D)
|
||||
#define CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID (0x2902)
|
||||
#define HEART_RATE_MEASURMENT_UUID (0x2A37)
|
||||
#define SENSOR_LOCATION_UUID (0x2A38)
|
||||
#define CONTROL_POINT_UUID (0x2A39)
|
||||
|
||||
/* UUIDs for Phone Alert status profile */
|
||||
#define PHONE_ALERT_SERVICE_UUID (0x180E)
|
||||
#define PHONE_ALERT_STATUS_CHARAC_UUID (0x2A3F)
|
||||
#define RINGER_CNTRL_POINT_CHARAC_UUID (0x2A40)
|
||||
#define RINGER_SETTING_CHARAC_UUID (0x2A41)
|
||||
|
||||
/* UUIDs for battery service */
|
||||
#define BATTERY_SERVICE_UUID (0x180F)
|
||||
#define BATTERY_LEVEL_CHAR_UUID (0x2A19)
|
||||
|
||||
/* UUIDs for Blood Pressure profile */
|
||||
#define BLOOD_PRESSURE_SERVICE_UUID (0x1810)
|
||||
#define BLOOD_PRESSURE_MEASUREMENT_CHAR_UUID (0x2A35)
|
||||
#define INTERMEDIATE_CUFF_PRESSURE_CHAR_UUID (0x2A36)
|
||||
#define BLOOD_PRESSURE_FEATURE_CHAR_UUID (0x2A49)
|
||||
|
||||
/* UUIDs for alert notification profile */
|
||||
#define ALERT_NOTIFICATION_SERVICE_UUID (0x1811)
|
||||
#define SUPPORTED_NEW_ALERT_CATEGORY_CHAR_UUID (0x2A47)
|
||||
#define NEW_ALERT_CHAR_UUID (0x2A46)
|
||||
#define SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR_UUID (0x2A48)
|
||||
#define UNREAD_ALERT_STATUS_CHAR_UUID (0x2A45)
|
||||
#define ALERT_NOTIFICATION_CONTROL_POINT_CHAR_UUID (0x2A44)
|
||||
|
||||
/* UUIDs for human interface device */
|
||||
#define HUMAN_INTERFACE_DEVICE_SERVICE_UUID (0x1812)
|
||||
#define PROTOCOL_MODE_CHAR_UUID (0x2A4E)
|
||||
#define REPORT_CHAR_UUID (0x2A4D)
|
||||
#define REPORT_MAP_CHAR_UUID (0x2A4B)
|
||||
#define BOOT_KEYBOARD_INPUT_REPORT_CHAR_UUID (0x2A22)
|
||||
#define BOOT_KEYBOARD_OUTPUT_REPORT_CHAR_UUID (0x2A32)
|
||||
#define BOOT_MOUSE_INPUT_REPORT_CHAR_UUID (0x2A33)
|
||||
#define HID_INFORMATION_CHAR_UUID (0x2A4A)
|
||||
#define HID_CONTROL_POINT_CHAR_UUID (0x2A4C)
|
||||
|
||||
/* UUIDs for scan parameter service */
|
||||
#define SCAN_PARAMETER_SERVICE_UUID (0x1813)
|
||||
#define SCAN_INTERVAL_WINDOW_CHAR_UUID (0x2A4F)
|
||||
#define SCAN_REFRESH_CHAR_UUID (0x2A31)
|
||||
|
||||
/* UUIDs for running speed and cadence service */
|
||||
#define RUNNING_SPEED_CADENCE_SERVICE_UUID (0x1814)
|
||||
#define RUNNING_SPEED_CADENCE_MEASUREMENT_CHAR_UUID (0x2A53)
|
||||
#define RUNNING_SPEED_CADENCE_FEATURE_CHAR_UUID (0x2A54)
|
||||
|
||||
/* UUIDs for automation IO service */
|
||||
#define AUTOMATION_IO_SERVICE_UUID (0x1815)
|
||||
#define AUTOMATION_IO_DIGITAL_CHAR_UUID (0x2A56)
|
||||
#define AUTOMATION_IO_ANALOG_CHAR_UUID (0x2A58)
|
||||
#define AUTOMATION_IO_AGGREGATE_CHAR_UUID (0x2A5A)
|
||||
|
||||
/* UUIDs for cycling speed and cadence service */
|
||||
#define CYCLING_SPEED_CADENCE_SERVICE_UUID (0x1816)
|
||||
#define CYCLING_SPEED_CADENCE_MEASUREMENT_CHAR_UUID (0x2A5B)
|
||||
#define CYCLING_SPEED_CADENCE_FEATURE_CHAR_UUID (0x2A5C)
|
||||
|
||||
/* UUIDs for cycling power service */
|
||||
#define CYCLING_POWER_SERVICE_UUID (0x1818)
|
||||
#define CYCLING_POWER_MEASUREMENT_CHAR_UUID (0x2A63)
|
||||
#define CYCLING_POWER_FEATURE_CHAR_UUID (0x2A65)
|
||||
#define CYCLING_POWER_SENSOR_LOCATION_CHAR_UUID (0x2A5D)
|
||||
|
||||
/* UUIDs for location and navigation device */
|
||||
#define LOCATION_NAVIGATION_SERVICE_UUID (0x1819)
|
||||
#define LN_FEATURE_UUID (0x2A6A)
|
||||
#define LOCATION_SPEED_UUID (0x2A67)
|
||||
#define POSITION_QUALITY_UUID (0x2A69)
|
||||
#define LN_CONTROL_POINT_UUID (0x2A6B)
|
||||
#define NAVIGATION_UUID (0x2A68)
|
||||
|
||||
/* UUIDs for environmental sensing profile */
|
||||
#define ENVIRONMENTAL_SENSING_SERVICE_UUID (0x181A)
|
||||
#define DESCRIPTOR_VALUE_CHANGED_UUID (0x2A7D)
|
||||
#define APPARENT_WIND_DIRECTION_UUID (0x2A73)
|
||||
#define APPARENT_WIND_SPEED_UUID (0x2A72)
|
||||
#define DEW_POINT_UUID (0x2A7B)
|
||||
#define ELEVATION_UUID (0x2A6C)
|
||||
#define GUST_FACTOR_UUID (0x2A74)
|
||||
#define HEAT_INDEX_UUID (0x2A7A)
|
||||
#define HUMIDITY_UUID (0x2A6F)
|
||||
#define IRRADIANCE_UUID (0x2A77)
|
||||
#define POLLEN_CONCENTRATION_UUID (0x2A75)
|
||||
#define RAINFALL_UUID (0x2A78)
|
||||
#define PRESSURE_UUID (0x2A6D)
|
||||
#define TEMPERATURE_UUID (0x2A6E)
|
||||
#define TRUE_WIND_DIRECTION_UUID (0x2A71)
|
||||
#define TRUE_WIND_SPEED_UUID (0x2A70)
|
||||
#define UV_INDEX_UUID (0x2A76)
|
||||
#define WIND_CHILL_UUID (0x2A79)
|
||||
#define BAROMETRIC_PRESSURE_TREND_UUID (0x2AA3)
|
||||
#define MAGNETIC_DECLINATION_UUID (0x2A2C)
|
||||
#define MAGNETIC_FLUX_DENSITY_2D_UUID (0x2AA0)
|
||||
#define MAGNETIC_FLUX_DENSITY_3D_UUID (0x2AA1)
|
||||
|
||||
/* UUIDs for body composition service */
|
||||
#define BODY_COMPOSITION_SERVICE_UUID (0x181B)
|
||||
#define BODY_COMPOSITION_MEASUREMENT_CHAR_UUID (0x2A9C)
|
||||
#define BODY_COMPOSITION_FEATURE_CHARAC (0x2A9B)
|
||||
|
||||
/* UUIDs for user data service */
|
||||
#define USER_DATA_SERVICE_UUID (0x181C)
|
||||
#define AERO_HR_LOWER_LIMIT_CHAR_UUID (0x2A7E)
|
||||
#define AEROBIC_THRESHOLD_CHAR_UUID (0x2A7F)
|
||||
#define AGE_CHAR_UUID (0x2A80)
|
||||
#define ANAERO_HR_LOWER_LIMIT_CHAR_UUID (0x2A81)
|
||||
#define ANAERO_HR_UPPER_LIMIT_CHAR_UUID (0x2A82)
|
||||
#define ANAEROBIC_THRESHOLD_CHAR_UUID (0x2A83)
|
||||
#define AERO_HR_UPPER_LIMIT_CHAR_UUID (0x2A84)
|
||||
#define BIRTH_DATE_CHAR_UUID (0x2A85)
|
||||
#define DATE_THRESHOLD_ASSESSMENT_CHAR_UUID (0x2A86)
|
||||
#define EMAIL_ADDRESS_CHAR_UUID (0x2A87)
|
||||
#define FAT_BURN_HR_LOWER_LIMIT_CHAR_UUID (0x2A88)
|
||||
#define FAT_BURN_HR_UPPER_LIMIT_CHAR_UUID (0x2A89)
|
||||
#define FIRST_NAME_CHAR_UUID (0x2A8A)
|
||||
#define FIVE_ZONE_HR_LIMIT_CHAR_UUID (0x2A8B)
|
||||
#define GENDER_CHAR_UUID (0x2A8C)
|
||||
#define HEART_RATE_MAX_CHAR_UUID (0x2A8D)
|
||||
#define HEIGHT_CHAR_UUID (0x2A8E)
|
||||
#define HIP_CIRC_CHAR_UUID (0x2A8F)
|
||||
#define LAST_NAME_CHAR_UUID (0x2A90)
|
||||
#define MAX_RECO_HEART_RATE_CHAR_UUID (0x2A91)
|
||||
#define RESTING_HEART_RATE_CHAR_UUID (0x2A92)
|
||||
#define SPORT_TYPE_CHAR_UUID (0x2A93)
|
||||
#define THREE_ZONE_HR_LIMIT_CHAR_UUID (0x2A94)
|
||||
#define TWO_ZONE_HR_LIMIT_CHAR_UUID (0x2A95)
|
||||
#define VO2_MAX_CHAR_UUID (0x2A96)
|
||||
#define WAIST_CIRC_CHAR_UUID (0x2A97)
|
||||
#define WEIGHT_CHAR_UUID (0x2A98)
|
||||
#define DATABASE_CHANGE_INCREMENT_CHAR_UUID (0x2A99)
|
||||
#define USER_INDEX_CHAR_UUID (0x2A9A)
|
||||
#define USER_CONTROL_POINT_CHAR_UUID (0x2A9F)
|
||||
#define LANGUAGE_CHAR_UUID (0x2AA2)
|
||||
|
||||
/* UUIDs for weight scale profile */
|
||||
#define WEIGHT_SCALE_SERVICE_UUID (0x181D)
|
||||
#define WEIGHT_SCALE_MEASUREMENT_CHAR_UUID (0x2A9D)
|
||||
#define WEIGHT_SCALE_FEATURE_CHAR_UUID (0x2A9E)
|
||||
|
||||
/* UUIDs for weight scale profile */
|
||||
#define BOND_MANAGEMENT_SERVICE_UUID (0x181E)
|
||||
#define BM_CONTROL_POINT_CHAR_UUID (0x2AA4)
|
||||
#define BM_FEATURE_CHAR_UUID (0x2AA5)
|
||||
|
||||
/* UUIDs for Internet Support Service */
|
||||
#define INTERNET_SUPPORT_SERVICE_UUID (0x1820)
|
||||
|
||||
/* UUIDs for Indoor Positioning Service */
|
||||
#define INDOOR_POSITIONING_SERVICE_UUID (0x1821)
|
||||
#define IP_CONFIGURATION_CHAR_UUID (0x2AAD)
|
||||
#define IP_LATITUDE_CHAR_UUID (0x2AAE)
|
||||
#define IP_LONGITUDE_CHAR_UUID (0x2AAF)
|
||||
|
||||
/* UUIDs for HTTP proxy Service */
|
||||
#define HTTP_PROXY_SERVICE_UUID (0x1823)
|
||||
#define HTTP_URI_CHAR_UUID (0x2AB6)
|
||||
#define HTTP_HEADERS_CHAR_UUID (0x2AB7)
|
||||
#define HTTP_STATUS_CODE_CHAR_UUID (0x2AB8)
|
||||
#define HTTP_ENTITY_BODY_CHAR_UUID (0x2AB9)
|
||||
#define HTTP_CONTROL_POINT_CHAR_UUID (0x2ABA)
|
||||
#define HTTP_SECURITY_CHAR_UUID (0x2ABB)
|
||||
|
||||
/* UUIDs for Object Transfer Service */
|
||||
#define OBJECT_TRANSFER_SERVICE_UUID (0x1825)
|
||||
#define OTS_FEATURE_CHAR_UUID (0x2ABD)
|
||||
#define OBJECT_NAME_CHAR_UUID (0x2ABE)
|
||||
#define OBJECT_TYPE_CHAR_UUID (0x2ABF)
|
||||
#define OBJECT_SIZE_CHAR_UUID (0x2AC0)
|
||||
#define OBJECT_PROPERTIES_CHAR_UUID (0x2AC4)
|
||||
#define OBJECT_ACTION_CONTROL_POINT_CHAR_UUID (0x2AC5)
|
||||
#define OBJECT_LIST_CONTROL_POINT_CHAR_UUID (0x2AC6)
|
||||
|
||||
/* UUIDs for Zigbee Direct Service */
|
||||
#define ZIGBEE_DIRECT_COMM_SERVICE_UUID (0xFFF7)
|
||||
|
||||
/* Custom Services*/
|
||||
/* UUIDs for data transfer service */
|
||||
#define DT_SERVICE_UUID (0xFE80)
|
||||
#define DT_TX_CHAR_UUID (0xFE81)
|
||||
#define DT_RX_CHAR_UUID (0xFE82)
|
||||
#define DT_THROUGHPUT_CHAR_UUID (0xFE83)
|
||||
|
||||
/* UUIDs for custom battery service */
|
||||
#define CUSTOM_BATTERY_SERVICE_UUID (0xF2F0)
|
||||
#define CUSTOM_BATTERY_LEVEL_CHAR_UUID (0xF2F1)
|
||||
|
||||
/* Custom Services*/
|
||||
/* UUIDs for data transfer service */
|
||||
#define LED_BUTTON_SERVICE_UUID (0x1A30)
|
||||
#define LED_CHAR_UUID (0x2B50)
|
||||
#define BUTTON_CHAR_UUID (0x2B51)
|
||||
/*UUIDs for End Device Management Service*/
|
||||
#define END_DEVICE_MGT_SERVICE_UUID (0x1A40)
|
||||
#define END_DEVICE_STATUS_CHAR_UUID (0x2B60)
|
||||
|
||||
#define P2P_SERVICE_UUID (0xFE40)
|
||||
#define P2P_WRITE_CHAR_UUID (0xFE41)
|
||||
#define P2P_NOTIFY_CHAR_UUID (0xFE42)
|
||||
|
||||
#define HOME_SERVICE_UUID (0xFE90)
|
||||
#define HOME_WRITE_CHAR_UUID (0xFE91)
|
||||
#define HOME_NOTIFY_CHAR_UUID (0xFE92)
|
||||
|
||||
#define CAM_SERVICE_UUID (0xFEA0)
|
||||
#define CAM_WRITE_CHAR_UUID (0xFEA1)
|
||||
#define CAM_NOTIFY_CHAR_UUID (0xFEA2)
|
||||
|
||||
/* UUIDs for Cable Replacement Service */
|
||||
#define CRS_SERVICE_UUID (0xFE60)
|
||||
#define CRS_TX_CHAR_UUID (0xFE61)
|
||||
#define CRS_RX_CHAR_UUID (0xFE62)
|
||||
|
||||
/* UUIDs for Apple Notification Center Service */
|
||||
#define ANCS_SERVICE_UUID (0xF431)
|
||||
#define ANCS_NOTIFICATION_SOURCE_CHAR_UUID (0x120D)
|
||||
#define ANCS_CONTROL_POINT_CHAR_UUID (0xD8F3)
|
||||
#define ANCS_DATA_SOURCE_CHAR_UUID (0xC6E9)
|
||||
|
||||
/* UUIDs for Apple Media Service start from iOS 8*/
|
||||
#define AMS_SERVICE_UUID (0x502B)
|
||||
#define AMS_REMOTE_COMMAND_CHAR_UUID (0x81D8)
|
||||
#define AMS_ENTITY_UPDATE_CHAR_UUID (0xABCE)
|
||||
#define AMS_ENTITY_ATTRIBUTE_CHAR_UUID (0xF38C)
|
||||
#endif /* _UUID_H_ */
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file zdd_stm.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for zdd_stm.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __ZDD_STM_H
|
||||
#define __ZDD_STM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
/* ZDD P2P Events */
|
||||
ZDD_P2P_STM__NOTIFY_ENABLED_EVT,
|
||||
ZDD_P2P_STM_NOTIFY_DISABLED_EVT,
|
||||
ZDD_P2P_STM_READ_EVT,
|
||||
ZDD_P2P_STM_WRITE_EVT,
|
||||
ZDD_P2P_STM_BOOT_REQUEST_EVT,
|
||||
/* ZDD Security Events */
|
||||
ZDD_SEC_P_256_INDICATE_ENABLED_EVT,
|
||||
ZDD_SEC_P_256_INDICATE_DISABLED_EVT,
|
||||
ZDD_SEC_P_256_WRITE_EVT,
|
||||
ZDD_SEC_CURVE25519_INDICATE_ENABLED_EVT,
|
||||
ZDD_SEC_CURVE25519_INDICATE_DISABLED_EVT,
|
||||
ZDD_SEC_CURVE25519_WRITE_EVT,
|
||||
/* ZDD Commissioning Events */
|
||||
ZDD_COMM_FORM_NWK_WRITE_EVT,
|
||||
ZDD_COMM_JOIN_NWK_WRITE_EVT,
|
||||
ZDD_COMM_PERMIT_JOIN_WRITE_EVT,
|
||||
ZDD_COMM_LEAVE_NWK_WRITE_EVT,
|
||||
ZDD_COMM_STATUS_NOTIFY_ENABLED_EVT,
|
||||
ZDD_COMM_STATUS_NOTIFY_DISABLED_EVT,
|
||||
ZDD_COMM_STATUS_READ_EVT,
|
||||
/* ZDD Tunnelling Events */
|
||||
ZDD_TUNN_ZDTS_NPDU_INDICATE_ENABLED_EVT,
|
||||
ZDD_TUNN_ZDTS_NPDU_INDICATE_DISABLED_EVT,
|
||||
ZDD_TUNN_ZDTS_NPDU_WRITE_EVT
|
||||
|
||||
} ZDD_STM_Opcode_evt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * pPayload;
|
||||
uint8_t Length;
|
||||
}ZDD_STM_Data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ZDD_STM_Opcode_evt_t ZDD_Evt_Opcode;
|
||||
ZDD_STM_Data_t DataTransfered;
|
||||
uint16_t ConnectionHandle;
|
||||
uint8_t ServiceInstance;
|
||||
}ZDD_STM_App_Notification_evt_t;
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define ZDD_P2P_NOTIFY_CHAR_UUID P2P_NOTIFY_CHAR_UUID /* Temp */
|
||||
#define ZDD_SEC_P_256_CHAR_UUID (0xAF42) /* P-256 */
|
||||
#define ZDD_SEC_CURVE25519_CHAR_UUID (0xAF43) /* Curve25519 */
|
||||
#define ZDD_COMM_STATUS_CHAR_UUID (0x377D) /* Commissioning Status */
|
||||
#define ZDD_TUNN_ZDTS_NPDU_CHAR_UUID (0x78FD) /* ZDTS-NPDU */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void ZDD_STM_Init( void );
|
||||
void ZDD_STM_App_Notification(ZDD_STM_App_Notification_evt_t *pNotification);
|
||||
tBleStatus ZDD_STM_App_Update_Char(uint16_t UUID, uint8_t payloadLen, uint8_t *pPayload);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__ZDD_STM_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file common_blesvc.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for ble modules
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __COMMON_BLESVC_H
|
||||
#define __COMMON_BLESVC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ble_common.h"
|
||||
#include "ble.h"
|
||||
#include "dbg_trace.h"
|
||||
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
COMSVC_Notification = ( 1 << 0 ),
|
||||
COMSVC_Indication = ( 1 << 1 ),
|
||||
} COMSVC_ClientCharConfMask_t;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__COMMON_BLESVC_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file svc_ctl.c
|
||||
* @author MCD Application Team
|
||||
* @brief BLE Controller
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "common_blesvc.h"
|
||||
#include "cmsis_compiler.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
#if (BLE_CFG_SVC_MAX_NBR_CB > 0)
|
||||
SVC_CTL_p_EvtHandler_t SVCCTL__SvcHandlerTab[BLE_CFG_SVC_MAX_NBR_CB];
|
||||
#endif
|
||||
uint8_t NbreOfRegisteredHandler;
|
||||
} SVCCTL_EvtHandler_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if (BLE_CFG_CLT_MAX_NBR_CB > 0)
|
||||
SVC_CTL_p_EvtHandler_t SVCCTL_CltHandlerTable[BLE_CFG_CLT_MAX_NBR_CB];
|
||||
#endif
|
||||
uint8_t NbreOfRegisteredHandler;
|
||||
} SVCCTL_CltHandler_t;
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define SVCCTL_EGID_EVT_MASK 0xFF00
|
||||
#define SVCCTL_GATT_EVT_TYPE 0x0C00
|
||||
#define SVCCTL_GAP_DEVICE_NAME_LENGTH 7
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* START of Section BLE_DRIVER_CONTEXT
|
||||
*/
|
||||
|
||||
PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") SVCCTL_EvtHandler_t SVCCTL_EvtHandler;
|
||||
PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") SVCCTL_CltHandler_t SVCCTL_CltHandler;
|
||||
|
||||
/**
|
||||
* END of Section BLE_DRIVER_CONTEXT
|
||||
*/
|
||||
|
||||
/* Private functions ----------------------------------------------------------*/
|
||||
/* Weak functions ----------------------------------------------------------*/
|
||||
void BVOPUS_STM_Init(void);
|
||||
|
||||
__WEAK void BAS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void BLS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void CRS_STM_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void DIS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void EDS_STM_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void HIDS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void HRS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void HTS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void IAS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void LLS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void TPS_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void MOTENV_STM_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void P2PS_STM_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void ZDD_STM_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void OTAS_STM_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void MESH_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void BVOPUS_STM_Init( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
__WEAK void SVCCTL_InitCustomSvc( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Functions Definition ------------------------------------------------------*/
|
||||
|
||||
void SVCCTL_Init( void )
|
||||
{
|
||||
|
||||
/**
|
||||
* Initialize the number of registered Handler
|
||||
*/
|
||||
SVCCTL_EvtHandler.NbreOfRegisteredHandler = 0;
|
||||
SVCCTL_CltHandler.NbreOfRegisteredHandler = 0;
|
||||
|
||||
/**
|
||||
* Add and Initialize requested services
|
||||
*/
|
||||
SVCCTL_SvcInit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void SVCCTL_SvcInit(void)
|
||||
{
|
||||
BAS_Init();
|
||||
|
||||
BLS_Init();
|
||||
|
||||
CRS_STM_Init();
|
||||
|
||||
DIS_Init();
|
||||
|
||||
EDS_STM_Init();
|
||||
|
||||
HIDS_Init();
|
||||
|
||||
HRS_Init();
|
||||
|
||||
HTS_Init();
|
||||
|
||||
IAS_Init();
|
||||
|
||||
LLS_Init();
|
||||
|
||||
TPS_Init();
|
||||
|
||||
MOTENV_STM_Init();
|
||||
|
||||
P2PS_STM_Init();
|
||||
|
||||
ZDD_STM_Init();
|
||||
|
||||
OTAS_STM_Init();
|
||||
|
||||
BVOPUS_STM_Init();
|
||||
|
||||
MESH_Init();
|
||||
|
||||
SVCCTL_InitCustomSvc();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BLE Controller initialization
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_RegisterSvcHandler( SVC_CTL_p_EvtHandler_t pfBLE_SVC_Service_Event_Handler )
|
||||
{
|
||||
#if (BLE_CFG_SVC_MAX_NBR_CB > 0)
|
||||
SVCCTL_EvtHandler.SVCCTL__SvcHandlerTab[SVCCTL_EvtHandler.NbreOfRegisteredHandler] = pfBLE_SVC_Service_Event_Handler;
|
||||
SVCCTL_EvtHandler.NbreOfRegisteredHandler++;
|
||||
#else
|
||||
(void)(pfBLE_SVC_Service_Event_Handler);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BLE Controller initialization
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVCCTL_RegisterCltHandler( SVC_CTL_p_EvtHandler_t pfBLE_SVC_Client_Event_Handler )
|
||||
{
|
||||
#if (BLE_CFG_CLT_MAX_NBR_CB > 0)
|
||||
SVCCTL_CltHandler.SVCCTL_CltHandlerTable[SVCCTL_CltHandler.NbreOfRegisteredHandler] = pfBLE_SVC_Client_Event_Handler;
|
||||
SVCCTL_CltHandler.NbreOfRegisteredHandler++;
|
||||
#else
|
||||
(void)(pfBLE_SVC_Client_Event_Handler);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK SVCCTL_UserEvtFlowStatus_t SVCCTL_UserEvtRx( void *pckt )
|
||||
{
|
||||
hci_event_pckt *event_pckt;
|
||||
evt_blecore_aci *blecore_evt;
|
||||
SVCCTL_EvtAckStatus_t event_notification_status;
|
||||
SVCCTL_UserEvtFlowStatus_t return_status;
|
||||
uint8_t index;
|
||||
|
||||
event_pckt = (hci_event_pckt*) ((hci_uart_pckt *) pckt)->data;
|
||||
event_notification_status = SVCCTL_EvtNotAck;
|
||||
|
||||
switch (event_pckt->evt)
|
||||
{
|
||||
case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE:
|
||||
{
|
||||
blecore_evt = (evt_blecore_aci*) event_pckt->data;
|
||||
|
||||
switch ((blecore_evt->ecode) & SVCCTL_EGID_EVT_MASK)
|
||||
{
|
||||
case SVCCTL_GATT_EVT_TYPE:
|
||||
#if (BLE_CFG_SVC_MAX_NBR_CB > 0)
|
||||
/* For Service event handler */
|
||||
for (index = 0; index < SVCCTL_EvtHandler.NbreOfRegisteredHandler; index++)
|
||||
{
|
||||
event_notification_status = SVCCTL_EvtHandler.SVCCTL__SvcHandlerTab[index](pckt);
|
||||
/**
|
||||
* When a GATT event has been acknowledged by a Service, there is no need to call the other registered handlers
|
||||
* a GATT event is relevant for only one Service
|
||||
*/
|
||||
if (event_notification_status != SVCCTL_EvtNotAck)
|
||||
{
|
||||
/**
|
||||
* The event has been managed. The Event processing should be stopped
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if (BLE_CFG_CLT_MAX_NBR_CB > 0)
|
||||
/* For Client event handler */
|
||||
event_notification_status = SVCCTL_EvtNotAck;
|
||||
for(index = 0; index <SVCCTL_CltHandler.NbreOfRegisteredHandler; index++)
|
||||
{
|
||||
event_notification_status = SVCCTL_CltHandler.SVCCTL_CltHandlerTable[index](pckt);
|
||||
/**
|
||||
* When a GATT event has been acknowledged by a Client, there is no need to call the other registered handlers
|
||||
* a GATT event is relevant for only one Client
|
||||
*/
|
||||
if (event_notification_status != SVCCTL_EvtNotAck)
|
||||
{
|
||||
/**
|
||||
* The event has been managed. The Event processing should be stopped
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break; /* HCI_HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE_SPECIFIC */
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* When no registered handlers (either Service or Client) has acknowledged the GATT event, it is reported to the application
|
||||
* a GAP event is always reported to the application.
|
||||
*/
|
||||
switch (event_notification_status)
|
||||
{
|
||||
case SVCCTL_EvtNotAck:
|
||||
/**
|
||||
* The event has NOT been managed.
|
||||
* It shall be passed to the application for processing
|
||||
*/
|
||||
return_status = SVCCTL_App_Notification(pckt);
|
||||
break;
|
||||
|
||||
case SVCCTL_EvtAckFlowEnable:
|
||||
return_status = SVCCTL_UserEvtFlowEnable;
|
||||
break;
|
||||
|
||||
case SVCCTL_EvtAckFlowDisable:
|
||||
return_status = SVCCTL_UserEvtFlowDisable;
|
||||
break;
|
||||
|
||||
default:
|
||||
return_status = SVCCTL_UserEvtFlowEnable;
|
||||
break;
|
||||
}
|
||||
|
||||
return (return_status);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file hw.h
|
||||
* @author MCD Application Team
|
||||
* @brief Hardware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __HW_H
|
||||
#define __HW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/******************************************************************************
|
||||
* HW IPCC
|
||||
******************************************************************************/
|
||||
void HW_IPCC_Enable( void );
|
||||
void HW_IPCC_Init( void );
|
||||
void HW_IPCC_Rx_Handler( void );
|
||||
void HW_IPCC_Tx_Handler( void );
|
||||
|
||||
void HW_IPCC_BLE_Init( void );
|
||||
void HW_IPCC_BLE_SendCmd( void );
|
||||
void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) );
|
||||
void HW_IPCC_BLE_RxEvtNot( void );
|
||||
void HW_IPCC_BLE_SendAclData( void );
|
||||
void HW_IPCC_BLE_AclDataAckNot( void );
|
||||
|
||||
void HW_IPCC_SYS_Init( void );
|
||||
void HW_IPCC_SYS_SendCmd( void );
|
||||
void HW_IPCC_SYS_CmdEvtNot( void );
|
||||
void HW_IPCC_SYS_EvtNot( void );
|
||||
|
||||
void HW_IPCC_THREAD_Init( void );
|
||||
void HW_IPCC_OT_SendCmd( void );
|
||||
void HW_IPCC_CLI_SendCmd( void );
|
||||
void HW_IPCC_THREAD_SendAck( void );
|
||||
void HW_IPCC_OT_CmdEvtNot( void );
|
||||
void HW_IPCC_CLI_CmdEvtNot( void );
|
||||
void HW_IPCC_THREAD_EvtNot( void );
|
||||
void HW_IPCC_THREAD_CliSendAck( void );
|
||||
void HW_IPCC_THREAD_CliEvtNot( void );
|
||||
|
||||
|
||||
void HW_IPCC_LLDTESTS_Init( void );
|
||||
void HW_IPCC_LLDTESTS_SendCliCmd( void );
|
||||
void HW_IPCC_LLDTESTS_ReceiveCliRsp( void );
|
||||
void HW_IPCC_LLDTESTS_SendCliRspAck( void );
|
||||
void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void );
|
||||
void HW_IPCC_LLDTESTS_SendM0CmdAck( void );
|
||||
|
||||
|
||||
void HW_IPCC_BLE_LLD_Init( void );
|
||||
void HW_IPCC_BLE_LLD_SendCliCmd( void );
|
||||
void HW_IPCC_BLE_LLD_ReceiveCliRsp( void );
|
||||
void HW_IPCC_BLE_LLD_SendCliRspAck( void );
|
||||
void HW_IPCC_BLE_LLD_ReceiveM0Cmd( void );
|
||||
void HW_IPCC_BLE_LLD_SendM0CmdAck( void );
|
||||
void HW_IPCC_BLE_LLD_SendCmd( void );
|
||||
void HW_IPCC_BLE_LLD_ReceiveRsp( void );
|
||||
void HW_IPCC_BLE_LLD_SendRspAck( void );
|
||||
|
||||
|
||||
void HW_IPCC_TRACES_Init( void );
|
||||
void HW_IPCC_TRACES_EvtNot( void );
|
||||
|
||||
void HW_IPCC_MAC_802_15_4_Init( void );
|
||||
void HW_IPCC_MAC_802_15_4_SendCmd( void );
|
||||
void HW_IPCC_MAC_802_15_4_SendAck( void );
|
||||
void HW_IPCC_MAC_802_15_4_CmdEvtNot( void );
|
||||
void HW_IPCC_MAC_802_15_4_EvtNot( void );
|
||||
|
||||
void HW_IPCC_ZIGBEE_Init( void );
|
||||
|
||||
void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */
|
||||
void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */
|
||||
|
||||
void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */
|
||||
void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */
|
||||
void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */
|
||||
void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__HW_H */
|
||||
|
||||
@@ -0,0 +1,780 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file shci.c
|
||||
* @author MCD Application Team
|
||||
* @brief HCI command for the system channel
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_wpan_common.h"
|
||||
|
||||
#include "shci_tl.h"
|
||||
#include "shci.h"
|
||||
#include "stm32wbxx.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Global variables ----------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Local Functions Definition ------------------------------------------------------*/
|
||||
/* Public Functions Definition ------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* C2 COMMAND
|
||||
* These commands are sent to the CPU2
|
||||
*/
|
||||
uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_error_code )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete with payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE + 1];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_GET_STATE,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
if(p_error_code != 0)
|
||||
{
|
||||
*p_error_code = (SHCI_FUS_GetState_ErrorCode_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]);
|
||||
}
|
||||
|
||||
return (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_add )
|
||||
{
|
||||
/**
|
||||
* TL_BLEEVT_CC_BUFFER_SIZE is 16 bytes so it is large enough to hold the 8 bytes of command parameters
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
uint32_t *p_cmd;
|
||||
uint8_t cmd_length;
|
||||
|
||||
p_cmd = (uint32_t*)local_buffer;
|
||||
cmd_length = 0;
|
||||
|
||||
if(fw_src_add != 0)
|
||||
{
|
||||
*p_cmd = fw_src_add;
|
||||
cmd_length += 4;
|
||||
}
|
||||
|
||||
if(fw_dest_add != 0)
|
||||
{
|
||||
*(p_cmd+1) = fw_dest_add;
|
||||
cmd_length += 4;
|
||||
}
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_FW_UPGRADE,
|
||||
cmd_length,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_FW_DELETE,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_FwPurge( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_FW_PURGE,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY,
|
||||
sizeof( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t ),
|
||||
(uint8_t*)pParam,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete with payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE + 1];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
uint8_t local_payload_len;
|
||||
|
||||
if(pParam->KeyType == KEYTYPE_ENCRYPTED)
|
||||
{
|
||||
/**
|
||||
* When the key is encrypted, the 12 bytes IV Key is included in the payload as well
|
||||
* The IV key is always 12 bytes
|
||||
*/
|
||||
local_payload_len = pParam->KeySize + 2 + 12;
|
||||
}
|
||||
else
|
||||
{
|
||||
local_payload_len = pParam->KeySize + 2;
|
||||
}
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_STORE_USR_KEY,
|
||||
local_payload_len ,
|
||||
(uint8_t*)pParam,
|
||||
p_rsp );
|
||||
|
||||
*p_key_index = (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]);
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = key_index;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_LOAD_USR_KEY,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_START_WS,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = key_index;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_LOCK_USR_KEY,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_UnloadUsrKey( uint8_t key_index )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = key_index;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_UNLOAD_USR_KEY,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FUS_ActivateAntiRollback( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FUS_ACTIVATE_ANTIROLLBACK,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_BLE_INIT,
|
||||
sizeof( SHCI_C2_Ble_Init_Cmd_Param_t ),
|
||||
(uint8_t*)&pCmdPacket->Param,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_THREAD_INIT,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_LLD_TESTS_INIT,
|
||||
param_size,
|
||||
p_param,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_BLE_LLD_INIT,
|
||||
param_size,
|
||||
p_param,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_DEBUG_INIT,
|
||||
sizeof( SHCI_C2_DEBUG_init_Cmd_Param_t ),
|
||||
(uint8_t*)&pCmdPacket->Param,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activity )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = erase_activity;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = Mode;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_CONCURRENT_SET_MODE,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_CONCURRENT_GetNextBleEvtTime( SHCI_C2_CONCURRENT_GetNextBleEvtTime_Param_t *pParam )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete with payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE+4];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
memcpy((void*)&(pParam->relative_time), (void*)&((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1], sizeof(pParam->relative_time));
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = Ip;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FLASH_STORE_DATA,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = Ip;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_FLASH_ERASE_DATA,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn)
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = Ip;
|
||||
local_buffer[1] = FlagRadioLowPowerOn;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER,
|
||||
2,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_Reinit( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_REINIT,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status)
|
||||
{
|
||||
/**
|
||||
* TL_BLEEVT_CC_BUFFER_SIZE is 16 bytes so it is large enough to hold the 8 bytes of command parameters
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_port = gpio_port;
|
||||
((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_pin_number = gpio_pin_number;
|
||||
((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_polarity = gpio_polarity;
|
||||
((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_status = gpio_status;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_EXTPA_CONFIG,
|
||||
8,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source)
|
||||
{
|
||||
/**
|
||||
* TL_BLEEVT_CC_BUFFER_SIZE is 16 bytes so it is large enough to hold the 1 byte of command parameter
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = (uint8_t)Source;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket)
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_CONFIG,
|
||||
sizeof(SHCI_C2_CONFIG_Cmd_Param_t),
|
||||
(uint8_t*)pCmdPacket,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_802_15_4_DeInit( void )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_802_15_4_DEINIT,
|
||||
0,
|
||||
0,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
SHCI_CmdStatus_t SHCI_C2_SetSystemClock( SHCI_C2_SET_SYSTEM_CLOCK_Cmd_Param_t clockSel )
|
||||
{
|
||||
/**
|
||||
* Buffer is large enough to hold command complete without payload
|
||||
*/
|
||||
uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE];
|
||||
TL_EvtPacket_t * p_rsp;
|
||||
|
||||
p_rsp = (TL_EvtPacket_t *)local_buffer;
|
||||
|
||||
local_buffer[0] = (uint8_t)clockSel;
|
||||
|
||||
shci_send( SHCI_OPCODE_C2_SET_SYSTEM_CLOCK,
|
||||
1,
|
||||
local_buffer,
|
||||
p_rsp );
|
||||
|
||||
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local System COMMAND
|
||||
* These commands are NOT sent to the CPU2
|
||||
*/
|
||||
|
||||
SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo )
|
||||
{
|
||||
uint32_t ipccdba = 0;
|
||||
MB_RefTable_t * p_RefTable = NULL;
|
||||
uint32_t wireless_firmware_version = 0;
|
||||
uint32_t wireless_firmware_memorySize = 0;
|
||||
uint32_t wireless_firmware_infoStack = 0;
|
||||
MB_FUS_DeviceInfoTable_t * p_fus_device_info_table = NULL;
|
||||
uint32_t fus_version = 0;
|
||||
uint32_t fus_memorySize = 0;
|
||||
|
||||
ipccdba = READ_BIT( FLASH->IPCCBR, FLASH_IPCCBR_IPCCDBA );
|
||||
|
||||
/**
|
||||
* The Device Info Table mapping depends on which firmware is running on CPU2.
|
||||
* If the FUS is running on CPU2, FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD shall be written in the table.
|
||||
* Otherwise, it means the Wireless Firmware is running on the CPU2
|
||||
*/
|
||||
p_fus_device_info_table = (MB_FUS_DeviceInfoTable_t*)(*(uint32_t*)((ipccdba<<2) + SRAM2A_BASE));
|
||||
|
||||
if(p_fus_device_info_table->DeviceInfoTableState == FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD)
|
||||
{
|
||||
/* The FUS is running on CPU2 */
|
||||
/**
|
||||
* Retrieve the WirelessFwInfoTable
|
||||
* This table is stored in RAM at startup during the TL (transport layer) initialization
|
||||
*/
|
||||
wireless_firmware_version = p_fus_device_info_table->WirelessStackVersion;
|
||||
wireless_firmware_memorySize = p_fus_device_info_table->WirelessStackMemorySize;
|
||||
wireless_firmware_infoStack = p_fus_device_info_table->WirelessFirmwareBleInfo;
|
||||
|
||||
/**
|
||||
* Retrieve the FusInfoTable
|
||||
* This table is stored in RAM at startup during the TL (transport layer) initialization
|
||||
*/
|
||||
fus_version = p_fus_device_info_table->FusVersion;
|
||||
fus_memorySize = p_fus_device_info_table->FusMemorySize;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The Wireless Firmware is running on CPU2 */
|
||||
p_RefTable = (MB_RefTable_t*)((ipccdba<<2) + SRAM2A_BASE);
|
||||
|
||||
/**
|
||||
* Retrieve the WirelessFwInfoTable
|
||||
* This table is stored in RAM at startup during the TL (transport layer) initialization
|
||||
*/
|
||||
wireless_firmware_version = p_RefTable->p_device_info_table->WirelessFwInfoTable.Version;
|
||||
wireless_firmware_memorySize = p_RefTable->p_device_info_table->WirelessFwInfoTable.MemorySize;
|
||||
wireless_firmware_infoStack = p_RefTable->p_device_info_table->WirelessFwInfoTable.InfoStack;
|
||||
|
||||
/**
|
||||
* Retrieve the FusInfoTable
|
||||
* This table is stored in RAM at startup during the TL (transport layer) initialization
|
||||
*/
|
||||
fus_version = p_RefTable->p_device_info_table->FusInfoTable.Version;
|
||||
fus_memorySize = p_RefTable->p_device_info_table->FusInfoTable.MemorySize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the WirelessFwInfoTable
|
||||
* This table is stored in RAM at startup during the TL (transport layer) initialization
|
||||
*/
|
||||
pWirelessInfo->VersionMajor = ((wireless_firmware_version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET);
|
||||
pWirelessInfo->VersionMinor = ((wireless_firmware_version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET);
|
||||
pWirelessInfo->VersionSub = ((wireless_firmware_version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET);
|
||||
pWirelessInfo->VersionBranch = ((wireless_firmware_version & INFO_VERSION_BRANCH_MASK) >> INFO_VERSION_BRANCH_OFFSET);
|
||||
pWirelessInfo->VersionReleaseType = ((wireless_firmware_version & INFO_VERSION_TYPE_MASK) >> INFO_VERSION_TYPE_OFFSET);
|
||||
|
||||
pWirelessInfo->MemorySizeSram2B = ((wireless_firmware_memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET);
|
||||
pWirelessInfo->MemorySizeSram2A = ((wireless_firmware_memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET);
|
||||
pWirelessInfo->MemorySizeSram1 = ((wireless_firmware_memorySize & INFO_SIZE_SRAM1_MASK) >> INFO_SIZE_SRAM1_OFFSET);
|
||||
pWirelessInfo->MemorySizeFlash = ((wireless_firmware_memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET);
|
||||
|
||||
pWirelessInfo->StackType = ((wireless_firmware_infoStack & INFO_STACK_TYPE_MASK) >> INFO_STACK_TYPE_OFFSET);
|
||||
|
||||
/**
|
||||
* Retrieve the FusInfoTable
|
||||
* This table is stored in RAM at startup during the TL (transport layer) initialization
|
||||
*/
|
||||
pWirelessInfo->FusVersionMajor = ((fus_version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET);
|
||||
pWirelessInfo->FusVersionMinor = ((fus_version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET);
|
||||
pWirelessInfo->FusVersionSub = ((fus_version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET);
|
||||
|
||||
pWirelessInfo->FusMemorySizeSram2B = ((fus_memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET);
|
||||
pWirelessInfo->FusMemorySizeSram2A = ((fus_memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET);
|
||||
pWirelessInfo->FusMemorySizeFlash = ((fus_memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET);
|
||||
|
||||
return (SHCI_Success);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,308 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file hci_tl.c
|
||||
* @author MCD Application Team
|
||||
* @brief Function for managing HCI interface.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ble_common.h"
|
||||
#include "ble_const.h"
|
||||
|
||||
#include "stm_list.h"
|
||||
#include "tl.h"
|
||||
#include "hci_tl.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
HCI_TL_CMD_RESP_RELEASE,
|
||||
HCI_TL_CMD_RESP_WAIT,
|
||||
} HCI_TL_CmdRespStatus_t;
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The default HCI layer timeout is set to 33s
|
||||
*/
|
||||
#define HCI_TL_DEFAULT_TIMEOUT (33000)
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Public variables ---------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/**
|
||||
* START of Section BLE_DRIVER_CONTEXT
|
||||
*/
|
||||
PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") static volatile uint8_t hci_timer_id;
|
||||
PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") static tListNode HciAsynchEventQueue;
|
||||
PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") static TL_CmdPacket_t *pCmdBuffer;
|
||||
PLACE_IN_SECTION("BLE_DRIVER_CONTEXT") HCI_TL_UserEventFlowStatus_t UserEventFlow;
|
||||
/**
|
||||
* END of Section BLE_DRIVER_CONTEXT
|
||||
*/
|
||||
|
||||
static tHciContext hciContext;
|
||||
static tListNode HciCmdEventQueue;
|
||||
static void (* StatusNotCallBackFunction) (HCI_TL_CmdStatus_t status);
|
||||
static volatile HCI_TL_CmdRespStatus_t CmdRspStatusFlag;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static void NotifyCmdStatus(HCI_TL_CmdStatus_t hcicmdstatus);
|
||||
static void SendCmd(uint16_t opcode, uint8_t plen, void *param);
|
||||
static void TlEvtReceived(TL_EvtPacket_t *hcievt);
|
||||
static void TlInit( TL_CmdPacket_t * p_cmdbuffer );
|
||||
|
||||
/* Interface ------- ---------------------------------------------------------*/
|
||||
void hci_init(void(* UserEvtRx)(void* pData), void* pConf)
|
||||
{
|
||||
StatusNotCallBackFunction = ((HCI_TL_HciInitConf_t *)pConf)->StatusNotCallBack;
|
||||
hciContext.UserEvtRx = UserEvtRx;
|
||||
|
||||
hci_register_io_bus (&hciContext.io);
|
||||
|
||||
TlInit((TL_CmdPacket_t *)(((HCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void hci_user_evt_proc(void)
|
||||
{
|
||||
TL_EvtPacket_t *phcievtbuffer;
|
||||
tHCI_UserEvtRxParam UserEvtRxParam;
|
||||
|
||||
/**
|
||||
* Up to release version v1.2.0, a while loop was implemented to read out events from the queue as long as
|
||||
* it is not empty. However, in a bare metal implementation, this leads to calling in a "blocking" mode
|
||||
* hci_user_evt_proc() as long as events are received without giving the opportunity to run other tasks
|
||||
* in the background.
|
||||
* From now, the events are reported one by one. When it is checked there is still an event pending in the queue,
|
||||
* a request to the user is made to call again hci_user_evt_proc().
|
||||
* This gives the opportunity to the application to run other background tasks between each event.
|
||||
*/
|
||||
|
||||
/**
|
||||
* It is more secure to use LST_remove_head()/LST_insert_head() compare to LST_get_next_node()/LST_remove_node()
|
||||
* in case the user overwrite the header where the next/prev pointers are located
|
||||
*/
|
||||
|
||||
if((LST_is_empty(&HciAsynchEventQueue) == FALSE) && (UserEventFlow != HCI_TL_UserEventFlow_Disable))
|
||||
{
|
||||
LST_remove_head ( &HciAsynchEventQueue, (tListNode **)&phcievtbuffer );
|
||||
|
||||
if (hciContext.UserEvtRx != NULL)
|
||||
{
|
||||
UserEvtRxParam.pckt = phcievtbuffer;
|
||||
UserEvtRxParam.status = HCI_TL_UserEventFlow_Enable;
|
||||
hciContext.UserEvtRx((void *)&UserEvtRxParam);
|
||||
UserEventFlow = UserEvtRxParam.status;
|
||||
}
|
||||
else
|
||||
{
|
||||
UserEventFlow = HCI_TL_UserEventFlow_Enable;
|
||||
}
|
||||
|
||||
if(UserEventFlow != HCI_TL_UserEventFlow_Disable)
|
||||
{
|
||||
TL_MM_EvtDone( phcievtbuffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* put back the event in the queue
|
||||
*/
|
||||
LST_insert_head ( &HciAsynchEventQueue, (tListNode *)phcievtbuffer );
|
||||
}
|
||||
}
|
||||
|
||||
if((LST_is_empty(&HciAsynchEventQueue) == FALSE) && (UserEventFlow != HCI_TL_UserEventFlow_Disable))
|
||||
{
|
||||
hci_notify_asynch_evt((void*) &HciAsynchEventQueue);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void hci_resume_flow( void )
|
||||
{
|
||||
UserEventFlow = HCI_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
|
||||
*/
|
||||
hci_notify_asynch_evt((void*) &HciAsynchEventQueue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int hci_send_req(struct hci_request *p_cmd, uint8_t async)
|
||||
{
|
||||
(void)(async);
|
||||
uint16_t opcode;
|
||||
TL_CcEvt_t *pcommand_complete_event;
|
||||
TL_CsEvt_t *pcommand_status_event;
|
||||
TL_EvtPacket_t *pevtpacket;
|
||||
uint8_t hci_cmd_complete_return_parameters_length;
|
||||
HCI_TL_CmdStatus_t local_cmd_status;
|
||||
|
||||
NotifyCmdStatus(HCI_TL_CmdBusy);
|
||||
local_cmd_status = HCI_TL_CmdBusy;
|
||||
opcode = ((p_cmd->ocf) & 0x03ff) | ((p_cmd->ogf) << 10);
|
||||
|
||||
CmdRspStatusFlag = HCI_TL_CMD_RESP_WAIT;
|
||||
SendCmd(opcode, p_cmd->clen, p_cmd->cparam);
|
||||
|
||||
while(local_cmd_status == HCI_TL_CmdBusy)
|
||||
{
|
||||
hci_cmd_resp_wait(HCI_TL_DEFAULT_TIMEOUT);
|
||||
|
||||
/**
|
||||
* Process Cmd Event
|
||||
*/
|
||||
while(LST_is_empty(&HciCmdEventQueue) == FALSE)
|
||||
{
|
||||
LST_remove_head (&HciCmdEventQueue, (tListNode **)&pevtpacket);
|
||||
|
||||
if(pevtpacket->evtserial.evt.evtcode == TL_BLEEVT_CS_OPCODE)
|
||||
{
|
||||
pcommand_status_event = (TL_CsEvt_t*)pevtpacket->evtserial.evt.payload;
|
||||
if(pcommand_status_event->cmdcode == opcode)
|
||||
{
|
||||
*(uint8_t *)(p_cmd->rparam) = pcommand_status_event->status;
|
||||
}
|
||||
|
||||
if(pcommand_status_event->numcmd != 0)
|
||||
{
|
||||
local_cmd_status = HCI_TL_CmdAvailable;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pcommand_complete_event = (TL_CcEvt_t*)pevtpacket->evtserial.evt.payload;
|
||||
|
||||
if(pcommand_complete_event->cmdcode == opcode)
|
||||
{
|
||||
hci_cmd_complete_return_parameters_length = pevtpacket->evtserial.evt.plen - TL_EVT_HDR_SIZE;
|
||||
p_cmd->rlen = MIN(hci_cmd_complete_return_parameters_length, p_cmd->rlen);
|
||||
memcpy(p_cmd->rparam, pcommand_complete_event->payload, p_cmd->rlen);
|
||||
}
|
||||
|
||||
if(pcommand_complete_event->numcmd != 0)
|
||||
{
|
||||
local_cmd_status = HCI_TL_CmdAvailable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NotifyCmdStatus(HCI_TL_CmdAvailable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
static void TlInit( TL_CmdPacket_t * p_cmdbuffer )
|
||||
{
|
||||
TL_BLE_InitConf_t Conf;
|
||||
|
||||
/**
|
||||
* Always initialize the command event queue
|
||||
*/
|
||||
LST_init_head (&HciCmdEventQueue);
|
||||
|
||||
pCmdBuffer = p_cmdbuffer;
|
||||
|
||||
LST_init_head (&HciAsynchEventQueue);
|
||||
|
||||
UserEventFlow = HCI_TL_UserEventFlow_Enable;
|
||||
|
||||
/* Initialize low level driver */
|
||||
if (hciContext.io.Init)
|
||||
{
|
||||
|
||||
Conf.p_cmdbuffer = (uint8_t *)p_cmdbuffer;
|
||||
Conf.IoBusEvtCallBack = TlEvtReceived;
|
||||
hciContext.io.Init(&Conf);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void SendCmd(uint16_t opcode, uint8_t plen, void *param)
|
||||
{
|
||||
pCmdBuffer->cmdserial.cmd.cmdcode = opcode;
|
||||
pCmdBuffer->cmdserial.cmd.plen = plen;
|
||||
memcpy( pCmdBuffer->cmdserial.cmd.payload, param, plen );
|
||||
|
||||
hciContext.io.Send(0,0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void NotifyCmdStatus(HCI_TL_CmdStatus_t hcicmdstatus)
|
||||
{
|
||||
if(hcicmdstatus == HCI_TL_CmdBusy)
|
||||
{
|
||||
if(StatusNotCallBackFunction != 0)
|
||||
{
|
||||
StatusNotCallBackFunction(HCI_TL_CmdBusy);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(StatusNotCallBackFunction != 0)
|
||||
{
|
||||
StatusNotCallBackFunction(HCI_TL_CmdAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void TlEvtReceived(TL_EvtPacket_t *hcievt)
|
||||
{
|
||||
if ( ((hcievt->evtserial.evt.evtcode) == TL_BLEEVT_CS_OPCODE) || ((hcievt->evtserial.evt.evtcode) == TL_BLEEVT_CC_OPCODE ) )
|
||||
{
|
||||
LST_insert_tail(&HciCmdEventQueue, (tListNode *)hcievt);
|
||||
hci_cmd_resp_release(0); /**< Notify the application a full Cmd Event has been received */
|
||||
}
|
||||
else
|
||||
{
|
||||
LST_insert_tail(&HciAsynchEventQueue, (tListNode *)hcievt);
|
||||
hci_notify_asynch_evt((void*) &HciAsynchEventQueue); /**< Notify the application a full HCI event has been received */
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Weak implementation ----------------------------------------------------------------*/
|
||||
__WEAK void hci_cmd_resp_wait(uint32_t timeout)
|
||||
{
|
||||
(void)timeout;
|
||||
|
||||
while(CmdRspStatusFlag != HCI_TL_CMD_RESP_RELEASE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void hci_cmd_resp_release(uint32_t flag)
|
||||
{
|
||||
(void)flag;
|
||||
|
||||
CmdRspStatusFlag = HCI_TL_CMD_RESP_RELEASE;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file hci_tl.h
|
||||
* @author MCD Application Team
|
||||
* @brief Constants and functions for HCI layer. See Bluetooth Core
|
||||
* v 4.0, Vol. 2, Part E.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __HCI_TL_H_
|
||||
#define __HCI_TL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "stm32_wpan_common.h"
|
||||
#include "tl.h"
|
||||
|
||||
/* Exported defines -----------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
HCI_TL_UserEventFlow_Disable,
|
||||
HCI_TL_UserEventFlow_Enable,
|
||||
} HCI_TL_UserEventFlowStatus_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HCI_TL_CmdBusy,
|
||||
HCI_TL_CmdAvailable
|
||||
} HCI_TL_CmdStatus_t;
|
||||
|
||||
/**
|
||||
* @brief Structure used to manage the BUS IO operations.
|
||||
* All the structure fields will point to functions defined at user level.
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int32_t (* Init) (void* pConf); /**< Pointer to HCI TL function for the IO Bus initialization */
|
||||
int32_t (* DeInit) (void); /**< Pointer to HCI TL function for the IO Bus de-initialization */
|
||||
int32_t (* Reset) (void); /**< Pointer to HCI TL function for the IO Bus reset */
|
||||
int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to HCI TL function for the IO Bus data reception */
|
||||
int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to HCI TL function for the IO Bus data transmission */
|
||||
int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to HCI TL function for the IO Bus data ack reception */
|
||||
int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */
|
||||
} tHciIO;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Contain the HCI context
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
tHciIO io; /**< Manage the BUS IO operations */
|
||||
void (* UserEvtRx) (void * pData); /**< ACI events callback function pointer */
|
||||
} tHciContext;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HCI_TL_UserEventFlowStatus_t status;
|
||||
TL_EvtPacket_t *pckt;
|
||||
} tHCI_UserEvtRxParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_cmdbuffer;
|
||||
void (* StatusNotCallBack) (HCI_TL_CmdStatus_t status);
|
||||
} HCI_TL_HciInitConf_t;
|
||||
|
||||
/**
|
||||
* @brief Register IO bus services.
|
||||
* @param fops The HCI IO structure managing the IO BUS
|
||||
* @retval None
|
||||
*/
|
||||
void hci_register_io_bus(tHciIO* fops);
|
||||
|
||||
/**
|
||||
* @brief This callback is called from either
|
||||
* - IPCC RX interrupt context
|
||||
* - hci_user_evt_proc() context.
|
||||
* - hci_resume_flow() context
|
||||
* It requests hci_user_evt_proc() to be executed.
|
||||
*
|
||||
* @param pdata Packet or event pointer
|
||||
* @retval None
|
||||
*/
|
||||
void hci_notify_asynch_evt(void* pdata);
|
||||
|
||||
/**
|
||||
* @brief This function resume the User Event Flow which has been stopped on return
|
||||
* from UserEvtRx() when the User Event has not been processed.
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void hci_resume_flow(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called when an ACI/HCI command is sent to the CPU2 and the response is waited.
|
||||
* It is called from the same context the HCI command has been sent.
|
||||
* It shall not return until the command response notified by hci_cmd_resp_release() is received.
|
||||
* A weak implementation is available in hci_tl.c based on polling mechanism
|
||||
* The user may re-implement this function in the application to improve performance :
|
||||
* - It may use UTIL_SEQ_WaitEvt() API when using the Sequencer
|
||||
* - It may use a semaphore when using cmsis_os interface
|
||||
*
|
||||
* @param timeout: Waiting timeout
|
||||
* @retval None
|
||||
*/
|
||||
void hci_cmd_resp_wait(uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief This function is called when an ACI/HCI command response is received from the CPU2.
|
||||
* A weak implementation is available in hci_tl.c based on polling mechanism
|
||||
* The user may re-implement this function in the application to improve performance :
|
||||
* - It may use UTIL_SEQ_SetEvt() API when using the Sequencer
|
||||
* - It may use a semaphore when using cmsis_os interface
|
||||
*
|
||||
* @param flag: Release flag
|
||||
* @retval None
|
||||
*/
|
||||
void hci_cmd_resp_release(uint32_t flag);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* END OF SECTION - FUNCTIONS TO BE IMPLEMENTED BY THE APPLICATION
|
||||
*********************************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*********************************************************************************************************************
|
||||
* START OF SECTION - PROCESS TO BE CALLED BY THE SCHEDULER
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This process shall be called by the scheduler each time it is requested with hci_notify_asynch_evt()
|
||||
* This process may send an ACI/HCI command when the svc_ctl.c module is used
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void hci_user_evt_proc(void);
|
||||
|
||||
/**
|
||||
* END OF SECTION - PROCESS TO BE CALLED BY THE SCHEDULER
|
||||
*********************************************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*********************************************************************************************************************
|
||||
* START OF SECTION - INTERFACES USED BY THE BLE DRIVER
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize the Host Controller Interface.
|
||||
* This function must be called before any data can be received
|
||||
* from BLE controller.
|
||||
*
|
||||
* @param pData: ACI events callback function pointer
|
||||
* This callback is triggered when an user event is received from
|
||||
* the BLE core device.
|
||||
* @param pConf: Configuration structure pointer
|
||||
* @retval None
|
||||
*/
|
||||
void hci_init(void(* UserEvtRx)(void* pData), void* pConf);
|
||||
|
||||
/**
|
||||
* END OF SECTION - INTERFACES USED BY THE BLE DRIVER
|
||||
*********************************************************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TL_BLE_HCI_H_ */
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file hci_tl_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief Transport layer interface to BLE
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "hci_tl.h"
|
||||
#include "tl.h"
|
||||
|
||||
|
||||
void hci_register_io_bus(tHciIO* fops)
|
||||
{
|
||||
/* Register IO bus services */
|
||||
fops->Init = TL_BLE_Init;
|
||||
fops->Send = TL_BLE_SendCmd;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mbox_def.h
|
||||
* @author MCD Application Team
|
||||
* @brief Mailbox definition
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MBOX_H
|
||||
#define __MBOX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "stm32_wpan_common.h"
|
||||
|
||||
/**
|
||||
* This file shall be identical between the CPU1 and the CPU2
|
||||
*/
|
||||
|
||||
/**
|
||||
*********************************************************************************
|
||||
* TABLES
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Version
|
||||
* [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version
|
||||
* [4:7] = branch - 0: Mass Market - x: ...
|
||||
* [8:15] = Subversion
|
||||
* [16:23] = Version minor
|
||||
* [24:31] = Version major
|
||||
*
|
||||
* Memory Size
|
||||
* [0:7] = Flash ( Number of 4k sector)
|
||||
* [8:15] = Reserved ( Shall be set to 0 - may be used as flash extension )
|
||||
* [16:23] = SRAM2b ( Number of 1k sector)
|
||||
* [24:31] = SRAM2a ( Number of 1k sector)
|
||||
*/
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint32_t Version;
|
||||
} MB_SafeBootInfoTable_t;
|
||||
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint32_t Version;
|
||||
uint32_t MemorySize;
|
||||
uint32_t FusInfo;
|
||||
} MB_FusInfoTable_t;
|
||||
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint32_t Version;
|
||||
uint32_t MemorySize;
|
||||
uint32_t InfoStack;
|
||||
uint32_t Reserved;
|
||||
} MB_WirelessFwInfoTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MB_SafeBootInfoTable_t SafeBootInfoTable;
|
||||
MB_FusInfoTable_t FusInfoTable;
|
||||
MB_WirelessFwInfoTable_t WirelessFwInfoTable;
|
||||
} MB_DeviceInfoTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *pcmd_buffer;
|
||||
uint8_t *pcs_buffer;
|
||||
uint8_t *pevt_queue;
|
||||
uint8_t *phci_acl_data_buffer;
|
||||
} MB_BleTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *notack_buffer;
|
||||
uint8_t *clicmdrsp_buffer;
|
||||
uint8_t *otcmdrsp_buffer;
|
||||
uint8_t *clinot_buffer;
|
||||
} MB_ThreadTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *clicmdrsp_buffer;
|
||||
uint8_t *m0cmd_buffer;
|
||||
} MB_LldTestsTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *cmdrsp_buffer;
|
||||
uint8_t *m0cmd_buffer;
|
||||
} MB_BleLldTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *notifM0toM4_buffer;
|
||||
uint8_t *appliCmdM4toM0_buffer;
|
||||
uint8_t *requestM0toM4_buffer;
|
||||
} MB_ZigbeeTable_t;
|
||||
/**
|
||||
* msg
|
||||
* [0:7] = cmd/evt
|
||||
* [8:31] = Reserved
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *pcmd_buffer;
|
||||
uint8_t *sys_queue;
|
||||
} MB_SysTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *spare_ble_buffer;
|
||||
uint8_t *spare_sys_buffer;
|
||||
uint8_t *blepool;
|
||||
uint32_t blepoolsize;
|
||||
uint8_t *pevt_free_buffer_queue;
|
||||
uint8_t *traces_evt_pool;
|
||||
uint32_t tracespoolsize;
|
||||
} MB_MemManagerTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *traces_queue;
|
||||
} MB_TracesTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_cmdrsp_buffer;
|
||||
uint8_t *p_notack_buffer;
|
||||
uint8_t *evt_queue;
|
||||
} MB_Mac_802_15_4_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MB_DeviceInfoTable_t *p_device_info_table;
|
||||
MB_BleTable_t *p_ble_table;
|
||||
MB_ThreadTable_t *p_thread_table;
|
||||
MB_SysTable_t *p_sys_table;
|
||||
MB_MemManagerTable_t *p_mem_manager_table;
|
||||
MB_TracesTable_t *p_traces_table;
|
||||
MB_Mac_802_15_4_t *p_mac_802_15_4_table;
|
||||
MB_ZigbeeTable_t *p_zigbee_table;
|
||||
MB_LldTestsTable_t *p_lld_tests_table;
|
||||
MB_BleLldTable_t *p_ble_lld_table;
|
||||
} MB_RefTable_t;
|
||||
|
||||
/**
|
||||
* This table shall be used only in the case the CPU2 runs the FUS.
|
||||
* It is used by the command SHCI_GetWirelessFwInfo()
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t DeviceInfoTableState;
|
||||
uint8_t Reserved1;
|
||||
uint8_t LastFusActiveState;
|
||||
uint8_t LastWirelessStackState;
|
||||
uint8_t CurrentWirelessStackType;
|
||||
uint32_t SafeBootVersion;
|
||||
uint32_t FusVersion;
|
||||
uint32_t FusMemorySize;
|
||||
uint32_t WirelessStackVersion;
|
||||
uint32_t WirelessStackMemorySize;
|
||||
uint32_t WirelessFirmwareBleInfo;
|
||||
uint32_t WirelessFirmwareThreadInfo;
|
||||
uint32_t Reserved2;
|
||||
uint64_t UID64;
|
||||
uint16_t DeviceId;
|
||||
} MB_FUS_DeviceInfoTable_t ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
*********************************************************************************
|
||||
* IPCC CHANNELS
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
/* CPU1 CPU2
|
||||
* | (SYSTEM) |
|
||||
* |----HW_IPCC_SYSTEM_CMD_RSP_CHANNEL-------------->|
|
||||
* | |
|
||||
* |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------|
|
||||
* | |
|
||||
* | (ZIGBEE) |
|
||||
* |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>|
|
||||
* | |
|
||||
* |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->|
|
||||
* | |
|
||||
* |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------|
|
||||
* | |
|
||||
* |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------|
|
||||
* | |
|
||||
* | (THREAD) |
|
||||
* |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->|
|
||||
* | |
|
||||
* |----HW_IPCC_THREAD_CLI_CMD_CHANNEL-------------->|
|
||||
* | |
|
||||
* |<---HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL------|
|
||||
* | |
|
||||
* |<---HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL--|
|
||||
* | |
|
||||
* | (BLE) |
|
||||
* |----HW_IPCC_BLE_CMD_CHANNEL--------------------->|
|
||||
* | |
|
||||
* |----HW_IPCC_HCI_ACL_DATA_CHANNEL---------------->|
|
||||
* | |
|
||||
* |<---HW_IPCC_BLE_EVENT_CHANNEL--------------------|
|
||||
* | |
|
||||
* | (BLE LLD) |
|
||||
* |----HW_IPCC_BLE_LLD_CMD_CHANNEL----------------->|
|
||||
* | |
|
||||
* |<---HW_IPCC_BLE_LLD_RSP_CHANNEL------------------|
|
||||
* | |
|
||||
* |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------|
|
||||
* | |
|
||||
* | (MAC) |
|
||||
* |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->|
|
||||
* | |
|
||||
* |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL|
|
||||
* | |
|
||||
* | (BUFFER) |
|
||||
* |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>|
|
||||
* | |
|
||||
* | (TRACE) |
|
||||
* |<----HW_IPCC_TRACES_CHANNEL----------------------|
|
||||
* | |
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** CPU1 */
|
||||
#define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1
|
||||
#define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2
|
||||
#define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4
|
||||
#define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_BLE_LLD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_BLE_LLD_CMD_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_HCI_ACL_DATA_CHANNEL LL_IPCC_CHANNEL_6
|
||||
|
||||
/** CPU2 */
|
||||
#define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1
|
||||
#define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2
|
||||
#define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3
|
||||
#define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4
|
||||
#define HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5
|
||||
#endif /*__MBOX_H */
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file shci.c
|
||||
* @author MCD Application Team
|
||||
* @brief System HCI command implementation
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_wpan_common.h"
|
||||
|
||||
#include "stm_list.h"
|
||||
#include "shci_tl.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
SHCI_TL_CMD_RESP_RELEASE,
|
||||
SHCI_TL_CMD_RESP_WAIT,
|
||||
} SHCI_TL_CmdRespStatus_t;
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/**
|
||||
* The default System HCI layer timeout is set to 33s
|
||||
*/
|
||||
#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);
|
||||
|
||||
static volatile SHCI_TL_CmdRespStatus_t CmdRspStatusFlag;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus);
|
||||
static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt);
|
||||
static void TlUserEvtReceived(TL_EvtPacket_t *shcievt);
|
||||
static void TlInit( TL_CmdPacket_t * p_cmdbuffer );
|
||||
|
||||
/* Interface ------- ---------------------------------------------------------*/
|
||||
void shci_init(void(* UserEvtRx)(void* pData), void* pConf)
|
||||
{
|
||||
StatusNotCallBackFunction = ((SHCI_TL_HciInitConf_t *)pConf)->StatusNotCallBack;
|
||||
shciContext.UserEvtRx = UserEvtRx;
|
||||
|
||||
shci_register_io_bus (&shciContext.io);
|
||||
|
||||
TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void shci_user_evt_proc(void)
|
||||
{
|
||||
TL_EvtPacket_t *phcievtbuffer;
|
||||
tSHCI_UserEvtRxParam UserEvtRxParam;
|
||||
|
||||
/**
|
||||
* Up to release version v1.2.0, a while loop was implemented to read out events from the queue as long as
|
||||
* it is not empty. However, in a bare metal implementation, this leads to calling in a "blocking" mode
|
||||
* shci_user_evt_proc() as long as events are received without giving the opportunity to run other tasks
|
||||
* in the background.
|
||||
* From now, the events are reported one by one. When it is checked there is still an event pending in the queue,
|
||||
* a request to the user is made to call again shci_user_evt_proc().
|
||||
* This gives the opportunity to the application to run other background tasks between each event.
|
||||
*/
|
||||
|
||||
/**
|
||||
* It is more secure to use LST_remove_head()/LST_insert_head() compare to LST_get_next_node()/LST_remove_node()
|
||||
* in case the user overwrite the header where the next/prev pointers are located
|
||||
*/
|
||||
if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable))
|
||||
{
|
||||
LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer );
|
||||
|
||||
if (shciContext.UserEvtRx != NULL)
|
||||
{
|
||||
UserEvtRxParam.pckt = phcievtbuffer;
|
||||
UserEvtRxParam.status = SHCI_TL_UserEventFlow_Enable;
|
||||
shciContext.UserEvtRx((void *)&UserEvtRxParam);
|
||||
SHCI_TL_UserEventFlow = UserEvtRxParam.status;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
|
||||
}
|
||||
|
||||
if(SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)
|
||||
{
|
||||
TL_MM_EvtDone( phcievtbuffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* put back the event in the queue
|
||||
*/
|
||||
LST_insert_head ( &SHciAsynchEventQueue, (tListNode *)phcievtbuffer );
|
||||
}
|
||||
}
|
||||
|
||||
if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable))
|
||||
{
|
||||
shci_notify_asynch_evt((void*) &SHciAsynchEventQueue);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void shci_resume_flow( void )
|
||||
{
|
||||
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
|
||||
|
||||
/**
|
||||
* It is better to go through the background process as it is not sure from which context this API may
|
||||
* be called
|
||||
*/
|
||||
shci_notify_asynch_evt((void*) &SHciAsynchEventQueue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp )
|
||||
{
|
||||
Cmd_SetStatus(SHCI_TL_CmdBusy);
|
||||
|
||||
pCmdBuffer->cmdserial.cmd.cmdcode = cmd_code;
|
||||
pCmdBuffer->cmdserial.cmd.plen = len_cmd_payload;
|
||||
|
||||
memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload );
|
||||
CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT;
|
||||
shciContext.io.Send(0,0);
|
||||
|
||||
shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT);
|
||||
|
||||
/**
|
||||
* The command complete of a system command does not have the header
|
||||
* It starts immediately with the evtserial field
|
||||
*/
|
||||
memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE );
|
||||
|
||||
Cmd_SetStatus(SHCI_TL_CmdAvailable);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
static void TlInit( TL_CmdPacket_t * p_cmdbuffer )
|
||||
{
|
||||
TL_SYS_InitConf_t Conf;
|
||||
|
||||
pCmdBuffer = p_cmdbuffer;
|
||||
|
||||
LST_init_head (&SHciAsynchEventQueue);
|
||||
|
||||
Cmd_SetStatus(SHCI_TL_CmdAvailable);
|
||||
|
||||
SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable;
|
||||
|
||||
/* Initialize low level driver */
|
||||
if (shciContext.io.Init)
|
||||
{
|
||||
|
||||
Conf.p_cmdbuffer = (uint8_t *)p_cmdbuffer;
|
||||
Conf.IoBusCallBackCmdEvt = TlCmdEvtReceived;
|
||||
Conf.IoBusCallBackUserEvt = TlUserEvtReceived;
|
||||
shciContext.io.Init(&Conf);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus)
|
||||
{
|
||||
if(shcicmdstatus == SHCI_TL_CmdBusy)
|
||||
{
|
||||
if(StatusNotCallBackFunction != 0)
|
||||
{
|
||||
StatusNotCallBackFunction( SHCI_TL_CmdBusy );
|
||||
}
|
||||
SHCICmdStatus = SHCI_TL_CmdBusy;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHCICmdStatus = SHCI_TL_CmdAvailable;
|
||||
if(StatusNotCallBackFunction != 0)
|
||||
{
|
||||
StatusNotCallBackFunction( SHCI_TL_CmdAvailable );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt)
|
||||
{
|
||||
(void)(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;
|
||||
}
|
||||
|
||||
/* Weak implementation ----------------------------------------------------------------*/
|
||||
__WEAK void shci_cmd_resp_wait(uint32_t timeout)
|
||||
{
|
||||
(void)timeout;
|
||||
|
||||
while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void shci_cmd_resp_release(uint32_t flag)
|
||||
{
|
||||
(void)flag;
|
||||
|
||||
CmdRspStatusFlag = SHCI_TL_CMD_RESP_RELEASE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file shci_tl.h
|
||||
* @author MCD Application Team
|
||||
* @brief System HCI command header for the system channel
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __SHCI_TL_H_
|
||||
#define __SHCI_TL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tl.h"
|
||||
|
||||
/* Exported defines -----------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
SHCI_TL_UserEventFlow_Disable,
|
||||
SHCI_TL_UserEventFlow_Enable,
|
||||
} SHCI_TL_UserEventFlowStatus_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SHCI_TL_CmdBusy,
|
||||
SHCI_TL_CmdAvailable
|
||||
} SHCI_TL_CmdStatus_t;
|
||||
|
||||
/**
|
||||
* @brief Structure used to manage the BUS IO operations.
|
||||
* All the structure fields will point to functions defined at user level.
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int32_t (* Init) (void* pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */
|
||||
int32_t (* DeInit) (void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */
|
||||
int32_t (* Reset) (void); /**< Pointer to SHCI TL function for the IO Bus reset */
|
||||
int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */
|
||||
int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */
|
||||
int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */
|
||||
int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */
|
||||
} tSHciIO;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Contain the SHCI context
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
tSHciIO io; /**< Manage the BUS IO operations */
|
||||
void (* UserEvtRx) (void * pData); /**< User System events callback function pointer */
|
||||
} tSHciContext;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SHCI_TL_UserEventFlowStatus_t status;
|
||||
TL_EvtPacket_t *pckt;
|
||||
} tSHCI_UserEvtRxParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_cmdbuffer;
|
||||
void (* StatusNotCallBack) (SHCI_TL_CmdStatus_t status);
|
||||
} SHCI_TL_HciInitConf_t;
|
||||
|
||||
/**
|
||||
* shci_send
|
||||
* @brief Send an System HCI Command
|
||||
*
|
||||
* @param : cmd_code = Opcode of the command
|
||||
* @param : len_cmd_payload = Length of the command payload
|
||||
* @param : p_cmd_payload = Address of the command payload
|
||||
* @param : p_rsp_status = Address of the full buffer holding the command complete event
|
||||
* @retval : None
|
||||
*/
|
||||
void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp_status );
|
||||
|
||||
/**
|
||||
* @brief Register IO bus services.
|
||||
* @param fops The SHCI IO structure managing the IO BUS
|
||||
* @retval None
|
||||
*/
|
||||
void shci_register_io_bus(tSHciIO* fops);
|
||||
|
||||
/**
|
||||
* @brief Interrupt service routine that must be called when the system channel
|
||||
* reports a packet has been received
|
||||
*
|
||||
* @param pdata Packet or event pointer
|
||||
* @retval None
|
||||
*/
|
||||
void shci_notify_asynch_evt(void* pdata);
|
||||
|
||||
/**
|
||||
* @brief This function resume the User Event Flow which has been stopped on return
|
||||
* from UserEvtRx() when the User Event has not been processed.
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void shci_resume_flow(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called when an System HCI Command is sent to the CPU2 and the response is waited.
|
||||
* It is called from the same context the System HCI command has been sent.
|
||||
* It shall not return until the command response notified by shci_cmd_resp_release() is received.
|
||||
* A weak implementation is available in shci_tl.c based on polling mechanism
|
||||
* The user may re-implement this function in the application to improve performance :
|
||||
* - It may use UTIL_SEQ_WaitEvt() API when using the Sequencer
|
||||
* - It may use a semaphore when using cmsis_os interface
|
||||
*
|
||||
* @param timeout: Waiting timeout
|
||||
* @retval None
|
||||
*/
|
||||
void shci_cmd_resp_wait(uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief This function is called when an System HCI command is received from the CPU2.
|
||||
* A weak implementation is available in shci_tl.c based on polling mechanism
|
||||
* The user may re-implement this function in the application to improve performance :
|
||||
* - It may use UTIL_SEQ_SetEvt() API when using the Sequencer
|
||||
* - It may use a semaphore when using cmsis_os interface
|
||||
*
|
||||
*
|
||||
* @param flag: Release flag
|
||||
* @retval None
|
||||
*/
|
||||
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 UserEvtRx: 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,30 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file shci_tl_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief Transport layer interface to the system channel
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "shci_tl.h"
|
||||
#include "tl.h"
|
||||
|
||||
|
||||
void shci_register_io_bus(tSHciIO* fops)
|
||||
{
|
||||
/* Register IO bus services */
|
||||
fops->Init = TL_SYS_Init;
|
||||
fops->Send = TL_SYS_SendCmd;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file tl.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for tl module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* 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_CLIRESP_PKT_TYPE ( 0x15 )
|
||||
#define TL_M0CMD_PKT_TYPE ( 0x16 )
|
||||
#define TL_LOCCMD_PKT_TYPE ( 0x20 )
|
||||
#define TL_LOCRSP_PKT_TYPE ( 0x21 )
|
||||
#define TL_TRACES_APP_PKT_TYPE ( 0x40 )
|
||||
#define TL_TRACES_WL_PKT_TYPE ( 0x41 )
|
||||
|
||||
#define TL_CMD_HDR_SIZE (4)
|
||||
#define TL_EVT_HDR_SIZE (3)
|
||||
#define TL_EVT_CS_PAYLOAD_SIZE (4)
|
||||
|
||||
#define TL_BLEEVT_CC_OPCODE (0x0E)
|
||||
#define TL_BLEEVT_CS_OPCODE (0x0F)
|
||||
#define TL_BLEEVT_VS_OPCODE (0xFF)
|
||||
|
||||
#define TL_BLEEVT_CC_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CcEvt_t))
|
||||
#define TL_BLEEVT_CC_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CC_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, only used a pointer
|
||||
*/
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint8_t numcmd;
|
||||
uint16_t cmdcode;
|
||||
uint8_t payload[2];
|
||||
} TL_CcEvt_t;
|
||||
|
||||
/**
|
||||
* This the payload of TL_Evt_t for an asynchronous event, only used a pointer
|
||||
*/
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint16_t subevtcode;
|
||||
uint8_t payload[2];
|
||||
} TL_AsynchEvt_t;
|
||||
|
||||
/**
|
||||
* This the payload of TL_Evt_t, only used a pointer
|
||||
*/
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint8_t evtcode;
|
||||
uint8_t plen;
|
||||
uint8_t payload[2];
|
||||
} 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;
|
||||
uint8_t *p_ThreadCliNotBuffer;
|
||||
} TL_TH_Config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_LldTestsCliCmdRspBuffer;
|
||||
uint8_t *p_LldTestsM0CmdBuffer;
|
||||
} TL_LLD_tests_Config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_BleLldCmdRspBuffer;
|
||||
uint8_t *p_BleLldM0CmdBuffer;
|
||||
} TL_BLE_LLD_Config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_Mac_802_15_4_CmdRspBuffer;
|
||||
uint8_t *p_Mac_802_15_4_NotAckBuffer;
|
||||
} TL_MAC_802_15_4_Config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_ZigbeeOtCmdRspBuffer;
|
||||
uint8_t *p_ZigbeeNotAckBuffer;
|
||||
uint8_t *p_ZigbeeNotifRequestBuffer;
|
||||
} TL_ZIGBEE_Config_t;
|
||||
|
||||
/**
|
||||
* @brief Contain the BLE HCI Init Configuration
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void (* IoBusEvtCallBack) ( TL_EvtPacket_t *phcievt );
|
||||
void (* IoBusAclDataTxAck) ( void );
|
||||
uint8_t *p_cmdbuffer;
|
||||
uint8_t *p_AclDataBuffer;
|
||||
} TL_BLE_InitConf_t;
|
||||
|
||||
/**
|
||||
* @brief Contain the SYSTEM HCI Init Configuration
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void (* IoBusCallBackCmdEvt) (TL_EvtPacket_t *phcievt);
|
||||
void (* IoBusCallBackUserEvt) (TL_EvtPacket_t *phcievt);
|
||||
uint8_t *p_cmdbuffer;
|
||||
} TL_SYS_InitConf_t;
|
||||
|
||||
/*****************************************************************************************
|
||||
* Event type copied from ble_legacy.h
|
||||
*/
|
||||
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t data[1];
|
||||
} hci_uart_pckt;
|
||||
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint8_t evt;
|
||||
uint8_t plen;
|
||||
uint8_t data[1];
|
||||
} hci_event_pckt;
|
||||
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint8_t subevent;
|
||||
uint8_t data[1];
|
||||
} evt_le_meta_event;
|
||||
|
||||
/**
|
||||
* Vendor specific event for BLE core.
|
||||
*/
|
||||
typedef PACKED_STRUCT
|
||||
{
|
||||
uint16_t ecode; /**< One of the BLE core event codes. */
|
||||
uint8_t data[1];
|
||||
} evt_blecore_aci;
|
||||
|
||||
/* Bluetooth 48 bit address (in little-endian order).
|
||||
*/
|
||||
typedef uint8_t tBDAddr[6];
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
/******************************************************************************
|
||||
* GENERAL
|
||||
******************************************************************************/
|
||||
void TL_Enable( void );
|
||||
void TL_Init( void );
|
||||
|
||||
/******************************************************************************
|
||||
* BLE
|
||||
******************************************************************************/
|
||||
int32_t TL_BLE_Init( void* pConf );
|
||||
int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size );
|
||||
int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size );
|
||||
|
||||
/******************************************************************************
|
||||
* SYSTEM
|
||||
******************************************************************************/
|
||||
int32_t TL_SYS_Init( void* pConf );
|
||||
int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size );
|
||||
|
||||
/******************************************************************************
|
||||
* THREAD
|
||||
******************************************************************************/
|
||||
void TL_THREAD_Init( TL_TH_Config_t *p_Config );
|
||||
void TL_OT_SendCmd( void );
|
||||
void TL_CLI_SendCmd( void );
|
||||
void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
|
||||
void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer );
|
||||
void TL_THREAD_SendAck ( void );
|
||||
void TL_THREAD_CliSendAck ( void );
|
||||
void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer );
|
||||
|
||||
/******************************************************************************
|
||||
* LLD TESTS
|
||||
******************************************************************************/
|
||||
void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config );
|
||||
void TL_LLDTESTS_SendCliCmd( void );
|
||||
void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer );
|
||||
void TL_LLDTESTS_SendCliRspAck( void );
|
||||
void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer );
|
||||
void TL_LLDTESTS_SendM0CmdAck( void );
|
||||
|
||||
/******************************************************************************
|
||||
* BLE LLD
|
||||
******************************************************************************/
|
||||
void TL_BLE_LLD_Init( TL_BLE_LLD_Config_t *p_Config );
|
||||
void TL_BLE_LLD_SendCliCmd( void );
|
||||
void TL_BLE_LLD_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer );
|
||||
void TL_BLE_LLD_SendCliRspAck( void );
|
||||
void TL_BLE_LLD_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer );
|
||||
void TL_BLE_LLD_SendM0CmdAck( void );
|
||||
void TL_BLE_LLD_SendCmd( void );
|
||||
void TL_BLE_LLD_ReceiveRsp( TL_CmdPacket_t * Notbuffer );
|
||||
void TL_BLE_LLD_SendRspAck( void );
|
||||
/******************************************************************************
|
||||
* MEMORY MANAGER
|
||||
******************************************************************************/
|
||||
void TL_MM_Init( TL_MM_Config_t *p_Config );
|
||||
void TL_MM_EvtDone( TL_EvtPacket_t * hcievt );
|
||||
|
||||
/******************************************************************************
|
||||
* TRACES
|
||||
******************************************************************************/
|
||||
void TL_TRACES_Init( void );
|
||||
void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt );
|
||||
|
||||
/******************************************************************************
|
||||
* MAC 802.15.4
|
||||
******************************************************************************/
|
||||
void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config );
|
||||
void TL_MAC_802_15_4_SendCmd( void );
|
||||
void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
|
||||
void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer );
|
||||
void TL_MAC_802_15_4_SendAck ( void );
|
||||
|
||||
/******************************************************************************
|
||||
* ZIGBEE
|
||||
******************************************************************************/
|
||||
void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config );
|
||||
void TL_ZIGBEE_SendM4RequestToM0( void );
|
||||
void TL_ZIGBEE_SendM4AckToM0Notify ( void );
|
||||
void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer );
|
||||
void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
|
||||
void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer );
|
||||
void TL_ZIGBEE_SendM4AckToM0Request(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*__TL_H */
|
||||
|
||||
@@ -0,0 +1,877 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file tl_mbox.c
|
||||
* @author MCD Application Team
|
||||
* @brief Transport layer for the mailbox interface
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_wpan_common.h"
|
||||
#include "hw.h"
|
||||
|
||||
#include "stm_list.h"
|
||||
#include "tl.h"
|
||||
#include "mbox_def.h"
|
||||
#include "tl_dbg_conf.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
TL_MB_MM_RELEASE_BUFFER,
|
||||
TL_MB_BLE_CMD,
|
||||
TL_MB_BLE_CMD_RSP,
|
||||
TL_MB_ACL_DATA,
|
||||
TL_MB_ACL_DATA_RSP,
|
||||
TL_MB_BLE_ASYNCH_EVT,
|
||||
TL_MB_SYS_CMD,
|
||||
TL_MB_SYS_CMD_RSP,
|
||||
TL_MB_SYS_ASYNCH_EVT,
|
||||
} TL_MB_PacketType_t;
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/**< reference table */
|
||||
PLACE_IN_SECTION("MAPPING_TABLE") static volatile MB_RefTable_t TL_RefTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_DeviceInfoTable_t TL_DeviceInfoTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleTable_t TL_BleTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ThreadTable_t TL_ThreadTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldTestsTable_t TL_LldTestsTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table;
|
||||
|
||||
/**< tables */
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue;
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue;
|
||||
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)];
|
||||
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue;
|
||||
PLACE_IN_SECTION("MB_MEM1") 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 );
|
||||
static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer);
|
||||
|
||||
/* Public Functions Definition ------------------------------------------------------*/
|
||||
|
||||
/******************************************************************************
|
||||
* GENERAL - refer to AN5289 for functions description.
|
||||
******************************************************************************/
|
||||
void TL_Enable( void )
|
||||
{
|
||||
HW_IPCC_Enable();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void TL_Init( void )
|
||||
{
|
||||
TL_RefTable.p_device_info_table = &TL_DeviceInfoTable;
|
||||
TL_RefTable.p_ble_table = &TL_BleTable;
|
||||
TL_RefTable.p_thread_table = &TL_ThreadTable;
|
||||
TL_RefTable.p_lld_tests_table = &TL_LldTestsTable;
|
||||
TL_RefTable.p_ble_lld_table = &TL_BleLldTable;
|
||||
TL_RefTable.p_sys_table = &TL_SysTable;
|
||||
TL_RefTable.p_mem_manager_table = &TL_MemManagerTable;
|
||||
TL_RefTable.p_traces_table = &TL_TracesTable;
|
||||
TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table;
|
||||
TL_RefTable.p_zigbee_table = &TL_Zigbee_Table;
|
||||
HW_IPCC_Init();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* BLE
|
||||
******************************************************************************/
|
||||
int32_t TL_BLE_Init( void* pConf )
|
||||
{
|
||||
MB_BleTable_t * p_bletable;
|
||||
|
||||
TL_BLE_InitConf_t *pInitHciConf = (TL_BLE_InitConf_t *) pConf;
|
||||
|
||||
LST_init_head (&EvtQueue);
|
||||
|
||||
p_bletable = TL_RefTable.p_ble_table;
|
||||
|
||||
p_bletable->pcmd_buffer = pInitHciConf->p_cmdbuffer;
|
||||
p_bletable->phci_acl_data_buffer = pInitHciConf->p_AclDataBuffer;
|
||||
p_bletable->pcs_buffer = (uint8_t*)CsBuffer;
|
||||
p_bletable->pevt_queue = (uint8_t*)&EvtQueue;
|
||||
|
||||
HW_IPCC_BLE_Init();
|
||||
|
||||
BLE_IoBusEvtCallBackFunction = pInitHciConf->IoBusEvtCallBack;
|
||||
BLE_IoBusAclDataTxAck = pInitHciConf->IoBusAclDataTxAck;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size )
|
||||
{
|
||||
(void)(buffer);
|
||||
(void)(size);
|
||||
|
||||
((TL_CmdPacket_t*)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE;
|
||||
|
||||
OutputDbgTrace(TL_MB_BLE_CMD, TL_RefTable.p_ble_table->pcmd_buffer);
|
||||
|
||||
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);
|
||||
|
||||
if ( ((phcievt->evtserial.evt.evtcode) == TL_BLEEVT_CS_OPCODE) || ((phcievt->evtserial.evt.evtcode) == TL_BLEEVT_CC_OPCODE ) )
|
||||
{
|
||||
OutputDbgTrace(TL_MB_BLE_CMD_RSP, (uint8_t*)phcievt);
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDbgTrace(TL_MB_BLE_ASYNCH_EVT, (uint8_t*)phcievt);
|
||||
}
|
||||
|
||||
BLE_IoBusEvtCallBackFunction(phcievt);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size )
|
||||
{
|
||||
(void)(buffer);
|
||||
(void)(size);
|
||||
|
||||
((TL_AclDataPacket_t *)(TL_RefTable.p_ble_table->phci_acl_data_buffer))->AclDataSerial.type = TL_ACL_DATA_PKT_TYPE;
|
||||
|
||||
OutputDbgTrace(TL_MB_ACL_DATA, TL_RefTable.p_ble_table->phci_acl_data_buffer);
|
||||
|
||||
HW_IPCC_BLE_SendAclData();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HW_IPCC_BLE_AclDataAckNot(void)
|
||||
{
|
||||
OutputDbgTrace(TL_MB_ACL_DATA_RSP, (uint8_t*)NULL);
|
||||
|
||||
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 )
|
||||
{
|
||||
(void)(buffer);
|
||||
(void)(size);
|
||||
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer))->cmdserial.type = TL_SYSCMD_PKT_TYPE;
|
||||
|
||||
OutputDbgTrace(TL_MB_SYS_CMD, TL_RefTable.p_sys_table->pcmd_buffer);
|
||||
|
||||
HW_IPCC_SYS_SendCmd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HW_IPCC_SYS_CmdEvtNot(void)
|
||||
{
|
||||
OutputDbgTrace(TL_MB_SYS_CMD_RSP, (uint8_t*)(TL_RefTable.p_sys_table->pcmd_buffer) );
|
||||
|
||||
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);
|
||||
|
||||
OutputDbgTrace(TL_MB_SYS_ASYNCH_EVT, (uint8_t*)p_evt );
|
||||
|
||||
SYS_EVT_IoBusCallBackFunction( p_evt );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* THREAD
|
||||
******************************************************************************/
|
||||
#ifdef THREAD_WB
|
||||
void TL_THREAD_Init( TL_TH_Config_t *p_Config )
|
||||
{
|
||||
MB_ThreadTable_t * p_thread_table;
|
||||
|
||||
p_thread_table = TL_RefTable.p_thread_table;
|
||||
|
||||
p_thread_table->clicmdrsp_buffer = p_Config->p_ThreadCliRspBuffer;
|
||||
p_thread_table->otcmdrsp_buffer = p_Config->p_ThreadOtCmdRspBuffer;
|
||||
p_thread_table->notack_buffer = p_Config->p_ThreadNotAckBuffer;
|
||||
p_thread_table->clinot_buffer = p_Config->p_ThreadCliNotBuffer;
|
||||
|
||||
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->clinot_buffer) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
|
||||
__WEAK void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ){};
|
||||
__WEAK void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ){};
|
||||
|
||||
#endif /* THREAD_WB */
|
||||
|
||||
/******************************************************************************
|
||||
* LLD TESTS
|
||||
******************************************************************************/
|
||||
#ifdef LLD_TESTS_WB
|
||||
void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config )
|
||||
{
|
||||
MB_LldTestsTable_t * p_lld_tests_table;
|
||||
|
||||
p_lld_tests_table = TL_RefTable.p_lld_tests_table;
|
||||
p_lld_tests_table->clicmdrsp_buffer = p_Config->p_LldTestsCliCmdRspBuffer;
|
||||
p_lld_tests_table->m0cmd_buffer = p_Config->p_LldTestsM0CmdBuffer;
|
||||
HW_IPCC_LLDTESTS_Init();
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_LLDTESTS_SendCliCmd( void )
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE;
|
||||
HW_IPCC_LLDTESTS_SendCliCmd();
|
||||
return;
|
||||
}
|
||||
|
||||
void HW_IPCC_LLDTESTS_ReceiveCliRsp( void )
|
||||
{
|
||||
TL_LLDTESTS_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer) );
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_LLDTESTS_SendCliRspAck( void )
|
||||
{
|
||||
HW_IPCC_LLDTESTS_SendCliRspAck();
|
||||
return;
|
||||
}
|
||||
|
||||
void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void )
|
||||
{
|
||||
TL_LLDTESTS_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->m0cmd_buffer) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void TL_LLDTESTS_SendM0CmdAck( void )
|
||||
{
|
||||
HW_IPCC_LLDTESTS_SendM0CmdAck();
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){};
|
||||
__WEAK void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){};
|
||||
#endif /* LLD_TESTS_WB */
|
||||
|
||||
/******************************************************************************
|
||||
* BLE LLD
|
||||
******************************************************************************/
|
||||
#ifdef BLE_LLD_WB
|
||||
void TL_BLE_LLD_Init( TL_BLE_LLD_Config_t *p_Config )
|
||||
{
|
||||
MB_BleLldTable_t * p_ble_lld_table;
|
||||
|
||||
p_ble_lld_table = TL_RefTable.p_ble_lld_table;
|
||||
p_ble_lld_table->cmdrsp_buffer = p_Config->p_BleLldCmdRspBuffer;
|
||||
p_ble_lld_table->m0cmd_buffer = p_Config->p_BleLldM0CmdBuffer;
|
||||
HW_IPCC_BLE_LLD_Init();
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_BLE_LLD_SendCliCmd( void )
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE;
|
||||
HW_IPCC_BLE_LLD_SendCliCmd();
|
||||
return;
|
||||
}
|
||||
|
||||
void HW_IPCC_BLE_LLD_ReceiveCliRsp( void )
|
||||
{
|
||||
TL_BLE_LLD_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer) );
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_BLE_LLD_SendCliRspAck( void )
|
||||
{
|
||||
HW_IPCC_BLE_LLD_SendCliRspAck();
|
||||
return;
|
||||
}
|
||||
|
||||
void HW_IPCC_BLE_LLD_ReceiveM0Cmd( void )
|
||||
{
|
||||
TL_BLE_LLD_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_ble_lld_table->m0cmd_buffer) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void TL_BLE_LLD_SendM0CmdAck( void )
|
||||
{
|
||||
HW_IPCC_BLE_LLD_SendM0CmdAck();
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void TL_BLE_LLD_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){};
|
||||
__WEAK void TL_BLE_LLD_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){};
|
||||
|
||||
/* Transparent Mode */
|
||||
void TL_BLE_LLD_SendCmd( void )
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE;
|
||||
HW_IPCC_BLE_LLD_SendCmd();
|
||||
return;
|
||||
}
|
||||
|
||||
void HW_IPCC_BLE_LLD_ReceiveRsp( void )
|
||||
{
|
||||
TL_BLE_LLD_ReceiveRsp( (TL_CmdPacket_t*)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer) );
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_BLE_LLD_SendRspAck( void )
|
||||
{
|
||||
HW_IPCC_BLE_LLD_SendRspAck();
|
||||
return;
|
||||
}
|
||||
#endif /* BLE_LLD_WB */
|
||||
|
||||
#ifdef MAC_802_15_4_WB
|
||||
/******************************************************************************
|
||||
* MAC 802.15.4
|
||||
******************************************************************************/
|
||||
void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config )
|
||||
{
|
||||
MB_Mac_802_15_4_t * p_mac_802_15_4_table;
|
||||
|
||||
p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table;
|
||||
|
||||
p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer;
|
||||
p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer;
|
||||
|
||||
HW_IPCC_MAC_802_15_4_Init();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_MAC_802_15_4_SendCmd( void )
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE;
|
||||
|
||||
HW_IPCC_MAC_802_15_4_SendCmd();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_MAC_802_15_4_SendAck ( void )
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
|
||||
|
||||
HW_IPCC_MAC_802_15_4_SendAck();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void HW_IPCC_MAC_802_15_4_CmdEvtNot(void)
|
||||
{
|
||||
TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void HW_IPCC_MAC_802_15_4_EvtNot( void )
|
||||
{
|
||||
TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
|
||||
__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){};
|
||||
#endif
|
||||
|
||||
#ifdef ZIGBEE_WB
|
||||
/******************************************************************************
|
||||
* ZIGBEE
|
||||
******************************************************************************/
|
||||
void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config )
|
||||
{
|
||||
MB_ZigbeeTable_t * p_zigbee_table;
|
||||
|
||||
p_zigbee_table = TL_RefTable.p_zigbee_table;
|
||||
p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer;
|
||||
p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer;
|
||||
p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer;
|
||||
|
||||
HW_IPCC_ZIGBEE_Init();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Zigbee M4 to M0 Request */
|
||||
void TL_ZIGBEE_SendM4RequestToM0( void )
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE;
|
||||
|
||||
HW_IPCC_ZIGBEE_SendM4RequestToM0();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Used to receive an ACK from the M0 */
|
||||
void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void)
|
||||
{
|
||||
TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Zigbee notification from M0 to M4 */
|
||||
void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void )
|
||||
{
|
||||
TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send an ACK to the M0 for a Notification */
|
||||
void TL_ZIGBEE_SendM4AckToM0Notify ( void )
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
|
||||
|
||||
HW_IPCC_ZIGBEE_SendM4AckToM0Notify();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Zigbee M0 to M4 Request */
|
||||
void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void )
|
||||
{
|
||||
TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send an ACK to the M0 for a Request */
|
||||
void TL_ZIGBEE_SendM4AckToM0Request(void)
|
||||
{
|
||||
((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
|
||||
|
||||
HW_IPCC_ZIGBEE_SendM4AckToM0Request();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
|
||||
__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* MEMORY MANAGER
|
||||
******************************************************************************/
|
||||
void TL_MM_Init( TL_MM_Config_t *p_Config )
|
||||
{
|
||||
static MB_MemManagerTable_t * p_mem_manager_table;
|
||||
|
||||
LST_init_head (&FreeBufQueue);
|
||||
LST_init_head (&LocalFreeBufQueue);
|
||||
|
||||
p_mem_manager_table = TL_RefTable.p_mem_manager_table;
|
||||
|
||||
p_mem_manager_table->blepool = p_Config->p_AsynchEvtPool;
|
||||
p_mem_manager_table->blepoolsize = p_Config->AsynchEvtPoolSize;
|
||||
p_mem_manager_table->pevt_free_buffer_queue = (uint8_t*)&FreeBufQueue;
|
||||
p_mem_manager_table->spare_ble_buffer = p_Config->p_BleSpareEvtBuffer;
|
||||
p_mem_manager_table->spare_sys_buffer = p_Config->p_SystemSpareEvtBuffer;
|
||||
p_mem_manager_table->traces_evt_pool = p_Config->p_TracesEvtPool;
|
||||
p_mem_manager_table->tracespoolsize = p_Config->TracesEvtPoolSize;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TL_MM_EvtDone(TL_EvtPacket_t * phcievt)
|
||||
{
|
||||
LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt);
|
||||
|
||||
OutputDbgTrace(TL_MB_MM_RELEASE_BUFFER, (uint8_t*)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 )
|
||||
{
|
||||
(void)(hcievt);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* DEBUG INFORMATION
|
||||
******************************************************************************/
|
||||
static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer)
|
||||
{
|
||||
TL_EvtPacket_t *p_evt_packet;
|
||||
TL_CmdPacket_t *p_cmd_packet;
|
||||
TL_AclDataPacket_t *p_acldata_packet;
|
||||
TL_EvtSerial_t *p_cmd_rsp_packet;
|
||||
|
||||
switch(packet_type)
|
||||
{
|
||||
case TL_MB_MM_RELEASE_BUFFER:
|
||||
p_evt_packet = (TL_EvtPacket_t*)buffer;
|
||||
switch(p_evt_packet->evtserial.evt.evtcode)
|
||||
{
|
||||
case TL_BLEEVT_CS_OPCODE:
|
||||
TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode);
|
||||
TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet);
|
||||
break;
|
||||
|
||||
case TL_BLEEVT_CC_OPCODE:
|
||||
TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode);
|
||||
TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet);
|
||||
break;
|
||||
|
||||
case TL_BLEEVT_VS_OPCODE:
|
||||
TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_MM_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode);
|
||||
TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet);
|
||||
break;
|
||||
|
||||
default:
|
||||
TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet);
|
||||
break;
|
||||
}
|
||||
|
||||
TL_MM_DBG_MSG("\r\n");
|
||||
break;
|
||||
|
||||
case TL_MB_BLE_CMD:
|
||||
p_cmd_packet = (TL_CmdPacket_t*)buffer;
|
||||
TL_HCI_CMD_DBG_MSG("ble cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode);
|
||||
if(p_cmd_packet->cmdserial.cmd.plen != 0)
|
||||
{
|
||||
TL_HCI_CMD_DBG_MSG(" payload:");
|
||||
TL_HCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, "");
|
||||
}
|
||||
TL_HCI_CMD_DBG_MSG("\r\n");
|
||||
|
||||
TL_HCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE);
|
||||
break;
|
||||
|
||||
case TL_MB_ACL_DATA:
|
||||
(void)p_acldata_packet;
|
||||
p_acldata_packet = (TL_AclDataPacket_t*)buffer;
|
||||
TL_HCI_CMD_DBG_MSG("acl_data: 0x%02X", p_acldata_packet->AclDataSerial.type);
|
||||
TL_HCI_CMD_DBG_MSG("acl_data: 0x%04X", p_acldata_packet->AclDataSerial.handle);
|
||||
TL_HCI_CMD_DBG_MSG("acl_data: 0x%04X", p_acldata_packet->AclDataSerial.length);
|
||||
/*if(p_acldata_packet->AclDataSerial.length != 0)
|
||||
{
|
||||
TL_HCI_CMD_DBG_MSG(" payload:");
|
||||
TL_HCI_CMD_DBG_BUF(p_acldata_packet->AclDataSerial.acl_data, p_acldata_packet->AclDataSerial.length, "");
|
||||
}*/
|
||||
TL_HCI_CMD_DBG_MSG("\r\n");
|
||||
/*TL_HCI_CMD_DBG_RAW(&p_acldata_packet->AclDataSerial, p_acldata_packet->AclDataSerial.length+TL_CMD_HDR_SIZE);*/
|
||||
break;
|
||||
|
||||
case TL_MB_ACL_DATA_RSP:
|
||||
TL_HCI_CMD_DBG_MSG(" ACL Data Tx Ack received");
|
||||
TL_HCI_CMD_DBG_MSG("\r\n");
|
||||
break;
|
||||
|
||||
case TL_MB_BLE_CMD_RSP:
|
||||
p_evt_packet = (TL_EvtPacket_t*)buffer;
|
||||
switch(p_evt_packet->evtserial.evt.evtcode)
|
||||
{
|
||||
case TL_BLEEVT_CS_OPCODE:
|
||||
TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode);
|
||||
TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd);
|
||||
TL_HCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->status);
|
||||
break;
|
||||
|
||||
case TL_BLEEVT_CC_OPCODE:
|
||||
TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode);
|
||||
TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd);
|
||||
TL_HCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[0]);
|
||||
if((p_evt_packet->evtserial.evt.plen-4) != 0)
|
||||
{
|
||||
TL_HCI_CMD_DBG_MSG(" payload:");
|
||||
TL_HCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, "");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
TL_HCI_CMD_DBG_MSG("unknown ble rsp received: %02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
break;
|
||||
}
|
||||
|
||||
TL_HCI_CMD_DBG_MSG("\r\n");
|
||||
|
||||
TL_HCI_CMD_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE);
|
||||
break;
|
||||
|
||||
case TL_MB_BLE_ASYNCH_EVT:
|
||||
p_evt_packet = (TL_EvtPacket_t*)buffer;
|
||||
if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE)
|
||||
{
|
||||
TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
if((p_evt_packet->evtserial.evt.plen) != 0)
|
||||
{
|
||||
TL_HCI_EVT_DBG_MSG(" payload:");
|
||||
TL_HCI_EVT_DBG_BUF(p_evt_packet->evtserial.evt.payload, p_evt_packet->evtserial.evt.plen, "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_HCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode);
|
||||
if((p_evt_packet->evtserial.evt.plen-2) != 0)
|
||||
{
|
||||
TL_HCI_EVT_DBG_MSG(" payload:");
|
||||
TL_HCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, "");
|
||||
}
|
||||
}
|
||||
|
||||
TL_HCI_EVT_DBG_MSG("\r\n");
|
||||
|
||||
TL_HCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE);
|
||||
break;
|
||||
|
||||
case TL_MB_SYS_CMD:
|
||||
p_cmd_packet = (TL_CmdPacket_t*)buffer;
|
||||
|
||||
TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode);
|
||||
|
||||
if(p_cmd_packet->cmdserial.cmd.plen != 0)
|
||||
{
|
||||
TL_SHCI_CMD_DBG_MSG(" payload:");
|
||||
TL_SHCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, "");
|
||||
}
|
||||
TL_SHCI_CMD_DBG_MSG("\r\n");
|
||||
|
||||
TL_SHCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE);
|
||||
break;
|
||||
|
||||
case TL_MB_SYS_CMD_RSP:
|
||||
p_cmd_rsp_packet = (TL_EvtSerial_t*)buffer;
|
||||
switch(p_cmd_rsp_packet->evt.evtcode)
|
||||
{
|
||||
case TL_BLEEVT_CC_OPCODE:
|
||||
TL_SHCI_CMD_DBG_MSG("sys rsp: 0x%02X", p_cmd_rsp_packet->evt.evtcode);
|
||||
TL_SHCI_CMD_DBG_MSG(" cmd opcode: 0x%02X", ((TL_CcEvt_t*)(p_cmd_rsp_packet->evt.payload))->cmdcode);
|
||||
TL_SHCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t*)(p_cmd_rsp_packet->evt.payload))->payload[0]);
|
||||
if((p_cmd_rsp_packet->evt.plen-4) != 0)
|
||||
{
|
||||
TL_SHCI_CMD_DBG_MSG(" payload:");
|
||||
TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_cmd_rsp_packet->evt.payload))->payload[1], p_cmd_rsp_packet->evt.plen-4, "");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_cmd_rsp_packet->evt.evtcode);
|
||||
break;
|
||||
}
|
||||
|
||||
TL_SHCI_CMD_DBG_MSG("\r\n");
|
||||
|
||||
TL_SHCI_CMD_DBG_RAW(&p_cmd_rsp_packet->evt, p_cmd_rsp_packet->evt.plen+TL_EVT_HDR_SIZE);
|
||||
break;
|
||||
|
||||
case TL_MB_SYS_ASYNCH_EVT:
|
||||
p_evt_packet = (TL_EvtPacket_t*)buffer;
|
||||
if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE)
|
||||
{
|
||||
TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
}
|
||||
else
|
||||
{
|
||||
TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode);
|
||||
TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode);
|
||||
if((p_evt_packet->evtserial.evt.plen-2) != 0)
|
||||
{
|
||||
TL_SHCI_EVT_DBG_MSG(" payload:");
|
||||
TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, "");
|
||||
}
|
||||
}
|
||||
|
||||
TL_SHCI_EVT_DBG_MSG("\r\n");
|
||||
|
||||
TL_SHCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32_wpan_common.h
|
||||
* @author MCD Application Team
|
||||
* @brief Common file to utilities
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32_WPAN_COMMON_H
|
||||
#define __STM32_WPAN_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined ( __CC_ARM )||defined (__ARMCC_VERSION)
|
||||
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||
#define __STATIC_INLINE static __inline
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
|
||||
#define __STATIC_INLINE static inline
|
||||
#elif defined ( __GNUC__ )
|
||||
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include "cmsis_compiler.h"
|
||||
|
||||
/* -------------------------------- *
|
||||
* Basic definitions *
|
||||
* -------------------------------- */
|
||||
|
||||
#undef NULL
|
||||
#define NULL 0U
|
||||
|
||||
#undef FALSE
|
||||
#define FALSE 0U
|
||||
|
||||
#undef TRUE
|
||||
#define TRUE (!0U)
|
||||
|
||||
/* -------------------------------- *
|
||||
* Critical Section definition *
|
||||
* -------------------------------- */
|
||||
#undef BACKUP_PRIMASK
|
||||
#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
|
||||
|
||||
#undef DISABLE_IRQ
|
||||
#define DISABLE_IRQ() __disable_irq()
|
||||
|
||||
#undef RESTORE_PRIMASK
|
||||
#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
|
||||
|
||||
/* -------------------------------- *
|
||||
* Macro delimiters *
|
||||
* -------------------------------- */
|
||||
#undef M_BEGIN
|
||||
#define M_BEGIN do {
|
||||
|
||||
#undef M_END
|
||||
#define M_END } while(0)
|
||||
|
||||
/* -------------------------------- *
|
||||
* Some useful macro definitions *
|
||||
* -------------------------------- */
|
||||
#undef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
#undef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#undef MODINC
|
||||
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
|
||||
|
||||
#undef MODDEC
|
||||
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
|
||||
|
||||
#undef MODADD
|
||||
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
|
||||
|
||||
#undef MODSUB
|
||||
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
|
||||
|
||||
#undef ALIGN
|
||||
#ifdef WIN32
|
||||
#define ALIGN(n)
|
||||
#else
|
||||
#define ALIGN(n) __attribute__((aligned(n)))
|
||||
#endif
|
||||
|
||||
#undef PAUSE
|
||||
#define PAUSE( t ) M_BEGIN \
|
||||
volatile int _i; \
|
||||
for ( _i = t; _i > 0; _i -- ); \
|
||||
M_END
|
||||
#undef DIVF
|
||||
#define DIVF( x, y ) ((x)/(y))
|
||||
|
||||
#undef DIVC
|
||||
#define DIVC( x, y ) (((x)+(y)-1)/(y))
|
||||
|
||||
#undef DIVR
|
||||
#define DIVR( x, y ) (((x)+((y)/2))/(y))
|
||||
|
||||
#undef SHRR
|
||||
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
|
||||
|
||||
#undef BITN
|
||||
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
|
||||
|
||||
#undef BITNSET
|
||||
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
|
||||
|
||||
/* -------------------------------- *
|
||||
* Section attribute *
|
||||
* -------------------------------- */
|
||||
#undef PLACE_IN_SECTION
|
||||
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
|
||||
|
||||
/* ----------------------------------- *
|
||||
* Packed usage (compiler dependent) *
|
||||
* ----------------------------------- */
|
||||
#undef PACKED__
|
||||
#undef PACKED_STRUCT
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
#if defined ( __GNUC__ )
|
||||
/* GNU extension */
|
||||
#define PACKED__ __attribute__((packed))
|
||||
#define PACKED_STRUCT struct PACKED__
|
||||
#elif 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
|
||||
#else
|
||||
#define PACKED_STRUCT __packed struct
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__STM32_WPAN_COMMON_H */
|
||||
@@ -0,0 +1,360 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dbg_trace.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the Interface with BLE Drivers functions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "utilities_common.h"
|
||||
#include "stm_queue.h"
|
||||
#include "dbg_trace.h"
|
||||
|
||||
/* Definition of the function */
|
||||
#if !defined(__GNUC__) /* SW4STM32 */
|
||||
size_t __write(int handle, const unsigned char * buf, size_t bufSize);
|
||||
#endif
|
||||
|
||||
/** @addtogroup TRACE
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup TRACE_LOG
|
||||
* @brief TRACE Logging functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/** @defgroup TRACE Log private typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/** @defgroup TRACE Log private defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup TRACE Log private macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/** @defgroup TRACE Log private variables
|
||||
* @{
|
||||
*/
|
||||
#if (( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 ))
|
||||
#if (DBG_TRACE_USE_CIRCULAR_QUEUE != 0)
|
||||
static queue_t MsgDbgTraceQueue;
|
||||
static uint8_t MsgDbgTraceQueueBuff[DBG_TRACE_MSG_QUEUE_SIZE];
|
||||
#endif
|
||||
__IO ITStatus DbgTracePeripheralReady = SET;
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Global variables ----------------------------------------------------------*/
|
||||
/** @defgroup TRACE Log Global variable
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/** @defgroup TRACE Log private function prototypes
|
||||
* @{
|
||||
*/
|
||||
#if (( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 ))
|
||||
static void DbgTrace_TxCpltCallback(void);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Private Functions Definition ------------------------------------------------------*/
|
||||
/** @defgroup TRACE Log Private function
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* Functions Definition ------------------------------------------------------*/
|
||||
/** @defgroup TRACE Log APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief DbgTraceGetFileName: Return filename string extracted from full path information
|
||||
* @param *fullPath Fullpath string (path + filename)
|
||||
* @retval char* Pointer on filename string
|
||||
*/
|
||||
|
||||
const char *DbgTraceGetFileName(const char *fullpath)
|
||||
{
|
||||
const char *ret = fullpath;
|
||||
|
||||
if (strrchr(fullpath, '\\') != NULL)
|
||||
{
|
||||
ret = strrchr(fullpath, '\\') + 1;
|
||||
}
|
||||
else if (strrchr(fullpath, '/') != NULL)
|
||||
{
|
||||
ret = strrchr(fullpath, '/') + 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DbgTraceBuffer: Output buffer content information to output Stream
|
||||
* @param *pBuffer Pointer on buffer to be output
|
||||
* @param u32Length buffer Size
|
||||
* @paramt strFormat string as expected by "printf" function. Used to desrcibe buffer content information.
|
||||
* @param ... Parameters to be "formatted" in strFormat string (if any)
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void DbgTraceBuffer(const void *pBuffer, uint32_t u32Length, const char *strFormat, ...)
|
||||
{
|
||||
va_list vaArgs;
|
||||
uint32_t u32Index;
|
||||
va_start(vaArgs, strFormat);
|
||||
vprintf(strFormat, vaArgs);
|
||||
va_end(vaArgs);
|
||||
for (u32Index = 0; u32Index < u32Length; u32Index ++)
|
||||
{
|
||||
printf(" %02X", ((const uint8_t *) pBuffer)[u32Index]);
|
||||
}
|
||||
}
|
||||
|
||||
#if (( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 ))
|
||||
/**
|
||||
* @brief DBG_TRACE USART Tx Transfer completed callback
|
||||
* @param UartHandle: UART handle.
|
||||
* @note Indicate the end of the transmission of a DBG_TRACE trace buffer to DBG_TRACE USART. If queue
|
||||
* contains new trace data to transmit, start a new transmission.
|
||||
* @retval None
|
||||
*/
|
||||
static void DbgTrace_TxCpltCallback(void)
|
||||
{
|
||||
#if (DBG_TRACE_USE_CIRCULAR_QUEUE != 0)
|
||||
uint8_t* buf;
|
||||
uint16_t bufSize;
|
||||
|
||||
BACKUP_PRIMASK();
|
||||
|
||||
DISABLE_IRQ(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||
/* Remove element just sent to UART */
|
||||
CircularQueue_Remove(&MsgDbgTraceQueue,&bufSize);
|
||||
|
||||
/* Sense if new data to be sent */
|
||||
buf=CircularQueue_Sense(&MsgDbgTraceQueue,&bufSize);
|
||||
|
||||
|
||||
if ( buf != NULL)
|
||||
{
|
||||
RESTORE_PRIMASK();
|
||||
DbgOutputTraces((uint8_t*)buf, bufSize, DbgTrace_TxCpltCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTracePeripheralReady = SET;
|
||||
RESTORE_PRIMASK();
|
||||
}
|
||||
|
||||
#else
|
||||
BACKUP_PRIMASK();
|
||||
|
||||
DISABLE_IRQ(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||
|
||||
DbgTracePeripheralReady = SET;
|
||||
|
||||
RESTORE_PRIMASK();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void DbgTraceInit( void )
|
||||
{
|
||||
#if (( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 ))
|
||||
DbgOutputInit();
|
||||
#if (DBG_TRACE_USE_CIRCULAR_QUEUE != 0)
|
||||
CircularQueue_Init(&MsgDbgTraceQueue, MsgDbgTraceQueueBuff, DBG_TRACE_MSG_QUEUE_SIZE, 0, CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG);
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#if (( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 ))
|
||||
#if defined(__GNUC__) /* SW4STM32 (GCC) */
|
||||
/**
|
||||
* @brief _write: override the __write standard lib function to redirect printf to USART.
|
||||
* @param handle output handle (STDIO, STDERR...)
|
||||
* @param buf buffer to write
|
||||
* @param bufsize buffer size
|
||||
* @param ...: arguments to be formatted in format string
|
||||
* @retval none
|
||||
*/
|
||||
size_t _write(int handle, const unsigned char * buf, size_t bufSize)
|
||||
{
|
||||
return ( DbgTraceWrite(handle, buf, bufSize) );
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* @brief __write: override the _write standard lib function to redirect printf to USART.
|
||||
* @param handle output handle (STDIO, STDERR...)
|
||||
* @param buf buffer to write
|
||||
* @param bufsize buffer size
|
||||
* @param ...: arguments to be formatted in format string
|
||||
* @retval none
|
||||
*/
|
||||
size_t __write(int handle, const unsigned char * buf, size_t bufSize)
|
||||
{
|
||||
return ( DbgTraceWrite(handle, buf, bufSize) );
|
||||
}
|
||||
#endif /* #if defined(__GNUC__) */
|
||||
|
||||
/**
|
||||
* @brief Override the standard lib function to redirect printf to USART.
|
||||
* @param handle output handle (STDIO, STDERR...)
|
||||
* @param buf buffer to write
|
||||
* @param bufsize buffer size
|
||||
* @retval Number of elements written
|
||||
*/
|
||||
size_t DbgTraceWrite(int handle, const unsigned char * buf, size_t bufSize)
|
||||
{
|
||||
size_t chars_written = 0;
|
||||
uint8_t* buffer;
|
||||
|
||||
BACKUP_PRIMASK();
|
||||
|
||||
/* Ignore flushes */
|
||||
if ( handle == -1 )
|
||||
{
|
||||
chars_written = ( size_t ) 0;
|
||||
}
|
||||
/* Only allow stdout/stderr output */
|
||||
else if ( ( handle != 1 ) && ( handle != 2 ) )
|
||||
{
|
||||
chars_written = ( size_t ) - 1;
|
||||
}
|
||||
/* Parameters OK, call the low-level character output routine */
|
||||
else if (bufSize != 0)
|
||||
{
|
||||
chars_written = bufSize;
|
||||
/* If queue emepty and TX free, send directly */
|
||||
/* CS Start */
|
||||
|
||||
#if (DBG_TRACE_USE_CIRCULAR_QUEUE != 0)
|
||||
DISABLE_IRQ(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||
buffer=CircularQueue_Add(&MsgDbgTraceQueue,(uint8_t*)buf, bufSize,1);
|
||||
if (buffer && DbgTracePeripheralReady)
|
||||
{
|
||||
DbgTracePeripheralReady = RESET;
|
||||
RESTORE_PRIMASK();
|
||||
DbgOutputTraces((uint8_t*)buffer, bufSize, DbgTrace_TxCpltCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
RESTORE_PRIMASK();
|
||||
}
|
||||
#else
|
||||
DISABLE_IRQ(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
|
||||
DbgTracePeripheralReady = RESET;
|
||||
RESTORE_PRIMASK();
|
||||
|
||||
DbgOutputTraces((uint8_t*)buf, bufSize, DbgTrace_TxCpltCallback);
|
||||
while (!DbgTracePeripheralReady);
|
||||
#endif
|
||||
/* CS END */
|
||||
}
|
||||
return ( chars_written );
|
||||
}
|
||||
|
||||
#if defined ( __CC_ARM ) || defined (__ARMCC_VERSION) /* Keil */
|
||||
|
||||
/**
|
||||
Called from assert() and prints a message on stderr and calls abort().
|
||||
|
||||
\param[in] expr assert expression that was not TRUE
|
||||
\param[in] file source file of the assertion
|
||||
\param[in] line source line of the assertion
|
||||
*/
|
||||
__attribute__((weak,noreturn))
|
||||
void __aeabi_assert (const char *expr, const char *file, int line) {
|
||||
char str[12], *p;
|
||||
|
||||
fputs("*** assertion failed: ", stderr);
|
||||
fputs(expr, stderr);
|
||||
fputs(", file ", stderr);
|
||||
fputs(file, stderr);
|
||||
fputs(", line ", stderr);
|
||||
|
||||
p = str + sizeof(str);
|
||||
*--p = '\0';
|
||||
*--p = '\n';
|
||||
while (line > 0) {
|
||||
*--p = '0' + (line % 10);
|
||||
line /= 10;
|
||||
}
|
||||
fputs(p, stderr);
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
/* For KEIL re-implement our own version of fputc */
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
/* temp char avoids endianness issue */
|
||||
char tempch = ch;
|
||||
/* Write one character to Debug Circular Queue */
|
||||
DbgTraceWrite(1U, (const unsigned char *) &tempch, 1);
|
||||
return ch;
|
||||
}
|
||||
|
||||
#endif /* #if defined ( __CC_ARM ) */
|
||||
|
||||
#endif /* #if (( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 )) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dbg_trace.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for dbg_trace.c
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DBG_TRACE_H
|
||||
#define __DBG_TRACE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
#if ( ( CFG_DEBUG_TRACE_FULL != 0 ) || ( CFG_DEBUG_TRACE_LIGHT != 0 ) )
|
||||
#define PRINT_LOG_BUFF_DBG(...) DbgTraceBuffer(__VA_ARGS__)
|
||||
#if ( CFG_DEBUG_TRACE_FULL != 0 )
|
||||
#define PRINT_MESG_DBG(...) do{printf("\r\n [%s][%s][%d] ", DbgTraceGetFileName(__FILE__),__FUNCTION__,__LINE__);printf(__VA_ARGS__);}while(0);
|
||||
#else
|
||||
#define PRINT_MESG_DBG printf
|
||||
#endif
|
||||
#else
|
||||
#define PRINT_LOG_BUFF_DBG(...)
|
||||
#define PRINT_MESG_DBG(...)
|
||||
#endif
|
||||
|
||||
#define PRINT_NO_MESG(...)
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Request the user to initialize the peripheral to output traces
|
||||
*
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
extern void DbgOutputInit( void );
|
||||
|
||||
/**
|
||||
* @brief Request the user to sent the traces on the output peripheral
|
||||
*
|
||||
* @param p_data: Address of the buffer to be sent
|
||||
* @param size: Size of the data to be sent
|
||||
* @param cb: Function to be called when the data has been sent
|
||||
* @retval None
|
||||
*/
|
||||
extern void DbgOutputTraces( uint8_t *p_data, uint16_t size, void (*cb)(void) );
|
||||
|
||||
/**
|
||||
* @brief DbgTraceInit Initialize Logging feature.
|
||||
*
|
||||
* @param: None
|
||||
* @retval: None
|
||||
*/
|
||||
void DbgTraceInit( void );
|
||||
|
||||
/**********************************************************************************************************************/
|
||||
/** This function outputs into the log the buffer (in hex) and the provided format string and arguments.
|
||||
***********************************************************************************************************************
|
||||
*
|
||||
* @param pBuffer Buffer to be output into the logs.
|
||||
* @param u32Length Length of the buffer, in bytes.
|
||||
* @param strFormat The format string in printf() style.
|
||||
* @param ... Arguments of the format string.
|
||||
*
|
||||
**********************************************************************************************************************/
|
||||
void DbgTraceBuffer( const void *pBuffer , uint32_t u32Length , const char *strFormat , ... );
|
||||
|
||||
const char *DbgTraceGetFileName( const char *fullpath );
|
||||
|
||||
/**
|
||||
* @brief Override the standard lib function to redirect printf to USART.
|
||||
* @param handle output handle (STDIO, STDERR...)
|
||||
* @param buf buffer to write
|
||||
* @param bufsize buffer size
|
||||
* @retval Number of elements written
|
||||
*/
|
||||
size_t DbgTraceWrite(int handle, const unsigned char * buf, size_t bufSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__DBG_TRACE_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file otp.c
|
||||
* @author MCD Application Team
|
||||
* @brief OTP manager
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* 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 ;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file otp.h
|
||||
* @author MCD Application Team
|
||||
* @brief OTP manager interface
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* 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 */
|
||||
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm_list.c
|
||||
* @author MCD Application Team
|
||||
* @brief TCircular Linked List Implementation.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* 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,63 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm_list.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header file for linked list library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _STM_LIST_H_
|
||||
#define _STM_LIST_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_wpan_common.h"
|
||||
|
||||
typedef PACKED_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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STM_LIST_H_ */
|
||||
@@ -0,0 +1,383 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm_queue.c
|
||||
* @author MCD Application Team
|
||||
* @brief Queue management
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "utilities_common.h"
|
||||
|
||||
#include "stm_queue.h"
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private typedef -------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
#define MOD(X,Y) (((X) >= (Y)) ? ((X)-(Y)) : (X))
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Global variables ----------------------------------------------------------*/
|
||||
/* Extern variables ----------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* Public functions ----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Initilaiilze queue structure .
|
||||
* @note This function is used to initialize the global queue structure.
|
||||
* @param q: pointer on queue structure to be initialised
|
||||
* @param queueBuffer: pointer on Queue Buffer
|
||||
* @param queueSize: Size of Queue Buffer
|
||||
* @param elementSize: Size of an element in the queue. if =0, the queue will manage variable sizze elements
|
||||
* @retval always 0
|
||||
*/
|
||||
int CircularQueue_Init(queue_t *q, uint8_t* queueBuffer, uint32_t queueSize, uint16_t elementSize, uint8_t optionFlags)
|
||||
{
|
||||
q->qBuff = queueBuffer;
|
||||
q->first = 0;
|
||||
q->last = 0; /* queueSize-1; */
|
||||
q->byteCount = 0;
|
||||
q->elementCount = 0;
|
||||
q->queueMaxSize = queueSize;
|
||||
q->elementSize = elementSize;
|
||||
q->optionFlags = optionFlags;
|
||||
|
||||
if ((optionFlags & CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG) && q-> elementSize)
|
||||
{
|
||||
/* can not deal with splitting at the end of buffer with fixed size element */
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add element to the queue .
|
||||
* @note This function is used to add one or more element(s) to the Circular Queue .
|
||||
* @param q: pointer on queue structure to be handled
|
||||
* @param X; pointer on element(s) to be added
|
||||
* @param elementSize: Size of element to be added to the queue. Only used if the queue manage variable size elements
|
||||
* @param nbElements: number of elements in the in buffer pointed by x
|
||||
* @retval pointer on last element just added to the queue, NULL if the element to be added do not fit in the queue (too big)
|
||||
*/
|
||||
uint8_t* CircularQueue_Add(queue_t *q, uint8_t* x, uint16_t elementSize, uint32_t nbElements)
|
||||
{
|
||||
|
||||
uint8_t* ptr = NULL; /* fct return ptr to the element freshly added, if no room fct return NULL */
|
||||
uint16_t curElementSize = 0; /* the size of the element currently stored at q->last position */
|
||||
uint8_t elemSizeStorageRoom = 0 ; /* Indicate the header (which contain only size) of element in case of varaibale size element (q->elementsize == 0) */
|
||||
uint32_t curBuffPosition; /* the current position in the queue buffer */
|
||||
uint32_t i; /* loop counter */
|
||||
uint32_t NbBytesToCopy = 0, NbCopiedBytes = 0 ; /* Indicators for copying bytes in queue */
|
||||
uint32_t eob_free_size; /* Eof End of Quque Buffer Free Size */
|
||||
uint8_t wrap_will_occur = 0; /* indicate if a wrap around will occurs */
|
||||
uint8_t wrapped_element_eob_size; /* In case of Wrap around, indicate size of parta of element that fit at thened of the queuue buffer */
|
||||
uint16_t overhead = 0; /* In case of CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG or CIRCULAR_QUEUE_NO_WRAP_FLAG options,
|
||||
indcate the size overhead that will be generated by adding the element with wrap management (split or no wrap ) */
|
||||
|
||||
|
||||
elemSizeStorageRoom = (q->elementSize == 0) ? 2 : 0;
|
||||
/* retrieve the size of last element sored: the value stored at the beginning of the queue element if element size is variable otherwise take it from fixed element Size member */
|
||||
if (q->byteCount)
|
||||
{
|
||||
curElementSize = (q->elementSize == 0) ? q->qBuff[q->last] + ((q->qBuff[MOD((q->last+1), q->queueMaxSize)])<<8) + 2 : q->elementSize;
|
||||
}
|
||||
/* if queue element have fixed size , reset the elementSize arg with fixed element size value */
|
||||
if (q->elementSize > 0)
|
||||
{
|
||||
elementSize = q->elementSize;
|
||||
}
|
||||
|
||||
eob_free_size = (q->last >= q->first) ? q->queueMaxSize - (q->last + curElementSize) : 0;
|
||||
|
||||
/* check how many bytes of wrapped element (if anay) are at end of buffer */
|
||||
wrapped_element_eob_size = (((elementSize + elemSizeStorageRoom )*nbElements) < eob_free_size) ? 0 : (eob_free_size % (elementSize + elemSizeStorageRoom));
|
||||
wrap_will_occur = wrapped_element_eob_size > elemSizeStorageRoom;
|
||||
|
||||
overhead = (wrap_will_occur && (q->optionFlags & CIRCULAR_QUEUE_NO_WRAP_FLAG)) ? wrapped_element_eob_size : overhead;
|
||||
overhead = (wrap_will_occur && (q->optionFlags & CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG)) ? elemSizeStorageRoom : overhead;
|
||||
|
||||
|
||||
/* Store now the elements if ennough room for all elements */
|
||||
if (elementSize && ((q->byteCount + ((elementSize + elemSizeStorageRoom )*nbElements) + overhead) <= q->queueMaxSize))
|
||||
{
|
||||
/* loop to add all elements */
|
||||
for (i=0; i < nbElements; i++)
|
||||
{
|
||||
q->last = MOD ((q->last + curElementSize),q->queueMaxSize);
|
||||
curBuffPosition = q->last;
|
||||
|
||||
/* store the element */
|
||||
/* store first the element size if element size is variable */
|
||||
if (q->elementSize == 0)
|
||||
{
|
||||
q->qBuff[curBuffPosition++]= elementSize & 0xFF;
|
||||
curBuffPosition = MOD(curBuffPosition, q->queueMaxSize);
|
||||
q->qBuff[curBuffPosition++]= (elementSize & 0xFF00) >> 8 ;
|
||||
curBuffPosition = MOD(curBuffPosition, q->queueMaxSize);
|
||||
q->byteCount += 2;
|
||||
}
|
||||
|
||||
/* Identify number of bytes of copy takeing account possible wrap, in this case NbBytesToCopy will contains size that fit at end of the queue buffer */
|
||||
NbBytesToCopy = MIN((q->queueMaxSize-curBuffPosition),elementSize);
|
||||
/* check if no wrap (NbBytesToCopy == elementSize) or if Wrap and no spsicf option;
|
||||
In this case part of data will copied at the end of the buffer and the rest a the beginning */
|
||||
if ((NbBytesToCopy == elementSize) || ((NbBytesToCopy < elementSize) && (q->optionFlags == CIRCULAR_QUEUE_NO_FLAG)))
|
||||
{
|
||||
/* Copy First part (or emtire buffer ) from current position up to the end of the buffer queue (or before if enough room) */
|
||||
memcpy(&q->qBuff[curBuffPosition],&x[i*elementSize],NbBytesToCopy);
|
||||
/* Adjust bytes count */
|
||||
q->byteCount += NbBytesToCopy;
|
||||
/* Wrap */
|
||||
curBuffPosition = 0;
|
||||
/* set NbCopiedBytes bytes with ampount copied */
|
||||
NbCopiedBytes = NbBytesToCopy;
|
||||
/* set the rest to copy if wrao , if no wrap will be 0 */
|
||||
NbBytesToCopy = elementSize - NbBytesToCopy;
|
||||
/* set the current element Size, will be used to calaculate next last position at beginning of loop */
|
||||
curElementSize = (elementSize) + elemSizeStorageRoom ;
|
||||
}
|
||||
else if (NbBytesToCopy) /* We have a wrap to manage */
|
||||
{
|
||||
/* case of CIRCULAR_QUEUE_NO_WRAP_FLAG option */
|
||||
if (q->optionFlags & CIRCULAR_QUEUE_NO_WRAP_FLAG)
|
||||
{
|
||||
/* if element size are variable and NO_WRAP option, Invalidate end of buffer setting 0xFFFF size*/
|
||||
if (q->elementSize == 0)
|
||||
{
|
||||
q->qBuff[curBuffPosition-2] = 0xFF;
|
||||
q->qBuff[curBuffPosition-1] = 0xFF;
|
||||
}
|
||||
q->byteCount += NbBytesToCopy; /* invalid data at the end of buffer are take into account in byteCount */
|
||||
/* No bytes coped a the end of buffer */
|
||||
NbCopiedBytes = 0;
|
||||
/* all element to be copied at the begnning of buffer */
|
||||
NbBytesToCopy = elementSize;
|
||||
/* Wrap */
|
||||
curBuffPosition = 0;
|
||||
/* if variable size element, invalidate end of buffer setting OxFFFF in element header (size) */
|
||||
if (q->elementSize == 0)
|
||||
{
|
||||
q->qBuff[curBuffPosition++] = NbBytesToCopy & 0xFF;
|
||||
q->qBuff[curBuffPosition++] = (NbBytesToCopy & 0xFF00) >> 8 ;
|
||||
q->byteCount += 2;
|
||||
}
|
||||
|
||||
}
|
||||
/* case of CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG option */
|
||||
else if (q->optionFlags & CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG)
|
||||
{
|
||||
if (q->elementSize == 0)
|
||||
{
|
||||
/* reset the size of current element to the nb bytes fitting at the end of buffer */
|
||||
q->qBuff[curBuffPosition-2] = NbBytesToCopy & 0xFF;
|
||||
q->qBuff[curBuffPosition-1] = (NbBytesToCopy & 0xFF00) >> 8 ;
|
||||
/* copy the bytes */
|
||||
memcpy(&q->qBuff[curBuffPosition],&x[i*elementSize],NbBytesToCopy);
|
||||
q->byteCount += NbBytesToCopy;
|
||||
/* set the number of copied bytes */
|
||||
NbCopiedBytes = NbBytesToCopy;
|
||||
/* set rest of data to be copied to begnning of buffer */
|
||||
NbBytesToCopy = elementSize - NbBytesToCopy;
|
||||
/* one element more dur to split in 2 elements */
|
||||
q->elementCount++;
|
||||
/* Wrap */
|
||||
curBuffPosition = 0;
|
||||
/* Set new size for rest of data */
|
||||
q->qBuff[curBuffPosition++] = NbBytesToCopy & 0xFF;
|
||||
q->qBuff[curBuffPosition++] = (NbBytesToCopy & 0xFF00) >> 8 ;
|
||||
q->byteCount += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Should not occur */
|
||||
/* can not manage split Flag on Fixed size element */
|
||||
/* Buffer is corrupted */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
curElementSize = (NbBytesToCopy) + elemSizeStorageRoom ;
|
||||
q->last = 0;
|
||||
}
|
||||
|
||||
/* some remaining byte to copy */
|
||||
if (NbBytesToCopy)
|
||||
{
|
||||
memcpy(&q->qBuff[curBuffPosition],&x[(i*elementSize)+NbCopiedBytes],NbBytesToCopy);
|
||||
q->byteCount += NbBytesToCopy;
|
||||
}
|
||||
|
||||
/* One more element */
|
||||
q->elementCount++;
|
||||
}
|
||||
|
||||
ptr = q->qBuff + (MOD((q->last+elemSizeStorageRoom ),q->queueMaxSize));
|
||||
}
|
||||
/* for Breakpoint only...to remove */
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove element from the queue and copy it in provided buffer
|
||||
* @note This function is used to remove and element from the Circular Queue .
|
||||
* @param q: pointer on queue structure to be handled
|
||||
* @param elementSize: Pointer to return Size of element to be removed
|
||||
* @param buffer: destination buffer where to copy element
|
||||
* @retval Pointer on removed element. NULL if queue was empty
|
||||
*/
|
||||
uint8_t* CircularQueue_Remove_Copy(queue_t *q, uint16_t* elementSize, uint8_t* buffer)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove element from the queue.
|
||||
* @note This function is used to remove and element from the Circular Queue .
|
||||
* @param q: pointer on queue structure to be handled
|
||||
* @param elementSize: Pointer to return Size of element to be removed (ignored if NULL)
|
||||
* @retval Pointer on removed element. NULL if queue was empty
|
||||
*/
|
||||
uint8_t* CircularQueue_Remove(queue_t *q, uint16_t* elementSize)
|
||||
{
|
||||
uint8_t elemSizeStorageRoom = 0;
|
||||
uint8_t* ptr= NULL;
|
||||
elemSizeStorageRoom = (q->elementSize == 0) ? 2 : 0;
|
||||
uint16_t eltSize = 0;
|
||||
if (q->byteCount > 0)
|
||||
{
|
||||
/* retrieve element Size */
|
||||
eltSize = (q->elementSize == 0) ? q->qBuff[q->first] + ((q->qBuff[MOD((q->first+1), q->queueMaxSize)])<<8) : q->elementSize;
|
||||
|
||||
if ((q->optionFlags & CIRCULAR_QUEUE_NO_WRAP_FLAG) && !(q->optionFlags & CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG))
|
||||
{
|
||||
if (((eltSize == 0xFFFF) && q->elementSize == 0 ) ||
|
||||
((q->first > q->last) && q->elementSize && ((q->queueMaxSize - q->first) < q->elementSize)))
|
||||
{
|
||||
/* all data from current position up to the end of buffer are invalid */
|
||||
q->byteCount -= (q->queueMaxSize - q->first);
|
||||
/* Adjust first element pos */
|
||||
q->first = 0;
|
||||
/* retrieve the right size after the wrap [if variable size element] */
|
||||
eltSize = (q->elementSize == 0) ? q->qBuff[q->first] + ((q->qBuff[MOD((q->first+1), q->queueMaxSize)])<<8) : q->elementSize;
|
||||
}
|
||||
}
|
||||
|
||||
/* retrieve element */
|
||||
ptr = q->qBuff + (MOD((q->first + elemSizeStorageRoom), q->queueMaxSize));
|
||||
|
||||
/* adjust byte count */
|
||||
q->byteCount -= (eltSize + elemSizeStorageRoom) ;
|
||||
|
||||
/* Adjust q->first */
|
||||
if (q->byteCount > 0)
|
||||
{
|
||||
q->first = MOD((q->first+ eltSize + elemSizeStorageRoom ), q->queueMaxSize);
|
||||
}
|
||||
/* adjust element count */
|
||||
--q->elementCount;
|
||||
}
|
||||
if (elementSize != NULL)
|
||||
{
|
||||
*elementSize = eltSize;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief "Sense" first element of the queue, without removing it and copy it in provided buffer
|
||||
* @note This function is used to return a pointer on the first element of the queue without removing it.
|
||||
* @param q: pointer on queue structure to be handled
|
||||
* @param elementSize: Pointer to return Size of element to be removed
|
||||
* @param buffer: destination buffer where to copy element
|
||||
* @retval Pointer on sensed element. NULL if queue was empty
|
||||
*/
|
||||
|
||||
uint8_t* CircularQueue_Sense_Copy(queue_t *q, uint16_t* elementSize, uint8_t* buffer)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief "Sense" first element of the queue, without removing it.
|
||||
* @note This function is used to return a pointer on the first element of the queue without removing it.
|
||||
* @param q: pointer on queue structure to be handled
|
||||
* @param elementSize: Pointer to return Size of element to be removed (ignored if NULL)
|
||||
* @retval Pointer on sensed element. NULL if queue was empty
|
||||
*/
|
||||
uint8_t* CircularQueue_Sense(queue_t *q, uint16_t* elementSize)
|
||||
{
|
||||
uint8_t elemSizeStorageRoom = 0;
|
||||
uint8_t* x= NULL;
|
||||
elemSizeStorageRoom = (q->elementSize == 0) ? 2 : 0;
|
||||
uint16_t eltSize = 0;
|
||||
uint32_t FirstElemetPos = 0;
|
||||
|
||||
if (q->byteCount > 0)
|
||||
{
|
||||
FirstElemetPos = q->first;
|
||||
eltSize = (q->elementSize == 0) ? q->qBuff[q->first] + ((q->qBuff[MOD((q->first+1), q->queueMaxSize)])<<8) : q->elementSize;
|
||||
|
||||
if ((q->optionFlags & CIRCULAR_QUEUE_NO_WRAP_FLAG) && !(q->optionFlags & CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG))
|
||||
{
|
||||
if (((eltSize == 0xFFFF) && q->elementSize == 0 ) ||
|
||||
((q->first > q->last) && q->elementSize && ((q->queueMaxSize - q->first) < q->elementSize)))
|
||||
|
||||
{
|
||||
/* all data from current position up to the end of buffer are invalid */
|
||||
FirstElemetPos = 0; /* wrap to the begiining of buffer */
|
||||
|
||||
/* retrieve the right size after the wrap [if variable size element] */
|
||||
eltSize = (q->elementSize == 0) ? q->qBuff[FirstElemetPos]+ ((q->qBuff[MOD((FirstElemetPos+1), q->queueMaxSize)])<<8) : q->elementSize;
|
||||
}
|
||||
}
|
||||
/* retrieve element */
|
||||
x = q->qBuff + (MOD((FirstElemetPos + elemSizeStorageRoom), q->queueMaxSize));
|
||||
}
|
||||
if (elementSize != NULL)
|
||||
{
|
||||
*elementSize = eltSize;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if queue is empty.
|
||||
* @note This function is used to to check if the queue is empty.
|
||||
* @param q: pointer on queue structure to be handled
|
||||
* @retval TRUE (!0) if the queue is empyu otherwise FALSE (0)
|
||||
*/
|
||||
int CircularQueue_Empty(queue_t *q)
|
||||
{
|
||||
int ret=FALSE;
|
||||
if (q->byteCount <= 0)
|
||||
{
|
||||
ret=TRUE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int CircularQueue_NbElement(queue_t *q)
|
||||
{
|
||||
return q->elementCount;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm_queue.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for stm_queue.c
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM_QUEUE_H
|
||||
#define __STM_QUEUE_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported define -----------------------------------------------------------*/
|
||||
/* Options flags */
|
||||
#define CIRCULAR_QUEUE_NO_FLAG 0
|
||||
#define CIRCULAR_QUEUE_NO_WRAP_FLAG 1
|
||||
#define CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG 2
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
uint8_t* qBuff; /* queue buffer, , provided by init fct */
|
||||
uint32_t queueMaxSize; /* size of the queue, provided by init fct (in bytes)*/
|
||||
uint16_t elementSize; /* -1 variable. If variable element size the size is stored in the 4 first of the queue element */
|
||||
uint32_t first; /* position of first element */
|
||||
uint32_t last; /* position of last element */
|
||||
uint32_t byteCount; /* number of bytes in the queue */
|
||||
uint32_t elementCount; /* number of element in the queue */
|
||||
uint8_t optionFlags; /* option to enable specific features */
|
||||
} queue_t;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
int CircularQueue_Init(queue_t *q, uint8_t* queueBuffer, uint32_t queueSize, uint16_t elementSize, uint8_t optionlags);
|
||||
uint8_t* CircularQueue_Add(queue_t *q, uint8_t* x, uint16_t elementSize, uint32_t nbElements);
|
||||
uint8_t* CircularQueue_Remove(queue_t *q, uint16_t* elementSize);
|
||||
uint8_t* CircularQueue_Sense(queue_t *q, uint16_t* elementSize);
|
||||
int CircularQueue_Empty(queue_t *q);
|
||||
int CircularQueue_NbElement(queue_t *q);
|
||||
uint8_t* CircularQueue_Remove_Copy(queue_t *q, uint16_t* elementSize, uint8_t* buffer);
|
||||
uint8_t* CircularQueue_Sense_Copy(queue_t *q, uint16_t* elementSize, uint8_t* buffer);
|
||||
|
||||
|
||||
#endif /* __STM_QUEUE_H */
|
||||
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file utilities_common.h
|
||||
* @author MCD Application Team
|
||||
* @brief Common file to utilities
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2018-2021 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __UTILITIES_COMMON_H
|
||||
#define __UTILITIES_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "app_conf.h"
|
||||
|
||||
/* -------------------------------- *
|
||||
* Basic definitions *
|
||||
* -------------------------------- */
|
||||
|
||||
#undef NULL
|
||||
#define NULL 0
|
||||
|
||||
#undef FALSE
|
||||
#define FALSE 0
|
||||
|
||||
#undef TRUE
|
||||
#define TRUE (!0)
|
||||
|
||||
/* -------------------------------- *
|
||||
* Critical Section definition *
|
||||
* -------------------------------- */
|
||||
#undef BACKUP_PRIMASK
|
||||
#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
|
||||
|
||||
#undef DISABLE_IRQ
|
||||
#define DISABLE_IRQ() __disable_irq()
|
||||
|
||||
#undef RESTORE_PRIMASK
|
||||
#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
|
||||
|
||||
/* -------------------------------- *
|
||||
* Macro delimiters *
|
||||
* -------------------------------- */
|
||||
#undef M_BEGIN
|
||||
#define M_BEGIN do {
|
||||
|
||||
#undef M_END
|
||||
#define M_END } while(0)
|
||||
|
||||
/* -------------------------------- *
|
||||
* Some useful macro definitions *
|
||||
* -------------------------------- */
|
||||
#undef MAX
|
||||
#define MAX( x, y ) (((x)>(y))?(x):(y))
|
||||
|
||||
#undef MIN
|
||||
#define MIN( x, y ) (((x)<(y))?(x):(y))
|
||||
|
||||
#undef MODINC
|
||||
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
|
||||
|
||||
#undef MODDEC
|
||||
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
|
||||
|
||||
#undef MODADD
|
||||
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
|
||||
|
||||
#undef MODSUB
|
||||
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
|
||||
|
||||
#undef ALIGN
|
||||
#ifdef WIN32
|
||||
#define ALIGN(n)
|
||||
#else
|
||||
#define ALIGN(n) __attribute__((aligned(n)))
|
||||
#endif
|
||||
|
||||
#undef PAUSE
|
||||
#define PAUSE( t ) M_BEGIN \
|
||||
volatile int _i; \
|
||||
for ( _i = t; _i > 0; _i -- ); \
|
||||
M_END
|
||||
#undef DIVF
|
||||
#define DIVF( x, y ) ((x)/(y))
|
||||
|
||||
#undef DIVC
|
||||
#define DIVC( x, y ) (((x)+(y)-1)/(y))
|
||||
|
||||
#undef DIVR
|
||||
#define DIVR( x, y ) (((x)+((y)/2))/(y))
|
||||
|
||||
#undef SHRR
|
||||
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
|
||||
|
||||
#undef BITN
|
||||
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
|
||||
|
||||
#undef BITNSET
|
||||
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
|
||||
|
||||
/* -------------------------------- *
|
||||
* Section attribute *
|
||||
* -------------------------------- */
|
||||
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
|
||||
|
||||
/* ----------------------------------- *
|
||||
* Packed usage (compiler dependent) *
|
||||
* ----------------------------------- */
|
||||
#undef PACKED__
|
||||
#undef PACKED_STRUCT
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
#if defined ( __GNUC__ )
|
||||
/* GNU extension */
|
||||
#define PACKED__ __attribute__((packed))
|
||||
#define PACKED_STRUCT struct PACKED__
|
||||
#elif 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
|
||||
#else
|
||||
#define PACKED_STRUCT __packed struct
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__UTILITIES_COMMON_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* $Date: 10. January 2017
|
||||
* $Revision: V2.1.0
|
||||
*
|
||||
* Project: CMSIS-RTOS API
|
||||
* Title: cmsis_os.h FreeRTOS header file
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CMSIS_OS_H_
|
||||
#define CMSIS_OS_H_
|
||||
|
||||
#define osCMSIS 0x20001U ///< API version (main[31:16].sub[15:0])
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#endif // CMSIS_OS_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
/* --------------------------------------------------------------------------
|
||||
* Copyright (c) 2013-2020 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Name: freertos_mpool.h
|
||||
* Purpose: CMSIS RTOS2 wrapper for FreeRTOS
|
||||
*
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FREERTOS_MPOOL_H_
|
||||
#define FREERTOS_MPOOL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* Memory Pool implementation definitions */
|
||||
#define MPOOL_STATUS 0x5EED0000U
|
||||
|
||||
/* Memory Block header */
|
||||
typedef struct {
|
||||
void *next; /* Pointer to next block */
|
||||
} MemPoolBlock_t;
|
||||
|
||||
/* Memory Pool control block */
|
||||
typedef struct MemPoolDef_t {
|
||||
MemPoolBlock_t *head; /* Pointer to head block */
|
||||
SemaphoreHandle_t sem; /* Pool semaphore handle */
|
||||
uint8_t *mem_arr; /* Pool memory array */
|
||||
uint32_t mem_sz; /* Pool memory array size */
|
||||
const char *name; /* Pointer to name string */
|
||||
uint32_t bl_sz; /* Size of a single block */
|
||||
uint32_t bl_cnt; /* Number of blocks */
|
||||
uint32_t n; /* Block allocation index */
|
||||
volatile uint32_t status; /* Object status flags */
|
||||
#if (configSUPPORT_STATIC_ALLOCATION == 1)
|
||||
StaticSemaphore_t mem_sem; /* Semaphore object memory */
|
||||
#endif
|
||||
} MemPool_t;
|
||||
|
||||
/* No need to hide static object type, just align to coding style */
|
||||
#define StaticMemPool_t MemPool_t
|
||||
|
||||
/* Define memory pool control block size */
|
||||
#define MEMPOOL_CB_SIZE (sizeof(StaticMemPool_t))
|
||||
|
||||
/* Define size of the byte array required to create count of blocks of given size */
|
||||
#define MEMPOOL_ARR_SIZE(bl_count, bl_size) (((((bl_size) + (4 - 1)) / 4) * 4)*(bl_count))
|
||||
|
||||
#endif /* FREERTOS_MPOOL_H_ */
|
||||
@@ -0,0 +1,310 @@
|
||||
/* --------------------------------------------------------------------------
|
||||
* Copyright (c) 2013-2021 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Name: freertos_os2.h
|
||||
* Purpose: CMSIS RTOS2 wrapper for FreeRTOS
|
||||
*
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FREERTOS_OS2_H_
|
||||
#define FREERTOS_OS2_H_
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core
|
||||
|
||||
#include CMSIS_device_header
|
||||
|
||||
/*
|
||||
CMSIS-RTOS2 FreeRTOS image size optimization definitions.
|
||||
|
||||
Note: Definitions configUSE_OS2 can be used to optimize FreeRTOS image size when
|
||||
certain functionality is not required when using CMSIS-RTOS2 API.
|
||||
In general optimization decisions are left to the tool chain but in cases
|
||||
when coding style prevents it to optimize the code following optional
|
||||
definitions can be used.
|
||||
*/
|
||||
|
||||
/*
|
||||
Option to exclude CMSIS-RTOS2 functions osThreadSuspend and osThreadResume from
|
||||
the application image.
|
||||
*/
|
||||
#ifndef configUSE_OS2_THREAD_SUSPEND_RESUME
|
||||
#define configUSE_OS2_THREAD_SUSPEND_RESUME 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
Option to exclude CMSIS-RTOS2 function osThreadEnumerate from the application image.
|
||||
*/
|
||||
#ifndef configUSE_OS2_THREAD_ENUMERATE
|
||||
#define configUSE_OS2_THREAD_ENUMERATE 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
Option to disable CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear
|
||||
operation from ISR.
|
||||
*/
|
||||
#ifndef configUSE_OS2_EVENTFLAGS_FROM_ISR
|
||||
#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
Option to exclude CMSIS-RTOS2 Thread Flags API functions from the application image.
|
||||
*/
|
||||
#ifndef configUSE_OS2_THREAD_FLAGS
|
||||
#define configUSE_OS2_THREAD_FLAGS configUSE_TASK_NOTIFICATIONS
|
||||
#endif
|
||||
|
||||
/*
|
||||
Option to exclude CMSIS-RTOS2 Timer API functions from the application image.
|
||||
*/
|
||||
#ifndef configUSE_OS2_TIMER
|
||||
#define configUSE_OS2_TIMER configUSE_TIMERS
|
||||
#endif
|
||||
|
||||
/*
|
||||
Option to exclude CMSIS-RTOS2 Mutex API functions from the application image.
|
||||
*/
|
||||
#ifndef configUSE_OS2_MUTEX
|
||||
#define configUSE_OS2_MUTEX configUSE_MUTEXES
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
CMSIS-RTOS2 FreeRTOS configuration check (FreeRTOSConfig.h).
|
||||
|
||||
Note: CMSIS-RTOS API requires functions included by using following definitions.
|
||||
In case if certain API function is not used compiler will optimize it away.
|
||||
*/
|
||||
#if (INCLUDE_xSemaphoreGetMutexHolder == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osMutexGetOwner uses FreeRTOS function xSemaphoreGetMutexHolder. In case if
|
||||
osMutexGetOwner is not used in the application image, compiler will optimize it away.
|
||||
Set #define INCLUDE_xSemaphoreGetMutexHolder 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_xSemaphoreGetMutexHolder must equal 1 to implement Mutex Management API."
|
||||
#endif
|
||||
#if (INCLUDE_vTaskDelay == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osDelay uses FreeRTOS function vTaskDelay. In case if
|
||||
osDelay is not used in the application image, compiler will optimize it away.
|
||||
Set #define INCLUDE_vTaskDelay 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_vTaskDelay must equal 1 to implement Generic Wait Functions API."
|
||||
#endif
|
||||
#if (INCLUDE_xTaskDelayUntil == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osDelayUntil uses FreeRTOS function xTaskDelayUntil. In case if
|
||||
osDelayUntil is not used in the application image, compiler will optimize it away.
|
||||
Set #define INCLUDE_xTaskDelayUntil 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_xTaskDelayUntil must equal 1 to implement Generic Wait Functions API."
|
||||
#endif
|
||||
#if (INCLUDE_vTaskDelete == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osThreadTerminate and osThreadExit uses FreeRTOS function
|
||||
vTaskDelete. In case if they are not used in the application image, compiler
|
||||
will optimize them away.
|
||||
Set #define INCLUDE_vTaskDelete 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_vTaskDelete must equal 1 to implement Thread Management API."
|
||||
#endif
|
||||
#if (INCLUDE_xTaskGetCurrentTaskHandle == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 API uses FreeRTOS function xTaskGetCurrentTaskHandle to implement
|
||||
functions osThreadGetId, osThreadFlagsClear and osThreadFlagsGet. In case if these
|
||||
functions are not used in the application image, compiler will optimize them away.
|
||||
Set #define INCLUDE_xTaskGetCurrentTaskHandle 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_xTaskGetCurrentTaskHandle must equal 1 to implement Thread Management API."
|
||||
#endif
|
||||
#if (INCLUDE_xTaskGetSchedulerState == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 API uses FreeRTOS function xTaskGetSchedulerState to implement Kernel
|
||||
tick handling and therefore it is vital that xTaskGetSchedulerState is included into
|
||||
the application image.
|
||||
Set #define INCLUDE_xTaskGetSchedulerState 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_xTaskGetSchedulerState must equal 1 to implement Kernel Information and Control API."
|
||||
#endif
|
||||
#if (INCLUDE_uxTaskGetStackHighWaterMark == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osThreadGetStackSpace uses FreeRTOS function uxTaskGetStackHighWaterMark.
|
||||
In case if osThreadGetStackSpace is not used in the application image, compiler will
|
||||
optimize it away.
|
||||
Set #define INCLUDE_uxTaskGetStackHighWaterMark 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_uxTaskGetStackHighWaterMark must equal 1 to implement Thread Management API."
|
||||
#endif
|
||||
#if (INCLUDE_uxTaskPriorityGet == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osThreadGetPriority uses FreeRTOS function uxTaskPriorityGet. In case if
|
||||
osThreadGetPriority is not used in the application image, compiler will optimize it away.
|
||||
Set #define INCLUDE_uxTaskPriorityGet 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_uxTaskPriorityGet must equal 1 to implement Thread Management API."
|
||||
#endif
|
||||
#if (INCLUDE_vTaskPrioritySet == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osThreadSetPriority uses FreeRTOS function vTaskPrioritySet. In case if
|
||||
osThreadSetPriority is not used in the application image, compiler will optimize it away.
|
||||
Set #define INCLUDE_vTaskPrioritySet 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_vTaskPrioritySet must equal 1 to implement Thread Management API."
|
||||
#endif
|
||||
#if (INCLUDE_eTaskGetState == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 API uses FreeRTOS function vTaskDelayUntil to implement functions osThreadGetState
|
||||
and osThreadTerminate. In case if these functions are not used in the application image,
|
||||
compiler will optimize them away.
|
||||
Set #define INCLUDE_eTaskGetState 1 to fix this error.
|
||||
*/
|
||||
#error "Definition INCLUDE_eTaskGetState must equal 1 to implement Thread Management API."
|
||||
#endif
|
||||
#if (INCLUDE_vTaskSuspend == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 API uses FreeRTOS functions vTaskSuspend and vTaskResume to implement
|
||||
functions osThreadSuspend and osThreadResume. In case if these functions are not
|
||||
used in the application image, compiler will optimize them away.
|
||||
Set #define INCLUDE_vTaskSuspend 1 to fix this error.
|
||||
|
||||
Alternatively, if the application does not use osThreadSuspend and
|
||||
osThreadResume they can be excluded from the image code by setting:
|
||||
#define configUSE_OS2_THREAD_SUSPEND_RESUME 0 (in FreeRTOSConfig.h)
|
||||
*/
|
||||
#if (configUSE_OS2_THREAD_SUSPEND_RESUME == 1)
|
||||
#error "Definition INCLUDE_vTaskSuspend must equal 1 to implement Kernel Information and Control API."
|
||||
#endif
|
||||
#endif
|
||||
#if (INCLUDE_xTimerPendFunctionCall == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear, when called from
|
||||
the ISR, call FreeRTOS functions xEventGroupSetBitsFromISR and
|
||||
xEventGroupClearBitsFromISR which are only enabled if timers are operational and
|
||||
xTimerPendFunctionCall in enabled.
|
||||
Set #define INCLUDE_xTimerPendFunctionCall 1 and #define configUSE_TIMERS 1
|
||||
to fix this error.
|
||||
|
||||
Alternatively, if the application does not use osEventFlagsSet and osEventFlagsClear
|
||||
from the ISR their operation from ISR can be restricted by setting:
|
||||
#define configUSE_OS2_EVENTFLAGS_FROM_ISR 0 (in FreeRTOSConfig.h)
|
||||
*/
|
||||
#if (configUSE_OS2_EVENTFLAGS_FROM_ISR == 1)
|
||||
#error "Definition INCLUDE_xTimerPendFunctionCall must equal 1 to implement Event Flags API."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (configUSE_TIMERS == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 Timer Management API functions use FreeRTOS timer functions to implement
|
||||
timer management. In case if these functions are not used in the application image,
|
||||
compiler will optimize them away.
|
||||
Set #define configUSE_TIMERS 1 to fix this error.
|
||||
|
||||
Alternatively, if the application does not use timer functions they can be
|
||||
excluded from the image code by setting:
|
||||
#define configUSE_OS2_TIMER 0 (in FreeRTOSConfig.h)
|
||||
*/
|
||||
#if (configUSE_OS2_TIMER == 1)
|
||||
#error "Definition configUSE_TIMERS must equal 1 to implement Timer Management API."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (configUSE_MUTEXES == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 Mutex Management API functions use FreeRTOS mutex functions to implement
|
||||
mutex management. In case if these functions are not used in the application image,
|
||||
compiler will optimize them away.
|
||||
Set #define configUSE_MUTEXES 1 to fix this error.
|
||||
|
||||
Alternatively, if the application does not use mutex functions they can be
|
||||
excluded from the image code by setting:
|
||||
#define configUSE_OS2_MUTEX 0 (in FreeRTOSConfig.h)
|
||||
*/
|
||||
#if (configUSE_OS2_MUTEX == 1)
|
||||
#error "Definition configUSE_MUTEXES must equal 1 to implement Mutex Management API."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (configUSE_COUNTING_SEMAPHORES == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 Memory Pool functions use FreeRTOS function xSemaphoreCreateCounting
|
||||
to implement memory pools. In case if these functions are not used in the application image,
|
||||
compiler will optimize them away.
|
||||
Set #define configUSE_COUNTING_SEMAPHORES 1 to fix this error.
|
||||
*/
|
||||
#error "Definition configUSE_COUNTING_SEMAPHORES must equal 1 to implement Memory Pool API."
|
||||
#endif
|
||||
#if (configUSE_TASK_NOTIFICATIONS == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 Thread Flags API functions use FreeRTOS Task Notification functions to implement
|
||||
thread flag management. In case if these functions are not used in the application image,
|
||||
compiler will optimize them away.
|
||||
Set #define configUSE_TASK_NOTIFICATIONS 1 to fix this error.
|
||||
|
||||
Alternatively, if the application does not use thread flags functions they can be
|
||||
excluded from the image code by setting:
|
||||
#define configUSE_OS2_THREAD_FLAGS 0 (in FreeRTOSConfig.h)
|
||||
*/
|
||||
#if (configUSE_OS2_THREAD_FLAGS == 1)
|
||||
#error "Definition configUSE_TASK_NOTIFICATIONS must equal 1 to implement Thread Flags API."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (configUSE_TRACE_FACILITY == 0)
|
||||
/*
|
||||
CMSIS-RTOS2 function osThreadEnumerate requires FreeRTOS function uxTaskGetSystemState
|
||||
which is only enabled if configUSE_TRACE_FACILITY == 1.
|
||||
Set #define configUSE_TRACE_FACILITY 1 to fix this error.
|
||||
|
||||
Alternatively, if the application does not use osThreadEnumerate it can be
|
||||
excluded from the image code by setting:
|
||||
#define configUSE_OS2_THREAD_ENUMERATE 0 (in FreeRTOSConfig.h)
|
||||
*/
|
||||
#if (configUSE_OS2_THREAD_ENUMERATE == 1)
|
||||
#error "Definition configUSE_TRACE_FACILITY must equal 1 to implement osThreadEnumerate."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (configUSE_16_BIT_TICKS == 1)
|
||||
/*
|
||||
CMSIS-RTOS2 wrapper for FreeRTOS relies on 32-bit tick timer which is also optimal on
|
||||
a 32-bit CPU architectures.
|
||||
Set #define configUSE_16_BIT_TICKS 0 to fix this error.
|
||||
*/
|
||||
#error "Definition configUSE_16_BIT_TICKS must be zero to implement CMSIS-RTOS2 API."
|
||||
#endif
|
||||
|
||||
#if (configMAX_PRIORITIES != 56)
|
||||
/*
|
||||
CMSIS-RTOS2 defines 56 different priorities (see osPriority_t) and portable CMSIS-RTOS2
|
||||
implementation should implement the same number of priorities.
|
||||
Set #define configMAX_PRIORITIES 56 to fix this error.
|
||||
*/
|
||||
#error "Definition configMAX_PRIORITIES must equal 56 to implement Thread Management API."
|
||||
#endif
|
||||
#if (configUSE_PORT_OPTIMISED_TASK_SELECTION != 0)
|
||||
/*
|
||||
CMSIS-RTOS2 requires handling of 56 different priorities (see osPriority_t) while FreeRTOS port
|
||||
optimised selection for Cortex core only handles 32 different priorities.
|
||||
Set #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 to fix this error.
|
||||
*/
|
||||
#error "Definition configUSE_PORT_OPTIMISED_TASK_SELECTION must be zero to implement Thread Management API."
|
||||
#endif
|
||||
|
||||
#endif /* FREERTOS_OS2_H_ */
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+363
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "croutine.h"
|
||||
|
||||
/* Remove the whole file is co-routines are not being used. */
|
||||
#if ( configUSE_CO_ROUTINES != 0 )
|
||||
|
||||
/*
|
||||
* Some kernel aware debuggers require data to be viewed to be global, rather
|
||||
* than file scope.
|
||||
*/
|
||||
#ifdef portREMOVE_STATIC_QUALIFIER
|
||||
#define static
|
||||
#endif
|
||||
|
||||
|
||||
/* Lists for ready and blocked co-routines. --------------------*/
|
||||
static List_t pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ]; /*< Prioritised ready co-routines. */
|
||||
static List_t xDelayedCoRoutineList1; /*< Delayed co-routines. */
|
||||
static List_t xDelayedCoRoutineList2; /*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */
|
||||
static List_t * pxDelayedCoRoutineList = NULL; /*< Points to the delayed co-routine list currently being used. */
|
||||
static List_t * pxOverflowDelayedCoRoutineList = NULL; /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */
|
||||
static List_t xPendingReadyCoRoutineList; /*< Holds co-routines that have been readied by an external event. They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */
|
||||
|
||||
/* Other file private variables. --------------------------------*/
|
||||
CRCB_t * pxCurrentCoRoutine = NULL;
|
||||
static UBaseType_t uxTopCoRoutineReadyPriority = 0;
|
||||
static TickType_t xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0;
|
||||
|
||||
/* The initial state of the co-routine when it is created. */
|
||||
#define corINITIAL_STATE ( 0 )
|
||||
|
||||
/*
|
||||
* Place the co-routine represented by pxCRCB into the appropriate ready queue
|
||||
* for the priority. It is inserted at the end of the list.
|
||||
*
|
||||
* This macro accesses the co-routine ready lists and therefore must not be
|
||||
* used from within an ISR.
|
||||
*/
|
||||
#define prvAddCoRoutineToReadyQueue( pxCRCB ) \
|
||||
do { \
|
||||
if( ( pxCRCB )->uxPriority > uxTopCoRoutineReadyPriority ) \
|
||||
{ \
|
||||
uxTopCoRoutineReadyPriority = ( pxCRCB )->uxPriority; \
|
||||
} \
|
||||
vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ ( pxCRCB )->uxPriority ] ), &( ( pxCRCB )->xGenericListItem ) ); \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
* Utility to ready all the lists used by the scheduler. This is called
|
||||
* automatically upon the creation of the first co-routine.
|
||||
*/
|
||||
static void prvInitialiseCoRoutineLists( void );
|
||||
|
||||
/*
|
||||
* Co-routines that are readied by an interrupt cannot be placed directly into
|
||||
* the ready lists (there is no mutual exclusion). Instead they are placed in
|
||||
* in the pending ready list in order that they can later be moved to the ready
|
||||
* list by the co-routine scheduler.
|
||||
*/
|
||||
static void prvCheckPendingReadyList( void );
|
||||
|
||||
/*
|
||||
* Macro that looks at the list of co-routines that are currently delayed to
|
||||
* see if any require waking.
|
||||
*
|
||||
* Co-routines are stored in the queue in the order of their wake time -
|
||||
* meaning once one co-routine has been found whose timer has not expired
|
||||
* we need not look any further down the list.
|
||||
*/
|
||||
static void prvCheckDelayedList( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode,
|
||||
UBaseType_t uxPriority,
|
||||
UBaseType_t uxIndex )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
CRCB_t * pxCoRoutine;
|
||||
|
||||
/* Allocate the memory that will store the co-routine control block. */
|
||||
pxCoRoutine = ( CRCB_t * ) pvPortMalloc( sizeof( CRCB_t ) );
|
||||
|
||||
if( pxCoRoutine )
|
||||
{
|
||||
/* If pxCurrentCoRoutine is NULL then this is the first co-routine to
|
||||
* be created and the co-routine data structures need initialising. */
|
||||
if( pxCurrentCoRoutine == NULL )
|
||||
{
|
||||
pxCurrentCoRoutine = pxCoRoutine;
|
||||
prvInitialiseCoRoutineLists();
|
||||
}
|
||||
|
||||
/* Check the priority is within limits. */
|
||||
if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES )
|
||||
{
|
||||
uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1;
|
||||
}
|
||||
|
||||
/* Fill out the co-routine control block from the function parameters. */
|
||||
pxCoRoutine->uxState = corINITIAL_STATE;
|
||||
pxCoRoutine->uxPriority = uxPriority;
|
||||
pxCoRoutine->uxIndex = uxIndex;
|
||||
pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode;
|
||||
|
||||
/* Initialise all the other co-routine control block parameters. */
|
||||
vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) );
|
||||
vListInitialiseItem( &( pxCoRoutine->xEventListItem ) );
|
||||
|
||||
/* Set the co-routine control block as a link back from the ListItem_t.
|
||||
* This is so we can get back to the containing CRCB from a generic item
|
||||
* in a list. */
|
||||
listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine );
|
||||
listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine );
|
||||
|
||||
/* Event lists are always in priority order. */
|
||||
listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), ( ( TickType_t ) configMAX_CO_ROUTINE_PRIORITIES - ( TickType_t ) uxPriority ) );
|
||||
|
||||
/* Now the co-routine has been initialised it can be added to the ready
|
||||
* list at the correct priority. */
|
||||
prvAddCoRoutineToReadyQueue( pxCoRoutine );
|
||||
|
||||
xReturn = pdPASS;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay,
|
||||
List_t * pxEventList )
|
||||
{
|
||||
TickType_t xTimeToWake;
|
||||
|
||||
/* Calculate the time to wake - this may overflow but this is
|
||||
* not a problem. */
|
||||
xTimeToWake = xCoRoutineTickCount + xTicksToDelay;
|
||||
|
||||
/* We must remove ourselves from the ready list before adding
|
||||
* ourselves to the blocked list as the same list item is used for
|
||||
* both lists. */
|
||||
( void ) uxListRemove( ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );
|
||||
|
||||
/* The list item will be inserted in wake time order. */
|
||||
listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake );
|
||||
|
||||
if( xTimeToWake < xCoRoutineTickCount )
|
||||
{
|
||||
/* Wake time has overflowed. Place this item in the
|
||||
* overflow list. */
|
||||
vListInsert( ( List_t * ) pxOverflowDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The wake time has not overflowed, so we can use the
|
||||
* current block list. */
|
||||
vListInsert( ( List_t * ) pxDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );
|
||||
}
|
||||
|
||||
if( pxEventList )
|
||||
{
|
||||
/* Also add the co-routine to an event list. If this is done then the
|
||||
* function must be called with interrupts disabled. */
|
||||
vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckPendingReadyList( void )
|
||||
{
|
||||
/* Are there any co-routines waiting to get moved to the ready list? These
|
||||
* are co-routines that have been readied by an ISR. The ISR cannot access
|
||||
* the ready lists itself. */
|
||||
while( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE )
|
||||
{
|
||||
CRCB_t * pxUnblockedCRCB;
|
||||
|
||||
/* The pending ready list can be accessed by an ISR. */
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyCoRoutineList ) );
|
||||
( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
( void ) uxListRemove( &( pxUnblockedCRCB->xGenericListItem ) );
|
||||
prvAddCoRoutineToReadyQueue( pxUnblockedCRCB );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckDelayedList( void )
|
||||
{
|
||||
CRCB_t * pxCRCB;
|
||||
|
||||
xPassedTicks = xTaskGetTickCount() - xLastTickCount;
|
||||
|
||||
while( xPassedTicks )
|
||||
{
|
||||
xCoRoutineTickCount++;
|
||||
xPassedTicks--;
|
||||
|
||||
/* If the tick count has overflowed we need to swap the ready lists. */
|
||||
if( xCoRoutineTickCount == 0 )
|
||||
{
|
||||
List_t * pxTemp;
|
||||
|
||||
/* Tick count has overflowed so we need to swap the delay lists. If there are
|
||||
* any items in pxDelayedCoRoutineList here then there is an error! */
|
||||
pxTemp = pxDelayedCoRoutineList;
|
||||
pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList;
|
||||
pxOverflowDelayedCoRoutineList = pxTemp;
|
||||
}
|
||||
|
||||
/* See if this tick has made a timeout expire. */
|
||||
while( listLIST_IS_EMPTY( pxDelayedCoRoutineList ) == pdFALSE )
|
||||
{
|
||||
pxCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList );
|
||||
|
||||
if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) )
|
||||
{
|
||||
/* Timeout not yet expired. */
|
||||
break;
|
||||
}
|
||||
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
/* The event could have occurred just before this critical
|
||||
* section. If this is the case then the generic list item will
|
||||
* have been moved to the pending ready list and the following
|
||||
* line is still valid. Also the pvContainer parameter will have
|
||||
* been set to NULL so the following lines are also valid. */
|
||||
( void ) uxListRemove( &( pxCRCB->xGenericListItem ) );
|
||||
|
||||
/* Is the co-routine waiting on an event also? */
|
||||
if( pxCRCB->xEventListItem.pxContainer )
|
||||
{
|
||||
( void ) uxListRemove( &( pxCRCB->xEventListItem ) );
|
||||
}
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
prvAddCoRoutineToReadyQueue( pxCRCB );
|
||||
}
|
||||
}
|
||||
|
||||
xLastTickCount = xCoRoutineTickCount;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vCoRoutineSchedule( void )
|
||||
{
|
||||
/* Only run a co-routine after prvInitialiseCoRoutineLists() has been
|
||||
* called. prvInitialiseCoRoutineLists() is called automatically when a
|
||||
* co-routine is created. */
|
||||
if( pxDelayedCoRoutineList != NULL )
|
||||
{
|
||||
/* See if any co-routines readied by events need moving to the ready lists. */
|
||||
prvCheckPendingReadyList();
|
||||
|
||||
/* See if any delayed co-routines have timed out. */
|
||||
prvCheckDelayedList();
|
||||
|
||||
/* Find the highest priority queue that contains ready co-routines. */
|
||||
while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
|
||||
{
|
||||
if( uxTopCoRoutineReadyPriority == 0 )
|
||||
{
|
||||
/* No more co-routines to check. */
|
||||
return;
|
||||
}
|
||||
|
||||
--uxTopCoRoutineReadyPriority;
|
||||
}
|
||||
|
||||
/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines
|
||||
* of the same priority get an equal share of the processor time. */
|
||||
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );
|
||||
|
||||
/* Call the co-routine. */
|
||||
( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitialiseCoRoutineLists( void )
|
||||
{
|
||||
UBaseType_t uxPriority;
|
||||
|
||||
for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ )
|
||||
{
|
||||
vListInitialise( ( List_t * ) &( pxReadyCoRoutineLists[ uxPriority ] ) );
|
||||
}
|
||||
|
||||
vListInitialise( ( List_t * ) &xDelayedCoRoutineList1 );
|
||||
vListInitialise( ( List_t * ) &xDelayedCoRoutineList2 );
|
||||
vListInitialise( ( List_t * ) &xPendingReadyCoRoutineList );
|
||||
|
||||
/* Start with pxDelayedCoRoutineList using list1 and the
|
||||
* pxOverflowDelayedCoRoutineList using list2. */
|
||||
pxDelayedCoRoutineList = &xDelayedCoRoutineList1;
|
||||
pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xCoRoutineRemoveFromEventList( const List_t * pxEventList )
|
||||
{
|
||||
CRCB_t * pxUnblockedCRCB;
|
||||
BaseType_t xReturn;
|
||||
|
||||
/* This function is called from within an interrupt. It can only access
|
||||
* event lists and the pending ready list. This function assumes that a
|
||||
* check has already been made to ensure pxEventList is not empty. */
|
||||
pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
|
||||
( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );
|
||||
vListInsertEnd( ( List_t * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) );
|
||||
|
||||
if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority )
|
||||
{
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFALSE;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
#endif /* configUSE_CO_ROUTINES == 0 */
|
||||
@@ -0,0 +1,799 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
|
||||
* all the API functions to use the MPU wrappers. That should only be done when
|
||||
* task.h is included from an application file. */
|
||||
#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
#include "event_groups.h"
|
||||
|
||||
/* Lint e961, e750 and e9021 are suppressed as a MISRA exception justified
|
||||
* because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
|
||||
* for the header files above, but not in this file, in order to generate the
|
||||
* correct privileged Vs unprivileged linkage and placement. */
|
||||
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021 See comment above. */
|
||||
|
||||
typedef struct EventGroupDef_t
|
||||
{
|
||||
EventBits_t uxEventBits;
|
||||
List_t xTasksWaitingForBits; /**< List of tasks waiting for a bit to be set. */
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxEventGroupNumber;
|
||||
#endif
|
||||
|
||||
#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
|
||||
uint8_t ucStaticallyAllocated; /**< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */
|
||||
#endif
|
||||
} EventGroup_t;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Test the bits set in uxCurrentEventBits to see if the wait condition is met.
|
||||
* The wait condition is defined by xWaitForAllBits. If xWaitForAllBits is
|
||||
* pdTRUE then the wait condition is met if all the bits set in uxBitsToWaitFor
|
||||
* are also set in uxCurrentEventBits. If xWaitForAllBits is pdFALSE then the
|
||||
* wait condition is met if any of the bits set in uxBitsToWait for are also set
|
||||
* in uxCurrentEventBits.
|
||||
*/
|
||||
static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
const BaseType_t xWaitForAllBits ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
|
||||
EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer )
|
||||
{
|
||||
EventGroup_t * pxEventBits;
|
||||
|
||||
/* A StaticEventGroup_t object must be provided. */
|
||||
configASSERT( pxEventGroupBuffer );
|
||||
|
||||
#if ( configASSERT_DEFINED == 1 )
|
||||
{
|
||||
/* Sanity check that the size of the structure used to declare a
|
||||
* variable of type StaticEventGroup_t equals the size of the real
|
||||
* event group structure. */
|
||||
volatile size_t xSize = sizeof( StaticEventGroup_t );
|
||||
configASSERT( xSize == sizeof( EventGroup_t ) );
|
||||
} /*lint !e529 xSize is referenced if configASSERT() is defined. */
|
||||
#endif /* configASSERT_DEFINED */
|
||||
|
||||
/* The user has provided a statically allocated event group - use it. */
|
||||
pxEventBits = ( EventGroup_t * ) pxEventGroupBuffer; /*lint !e740 !e9087 EventGroup_t and StaticEventGroup_t are deliberately aliased for data hiding purposes and guaranteed to have the same size and alignment requirement - checked by configASSERT(). */
|
||||
|
||||
if( pxEventBits != NULL )
|
||||
{
|
||||
pxEventBits->uxEventBits = 0;
|
||||
vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
|
||||
|
||||
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
{
|
||||
/* Both static and dynamic allocation can be used, so note that
|
||||
* this event group was created statically in case the event group
|
||||
* is later deleted. */
|
||||
pxEventBits->ucStaticallyAllocated = pdTRUE;
|
||||
}
|
||||
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
|
||||
|
||||
traceEVENT_GROUP_CREATE( pxEventBits );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* xEventGroupCreateStatic should only ever be called with
|
||||
* pxEventGroupBuffer pointing to a pre-allocated (compile time
|
||||
* allocated) StaticEventGroup_t variable. */
|
||||
traceEVENT_GROUP_CREATE_FAILED();
|
||||
}
|
||||
|
||||
return pxEventBits;
|
||||
}
|
||||
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
|
||||
EventGroupHandle_t xEventGroupCreate( void )
|
||||
{
|
||||
EventGroup_t * pxEventBits;
|
||||
|
||||
/* Allocate the event group. Justification for MISRA deviation as
|
||||
* follows: pvPortMalloc() always ensures returned memory blocks are
|
||||
* aligned per the requirements of the MCU stack. In this case
|
||||
* pvPortMalloc() must return a pointer that is guaranteed to meet the
|
||||
* alignment requirements of the EventGroup_t structure - which (if you
|
||||
* follow it through) is the alignment requirements of the TickType_t type
|
||||
* (EventBits_t being of TickType_t itself). Therefore, whenever the
|
||||
* stack alignment requirements are greater than or equal to the
|
||||
* TickType_t alignment requirements the cast is safe. In other cases,
|
||||
* where the natural word size of the architecture is less than
|
||||
* sizeof( TickType_t ), the TickType_t variables will be accessed in two
|
||||
* or more reads operations, and the alignment requirements is only that
|
||||
* of each individual read. */
|
||||
pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) ); /*lint !e9087 !e9079 see comment above. */
|
||||
|
||||
if( pxEventBits != NULL )
|
||||
{
|
||||
pxEventBits->uxEventBits = 0;
|
||||
vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
|
||||
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
{
|
||||
/* Both static and dynamic allocation can be used, so note this
|
||||
* event group was allocated statically in case the event group is
|
||||
* later deleted. */
|
||||
pxEventBits->ucStaticallyAllocated = pdFALSE;
|
||||
}
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
|
||||
traceEVENT_GROUP_CREATE( pxEventBits );
|
||||
}
|
||||
else
|
||||
{
|
||||
traceEVENT_GROUP_CREATE_FAILED(); /*lint !e9063 Else branch only exists to allow tracing and does not generate code if trace macros are not defined. */
|
||||
}
|
||||
|
||||
return pxEventBits;
|
||||
}
|
||||
|
||||
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
TickType_t xTicksToWait )
|
||||
{
|
||||
EventBits_t uxOriginalBitValue, uxReturn;
|
||||
EventGroup_t * pxEventBits = xEventGroup;
|
||||
BaseType_t xAlreadyYielded;
|
||||
BaseType_t xTimeoutOccurred = pdFALSE;
|
||||
|
||||
configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
|
||||
configASSERT( uxBitsToWaitFor != 0 );
|
||||
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
|
||||
{
|
||||
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
uxOriginalBitValue = pxEventBits->uxEventBits;
|
||||
|
||||
( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet );
|
||||
|
||||
if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor )
|
||||
{
|
||||
/* All the rendezvous bits are now set - no need to block. */
|
||||
uxReturn = ( uxOriginalBitValue | uxBitsToSet );
|
||||
|
||||
/* Rendezvous always clear the bits. They will have been cleared
|
||||
* already unless this is the only task in the rendezvous. */
|
||||
pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
|
||||
|
||||
xTicksToWait = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( xTicksToWait != ( TickType_t ) 0 )
|
||||
{
|
||||
traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor );
|
||||
|
||||
/* Store the bits that the calling task is waiting for in the
|
||||
* task's event list item so the kernel knows when a match is
|
||||
* found. Then enter the blocked state. */
|
||||
vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | eventCLEAR_EVENTS_ON_EXIT_BIT | eventWAIT_FOR_ALL_BITS ), xTicksToWait );
|
||||
|
||||
/* This assignment is obsolete as uxReturn will get set after
|
||||
* the task unblocks, but some compilers mistakenly generate a
|
||||
* warning about uxReturn being returned without being set if the
|
||||
* assignment is omitted. */
|
||||
uxReturn = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The rendezvous bits were not set, but no block time was
|
||||
* specified - just return the current event bit value. */
|
||||
uxReturn = pxEventBits->uxEventBits;
|
||||
xTimeoutOccurred = pdTRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
xAlreadyYielded = xTaskResumeAll();
|
||||
|
||||
if( xTicksToWait != ( TickType_t ) 0 )
|
||||
{
|
||||
if( xAlreadyYielded == pdFALSE )
|
||||
{
|
||||
portYIELD_WITHIN_API();
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
/* The task blocked to wait for its required bits to be set - at this
|
||||
* point either the required bits were set or the block time expired. If
|
||||
* the required bits were set they will have been stored in the task's
|
||||
* event list item, and they should now be retrieved then cleared. */
|
||||
uxReturn = uxTaskResetEventItemValue();
|
||||
|
||||
if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
|
||||
{
|
||||
/* The task timed out, just return the current event bit value. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
uxReturn = pxEventBits->uxEventBits;
|
||||
|
||||
/* Although the task got here because it timed out before the
|
||||
* bits it was waiting for were set, it is possible that since it
|
||||
* unblocked another task has set the bits. If this is the case
|
||||
* then it needs to clear the bits before exiting. */
|
||||
if( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor )
|
||||
{
|
||||
pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
xTimeoutOccurred = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The task unblocked because the bits were set. */
|
||||
}
|
||||
|
||||
/* Control bits might be set as the task had blocked should not be
|
||||
* returned. */
|
||||
uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;
|
||||
}
|
||||
|
||||
traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred );
|
||||
|
||||
/* Prevent compiler warnings when trace macros are not used. */
|
||||
( void ) xTimeoutOccurred;
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
const BaseType_t xClearOnExit,
|
||||
const BaseType_t xWaitForAllBits,
|
||||
TickType_t xTicksToWait )
|
||||
{
|
||||
EventGroup_t * pxEventBits = xEventGroup;
|
||||
EventBits_t uxReturn, uxControlBits = 0;
|
||||
BaseType_t xWaitConditionMet, xAlreadyYielded;
|
||||
BaseType_t xTimeoutOccurred = pdFALSE;
|
||||
|
||||
/* Check the user is not attempting to wait on the bits used by the kernel
|
||||
* itself, and that at least one bit is being requested. */
|
||||
configASSERT( xEventGroup );
|
||||
configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
|
||||
configASSERT( uxBitsToWaitFor != 0 );
|
||||
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
|
||||
{
|
||||
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
const EventBits_t uxCurrentEventBits = pxEventBits->uxEventBits;
|
||||
|
||||
/* Check to see if the wait condition is already met or not. */
|
||||
xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits );
|
||||
|
||||
if( xWaitConditionMet != pdFALSE )
|
||||
{
|
||||
/* The wait condition has already been met so there is no need to
|
||||
* block. */
|
||||
uxReturn = uxCurrentEventBits;
|
||||
xTicksToWait = ( TickType_t ) 0;
|
||||
|
||||
/* Clear the wait bits if requested to do so. */
|
||||
if( xClearOnExit != pdFALSE )
|
||||
{
|
||||
pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
else if( xTicksToWait == ( TickType_t ) 0 )
|
||||
{
|
||||
/* The wait condition has not been met, but no block time was
|
||||
* specified, so just return the current value. */
|
||||
uxReturn = uxCurrentEventBits;
|
||||
xTimeoutOccurred = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The task is going to block to wait for its required bits to be
|
||||
* set. uxControlBits are used to remember the specified behaviour of
|
||||
* this call to xEventGroupWaitBits() - for use when the event bits
|
||||
* unblock the task. */
|
||||
if( xClearOnExit != pdFALSE )
|
||||
{
|
||||
uxControlBits |= eventCLEAR_EVENTS_ON_EXIT_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
if( xWaitForAllBits != pdFALSE )
|
||||
{
|
||||
uxControlBits |= eventWAIT_FOR_ALL_BITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
/* Store the bits that the calling task is waiting for in the
|
||||
* task's event list item so the kernel knows when a match is
|
||||
* found. Then enter the blocked state. */
|
||||
vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait );
|
||||
|
||||
/* This is obsolete as it will get set after the task unblocks, but
|
||||
* some compilers mistakenly generate a warning about the variable
|
||||
* being returned without being set if it is not done. */
|
||||
uxReturn = 0;
|
||||
|
||||
traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor );
|
||||
}
|
||||
}
|
||||
xAlreadyYielded = xTaskResumeAll();
|
||||
|
||||
if( xTicksToWait != ( TickType_t ) 0 )
|
||||
{
|
||||
if( xAlreadyYielded == pdFALSE )
|
||||
{
|
||||
portYIELD_WITHIN_API();
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
/* The task blocked to wait for its required bits to be set - at this
|
||||
* point either the required bits were set or the block time expired. If
|
||||
* the required bits were set they will have been stored in the task's
|
||||
* event list item, and they should now be retrieved then cleared. */
|
||||
uxReturn = uxTaskResetEventItemValue();
|
||||
|
||||
if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
/* The task timed out, just return the current event bit value. */
|
||||
uxReturn = pxEventBits->uxEventBits;
|
||||
|
||||
/* It is possible that the event bits were updated between this
|
||||
* task leaving the Blocked state and running again. */
|
||||
if( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE )
|
||||
{
|
||||
if( xClearOnExit != pdFALSE )
|
||||
{
|
||||
pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
xTimeoutOccurred = pdTRUE;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The task unblocked because the bits were set. */
|
||||
}
|
||||
|
||||
/* The task blocked so control bits may have been set. */
|
||||
uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;
|
||||
}
|
||||
|
||||
traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred );
|
||||
|
||||
/* Prevent compiler warnings when trace macros are not used. */
|
||||
( void ) xTimeoutOccurred;
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToClear )
|
||||
{
|
||||
EventGroup_t * pxEventBits = xEventGroup;
|
||||
EventBits_t uxReturn;
|
||||
|
||||
/* Check the user is not attempting to clear the bits used by the kernel
|
||||
* itself. */
|
||||
configASSERT( xEventGroup );
|
||||
configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );
|
||||
|
||||
/* The value returned is the event group value prior to the bits being
|
||||
* cleared. */
|
||||
uxReturn = pxEventBits->uxEventBits;
|
||||
|
||||
/* Clear the bits. */
|
||||
pxEventBits->uxEventBits &= ~uxBitsToClear;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
|
||||
|
||||
BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToClear )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear );
|
||||
xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
#endif /* if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
UBaseType_t uxSavedInterruptStatus;
|
||||
EventGroup_t const * const pxEventBits = xEventGroup;
|
||||
EventBits_t uxReturn;
|
||||
|
||||
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||
{
|
||||
uxReturn = pxEventBits->uxEventBits;
|
||||
}
|
||||
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
|
||||
|
||||
return uxReturn;
|
||||
} /*lint !e818 EventGroupHandle_t is a typedef used in other functions to so can't be pointer to const. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet )
|
||||
{
|
||||
ListItem_t * pxListItem;
|
||||
ListItem_t * pxNext;
|
||||
ListItem_t const * pxListEnd;
|
||||
List_t const * pxList;
|
||||
EventBits_t uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits;
|
||||
EventGroup_t * pxEventBits = xEventGroup;
|
||||
BaseType_t xMatchFound = pdFALSE;
|
||||
|
||||
/* Check the user is not attempting to set the bits used by the kernel
|
||||
* itself. */
|
||||
configASSERT( xEventGroup );
|
||||
configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
|
||||
|
||||
pxList = &( pxEventBits->xTasksWaitingForBits );
|
||||
pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
|
||||
|
||||
pxListItem = listGET_HEAD_ENTRY( pxList );
|
||||
|
||||
/* Set the bits. */
|
||||
pxEventBits->uxEventBits |= uxBitsToSet;
|
||||
|
||||
/* See if the new bit value should unblock any tasks. */
|
||||
while( pxListItem != pxListEnd )
|
||||
{
|
||||
pxNext = listGET_NEXT( pxListItem );
|
||||
uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem );
|
||||
xMatchFound = pdFALSE;
|
||||
|
||||
/* Split the bits waited for from the control bits. */
|
||||
uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES;
|
||||
uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES;
|
||||
|
||||
if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 )
|
||||
{
|
||||
/* Just looking for single bit being set. */
|
||||
if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 )
|
||||
{
|
||||
xMatchFound = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor )
|
||||
{
|
||||
/* All bits are set. */
|
||||
xMatchFound = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Need all bits to be set, but not all the bits were set. */
|
||||
}
|
||||
|
||||
if( xMatchFound != pdFALSE )
|
||||
{
|
||||
/* The bits match. Should the bits be cleared on exit? */
|
||||
if( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( EventBits_t ) 0 )
|
||||
{
|
||||
uxBitsToClear |= uxBitsWaitedFor;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
/* Store the actual event flag value in the task's event list
|
||||
* item before removing the task from the event list. The
|
||||
* eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows
|
||||
* that is was unblocked due to its required bits matching, rather
|
||||
* than because it timed out. */
|
||||
vTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET );
|
||||
}
|
||||
|
||||
/* Move onto the next list item. Note pxListItem->pxNext is not
|
||||
* used here as the list item may have been removed from the event list
|
||||
* and inserted into the ready/pending reading list. */
|
||||
pxListItem = pxNext;
|
||||
}
|
||||
|
||||
/* Clear any bits that matched when the eventCLEAR_EVENTS_ON_EXIT_BIT
|
||||
* bit was set in the control word. */
|
||||
pxEventBits->uxEventBits &= ~uxBitsToClear;
|
||||
}
|
||||
( void ) xTaskResumeAll();
|
||||
|
||||
return pxEventBits->uxEventBits;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vEventGroupDelete( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
EventGroup_t * pxEventBits = xEventGroup;
|
||||
const List_t * pxTasksWaitingForBits;
|
||||
|
||||
configASSERT( pxEventBits );
|
||||
|
||||
pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
traceEVENT_GROUP_DELETE( xEventGroup );
|
||||
|
||||
while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )
|
||||
{
|
||||
/* Unblock the task, returning 0 as the event list is being deleted
|
||||
* and cannot therefore have any bits set. */
|
||||
configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );
|
||||
vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
|
||||
}
|
||||
}
|
||||
( void ) xTaskResumeAll();
|
||||
|
||||
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
|
||||
{
|
||||
/* The event group can only have been allocated dynamically - free
|
||||
* it again. */
|
||||
vPortFree( pxEventBits );
|
||||
}
|
||||
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
|
||||
{
|
||||
/* The event group could have been allocated statically or
|
||||
* dynamically, so check before attempting to free the memory. */
|
||||
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
|
||||
{
|
||||
vPortFree( pxEventBits );
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
|
||||
StaticEventGroup_t ** ppxEventGroupBuffer )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
EventGroup_t * pxEventBits = xEventGroup;
|
||||
|
||||
configASSERT( pxEventBits );
|
||||
configASSERT( ppxEventGroupBuffer );
|
||||
|
||||
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
{
|
||||
/* Check if the event group was statically allocated. */
|
||||
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdTRUE )
|
||||
{
|
||||
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFALSE;
|
||||
}
|
||||
}
|
||||
#else /* configSUPPORT_DYNAMIC_ALLOCATION */
|
||||
{
|
||||
/* Event group must have been statically allocated. */
|
||||
*ppxEventGroupBuffer = ( StaticEventGroup_t * ) pxEventBits;
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* For internal use only - execute a 'set bits' command that was pended from
|
||||
* an interrupt. */
|
||||
void vEventGroupSetBitsCallback( void * pvEventGroup,
|
||||
const uint32_t ulBitsToSet )
|
||||
{
|
||||
( void ) xEventGroupSetBits( pvEventGroup, ( EventBits_t ) ulBitsToSet ); /*lint !e9079 Can't avoid cast to void* as a generic timer callback prototype. Callback casts back to original type so safe. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* For internal use only - execute a 'clear bits' command that was pended from
|
||||
* an interrupt. */
|
||||
void vEventGroupClearBitsCallback( void * pvEventGroup,
|
||||
const uint32_t ulBitsToClear )
|
||||
{
|
||||
( void ) xEventGroupClearBits( pvEventGroup, ( EventBits_t ) ulBitsToClear ); /*lint !e9079 Can't avoid cast to void* as a generic timer callback prototype. Callback casts back to original type so safe. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
const BaseType_t xWaitForAllBits )
|
||||
{
|
||||
BaseType_t xWaitConditionMet = pdFALSE;
|
||||
|
||||
if( xWaitForAllBits == pdFALSE )
|
||||
{
|
||||
/* Task only has to wait for one bit within uxBitsToWaitFor to be
|
||||
* set. Is one already set? */
|
||||
if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( EventBits_t ) 0 )
|
||||
{
|
||||
xWaitConditionMet = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Task has to wait for all the bits in uxBitsToWaitFor to be set.
|
||||
* Are they set already? */
|
||||
if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor )
|
||||
{
|
||||
xWaitConditionMet = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
|
||||
return xWaitConditionMet;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
|
||||
|
||||
BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
BaseType_t * pxHigherPriorityTaskWoken )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet );
|
||||
xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
#endif /* if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
|
||||
UBaseType_t uxEventGroupGetNumber( void * xEventGroup )
|
||||
{
|
||||
UBaseType_t xReturn;
|
||||
EventGroup_t const * pxEventBits = ( EventGroup_t * ) xEventGroup; /*lint !e9087 !e9079 EventGroupHandle_t is a pointer to an EventGroup_t, but EventGroupHandle_t is kept opaque outside of this file for data hiding purposes. */
|
||||
|
||||
if( xEventGroup == NULL )
|
||||
{
|
||||
xReturn = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pxEventBits->uxEventGroupNumber;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
#endif /* configUSE_TRACE_FACILITY */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
|
||||
void vEventGroupSetNumber( void * xEventGroup,
|
||||
UBaseType_t uxEventGroupNumber )
|
||||
{
|
||||
( ( EventGroup_t * ) xEventGroup )->uxEventGroupNumber = uxEventGroupNumber; /*lint !e9087 !e9079 EventGroupHandle_t is a pointer to an EventGroup_t, but EventGroupHandle_t is kept opaque outside of this file for data hiding purposes. */
|
||||
}
|
||||
|
||||
#endif /* configUSE_TRACE_FACILITY */
|
||||
/*-----------------------------------------------------------*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _MSC_VER /* Visual Studio doesn't support #warning. */
|
||||
#warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in a future release.
|
||||
#endif
|
||||
|
||||
#include "stack_macros.h"
|
||||
@@ -0,0 +1,419 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file atomic.h
|
||||
* @brief FreeRTOS atomic operation support.
|
||||
*
|
||||
* This file implements atomic functions by disabling interrupts globally.
|
||||
* Implementations with architecture specific atomic instructions can be
|
||||
* provided under each compiler directory.
|
||||
*/
|
||||
|
||||
#ifndef ATOMIC_H
|
||||
#define ATOMIC_H
|
||||
|
||||
#ifndef INC_FREERTOS_H
|
||||
#error "include FreeRTOS.h must appear in source files before include atomic.h"
|
||||
#endif
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/*
|
||||
* Port specific definitions -- entering/exiting critical section.
|
||||
* Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
|
||||
*
|
||||
* Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
|
||||
* ATOMIC_ENTER_CRITICAL().
|
||||
*
|
||||
*/
|
||||
#if defined( portSET_INTERRUPT_MASK_FROM_ISR )
|
||||
|
||||
/* Nested interrupt scheme is supported in this port. */
|
||||
#define ATOMIC_ENTER_CRITICAL() \
|
||||
UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
|
||||
|
||||
#define ATOMIC_EXIT_CRITICAL() \
|
||||
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType )
|
||||
|
||||
#else
|
||||
|
||||
/* Nested interrupt scheme is NOT supported in this port. */
|
||||
#define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
|
||||
#define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
|
||||
|
||||
#endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
|
||||
|
||||
/*
|
||||
* Port specific definition -- "always inline".
|
||||
* Inline is compiler specific, and may not always get inlined depending on your
|
||||
* optimization level. Also, inline is considered as performance optimization
|
||||
* for atomic. Thus, if portFORCE_INLINE is not provided by portmacro.h,
|
||||
* instead of resulting error, simply define it away.
|
||||
*/
|
||||
#ifndef portFORCE_INLINE
|
||||
#define portFORCE_INLINE
|
||||
#endif
|
||||
|
||||
#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */
|
||||
#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */
|
||||
|
||||
/*----------------------------- Swap && CAS ------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic compare-and-swap
|
||||
*
|
||||
* @brief Performs an atomic compare-and-swap operation on the specified values.
|
||||
*
|
||||
* @param[in, out] pulDestination Pointer to memory location from where value is
|
||||
* to be loaded and checked.
|
||||
* @param[in] ulExchange If condition meets, write this value to memory.
|
||||
* @param[in] ulComparand Swap condition.
|
||||
*
|
||||
* @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
|
||||
*
|
||||
* @note This function only swaps *pulDestination with ulExchange, if previous
|
||||
* *pulDestination value equals ulComparand.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pulDestination,
|
||||
uint32_t ulExchange,
|
||||
uint32_t ulComparand )
|
||||
{
|
||||
uint32_t ulReturnValue;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
if( *pulDestination == ulComparand )
|
||||
{
|
||||
*pulDestination = ulExchange;
|
||||
ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
|
||||
}
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulReturnValue;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic swap (pointers)
|
||||
*
|
||||
* @brief Atomically sets the address pointed to by *ppvDestination to the value
|
||||
* of *pvExchange.
|
||||
*
|
||||
* @param[in, out] ppvDestination Pointer to memory location from where a pointer
|
||||
* value is to be loaded and written back to.
|
||||
* @param[in] pvExchange Pointer value to be written to *ppvDestination.
|
||||
*
|
||||
* @return The initial value of *ppvDestination.
|
||||
*/
|
||||
static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppvDestination,
|
||||
void * pvExchange )
|
||||
{
|
||||
void * pReturnValue;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
pReturnValue = *ppvDestination;
|
||||
*ppvDestination = pvExchange;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return pReturnValue;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic compare-and-swap (pointers)
|
||||
*
|
||||
* @brief Performs an atomic compare-and-swap operation on the specified pointer
|
||||
* values.
|
||||
*
|
||||
* @param[in, out] ppvDestination Pointer to memory location from where a pointer
|
||||
* value is to be loaded and checked.
|
||||
* @param[in] pvExchange If condition meets, write this value to memory.
|
||||
* @param[in] pvComparand Swap condition.
|
||||
*
|
||||
* @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
|
||||
*
|
||||
* @note This function only swaps *ppvDestination with pvExchange, if previous
|
||||
* *ppvDestination value equals pvComparand.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppvDestination,
|
||||
void * pvExchange,
|
||||
void * pvComparand )
|
||||
{
|
||||
uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
if( *ppvDestination == pvComparand )
|
||||
{
|
||||
*ppvDestination = pvExchange;
|
||||
ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
|
||||
}
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulReturnValue;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------- Arithmetic ------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic add
|
||||
*
|
||||
* @brief Atomically adds count to the value of the specified pointer points to.
|
||||
*
|
||||
* @param[in,out] pulAddend Pointer to memory location from where value is to be
|
||||
* loaded and written back to.
|
||||
* @param[in] ulCount Value to be added to *pulAddend.
|
||||
*
|
||||
* @return previous *pulAddend value.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pulAddend,
|
||||
uint32_t ulCount )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulAddend;
|
||||
*pulAddend += ulCount;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic subtract
|
||||
*
|
||||
* @brief Atomically subtracts count from the value of the specified pointer
|
||||
* pointers to.
|
||||
*
|
||||
* @param[in,out] pulAddend Pointer to memory location from where value is to be
|
||||
* loaded and written back to.
|
||||
* @param[in] ulCount Value to be subtract from *pulAddend.
|
||||
*
|
||||
* @return previous *pulAddend value.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pulAddend,
|
||||
uint32_t ulCount )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulAddend;
|
||||
*pulAddend -= ulCount;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic increment
|
||||
*
|
||||
* @brief Atomically increments the value of the specified pointer points to.
|
||||
*
|
||||
* @param[in,out] pulAddend Pointer to memory location from where value is to be
|
||||
* loaded and written back to.
|
||||
*
|
||||
* @return *pulAddend value before increment.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pulAddend )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulAddend;
|
||||
*pulAddend += 1;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic decrement
|
||||
*
|
||||
* @brief Atomically decrements the value of the specified pointer points to
|
||||
*
|
||||
* @param[in,out] pulAddend Pointer to memory location from where value is to be
|
||||
* loaded and written back to.
|
||||
*
|
||||
* @return *pulAddend value before decrement.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pulAddend )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulAddend;
|
||||
*pulAddend -= 1;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
|
||||
/*----------------------------- Bitwise Logical ------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic OR
|
||||
*
|
||||
* @brief Performs an atomic OR operation on the specified values.
|
||||
*
|
||||
* @param [in, out] pulDestination Pointer to memory location from where value is
|
||||
* to be loaded and written back to.
|
||||
* @param [in] ulValue Value to be ORed with *pulDestination.
|
||||
*
|
||||
* @return The original value of *pulDestination.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pulDestination,
|
||||
uint32_t ulValue )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulDestination;
|
||||
*pulDestination |= ulValue;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic AND
|
||||
*
|
||||
* @brief Performs an atomic AND operation on the specified values.
|
||||
*
|
||||
* @param [in, out] pulDestination Pointer to memory location from where value is
|
||||
* to be loaded and written back to.
|
||||
* @param [in] ulValue Value to be ANDed with *pulDestination.
|
||||
*
|
||||
* @return The original value of *pulDestination.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pulDestination,
|
||||
uint32_t ulValue )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulDestination;
|
||||
*pulDestination &= ulValue;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic NAND
|
||||
*
|
||||
* @brief Performs an atomic NAND operation on the specified values.
|
||||
*
|
||||
* @param [in, out] pulDestination Pointer to memory location from where value is
|
||||
* to be loaded and written back to.
|
||||
* @param [in] ulValue Value to be NANDed with *pulDestination.
|
||||
*
|
||||
* @return The original value of *pulDestination.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pulDestination,
|
||||
uint32_t ulValue )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulDestination;
|
||||
*pulDestination = ~( ulCurrent & ulValue );
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Atomic XOR
|
||||
*
|
||||
* @brief Performs an atomic XOR operation on the specified values.
|
||||
*
|
||||
* @param [in, out] pulDestination Pointer to memory location from where value is
|
||||
* to be loaded and written back to.
|
||||
* @param [in] ulValue Value to be XORed with *pulDestination.
|
||||
*
|
||||
* @return The original value of *pulDestination.
|
||||
*/
|
||||
static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pulDestination,
|
||||
uint32_t ulValue )
|
||||
{
|
||||
uint32_t ulCurrent;
|
||||
|
||||
ATOMIC_ENTER_CRITICAL();
|
||||
{
|
||||
ulCurrent = *pulDestination;
|
||||
*pulDestination ^= ulValue;
|
||||
}
|
||||
ATOMIC_EXIT_CRITICAL();
|
||||
|
||||
return ulCurrent;
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* ATOMIC_H */
|
||||
@@ -0,0 +1,755 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CO_ROUTINE_H
|
||||
#define CO_ROUTINE_H
|
||||
|
||||
#ifndef INC_FREERTOS_H
|
||||
#error "include FreeRTOS.h must appear in source files before include croutine.h"
|
||||
#endif
|
||||
|
||||
#include "list.h"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Used to hide the implementation of the co-routine control block. The
|
||||
* control block structure however has to be included in the header due to
|
||||
* the macro implementation of the co-routine functionality. */
|
||||
typedef void * CoRoutineHandle_t;
|
||||
|
||||
/* Defines the prototype to which co-routine functions must conform. */
|
||||
typedef void (* crCOROUTINE_CODE)( CoRoutineHandle_t,
|
||||
UBaseType_t );
|
||||
|
||||
typedef struct corCoRoutineControlBlock
|
||||
{
|
||||
crCOROUTINE_CODE pxCoRoutineFunction;
|
||||
ListItem_t xGenericListItem; /**< List item used to place the CRCB in ready and blocked queues. */
|
||||
ListItem_t xEventListItem; /**< List item used to place the CRCB in event lists. */
|
||||
UBaseType_t uxPriority; /**< The priority of the co-routine in relation to other co-routines. */
|
||||
UBaseType_t uxIndex; /**< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */
|
||||
uint16_t uxState; /**< Used internally by the co-routine implementation. */
|
||||
} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* BaseType_t xCoRoutineCreate(
|
||||
* crCOROUTINE_CODE pxCoRoutineCode,
|
||||
* UBaseType_t uxPriority,
|
||||
* UBaseType_t uxIndex
|
||||
* );
|
||||
* @endcode
|
||||
*
|
||||
* Create a new co-routine and add it to the list of co-routines that are
|
||||
* ready to run.
|
||||
*
|
||||
* @param pxCoRoutineCode Pointer to the co-routine function. Co-routine
|
||||
* functions require special syntax - see the co-routine section of the WEB
|
||||
* documentation for more information.
|
||||
*
|
||||
* @param uxPriority The priority with respect to other co-routines at which
|
||||
* the co-routine will run.
|
||||
*
|
||||
* @param uxIndex Used to distinguish between different co-routines that
|
||||
* execute the same function. See the example below and the co-routine section
|
||||
* of the WEB documentation for further information.
|
||||
*
|
||||
* @return pdPASS if the co-routine was successfully created and added to a ready
|
||||
* list, otherwise an error code defined with ProjDefs.h.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // Co-routine to be created.
|
||||
* void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* // Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
* // This may not be necessary for const variables.
|
||||
* static const char cLedToFlash[ 2 ] = { 5, 6 };
|
||||
* static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };
|
||||
*
|
||||
* // Must start every co-routine with a call to crSTART();
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // This co-routine just delays for a fixed period, then toggles
|
||||
* // an LED. Two co-routines are created using this function, so
|
||||
* // the uxIndex parameter is used to tell the co-routine which
|
||||
* // LED to flash and how int32_t to delay. This assumes xQueue has
|
||||
* // already been created.
|
||||
* vParTestToggleLED( cLedToFlash[ uxIndex ] );
|
||||
* crDELAY( xHandle, uxFlashRates[ uxIndex ] );
|
||||
* }
|
||||
*
|
||||
* // Must end every co-routine with a call to crEND();
|
||||
* crEND();
|
||||
* }
|
||||
*
|
||||
* // Function that creates two co-routines.
|
||||
* void vOtherFunction( void )
|
||||
* {
|
||||
* uint8_t ucParameterToPass;
|
||||
* TaskHandle_t xHandle;
|
||||
*
|
||||
* // Create two co-routines at priority 0. The first is given index 0
|
||||
* // so (from the code above) toggles LED 5 every 200 ticks. The second
|
||||
* // is given index 1 so toggles LED 6 every 400 ticks.
|
||||
* for( uxIndex = 0; uxIndex < 2; uxIndex++ )
|
||||
* {
|
||||
* xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xCoRoutineCreate xCoRoutineCreate
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode,
|
||||
UBaseType_t uxPriority,
|
||||
UBaseType_t uxIndex );
|
||||
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* void vCoRoutineSchedule( void );
|
||||
* @endcode
|
||||
*
|
||||
* Run a co-routine.
|
||||
*
|
||||
* vCoRoutineSchedule() executes the highest priority co-routine that is able
|
||||
* to run. The co-routine will execute until it either blocks, yields or is
|
||||
* preempted by a task. Co-routines execute cooperatively so one
|
||||
* co-routine cannot be preempted by another, but can be preempted by a task.
|
||||
*
|
||||
* If an application comprises of both tasks and co-routines then
|
||||
* vCoRoutineSchedule should be called from the idle task (in an idle task
|
||||
* hook).
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // This idle task hook will schedule a co-routine each time it is called.
|
||||
* // The rest of the idle task will execute between co-routine calls.
|
||||
* void vApplicationIdleHook( void )
|
||||
* {
|
||||
* vCoRoutineSchedule();
|
||||
* }
|
||||
*
|
||||
* // Alternatively, if you do not require any other part of the idle task to
|
||||
* // execute, the idle task hook can call vCoRoutineSchedule() within an
|
||||
* // infinite loop.
|
||||
* void vApplicationIdleHook( void )
|
||||
* {
|
||||
* for( ;; )
|
||||
* {
|
||||
* vCoRoutineSchedule();
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup vCoRoutineSchedule vCoRoutineSchedule
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
void vCoRoutineSchedule( void );
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* crSTART( CoRoutineHandle_t xHandle );
|
||||
* @endcode
|
||||
*
|
||||
* This macro MUST always be called at the start of a co-routine function.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // Co-routine to be created.
|
||||
* void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* // Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
* static int32_t ulAVariable;
|
||||
*
|
||||
* // Must start every co-routine with a call to crSTART();
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Co-routine functionality goes here.
|
||||
* }
|
||||
*
|
||||
* // Must end every co-routine with a call to crEND();
|
||||
* crEND();
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup crSTART crSTART
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crSTART( pxCRCB ) \
|
||||
switch( ( ( CRCB_t * ) ( pxCRCB ) )->uxState ) { \
|
||||
case 0:
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* crEND();
|
||||
* @endcode
|
||||
*
|
||||
* This macro MUST always be called at the end of a co-routine function.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // Co-routine to be created.
|
||||
* void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* // Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
* static int32_t ulAVariable;
|
||||
*
|
||||
* // Must start every co-routine with a call to crSTART();
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Co-routine functionality goes here.
|
||||
* }
|
||||
*
|
||||
* // Must end every co-routine with a call to crEND();
|
||||
* crEND();
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup crSTART crSTART
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crEND() }
|
||||
|
||||
/*
|
||||
* These macros are intended for internal use by the co-routine implementation
|
||||
* only. The macros should not be used directly by application writers.
|
||||
*/
|
||||
#define crSET_STATE0( xHandle ) \
|
||||
( ( CRCB_t * ) ( xHandle ) )->uxState = ( __LINE__ * 2 ); return; \
|
||||
case ( __LINE__ * 2 ):
|
||||
#define crSET_STATE1( xHandle ) \
|
||||
( ( CRCB_t * ) ( xHandle ) )->uxState = ( ( __LINE__ * 2 ) + 1 ); return; \
|
||||
case ( ( __LINE__ * 2 ) + 1 ):
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );
|
||||
* @endcode
|
||||
*
|
||||
* Delay a co-routine for a fixed period of time.
|
||||
*
|
||||
* crDELAY can only be called from the co-routine function itself - not
|
||||
* from within a function called by the co-routine function. This is because
|
||||
* co-routines do not maintain their own stack.
|
||||
*
|
||||
* @param xHandle The handle of the co-routine to delay. This is the xHandle
|
||||
* parameter of the co-routine function.
|
||||
*
|
||||
* @param xTickToDelay The number of ticks that the co-routine should delay
|
||||
* for. The actual amount of time this equates to is defined by
|
||||
* configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_PERIOD_MS
|
||||
* can be used to convert ticks to milliseconds.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // Co-routine to be created.
|
||||
* void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* // Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
* // This may not be necessary for const variables.
|
||||
* // We are to delay for 200ms.
|
||||
* static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;
|
||||
*
|
||||
* // Must start every co-routine with a call to crSTART();
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Delay for 200ms.
|
||||
* crDELAY( xHandle, xDelayTime );
|
||||
*
|
||||
* // Do something here.
|
||||
* }
|
||||
*
|
||||
* // Must end every co-routine with a call to crEND();
|
||||
* crEND();
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup crDELAY crDELAY
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crDELAY( xHandle, xTicksToDelay ) \
|
||||
do { \
|
||||
if( ( xTicksToDelay ) > 0 ) \
|
||||
{ \
|
||||
vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \
|
||||
} \
|
||||
crSET_STATE0( ( xHandle ) ); \
|
||||
} while( 0 )
|
||||
|
||||
/**
|
||||
* @code{c}
|
||||
* crQUEUE_SEND(
|
||||
* CoRoutineHandle_t xHandle,
|
||||
* QueueHandle_t pxQueue,
|
||||
* void *pvItemToQueue,
|
||||
* TickType_t xTicksToWait,
|
||||
* BaseType_t *pxResult
|
||||
* )
|
||||
* @endcode
|
||||
*
|
||||
* The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine
|
||||
* equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas
|
||||
* xQueueSend() and xQueueReceive() can only be used from tasks.
|
||||
*
|
||||
* crQUEUE_SEND can only be called from the co-routine function itself - not
|
||||
* from within a function called by the co-routine function. This is because
|
||||
* co-routines do not maintain their own stack.
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xHandle The handle of the calling co-routine. This is the xHandle
|
||||
* parameter of the co-routine function.
|
||||
*
|
||||
* @param pxQueue The handle of the queue on which the data will be posted.
|
||||
* The handle is obtained as the return value when the queue is created using
|
||||
* the xQueueCreate() API function.
|
||||
*
|
||||
* @param pvItemToQueue A pointer to the data being posted onto the queue.
|
||||
* The number of bytes of each queued item is specified when the queue is
|
||||
* created. This number of bytes is copied from pvItemToQueue into the queue
|
||||
* itself.
|
||||
*
|
||||
* @param xTickToDelay The number of ticks that the co-routine should block
|
||||
* to wait for space to become available on the queue, should space not be
|
||||
* available immediately. The actual amount of time this equates to is defined
|
||||
* by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant
|
||||
* portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see example
|
||||
* below).
|
||||
*
|
||||
* @param pxResult The variable pointed to by pxResult will be set to pdPASS if
|
||||
* data was successfully posted onto the queue, otherwise it will be set to an
|
||||
* error defined within ProjDefs.h.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // Co-routine function that blocks for a fixed period then posts a number onto
|
||||
* // a queue.
|
||||
* static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* // Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
* static BaseType_t xNumberToPost = 0;
|
||||
* static BaseType_t xResult;
|
||||
*
|
||||
* // Co-routines must begin with a call to crSTART().
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // This assumes the queue has already been created.
|
||||
* crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
|
||||
*
|
||||
* if( xResult != pdPASS )
|
||||
* {
|
||||
* // The message was not posted!
|
||||
* }
|
||||
*
|
||||
* // Increment the number to be posted onto the queue.
|
||||
* xNumberToPost++;
|
||||
*
|
||||
* // Delay for 100 ticks.
|
||||
* crDELAY( xHandle, 100 );
|
||||
* }
|
||||
*
|
||||
* // Co-routines must end with a call to crEND().
|
||||
* crEND();
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup crQUEUE_SEND crQUEUE_SEND
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \
|
||||
do { \
|
||||
*( pxResult ) = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), ( xTicksToWait ) ); \
|
||||
if( *( pxResult ) == errQUEUE_BLOCKED ) \
|
||||
{ \
|
||||
crSET_STATE0( ( xHandle ) ); \
|
||||
*pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \
|
||||
} \
|
||||
if( *pxResult == errQUEUE_YIELD ) \
|
||||
{ \
|
||||
crSET_STATE1( ( xHandle ) ); \
|
||||
*pxResult = pdPASS; \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* crQUEUE_RECEIVE(
|
||||
* CoRoutineHandle_t xHandle,
|
||||
* QueueHandle_t pxQueue,
|
||||
* void *pvBuffer,
|
||||
* TickType_t xTicksToWait,
|
||||
* BaseType_t *pxResult
|
||||
* )
|
||||
* @endcode
|
||||
*
|
||||
* The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine
|
||||
* equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas
|
||||
* xQueueSend() and xQueueReceive() can only be used from tasks.
|
||||
*
|
||||
* crQUEUE_RECEIVE can only be called from the co-routine function itself - not
|
||||
* from within a function called by the co-routine function. This is because
|
||||
* co-routines do not maintain their own stack.
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xHandle The handle of the calling co-routine. This is the xHandle
|
||||
* parameter of the co-routine function.
|
||||
*
|
||||
* @param pxQueue The handle of the queue from which the data will be received.
|
||||
* The handle is obtained as the return value when the queue is created using
|
||||
* the xQueueCreate() API function.
|
||||
*
|
||||
* @param pvBuffer The buffer into which the received item is to be copied.
|
||||
* The number of bytes of each queued item is specified when the queue is
|
||||
* created. This number of bytes is copied into pvBuffer.
|
||||
*
|
||||
* @param xTickToDelay The number of ticks that the co-routine should block
|
||||
* to wait for data to become available from the queue, should data not be
|
||||
* available immediately. The actual amount of time this equates to is defined
|
||||
* by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant
|
||||
* portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see the
|
||||
* crQUEUE_SEND example).
|
||||
*
|
||||
* @param pxResult The variable pointed to by pxResult will be set to pdPASS if
|
||||
* data was successfully retrieved from the queue, otherwise it will be set to
|
||||
* an error code as defined within ProjDefs.h.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // A co-routine receives the number of an LED to flash from a queue. It
|
||||
* // blocks on the queue until the number is received.
|
||||
* static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* // Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
* static BaseType_t xResult;
|
||||
* static UBaseType_t uxLEDToFlash;
|
||||
*
|
||||
* // All co-routines must start with a call to crSTART().
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Wait for data to become available on the queue.
|
||||
* crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
|
||||
*
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // We received the LED to flash - flash it!
|
||||
* vParTestToggleLED( uxLEDToFlash );
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* crEND();
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \
|
||||
do { \
|
||||
*( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), ( xTicksToWait ) ); \
|
||||
if( *( pxResult ) == errQUEUE_BLOCKED ) \
|
||||
{ \
|
||||
crSET_STATE0( ( xHandle ) ); \
|
||||
*( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), 0 ); \
|
||||
} \
|
||||
if( *( pxResult ) == errQUEUE_YIELD ) \
|
||||
{ \
|
||||
crSET_STATE1( ( xHandle ) ); \
|
||||
*( pxResult ) = pdPASS; \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* crQUEUE_SEND_FROM_ISR(
|
||||
* QueueHandle_t pxQueue,
|
||||
* void *pvItemToQueue,
|
||||
* BaseType_t xCoRoutinePreviouslyWoken
|
||||
* )
|
||||
* @endcode
|
||||
*
|
||||
* The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the
|
||||
* co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()
|
||||
* functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to
|
||||
* pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and
|
||||
* xQueueReceiveFromISR() can only be used to pass data between a task and and
|
||||
* ISR.
|
||||
*
|
||||
* crQUEUE_SEND_FROM_ISR can only be called from an ISR to send data to a queue
|
||||
* that is being used from within a co-routine.
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xQueue The handle to the queue on which the item is to be posted.
|
||||
*
|
||||
* @param pvItemToQueue A pointer to the item that is to be placed on the
|
||||
* queue. The size of the items the queue will hold was defined when the
|
||||
* queue was created, so this many bytes will be copied from pvItemToQueue
|
||||
* into the queue storage area.
|
||||
*
|
||||
* @param xCoRoutinePreviouslyWoken This is included so an ISR can post onto
|
||||
* the same queue multiple times from a single interrupt. The first call
|
||||
* should always pass in pdFALSE. Subsequent calls should pass in
|
||||
* the value returned from the previous call.
|
||||
*
|
||||
* @return pdTRUE if a co-routine was woken by posting onto the queue. This is
|
||||
* used by the ISR to determine if a context switch may be required following
|
||||
* the ISR.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // A co-routine that blocks on a queue waiting for characters to be received.
|
||||
* static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* char cRxedChar;
|
||||
* BaseType_t xResult;
|
||||
*
|
||||
* // All co-routines must start with a call to crSTART().
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Wait for data to become available on the queue. This assumes the
|
||||
* // queue xCommsRxQueue has already been created!
|
||||
* crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
|
||||
*
|
||||
* // Was a character received?
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // Process the character here.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // All co-routines must end with a call to crEND().
|
||||
* crEND();
|
||||
* }
|
||||
*
|
||||
* // An ISR that uses a queue to send characters received on a serial port to
|
||||
* // a co-routine.
|
||||
* void vUART_ISR( void )
|
||||
* {
|
||||
* char cRxedChar;
|
||||
* BaseType_t xCRWokenByPost = pdFALSE;
|
||||
*
|
||||
* // We loop around reading characters until there are none left in the UART.
|
||||
* while( UART_RX_REG_NOT_EMPTY() )
|
||||
* {
|
||||
* // Obtain the character from the UART.
|
||||
* cRxedChar = UART_RX_REG;
|
||||
*
|
||||
* // Post the character onto a queue. xCRWokenByPost will be pdFALSE
|
||||
* // the first time around the loop. If the post causes a co-routine
|
||||
* // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
|
||||
* // In this manner we can ensure that if more than one co-routine is
|
||||
* // blocked on the queue only one is woken by this ISR no matter how
|
||||
* // many characters are posted to the queue.
|
||||
* xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) \
|
||||
xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) )
|
||||
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* @code{c}
|
||||
* crQUEUE_SEND_FROM_ISR(
|
||||
* QueueHandle_t pxQueue,
|
||||
* void *pvBuffer,
|
||||
* BaseType_t * pxCoRoutineWoken
|
||||
* )
|
||||
* @endcode
|
||||
*
|
||||
* The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the
|
||||
* co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()
|
||||
* functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to
|
||||
* pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and
|
||||
* xQueueReceiveFromISR() can only be used to pass data between a task and and
|
||||
* ISR.
|
||||
*
|
||||
* crQUEUE_RECEIVE_FROM_ISR can only be called from an ISR to receive data
|
||||
* from a queue that is being used from within a co-routine (a co-routine
|
||||
* posted to the queue).
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xQueue The handle to the queue on which the item is to be posted.
|
||||
*
|
||||
* @param pvBuffer A pointer to a buffer into which the received item will be
|
||||
* placed. The size of the items the queue will hold was defined when the
|
||||
* queue was created, so this many bytes will be copied from the queue into
|
||||
* pvBuffer.
|
||||
*
|
||||
* @param pxCoRoutineWoken A co-routine may be blocked waiting for space to become
|
||||
* available on the queue. If crQUEUE_RECEIVE_FROM_ISR causes such a
|
||||
* co-routine to unblock *pxCoRoutineWoken will get set to pdTRUE, otherwise
|
||||
* *pxCoRoutineWoken will remain unchanged.
|
||||
*
|
||||
* @return pdTRUE an item was successfully received from the queue, otherwise
|
||||
* pdFALSE.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // A co-routine that posts a character to a queue then blocks for a fixed
|
||||
* // period. The character is incremented each time.
|
||||
* static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
|
||||
* {
|
||||
* // cChar holds its value while this co-routine is blocked and must therefore
|
||||
* // be declared static.
|
||||
* static char cCharToTx = 'a';
|
||||
* BaseType_t xResult;
|
||||
*
|
||||
* // All co-routines must start with a call to crSTART().
|
||||
* crSTART( xHandle );
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Send the next character to the queue.
|
||||
* crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
|
||||
*
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // The character was successfully posted to the queue.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Could not post the character to the queue.
|
||||
* }
|
||||
*
|
||||
* // Enable the UART Tx interrupt to cause an interrupt in this
|
||||
* // hypothetical UART. The interrupt will obtain the character
|
||||
* // from the queue and send it.
|
||||
* ENABLE_RX_INTERRUPT();
|
||||
*
|
||||
* // Increment to the next character then block for a fixed period.
|
||||
* // cCharToTx will maintain its value across the delay as it is
|
||||
* // declared static.
|
||||
* cCharToTx++;
|
||||
* if( cCharToTx > 'x' )
|
||||
* {
|
||||
* cCharToTx = 'a';
|
||||
* }
|
||||
* crDELAY( 100 );
|
||||
* }
|
||||
*
|
||||
* // All co-routines must end with a call to crEND().
|
||||
* crEND();
|
||||
* }
|
||||
*
|
||||
* // An ISR that uses a queue to receive characters to send on a UART.
|
||||
* void vUART_ISR( void )
|
||||
* {
|
||||
* char cCharToTx;
|
||||
* BaseType_t xCRWokenByPost = pdFALSE;
|
||||
*
|
||||
* while( UART_TX_REG_EMPTY() )
|
||||
* {
|
||||
* // Are there any characters in the queue waiting to be sent?
|
||||
* // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
|
||||
* // is woken by the post - ensuring that only a single co-routine is
|
||||
* // woken no matter how many times we go around this loop.
|
||||
* if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
|
||||
* {
|
||||
* SEND_CHARACTER( cCharToTx );
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) \
|
||||
xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) )
|
||||
|
||||
/*
|
||||
* This function is intended for internal use by the co-routine macros only.
|
||||
* The macro nature of the co-routine implementation requires that the
|
||||
* prototype appears here. The function should not be used by application
|
||||
* writers.
|
||||
*
|
||||
* Removes the current co-routine from its ready list and places it in the
|
||||
* appropriate delayed list.
|
||||
*/
|
||||
void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay,
|
||||
List_t * pxEventList );
|
||||
|
||||
/*
|
||||
* This function is intended for internal use by the queue implementation only.
|
||||
* The function should not be used by application writers.
|
||||
*
|
||||
* Removes the highest priority co-routine from the event list and places it in
|
||||
* the pending ready list.
|
||||
*/
|
||||
BaseType_t xCoRoutineRemoveFromEventList( const List_t * pxEventList );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* CO_ROUTINE_H */
|
||||
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DEPRECATED_DEFINITIONS_H
|
||||
#define DEPRECATED_DEFINITIONS_H
|
||||
|
||||
|
||||
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a
|
||||
* pre-processor definition was used to ensure the pre-processor found the correct
|
||||
* portmacro.h file for the port being used. That scheme was deprecated in favour
|
||||
* of setting the compiler's include path such that it found the correct
|
||||
* portmacro.h file - removing the need for the constant and allowing the
|
||||
* portmacro.h file to be located anywhere in relation to the port being used. The
|
||||
* definitions below remain in the code for backward compatibility only. New
|
||||
* projects should not use them. */
|
||||
|
||||
#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT
|
||||
#include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h"
|
||||
typedef void ( __interrupt __far * pxISR )();
|
||||
#endif
|
||||
|
||||
#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT
|
||||
#include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h"
|
||||
typedef void ( __interrupt __far * pxISR )();
|
||||
#endif
|
||||
|
||||
#ifdef GCC_MEGA_AVR
|
||||
#include "../portable/GCC/ATMega323/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef IAR_MEGA_AVR
|
||||
#include "../portable/IAR/ATMega323/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef MPLAB_PIC24_PORT
|
||||
#include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef MPLAB_DSPIC_PORT
|
||||
#include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef MPLAB_PIC18F_PORT
|
||||
#include "../../Source/portable/MPLAB/PIC18F/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef MPLAB_PIC32MX_PORT
|
||||
#include "../../Source/portable/MPLAB/PIC32MX/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef _FEDPICC
|
||||
#include "libFreeRTOS/Include/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef SDCC_CYGNAL
|
||||
#include "../../Source/portable/SDCC/Cygnal/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_ARM7
|
||||
#include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_ARM7_ECLIPSE
|
||||
#include "portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef ROWLEY_LPC23xx
|
||||
#include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef IAR_MSP430
|
||||
#include "..\..\Source\portable\IAR\MSP430\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_MSP430
|
||||
#include "../../Source/portable/GCC/MSP430F449/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef ROWLEY_MSP430
|
||||
#include "../../Source/portable/Rowley/MSP430F449/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef ARM7_LPC21xx_KEIL_RVDS
|
||||
#include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef SAM7_GCC
|
||||
#include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef SAM7_IAR
|
||||
#include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef SAM9XE_IAR
|
||||
#include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef LPC2000_IAR
|
||||
#include "..\..\Source\portable\IAR\LPC2000\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef STR71X_IAR
|
||||
#include "..\..\Source\portable\IAR\STR71x\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef STR75X_IAR
|
||||
#include "..\..\Source\portable\IAR\STR75x\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef STR75X_GCC
|
||||
#include "..\..\Source\portable\GCC\STR75x\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef STR91X_IAR
|
||||
#include "..\..\Source\portable\IAR\STR91x\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_H8S
|
||||
#include "../../Source/portable/GCC/H8S2329/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_AT91FR40008
|
||||
#include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef RVDS_ARMCM3_LM3S102
|
||||
#include "../../Source/portable/RVDS/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_ARMCM3_LM3S102
|
||||
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_ARMCM3
|
||||
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef IAR_ARM_CM3
|
||||
#include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef IAR_ARMCM3_LM
|
||||
#include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef HCS12_CODE_WARRIOR
|
||||
#include "../../Source/portable/CodeWarrior/HCS12/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef MICROBLAZE_GCC
|
||||
#include "../../Source/portable/GCC/MicroBlaze/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef TERN_EE
|
||||
#include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_HCS12
|
||||
#include "../../Source/portable/GCC/HCS12/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_MCF5235
|
||||
#include "../../Source/portable/GCC/MCF5235/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef COLDFIRE_V2_GCC
|
||||
#include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef COLDFIRE_V2_CODEWARRIOR
|
||||
#include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_PPC405
|
||||
#include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_PPC440
|
||||
#include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef _16FX_SOFTUNE
|
||||
#include "..\..\Source\portable\Softune\MB96340\portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef BCC_INDUSTRIAL_PC_PORT
|
||||
|
||||
/* A short file name has to be used in place of the normal
|
||||
* FreeRTOSConfig.h when using the Borland compiler. */
|
||||
#include "frconfig.h"
|
||||
#include "..\portable\BCC\16BitDOS\PC\prtmacro.h"
|
||||
typedef void ( __interrupt __far * pxISR )();
|
||||
#endif
|
||||
|
||||
#ifdef BCC_FLASH_LITE_186_PORT
|
||||
|
||||
/* A short file name has to be used in place of the normal
|
||||
* FreeRTOSConfig.h when using the Borland compiler. */
|
||||
#include "frconfig.h"
|
||||
#include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h"
|
||||
typedef void ( __interrupt __far * pxISR )();
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef __AVR32_AVR32A__
|
||||
#include "portmacro.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __ICCAVR32__
|
||||
#ifdef __CORE__
|
||||
#if __CORE__ == __AVR32A__
|
||||
#include "portmacro.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __91467D
|
||||
#include "portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef __96340
|
||||
#include "portmacro.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __IAR_V850ES_Fx3__
|
||||
#include "../../Source/portable/IAR/V850ES/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef __IAR_V850ES_Jx3__
|
||||
#include "../../Source/portable/IAR/V850ES/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef __IAR_V850ES_Jx3_L__
|
||||
#include "../../Source/portable/IAR/V850ES/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef __IAR_V850ES_Jx2__
|
||||
#include "../../Source/portable/IAR/V850ES/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef __IAR_V850ES_Hx2__
|
||||
#include "../../Source/portable/IAR/V850ES/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef __IAR_78K0R_Kx3__
|
||||
#include "../../Source/portable/IAR/78K0R/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef __IAR_78K0R_Kx3L__
|
||||
#include "../../Source/portable/IAR/78K0R/portmacro.h"
|
||||
#endif
|
||||
|
||||
#endif /* DEPRECATED_DEFINITIONS_H */
|
||||
@@ -0,0 +1,827 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EVENT_GROUPS_H
|
||||
#define EVENT_GROUPS_H
|
||||
|
||||
#ifndef INC_FREERTOS_H
|
||||
#error "include FreeRTOS.h" must appear in source files before "include event_groups.h"
|
||||
#endif
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "timers.h"
|
||||
|
||||
/* The following bit fields convey control information in a task's event list
|
||||
* item value. It is important they don't clash with the
|
||||
* taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
|
||||
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
|
||||
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100U
|
||||
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200U
|
||||
#define eventWAIT_FOR_ALL_BITS 0x0400U
|
||||
#define eventEVENT_BITS_CONTROL_BYTES 0xff00U
|
||||
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
|
||||
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x01000000UL
|
||||
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x02000000UL
|
||||
#define eventWAIT_FOR_ALL_BITS 0x04000000UL
|
||||
#define eventEVENT_BITS_CONTROL_BYTES 0xff000000UL
|
||||
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
|
||||
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100000000000000ULL
|
||||
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200000000000000ULL
|
||||
#define eventWAIT_FOR_ALL_BITS 0x0400000000000000ULL
|
||||
#define eventEVENT_BITS_CONTROL_BYTES 0xff00000000000000ULL
|
||||
#endif /* if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/**
|
||||
* An event group is a collection of bits to which an application can assign a
|
||||
* meaning. For example, an application may create an event group to convey
|
||||
* the status of various CAN bus related events in which bit 0 might mean "A CAN
|
||||
* message has been received and is ready for processing", bit 1 might mean "The
|
||||
* application has queued a message that is ready for sending onto the CAN
|
||||
* network", and bit 2 might mean "It is time to send a SYNC message onto the
|
||||
* CAN network" etc. A task can then test the bit values to see which events
|
||||
* are active, and optionally enter the Blocked state to wait for a specified
|
||||
* bit or a group of specified bits to be active. To continue the CAN bus
|
||||
* example, a CAN controlling task can enter the Blocked state (and therefore
|
||||
* not consume any processing time) until either bit 0, bit 1 or bit 2 are
|
||||
* active, at which time the bit that was actually active would inform the task
|
||||
* which action it had to take (process a received message, send a message, or
|
||||
* send a SYNC).
|
||||
*
|
||||
* The event groups implementation contains intelligence to avoid race
|
||||
* conditions that would otherwise occur were an application to use a simple
|
||||
* variable for the same purpose. This is particularly important with respect
|
||||
* to when a bit within an event group is to be cleared, and when bits have to
|
||||
* be set and then tested atomically - as is the case where event groups are
|
||||
* used to create a synchronisation point between multiple tasks (a
|
||||
* 'rendezvous').
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*
|
||||
* Type by which event groups are referenced. For example, a call to
|
||||
* xEventGroupCreate() returns an EventGroupHandle_t variable that can then
|
||||
* be used as a parameter to other event group functions.
|
||||
*
|
||||
* \defgroup EventGroupHandle_t EventGroupHandle_t
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
struct EventGroupDef_t;
|
||||
typedef struct EventGroupDef_t * EventGroupHandle_t;
|
||||
|
||||
/*
|
||||
* The type that holds event bits always matches TickType_t - therefore the
|
||||
* number of bits it holds is set by configTICK_TYPE_WIDTH_IN_BITS (16 bits if set to 0,
|
||||
* 32 bits if set to 1, 64 bits if set to 2.
|
||||
*
|
||||
* \defgroup EventBits_t EventBits_t
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
typedef TickType_t EventBits_t;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventGroupHandle_t xEventGroupCreate( void );
|
||||
* @endcode
|
||||
*
|
||||
* Create a new event group.
|
||||
*
|
||||
* Internally, within the FreeRTOS implementation, event groups use a [small]
|
||||
* block of memory, in which the event group's structure is stored. If an event
|
||||
* groups is created using xEventGroupCreate() then the required memory is
|
||||
* automatically dynamically allocated inside the xEventGroupCreate() function.
|
||||
* (see https://www.FreeRTOS.org/a00111.html). If an event group is created
|
||||
* using xEventGroupCreateStatic() then the application writer must instead
|
||||
* provide the memory that will get used by the event group.
|
||||
* xEventGroupCreateStatic() therefore allows an event group to be created
|
||||
* without using any dynamic memory allocation.
|
||||
*
|
||||
* Although event groups are not related to ticks, for internal implementation
|
||||
* reasons the number of bits available for use in an event group is dependent
|
||||
* on the configTICK_TYPE_WIDTH_IN_BITS setting in FreeRTOSConfig.h. If
|
||||
* configTICK_TYPE_WIDTH_IN_BITS is 0 then each event group contains 8 usable bits (bit
|
||||
* 0 to bit 7). If configTICK_TYPE_WIDTH_IN_BITS is set to 1 then each event group has
|
||||
* 24 usable bits (bit 0 to bit 23). If configTICK_TYPE_WIDTH_IN_BITS is set to 2 then
|
||||
* each event group has 56 usable bits (bit 0 to bit 53). The EventBits_t type
|
||||
* is used to store event bits within an event group.
|
||||
*
|
||||
* @return If the event group was created then a handle to the event group is
|
||||
* returned. If there was insufficient FreeRTOS heap available to create the
|
||||
* event group then NULL is returned. See https://www.FreeRTOS.org/a00111.html
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // Declare a variable to hold the created event group.
|
||||
* EventGroupHandle_t xCreatedEventGroup;
|
||||
*
|
||||
* // Attempt to create the event group.
|
||||
* xCreatedEventGroup = xEventGroupCreate();
|
||||
*
|
||||
* // Was the event group created successfully?
|
||||
* if( xCreatedEventGroup == NULL )
|
||||
* {
|
||||
* // The event group was not created because there was insufficient
|
||||
* // FreeRTOS heap available.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // The event group was created.
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xEventGroupCreate xEventGroupCreate
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventGroupHandle_t xEventGroupCreateStatic( EventGroupHandle_t * pxEventGroupBuffer );
|
||||
* @endcode
|
||||
*
|
||||
* Create a new event group.
|
||||
*
|
||||
* Internally, within the FreeRTOS implementation, event groups use a [small]
|
||||
* block of memory, in which the event group's structure is stored. If an event
|
||||
* groups is created using xEventGroupCreate() then the required memory is
|
||||
* automatically dynamically allocated inside the xEventGroupCreate() function.
|
||||
* (see https://www.FreeRTOS.org/a00111.html). If an event group is created
|
||||
* using xEventGroupCreateStatic() then the application writer must instead
|
||||
* provide the memory that will get used by the event group.
|
||||
* xEventGroupCreateStatic() therefore allows an event group to be created
|
||||
* without using any dynamic memory allocation.
|
||||
*
|
||||
* Although event groups are not related to ticks, for internal implementation
|
||||
* reasons the number of bits available for use in an event group is dependent
|
||||
* on the configTICK_TYPE_WIDTH_IN_BITS setting in FreeRTOSConfig.h. If
|
||||
* configTICK_TYPE_WIDTH_IN_BITS is 0 then each event group contains 8 usable bits (bit
|
||||
* 0 to bit 7). If configTICK_TYPE_WIDTH_IN_BITS is set to 1 then each event group has
|
||||
* 24 usable bits (bit 0 to bit 23). If configTICK_TYPE_WIDTH_IN_BITS is set to 2 then
|
||||
* each event group has 56 usable bits (bit 0 to bit 53). The EventBits_t type
|
||||
* is used to store event bits within an event group.
|
||||
*
|
||||
* @param pxEventGroupBuffer pxEventGroupBuffer must point to a variable of type
|
||||
* StaticEventGroup_t, which will be then be used to hold the event group's data
|
||||
* structures, removing the need for the memory to be allocated dynamically.
|
||||
*
|
||||
* @return If the event group was created then a handle to the event group is
|
||||
* returned. If pxEventGroupBuffer was NULL then NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // StaticEventGroup_t is a publicly accessible structure that has the same
|
||||
* // size and alignment requirements as the real event group structure. It is
|
||||
* // provided as a mechanism for applications to know the size of the event
|
||||
* // group (which is dependent on the architecture and configuration file
|
||||
* // settings) without breaking the strict data hiding policy by exposing the
|
||||
* // real event group internals. This StaticEventGroup_t variable is passed
|
||||
* // into the xSemaphoreCreateEventGroupStatic() function and is used to store
|
||||
* // the event group's data structures
|
||||
* StaticEventGroup_t xEventGroupBuffer;
|
||||
*
|
||||
* // Create the event group without dynamically allocating any memory.
|
||||
* xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer );
|
||||
* @endcode
|
||||
*/
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
|
||||
* const EventBits_t uxBitsToWaitFor,
|
||||
* const BaseType_t xClearOnExit,
|
||||
* const BaseType_t xWaitForAllBits,
|
||||
* const TickType_t xTicksToWait );
|
||||
* @endcode
|
||||
*
|
||||
* [Potentially] block to wait for one or more bits to be set within a
|
||||
* previously created event group.
|
||||
*
|
||||
* This function cannot be called from an interrupt.
|
||||
*
|
||||
* @param xEventGroup The event group in which the bits are being tested. The
|
||||
* event group must have previously been created using a call to
|
||||
* xEventGroupCreate().
|
||||
*
|
||||
* @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test
|
||||
* inside the event group. For example, to wait for bit 0 and/or bit 2 set
|
||||
* uxBitsToWaitFor to 0x05. To wait for bits 0 and/or bit 1 and/or bit 2 set
|
||||
* uxBitsToWaitFor to 0x07. Etc.
|
||||
*
|
||||
* @param xClearOnExit If xClearOnExit is set to pdTRUE then any bits within
|
||||
* uxBitsToWaitFor that are set within the event group will be cleared before
|
||||
* xEventGroupWaitBits() returns if the wait condition was met (if the function
|
||||
* returns for a reason other than a timeout). If xClearOnExit is set to
|
||||
* pdFALSE then the bits set in the event group are not altered when the call to
|
||||
* xEventGroupWaitBits() returns.
|
||||
*
|
||||
* @param xWaitForAllBits If xWaitForAllBits is set to pdTRUE then
|
||||
* xEventGroupWaitBits() will return when either all the bits in uxBitsToWaitFor
|
||||
* are set or the specified block time expires. If xWaitForAllBits is set to
|
||||
* pdFALSE then xEventGroupWaitBits() will return when any one of the bits set
|
||||
* in uxBitsToWaitFor is set or the specified block time expires. The block
|
||||
* time is specified by the xTicksToWait parameter.
|
||||
*
|
||||
* @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait
|
||||
* for one/all (depending on the xWaitForAllBits value) of the bits specified by
|
||||
* uxBitsToWaitFor to become set. A value of portMAX_DELAY can be used to block
|
||||
* indefinitely (provided INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h).
|
||||
*
|
||||
* @return The value of the event group at the time either the bits being waited
|
||||
* for became set, or the block time expired. Test the return value to know
|
||||
* which bits were set. If xEventGroupWaitBits() returned because its timeout
|
||||
* expired then not all the bits being waited for will be set. If
|
||||
* xEventGroupWaitBits() returned because the bits it was waiting for were set
|
||||
* then the returned value is the event group value before any bits were
|
||||
* automatically cleared in the case that xClearOnExit parameter was set to
|
||||
* pdTRUE.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
* const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
*
|
||||
* // Wait a maximum of 100ms for either bit 0 or bit 4 to be set within
|
||||
* // the event group. Clear the bits before exiting.
|
||||
* uxBits = xEventGroupWaitBits(
|
||||
* xEventGroup, // The event group being tested.
|
||||
* BIT_0 | BIT_4, // The bits within the event group to wait for.
|
||||
* pdTRUE, // BIT_0 and BIT_4 should be cleared before returning.
|
||||
* pdFALSE, // Don't wait for both bits, either bit will do.
|
||||
* xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because both bits were set.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because just BIT_0 was set.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because just BIT_4 was set.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because xTicksToWait ticks passed
|
||||
* // without either BIT_0 or BIT_4 becoming set.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xEventGroupWaitBits xEventGroupWaitBits
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
const BaseType_t xClearOnExit,
|
||||
const BaseType_t xWaitForAllBits,
|
||||
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );
|
||||
* @endcode
|
||||
*
|
||||
* Clear bits within an event group. This function cannot be called from an
|
||||
* interrupt.
|
||||
*
|
||||
* @param xEventGroup The event group in which the bits are to be cleared.
|
||||
*
|
||||
* @param uxBitsToClear A bitwise value that indicates the bit or bits to clear
|
||||
* in the event group. For example, to clear bit 3 only, set uxBitsToClear to
|
||||
* 0x08. To clear bit 3 and bit 0 set uxBitsToClear to 0x09.
|
||||
*
|
||||
* @return The value of the event group before the specified bits were cleared.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
*
|
||||
* // Clear bit 0 and bit 4 in xEventGroup.
|
||||
* uxBits = xEventGroupClearBits(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 );// The bits being cleared.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // Both bit 0 and bit 4 were set before xEventGroupClearBits() was
|
||||
* // called. Both will now be clear (not set).
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // Bit 0 was set before xEventGroupClearBits() was called. It will
|
||||
* // now be clear.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // Bit 4 was set before xEventGroupClearBits() was called. It will
|
||||
* // now be clear.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Neither bit 0 nor bit 4 were set in the first place.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xEventGroupClearBits xEventGroupClearBits
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
|
||||
* @endcode
|
||||
*
|
||||
* A version of xEventGroupClearBits() that can be called from an interrupt.
|
||||
*
|
||||
* Setting bits in an event group is not a deterministic operation because there
|
||||
* are an unknown number of tasks that may be waiting for the bit or bits being
|
||||
* set. FreeRTOS does not allow nondeterministic operations to be performed
|
||||
* while interrupts are disabled, so protects event groups that are accessed
|
||||
* from tasks by suspending the scheduler rather than disabling interrupts. As
|
||||
* a result event groups cannot be accessed directly from an interrupt service
|
||||
* routine. Therefore xEventGroupClearBitsFromISR() sends a message to the
|
||||
* timer task to have the clear operation performed in the context of the timer
|
||||
* task.
|
||||
*
|
||||
* @note If this function returns pdPASS then the timer task is ready to run
|
||||
* and a portYIELD_FROM_ISR(pdTRUE) should be executed to perform the needed
|
||||
* clear on the event group. This behavior is different from
|
||||
* xEventGroupSetBitsFromISR because the parameter xHigherPriorityTaskWoken is
|
||||
* not present.
|
||||
*
|
||||
* @param xEventGroup The event group in which the bits are to be cleared.
|
||||
*
|
||||
* @param uxBitsToClear A bitwise value that indicates the bit or bits to clear.
|
||||
* For example, to clear bit 3 only, set uxBitsToClear to 0x08. To clear bit 3
|
||||
* and bit 0 set uxBitsToClear to 0x09.
|
||||
*
|
||||
* @return If the request to execute the function was posted successfully then
|
||||
* pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned
|
||||
* if the timer service queue was full.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* // An event group which it is assumed has already been created by a call to
|
||||
* // xEventGroupCreate().
|
||||
* EventGroupHandle_t xEventGroup;
|
||||
*
|
||||
* void anInterruptHandler( void )
|
||||
* {
|
||||
* // Clear bit 0 and bit 4 in xEventGroup.
|
||||
* xResult = xEventGroupClearBitsFromISR(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 ); // The bits being set.
|
||||
*
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // The message was posted successfully.
|
||||
* portYIELD_FROM_ISR(pdTRUE);
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xEventGroupClearBitsFromISR xEventGroupClearBitsFromISR
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
#else
|
||||
#define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) \
|
||||
xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) ( xEventGroup ), ( uint32_t ) ( uxBitsToClear ), NULL )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
|
||||
* @endcode
|
||||
*
|
||||
* Set bits within an event group.
|
||||
* This function cannot be called from an interrupt. xEventGroupSetBitsFromISR()
|
||||
* is a version that can be called from an interrupt.
|
||||
*
|
||||
* Setting bits in an event group will automatically unblock tasks that are
|
||||
* blocked waiting for the bits.
|
||||
*
|
||||
* @param xEventGroup The event group in which the bits are to be set.
|
||||
*
|
||||
* @param uxBitsToSet A bitwise value that indicates the bit or bits to set.
|
||||
* For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3
|
||||
* and bit 0 set uxBitsToSet to 0x09.
|
||||
*
|
||||
* @return The value of the event group at the time the call to
|
||||
* xEventGroupSetBits() returns. There are two reasons why the returned value
|
||||
* might have the bits specified by the uxBitsToSet parameter cleared. First,
|
||||
* if setting a bit results in a task that was waiting for the bit leaving the
|
||||
* blocked state then it is possible the bit will be cleared automatically
|
||||
* (see the xClearBitOnExit parameter of xEventGroupWaitBits()). Second, any
|
||||
* unblocked (or otherwise Ready state) task that has a priority above that of
|
||||
* the task that called xEventGroupSetBits() will execute and may change the
|
||||
* event group value before the call to xEventGroupSetBits() returns.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
*
|
||||
* // Set bit 0 and bit 4 in xEventGroup.
|
||||
* uxBits = xEventGroupSetBits(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 );// The bits being set.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // Both bit 0 and bit 4 remained set when the function returned.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // Bit 0 remained set when the function returned, but bit 4 was
|
||||
* // cleared. It might be that bit 4 was cleared automatically as a
|
||||
* // task that was waiting for bit 4 was removed from the Blocked
|
||||
* // state.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // Bit 4 remained set when the function returned, but bit 0 was
|
||||
* // cleared. It might be that bit 0 was cleared automatically as a
|
||||
* // task that was waiting for bit 0 was removed from the Blocked
|
||||
* // state.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Neither bit 0 nor bit 4 remained set. It might be that a task
|
||||
* // was waiting for both of the bits to be set, and the bits were
|
||||
* // cleared as the task left the Blocked state.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xEventGroupSetBits xEventGroupSetBits
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
|
||||
* @endcode
|
||||
*
|
||||
* A version of xEventGroupSetBits() that can be called from an interrupt.
|
||||
*
|
||||
* Setting bits in an event group is not a deterministic operation because there
|
||||
* are an unknown number of tasks that may be waiting for the bit or bits being
|
||||
* set. FreeRTOS does not allow nondeterministic operations to be performed in
|
||||
* interrupts or from critical sections. Therefore xEventGroupSetBitsFromISR()
|
||||
* sends a message to the timer task to have the set operation performed in the
|
||||
* context of the timer task - where a scheduler lock is used in place of a
|
||||
* critical section.
|
||||
*
|
||||
* @param xEventGroup The event group in which the bits are to be set.
|
||||
*
|
||||
* @param uxBitsToSet A bitwise value that indicates the bit or bits to set.
|
||||
* For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3
|
||||
* and bit 0 set uxBitsToSet to 0x09.
|
||||
*
|
||||
* @param pxHigherPriorityTaskWoken As mentioned above, calling this function
|
||||
* will result in a message being sent to the timer daemon task. If the
|
||||
* priority of the timer daemon task is higher than the priority of the
|
||||
* currently running task (the task the interrupt interrupted) then
|
||||
* *pxHigherPriorityTaskWoken will be set to pdTRUE by
|
||||
* xEventGroupSetBitsFromISR(), indicating that a context switch should be
|
||||
* requested before the interrupt exits. For that reason
|
||||
* *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the
|
||||
* example code below.
|
||||
*
|
||||
* @return If the request to execute the function was posted successfully then
|
||||
* pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned
|
||||
* if the timer service queue was full.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* // An event group which it is assumed has already been created by a call to
|
||||
* // xEventGroupCreate().
|
||||
* EventGroupHandle_t xEventGroup;
|
||||
*
|
||||
* void anInterruptHandler( void )
|
||||
* {
|
||||
* BaseType_t xHigherPriorityTaskWoken, xResult;
|
||||
*
|
||||
* // xHigherPriorityTaskWoken must be initialised to pdFALSE.
|
||||
* xHigherPriorityTaskWoken = pdFALSE;
|
||||
*
|
||||
* // Set bit 0 and bit 4 in xEventGroup.
|
||||
* xResult = xEventGroupSetBitsFromISR(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 // The bits being set.
|
||||
* &xHigherPriorityTaskWoken );
|
||||
*
|
||||
* // Was the message posted successfully?
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // If xHigherPriorityTaskWoken is now set to pdTRUE then a context
|
||||
* // switch should be requested. The macro used is port specific and
|
||||
* // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() -
|
||||
* // refer to the documentation page for the port being used.
|
||||
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
#else
|
||||
#define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) \
|
||||
xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) ( xEventGroup ), ( uint32_t ) ( uxBitsToSet ), ( pxHigherPriorityTaskWoken ) )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
|
||||
* const EventBits_t uxBitsToSet,
|
||||
* const EventBits_t uxBitsToWaitFor,
|
||||
* TickType_t xTicksToWait );
|
||||
* @endcode
|
||||
*
|
||||
* Atomically set bits within an event group, then wait for a combination of
|
||||
* bits to be set within the same event group. This functionality is typically
|
||||
* used to synchronise multiple tasks, where each task has to wait for the other
|
||||
* tasks to reach a synchronisation point before proceeding.
|
||||
*
|
||||
* This function cannot be used from an interrupt.
|
||||
*
|
||||
* The function will return before its block time expires if the bits specified
|
||||
* by the uxBitsToWait parameter are set, or become set within that time. In
|
||||
* this case all the bits specified by uxBitsToWait will be automatically
|
||||
* cleared before the function returns.
|
||||
*
|
||||
* @param xEventGroup The event group in which the bits are being tested. The
|
||||
* event group must have previously been created using a call to
|
||||
* xEventGroupCreate().
|
||||
*
|
||||
* @param uxBitsToSet The bits to set in the event group before determining
|
||||
* if, and possibly waiting for, all the bits specified by the uxBitsToWait
|
||||
* parameter are set.
|
||||
*
|
||||
* @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test
|
||||
* inside the event group. For example, to wait for bit 0 and bit 2 set
|
||||
* uxBitsToWaitFor to 0x05. To wait for bits 0 and bit 1 and bit 2 set
|
||||
* uxBitsToWaitFor to 0x07. Etc.
|
||||
*
|
||||
* @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait
|
||||
* for all of the bits specified by uxBitsToWaitFor to become set.
|
||||
*
|
||||
* @return The value of the event group at the time either the bits being waited
|
||||
* for became set, or the block time expired. Test the return value to know
|
||||
* which bits were set. If xEventGroupSync() returned because its timeout
|
||||
* expired then not all the bits being waited for will be set. If
|
||||
* xEventGroupSync() returned because all the bits it was waiting for were
|
||||
* set then the returned value is the event group value before any bits were
|
||||
* automatically cleared.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // Bits used by the three tasks.
|
||||
* #define TASK_0_BIT ( 1 << 0 )
|
||||
* #define TASK_1_BIT ( 1 << 1 )
|
||||
* #define TASK_2_BIT ( 1 << 2 )
|
||||
*
|
||||
* #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )
|
||||
*
|
||||
* // Use an event group to synchronise three tasks. It is assumed this event
|
||||
* // group has already been created elsewhere.
|
||||
* EventGroupHandle_t xEventBits;
|
||||
*
|
||||
* void vTask0( void *pvParameters )
|
||||
* {
|
||||
* EventBits_t uxReturn;
|
||||
* TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 0 in the event flag to note this task has reached the
|
||||
* // sync point. The other two tasks will set the other two bits defined
|
||||
* // by ALL_SYNC_BITS. All three tasks have reached the synchronisation
|
||||
* // point when all the ALL_SYNC_BITS are set. Wait a maximum of 100ms
|
||||
* // for this to happen.
|
||||
* uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );
|
||||
*
|
||||
* if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )
|
||||
* {
|
||||
* // All three tasks reached the synchronisation point before the call
|
||||
* // to xEventGroupSync() timed out.
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void vTask1( void *pvParameters )
|
||||
* {
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 1 in the event flag to note this task has reached the
|
||||
* // synchronisation point. The other two tasks will set the other two
|
||||
* // bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
* // synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
* // indefinitely for this to happen.
|
||||
* xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
*
|
||||
* // xEventGroupSync() was called with an indefinite block time, so
|
||||
* // this task will only reach here if the synchronisation was made by all
|
||||
* // three tasks, so there is no need to test the return value.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void vTask2( void *pvParameters )
|
||||
* {
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 2 in the event flag to note this task has reached the
|
||||
* // synchronisation point. The other two tasks will set the other two
|
||||
* // bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
* // synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
* // indefinitely for this to happen.
|
||||
* xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
*
|
||||
* // xEventGroupSync() was called with an indefinite block time, so
|
||||
* // this task will only reach here if the synchronisation was made by all
|
||||
* // three tasks, so there is no need to test the return value.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* \defgroup xEventGroupSync xEventGroupSync
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );
|
||||
* @endcode
|
||||
*
|
||||
* Returns the current value of the bits in an event group. This function
|
||||
* cannot be used from an interrupt.
|
||||
*
|
||||
* @param xEventGroup The event group being queried.
|
||||
*
|
||||
* @return The event group bits at the time xEventGroupGetBits() was called.
|
||||
*
|
||||
* \defgroup xEventGroupGetBits xEventGroupGetBits
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( ( xEventGroup ), 0 )
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
|
||||
* @endcode
|
||||
*
|
||||
* A version of xEventGroupGetBits() that can be called from an ISR.
|
||||
*
|
||||
* @param xEventGroup The event group being queried.
|
||||
*
|
||||
* @return The event group bits at the time xEventGroupGetBitsFromISR() was called.
|
||||
*
|
||||
* \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* void xEventGroupDelete( EventGroupHandle_t xEventGroup );
|
||||
* @endcode
|
||||
*
|
||||
* Delete an event group that was previously created by a call to
|
||||
* xEventGroupCreate(). Tasks that are blocked on the event group will be
|
||||
* unblocked and obtain 0 as the event group's value.
|
||||
*
|
||||
* @param xEventGroup The event group being deleted.
|
||||
*/
|
||||
void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
* @code{c}
|
||||
* BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
|
||||
* StaticEventGroup_t ** ppxEventGroupBuffer );
|
||||
* @endcode
|
||||
*
|
||||
* Retrieve a pointer to a statically created event groups's data structure
|
||||
* buffer. It is the same buffer that is supplied at the time of creation.
|
||||
*
|
||||
* @param xEventGroup The event group for which to retrieve the buffer.
|
||||
*
|
||||
* @param ppxEventGroupBuffer Used to return a pointer to the event groups's
|
||||
* data structure buffer.
|
||||
*
|
||||
* @return pdTRUE if the buffer was retrieved, pdFALSE otherwise.
|
||||
*/
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
|
||||
StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
|
||||
/* For internal use only. */
|
||||
void vEventGroupSetBitsCallback( void * pvEventGroup,
|
||||
const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;
|
||||
void vEventGroupClearBitsCallback( void * pvEventGroup,
|
||||
const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxEventGroupGetNumber( void * xEventGroup ) PRIVILEGED_FUNCTION;
|
||||
void vEventGroupSetNumber( void * xEventGroup,
|
||||
UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* EVENT_GROUPS_H */
|
||||
@@ -0,0 +1,503 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the list implementation used by the scheduler. While it is tailored
|
||||
* heavily for the schedulers needs, it is also available for use by
|
||||
* application code.
|
||||
*
|
||||
* list_ts can only store pointers to list_item_ts. Each ListItem_t contains a
|
||||
* numeric value (xItemValue). Most of the time the lists are sorted in
|
||||
* ascending item value order.
|
||||
*
|
||||
* Lists are created already containing one list item. The value of this
|
||||
* item is the maximum possible that can be stored, it is therefore always at
|
||||
* the end of the list and acts as a marker. The list member pxHead always
|
||||
* points to this marker - even though it is at the tail of the list. This
|
||||
* is because the tail contains a wrap back pointer to the true head of
|
||||
* the list.
|
||||
*
|
||||
* In addition to it's value, each list item contains a pointer to the next
|
||||
* item in the list (pxNext), a pointer to the list it is in (pxContainer)
|
||||
* and a pointer to back to the object that contains it. These later two
|
||||
* pointers are included for efficiency of list manipulation. There is
|
||||
* effectively a two way link between the object containing the list item and
|
||||
* the list item itself.
|
||||
*
|
||||
*
|
||||
* \page ListIntroduction List Implementation
|
||||
* \ingroup FreeRTOSIntro
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
#ifndef INC_FREERTOS_H
|
||||
#error "FreeRTOS.h must be included before list.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The list structure members are modified from within interrupts, and therefore
|
||||
* by rights should be declared volatile. However, they are only modified in a
|
||||
* functionally atomic way (within critical sections of with the scheduler
|
||||
* suspended) and are either passed by reference into a function or indexed via
|
||||
* a volatile variable. Therefore, in all use cases tested so far, the volatile
|
||||
* qualifier can be omitted in order to provide a moderate performance
|
||||
* improvement without adversely affecting functional behaviour. The assembly
|
||||
* instructions generated by the IAR, ARM and GCC compilers when the respective
|
||||
* compiler's options were set for maximum optimisation has been inspected and
|
||||
* deemed to be as intended. That said, as compiler technology advances, and
|
||||
* especially if aggressive cross module optimisation is used (a use case that
|
||||
* has not been exercised to any great extend) then it is feasible that the
|
||||
* volatile qualifier will be needed for correct optimisation. It is expected
|
||||
* that a compiler removing essential code because, without the volatile
|
||||
* qualifier on the list structure members and with aggressive cross module
|
||||
* optimisation, the compiler deemed the code unnecessary will result in
|
||||
* complete and obvious failure of the scheduler. If this is ever experienced
|
||||
* then the volatile qualifier can be inserted in the relevant places within the
|
||||
* list structures by simply defining configLIST_VOLATILE to volatile in
|
||||
* FreeRTOSConfig.h (as per the example at the bottom of this comment block).
|
||||
* If configLIST_VOLATILE is not defined then the preprocessor directives below
|
||||
* will simply #define configLIST_VOLATILE away completely.
|
||||
*
|
||||
* To use volatile list structure members then add the following line to
|
||||
* FreeRTOSConfig.h (without the quotes):
|
||||
* "#define configLIST_VOLATILE volatile"
|
||||
*/
|
||||
#ifndef configLIST_VOLATILE
|
||||
#define configLIST_VOLATILE
|
||||
#endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Macros that can be used to place known values within the list structures,
|
||||
* then check that the known values do not get corrupted during the execution of
|
||||
* the application. These may catch the list data structures being overwritten in
|
||||
* memory. They will not catch data errors caused by incorrect configuration or
|
||||
* use of FreeRTOS.*/
|
||||
#if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 )
|
||||
/* Define the macros to do nothing. */
|
||||
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE
|
||||
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE
|
||||
#define listFIRST_LIST_INTEGRITY_CHECK_VALUE
|
||||
#define listSECOND_LIST_INTEGRITY_CHECK_VALUE
|
||||
#define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )
|
||||
#define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )
|
||||
#define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList )
|
||||
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList )
|
||||
#define listTEST_LIST_ITEM_INTEGRITY( pxItem )
|
||||
#define listTEST_LIST_INTEGRITY( pxList )
|
||||
#else /* if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) */
|
||||
/* Define macros that add new members into the list structures. */
|
||||
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1;
|
||||
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2;
|
||||
#define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1;
|
||||
#define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2;
|
||||
|
||||
/* Define macros that set the new structure members to known values. */
|
||||
#define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
|
||||
#define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
|
||||
#define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
|
||||
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
|
||||
|
||||
/* Define macros that will assert if one of the structure members does not
|
||||
* contain its expected value. */
|
||||
#define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
|
||||
#define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
|
||||
#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */
|
||||
|
||||
|
||||
/*
|
||||
* Definition of the only type of object that a list can contain.
|
||||
*/
|
||||
struct xLIST;
|
||||
struct xLIST_ITEM
|
||||
{
|
||||
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
|
||||
configLIST_VOLATILE TickType_t xItemValue; /**< The value being listed. In most cases this is used to sort the list in ascending order. */
|
||||
struct xLIST_ITEM * configLIST_VOLATILE pxNext; /**< Pointer to the next ListItem_t in the list. */
|
||||
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /**< Pointer to the previous ListItem_t in the list. */
|
||||
void * pvOwner; /**< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
|
||||
struct xLIST * configLIST_VOLATILE pxContainer; /**< Pointer to the list in which this list item is placed (if any). */
|
||||
listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
|
||||
};
|
||||
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */
|
||||
|
||||
#if ( configUSE_MINI_LIST_ITEM == 1 )
|
||||
struct xMINI_LIST_ITEM
|
||||
{
|
||||
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
|
||||
configLIST_VOLATILE TickType_t xItemValue;
|
||||
struct xLIST_ITEM * configLIST_VOLATILE pxNext;
|
||||
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;
|
||||
};
|
||||
typedef struct xMINI_LIST_ITEM MiniListItem_t;
|
||||
#else
|
||||
typedef struct xLIST_ITEM MiniListItem_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Definition of the type of queue used by the scheduler.
|
||||
*/
|
||||
typedef struct xLIST
|
||||
{
|
||||
listFIRST_LIST_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
|
||||
volatile UBaseType_t uxNumberOfItems;
|
||||
ListItem_t * configLIST_VOLATILE pxIndex; /**< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
|
||||
MiniListItem_t xListEnd; /**< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
|
||||
listSECOND_LIST_INTEGRITY_CHECK_VALUE /**< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
|
||||
} List_t;
|
||||
|
||||
/*
|
||||
* Access macro to set the owner of a list item. The owner of a list item
|
||||
* is the object (usually a TCB) that contains the list item.
|
||||
*
|
||||
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) )
|
||||
|
||||
/*
|
||||
* Access macro to get the owner of a list item. The owner of a list item
|
||||
* is the object (usually a TCB) that contains the list item.
|
||||
*
|
||||
* \page listGET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner )
|
||||
|
||||
/*
|
||||
* Access macro to set the value of the list item. In most cases the value is
|
||||
* used to sort the list in ascending order.
|
||||
*
|
||||
* \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) )
|
||||
|
||||
/*
|
||||
* Access macro to retrieve the value of the list item. The value can
|
||||
* represent anything - for example the priority of a task, or the time at
|
||||
* which a task should be unblocked.
|
||||
*
|
||||
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue )
|
||||
|
||||
/*
|
||||
* Access macro to retrieve the value of the list item at the head of a given
|
||||
* list.
|
||||
*
|
||||
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue )
|
||||
|
||||
/*
|
||||
* Return the list item at the head of the list.
|
||||
*
|
||||
* \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext )
|
||||
|
||||
/*
|
||||
* Return the next list item.
|
||||
*
|
||||
* \page listGET_NEXT listGET_NEXT
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext )
|
||||
|
||||
/*
|
||||
* Return the list item that marks the end of the list
|
||||
*
|
||||
* \page listGET_END_MARKER listGET_END_MARKER
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) )
|
||||
|
||||
/*
|
||||
* Access macro to determine if a list contains any items. The macro will
|
||||
* only have the value true if the list is empty.
|
||||
*
|
||||
* \page listLIST_IS_EMPTY listLIST_IS_EMPTY
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE )
|
||||
|
||||
/*
|
||||
* Access macro to return the number of items in the list.
|
||||
*/
|
||||
#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems )
|
||||
|
||||
/*
|
||||
* Access function to obtain the owner of the next entry in a list.
|
||||
*
|
||||
* The list member pxIndex is used to walk through a list. Calling
|
||||
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list
|
||||
* and returns that entry's pxOwner parameter. Using multiple calls to this
|
||||
* function it is therefore possible to move through every item contained in
|
||||
* a list.
|
||||
*
|
||||
* The pxOwner parameter of a list item is a pointer to the object that owns
|
||||
* the list item. In the scheduler this is normally a task control block.
|
||||
* The pxOwner parameter effectively creates a two way link between the list
|
||||
* item and its owner.
|
||||
*
|
||||
* @param pxTCB pxTCB is set to the address of the owner of the next list item.
|
||||
* @param pxList The list from which the next item owner is to be returned.
|
||||
*
|
||||
* \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \
|
||||
do { \
|
||||
List_t * const pxConstList = ( pxList ); \
|
||||
/* Increment the index to the next item and return the item, ensuring */ \
|
||||
/* we don't return the marker used at the end of the list. */ \
|
||||
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
|
||||
if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \
|
||||
{ \
|
||||
( pxConstList )->pxIndex = ( pxConstList )->xListEnd.pxNext; \
|
||||
} \
|
||||
( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
* Version of uxListRemove() that does not return a value. Provided as a slight
|
||||
* optimisation for xTaskIncrementTick() by being inline.
|
||||
*
|
||||
* Remove an item from a list. The list item has a pointer to the list that
|
||||
* it is in, so only the list item need be passed into the function.
|
||||
*
|
||||
* @param uxListRemove The item to be removed. The item will remove itself from
|
||||
* the list pointed to by it's pxContainer parameter.
|
||||
*
|
||||
* @return The number of items that remain in the list after the list item has
|
||||
* been removed.
|
||||
*
|
||||
* \page listREMOVE_ITEM listREMOVE_ITEM
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listREMOVE_ITEM( pxItemToRemove ) \
|
||||
do { \
|
||||
/* The list item knows which list it is in. Obtain the list from the list \
|
||||
* item. */ \
|
||||
List_t * const pxList = ( pxItemToRemove )->pxContainer; \
|
||||
\
|
||||
( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \
|
||||
( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \
|
||||
/* Make sure the index is left pointing to a valid item. */ \
|
||||
if( pxList->pxIndex == ( pxItemToRemove ) ) \
|
||||
{ \
|
||||
pxList->pxIndex = ( pxItemToRemove )->pxPrevious; \
|
||||
} \
|
||||
\
|
||||
( pxItemToRemove )->pxContainer = NULL; \
|
||||
( pxList->uxNumberOfItems )--; \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
* Inline version of vListInsertEnd() to provide slight optimisation for
|
||||
* xTaskIncrementTick().
|
||||
*
|
||||
* Insert a list item into a list. The item will be inserted in a position
|
||||
* such that it will be the last item within the list returned by multiple
|
||||
* calls to listGET_OWNER_OF_NEXT_ENTRY.
|
||||
*
|
||||
* The list member pxIndex is used to walk through a list. Calling
|
||||
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list.
|
||||
* Placing an item in a list using vListInsertEnd effectively places the item
|
||||
* in the list position pointed to by pxIndex. This means that every other
|
||||
* item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before
|
||||
* the pxIndex parameter again points to the item being inserted.
|
||||
*
|
||||
* @param pxList The list into which the item is to be inserted.
|
||||
*
|
||||
* @param pxNewListItem The list item to be inserted into the list.
|
||||
*
|
||||
* \page listINSERT_END listINSERT_END
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listINSERT_END( pxList, pxNewListItem ) \
|
||||
do { \
|
||||
ListItem_t * const pxIndex = ( pxList )->pxIndex; \
|
||||
\
|
||||
/* Only effective when configASSERT() is also defined, these tests may catch \
|
||||
* the list data structures being overwritten in memory. They will not catch \
|
||||
* data errors caused by incorrect configuration or use of FreeRTOS. */ \
|
||||
listTEST_LIST_INTEGRITY( ( pxList ) ); \
|
||||
listTEST_LIST_ITEM_INTEGRITY( ( pxNewListItem ) ); \
|
||||
\
|
||||
/* Insert a new list item into ( pxList ), but rather than sort the list, \
|
||||
* makes the new list item the last item to be removed by a call to \
|
||||
* listGET_OWNER_OF_NEXT_ENTRY(). */ \
|
||||
( pxNewListItem )->pxNext = pxIndex; \
|
||||
( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \
|
||||
\
|
||||
pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \
|
||||
pxIndex->pxPrevious = ( pxNewListItem ); \
|
||||
\
|
||||
/* Remember which list the item is in. */ \
|
||||
( pxNewListItem )->pxContainer = ( pxList ); \
|
||||
\
|
||||
( ( pxList )->uxNumberOfItems )++; \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
* Access function to obtain the owner of the first entry in a list. Lists
|
||||
* are normally sorted in ascending item value order.
|
||||
*
|
||||
* This function returns the pxOwner member of the first item in the list.
|
||||
* The pxOwner parameter of a list item is a pointer to the object that owns
|
||||
* the list item. In the scheduler this is normally a task control block.
|
||||
* The pxOwner parameter effectively creates a two way link between the list
|
||||
* item and its owner.
|
||||
*
|
||||
* @param pxList The list from which the owner of the head item is to be
|
||||
* returned.
|
||||
*
|
||||
* \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( &( ( pxList )->xListEnd ) )->pxNext->pvOwner )
|
||||
|
||||
/*
|
||||
* Check to see if a list item is within a list. The list item maintains a
|
||||
* "container" pointer that points to the list it is in. All this macro does
|
||||
* is check to see if the container and the list match.
|
||||
*
|
||||
* @param pxList The list we want to know if the list item is within.
|
||||
* @param pxListItem The list item we want to know if is in the list.
|
||||
* @return pdTRUE if the list item is in the list, otherwise pdFALSE.
|
||||
*/
|
||||
#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) )
|
||||
|
||||
/*
|
||||
* Return the list a list item is contained within (referenced from).
|
||||
*
|
||||
* @param pxListItem The list item being queried.
|
||||
* @return A pointer to the List_t object that references the pxListItem
|
||||
*/
|
||||
#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer )
|
||||
|
||||
/*
|
||||
* This provides a crude means of knowing if a list has been initialised, as
|
||||
* pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise()
|
||||
* function.
|
||||
*/
|
||||
#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY )
|
||||
|
||||
/*
|
||||
* Must be called before a list is used! This initialises all the members
|
||||
* of the list structure and inserts the xListEnd item into the list as a
|
||||
* marker to the back of the list.
|
||||
*
|
||||
* @param pxList Pointer to the list being initialised.
|
||||
*
|
||||
* \page vListInitialise vListInitialise
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* Must be called before a list item is used. This sets the list container to
|
||||
* null so the item does not think that it is already contained in a list.
|
||||
*
|
||||
* @param pxItem Pointer to the list item being initialised.
|
||||
*
|
||||
* \page vListInitialiseItem vListInitialiseItem
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* Insert a list item into a list. The item will be inserted into the list in
|
||||
* a position determined by its item value (ascending item value order).
|
||||
*
|
||||
* @param pxList The list into which the item is to be inserted.
|
||||
*
|
||||
* @param pxNewListItem The item that is to be placed in the list.
|
||||
*
|
||||
* \page vListInsert vListInsert
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInsert( List_t * const pxList,
|
||||
ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* Insert a list item into a list. The item will be inserted in a position
|
||||
* such that it will be the last item within the list returned by multiple
|
||||
* calls to listGET_OWNER_OF_NEXT_ENTRY.
|
||||
*
|
||||
* The list member pxIndex is used to walk through a list. Calling
|
||||
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list.
|
||||
* Placing an item in a list using vListInsertEnd effectively places the item
|
||||
* in the list position pointed to by pxIndex. This means that every other
|
||||
* item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before
|
||||
* the pxIndex parameter again points to the item being inserted.
|
||||
*
|
||||
* @param pxList The list into which the item is to be inserted.
|
||||
*
|
||||
* @param pxNewListItem The list item to be inserted into the list.
|
||||
*
|
||||
* \page vListInsertEnd vListInsertEnd
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInsertEnd( List_t * const pxList,
|
||||
ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* Remove an item from a list. The list item has a pointer to the list that
|
||||
* it is in, so only the list item need be passed into the function.
|
||||
*
|
||||
* @param uxListRemove The item to be removed. The item will remove itself from
|
||||
* the list pointed to by it's pxContainer parameter.
|
||||
*
|
||||
* @return The number of items that remain in the list after the list item has
|
||||
* been removed.
|
||||
*
|
||||
* \page uxListRemove uxListRemove
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* ifndef LIST_H */
|
||||
@@ -0,0 +1,887 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Message buffers build functionality on top of FreeRTOS stream buffers.
|
||||
* Whereas stream buffers are used to send a continuous stream of data from one
|
||||
* task or interrupt to another, message buffers are used to send variable
|
||||
* length discrete messages from one task or interrupt to another. Their
|
||||
* implementation is light weight, making them particularly suited for interrupt
|
||||
* to task and core to core communication scenarios.
|
||||
*
|
||||
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
|
||||
* implementation (so also the message buffer implementation, as message buffers
|
||||
* are built on top of stream buffers) assumes there is only one task or
|
||||
* interrupt that will write to the buffer (the writer), and only one task or
|
||||
* interrupt that will read from the buffer (the reader). It is safe for the
|
||||
* writer and reader to be different tasks or interrupts, but, unlike other
|
||||
* FreeRTOS objects, it is not safe to have multiple different writers or
|
||||
* multiple different readers. If there are to be multiple different writers
|
||||
* then the application writer must place each call to a writing API function
|
||||
* (such as xMessageBufferSend()) inside a critical section and set the send
|
||||
* block time to 0. Likewise, if there are to be multiple different readers
|
||||
* then the application writer must place each call to a reading API function
|
||||
* (such as xMessageBufferRead()) inside a critical section and set the receive
|
||||
* timeout to 0.
|
||||
*
|
||||
* Message buffers hold variable length messages. To enable that, when a
|
||||
* message is written to the message buffer an additional sizeof( size_t ) bytes
|
||||
* are also written to store the message's length (that happens internally, with
|
||||
* the API function). sizeof( size_t ) is typically 4 bytes on a 32-bit
|
||||
* architecture, so writing a 10 byte message to a message buffer on a 32-bit
|
||||
* architecture will actually reduce the available space in the message buffer
|
||||
* by 14 bytes (10 byte are used by the message, and 4 bytes to hold the length
|
||||
* of the message).
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_MESSAGE_BUFFER_H
|
||||
#define FREERTOS_MESSAGE_BUFFER_H
|
||||
|
||||
#ifndef INC_FREERTOS_H
|
||||
#error "include FreeRTOS.h must appear in source files before include message_buffer.h"
|
||||
#endif
|
||||
|
||||
/* Message buffers are built onto of stream buffers. */
|
||||
#include "stream_buffer.h"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#if defined( __cplusplus )
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/**
|
||||
* Type by which message buffers are referenced. For example, a call to
|
||||
* xMessageBufferCreate() returns an MessageBufferHandle_t variable that can
|
||||
* then be used as a parameter to xMessageBufferSend(), xMessageBufferReceive(),
|
||||
* etc. Message buffer is essentially built as a stream buffer hence its handle
|
||||
* is also set to same type as a stream buffer handle.
|
||||
*/
|
||||
typedef StreamBufferHandle_t MessageBufferHandle_t;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes );
|
||||
* @endcode
|
||||
*
|
||||
* Creates a new message buffer using dynamically allocated memory. See
|
||||
* xMessageBufferCreateStatic() for a version that uses statically allocated
|
||||
* memory (memory that is allocated at compile time).
|
||||
*
|
||||
* configSUPPORT_DYNAMIC_ALLOCATION must be set to 1 or left undefined in
|
||||
* FreeRTOSConfig.h for xMessageBufferCreate() to be available.
|
||||
*
|
||||
* @param xBufferSizeBytes The total number of bytes (not messages) the message
|
||||
* buffer will be able to hold at any one time. When a message is written to
|
||||
* the message buffer an additional sizeof( size_t ) bytes are also written to
|
||||
* store the message's length. sizeof( size_t ) is typically 4 bytes on a
|
||||
* 32-bit architecture, so on most 32-bit architectures a 10 byte message will
|
||||
* take up 14 bytes of message buffer space.
|
||||
*
|
||||
* @param pxSendCompletedCallback Callback invoked when a send operation to the
|
||||
* message buffer is complete. If the parameter is NULL or xMessageBufferCreate()
|
||||
* is called without the parameter, then it will use the default implementation
|
||||
* provided by sbSEND_COMPLETED macro. To enable the callback,
|
||||
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
|
||||
*
|
||||
* @param pxReceiveCompletedCallback Callback invoked when a receive operation from
|
||||
* the message buffer is complete. If the parameter is NULL or xMessageBufferCreate()
|
||||
* is called without the parameter, it will use the default implementation provided
|
||||
* by sbRECEIVE_COMPLETED macro. To enable the callback,
|
||||
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
|
||||
*
|
||||
* @return If NULL is returned, then the message buffer cannot be created
|
||||
* because there is insufficient heap memory available for FreeRTOS to allocate
|
||||
* the message buffer data structures and storage area. A non-NULL value being
|
||||
* returned indicates that the message buffer has been created successfully -
|
||||
* the returned value should be stored as the handle to the created message
|
||||
* buffer.
|
||||
*
|
||||
* Example use:
|
||||
* @code{c}
|
||||
*
|
||||
* void vAFunction( void )
|
||||
* {
|
||||
* MessageBufferHandle_t xMessageBuffer;
|
||||
* const size_t xMessageBufferSizeBytes = 100;
|
||||
*
|
||||
* // Create a message buffer that can hold 100 bytes. The memory used to hold
|
||||
* // both the message buffer structure and the messages themselves is allocated
|
||||
* // dynamically. Each message added to the buffer consumes an additional 4
|
||||
* // bytes which are used to hold the length of the message.
|
||||
* xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes );
|
||||
*
|
||||
* if( xMessageBuffer == NULL )
|
||||
* {
|
||||
* // There was not enough heap memory space available to create the
|
||||
* // message buffer.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // The message buffer was created successfully and can now be used.
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* \defgroup xMessageBufferCreate xMessageBufferCreate
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferCreate( xBufferSizeBytes ) \
|
||||
xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( size_t ) 0, pdTRUE, NULL, NULL )
|
||||
|
||||
#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
|
||||
#define xMessageBufferCreateWithCallback( xBufferSizeBytes, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
|
||||
xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( size_t ) 0, pdTRUE, ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes,
|
||||
* uint8_t *pucMessageBufferStorageArea,
|
||||
* StaticMessageBuffer_t *pxStaticMessageBuffer );
|
||||
* @endcode
|
||||
* Creates a new message buffer using statically allocated memory. See
|
||||
* xMessageBufferCreate() for a version that uses dynamically allocated memory.
|
||||
*
|
||||
* @param xBufferSizeBytes The size, in bytes, of the buffer pointed to by the
|
||||
* pucMessageBufferStorageArea parameter. When a message is written to the
|
||||
* message buffer an additional sizeof( size_t ) bytes are also written to store
|
||||
* the message's length. sizeof( size_t ) is typically 4 bytes on a 32-bit
|
||||
* architecture, so on most 32-bit architecture a 10 byte message will take up
|
||||
* 14 bytes of message buffer space. The maximum number of bytes that can be
|
||||
* stored in the message buffer is actually (xBufferSizeBytes - 1).
|
||||
*
|
||||
* @param pucMessageBufferStorageArea Must point to a uint8_t array that is at
|
||||
* least xBufferSizeBytes big. This is the array to which messages are
|
||||
* copied when they are written to the message buffer.
|
||||
*
|
||||
* @param pxStaticMessageBuffer Must point to a variable of type
|
||||
* StaticMessageBuffer_t, which will be used to hold the message buffer's data
|
||||
* structure.
|
||||
*
|
||||
* @param pxSendCompletedCallback Callback invoked when a new message is sent to the message buffer.
|
||||
* If the parameter is NULL or xMessageBufferCreate() is called without the parameter, then it will use the default
|
||||
* implementation provided by sbSEND_COMPLETED macro. To enable the callback,
|
||||
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
|
||||
*
|
||||
* @param pxReceiveCompletedCallback Callback invoked when a message is read from a
|
||||
* message buffer. If the parameter is NULL or xMessageBufferCreate() is called without the parameter, it will
|
||||
* use the default implementation provided by sbRECEIVE_COMPLETED macro. To enable the callback,
|
||||
* configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
|
||||
*
|
||||
* @return If the message buffer is created successfully then a handle to the
|
||||
* created message buffer is returned. If either pucMessageBufferStorageArea or
|
||||
* pxStaticmessageBuffer are NULL then NULL is returned.
|
||||
*
|
||||
* Example use:
|
||||
* @code{c}
|
||||
*
|
||||
* // Used to dimension the array used to hold the messages. The available space
|
||||
* // will actually be one less than this, so 999.
|
||||
#define STORAGE_SIZE_BYTES 1000
|
||||
*
|
||||
* // Defines the memory that will actually hold the messages within the message
|
||||
* // buffer.
|
||||
* static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ];
|
||||
*
|
||||
* // The variable used to hold the message buffer structure.
|
||||
* StaticMessageBuffer_t xMessageBufferStruct;
|
||||
*
|
||||
* void MyFunction( void )
|
||||
* {
|
||||
* MessageBufferHandle_t xMessageBuffer;
|
||||
*
|
||||
* xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucStorageBuffer ),
|
||||
* ucStorageBuffer,
|
||||
* &xMessageBufferStruct );
|
||||
*
|
||||
* // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer
|
||||
* // parameters were NULL, xMessageBuffer will not be NULL, and can be used to
|
||||
* // reference the created message buffer in other message buffer API calls.
|
||||
*
|
||||
* // Other code that uses the message buffer can go here.
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* \defgroup xMessageBufferCreateStatic xMessageBufferCreateStatic
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) \
|
||||
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), 0, pdTRUE, ( pucMessageBufferStorageArea ), ( pxStaticMessageBuffer ), NULL, NULL )
|
||||
|
||||
#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
|
||||
#define xMessageBufferCreateStaticWithCallback( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
|
||||
xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), 0, pdTRUE, ( pucMessageBufferStorageArea ), ( pxStaticMessageBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* BaseType_t xMessageBufferGetStaticBuffers( MessageBufferHandle_t xMessageBuffer,
|
||||
* uint8_t ** ppucMessageBufferStorageArea,
|
||||
* StaticMessageBuffer_t ** ppxStaticMessageBuffer );
|
||||
* @endcode
|
||||
*
|
||||
* Retrieve pointers to a statically created message buffer's data structure
|
||||
* buffer and storage area buffer. These are the same buffers that are supplied
|
||||
* at the time of creation.
|
||||
*
|
||||
* @param xMessageBuffer The message buffer for which to retrieve the buffers.
|
||||
*
|
||||
* @param ppucMessageBufferStorageArea Used to return a pointer to the
|
||||
* message buffer's storage area buffer.
|
||||
*
|
||||
* @param ppxStaticMessageBuffer Used to return a pointer to the message
|
||||
* buffer's data structure buffer.
|
||||
*
|
||||
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise..
|
||||
*
|
||||
* \defgroup xMessageBufferGetStaticBuffers xMessageBufferGetStaticBuffers
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
#define xMessageBufferGetStaticBuffers( xMessageBuffer, ppucMessageBufferStorageArea, ppxStaticMessageBuffer ) \
|
||||
xStreamBufferGetStaticBuffers( ( xMessageBuffer ), ( ppucMessageBufferStorageArea ), ( ppxStaticMessageBuffer ) )
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer,
|
||||
* const void *pvTxData,
|
||||
* size_t xDataLengthBytes,
|
||||
* TickType_t xTicksToWait );
|
||||
* @endcode
|
||||
*
|
||||
* Sends a discrete message to the message buffer. The message can be any
|
||||
* length that fits within the buffer's free space, and is copied into the
|
||||
* buffer.
|
||||
*
|
||||
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
|
||||
* implementation (so also the message buffer implementation, as message buffers
|
||||
* are built on top of stream buffers) assumes there is only one task or
|
||||
* interrupt that will write to the buffer (the writer), and only one task or
|
||||
* interrupt that will read from the buffer (the reader). It is safe for the
|
||||
* writer and reader to be different tasks or interrupts, but, unlike other
|
||||
* FreeRTOS objects, it is not safe to have multiple different writers or
|
||||
* multiple different readers. If there are to be multiple different writers
|
||||
* then the application writer must place each call to a writing API function
|
||||
* (such as xMessageBufferSend()) inside a critical section and set the send
|
||||
* block time to 0. Likewise, if there are to be multiple different readers
|
||||
* then the application writer must place each call to a reading API function
|
||||
* (such as xMessageBufferRead()) inside a critical section and set the receive
|
||||
* block time to 0.
|
||||
*
|
||||
* Use xMessageBufferSend() to write to a message buffer from a task. Use
|
||||
* xMessageBufferSendFromISR() to write to a message buffer from an interrupt
|
||||
* service routine (ISR).
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer to which a message is
|
||||
* being sent.
|
||||
*
|
||||
* @param pvTxData A pointer to the message that is to be copied into the
|
||||
* message buffer.
|
||||
*
|
||||
* @param xDataLengthBytes The length of the message. That is, the number of
|
||||
* bytes to copy from pvTxData into the message buffer. When a message is
|
||||
* written to the message buffer an additional sizeof( size_t ) bytes are also
|
||||
* written to store the message's length. sizeof( size_t ) is typically 4 bytes
|
||||
* on a 32-bit architecture, so on most 32-bit architecture setting
|
||||
* xDataLengthBytes to 20 will reduce the free space in the message buffer by 24
|
||||
* bytes (20 bytes of message data and 4 bytes to hold the message length).
|
||||
*
|
||||
* @param xTicksToWait The maximum amount of time the calling task should remain
|
||||
* in the Blocked state to wait for enough space to become available in the
|
||||
* message buffer, should the message buffer have insufficient space when
|
||||
* xMessageBufferSend() is called. The calling task will never block if
|
||||
* xTicksToWait is zero. The block time is specified in tick periods, so the
|
||||
* absolute time it represents is dependent on the tick frequency. The macro
|
||||
* pdMS_TO_TICKS() can be used to convert a time specified in milliseconds into
|
||||
* a time specified in ticks. Setting xTicksToWait to portMAX_DELAY will cause
|
||||
* the task to wait indefinitely (without timing out), provided
|
||||
* INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h. Tasks do not use any
|
||||
* CPU time when they are in the Blocked state.
|
||||
*
|
||||
* @return The number of bytes written to the message buffer. If the call to
|
||||
* xMessageBufferSend() times out before there was enough space to write the
|
||||
* message into the message buffer then zero is returned. If the call did not
|
||||
* time out then xDataLengthBytes is returned.
|
||||
*
|
||||
* Example use:
|
||||
* @code{c}
|
||||
* void vAFunction( MessageBufferHandle_t xMessageBuffer )
|
||||
* {
|
||||
* size_t xBytesSent;
|
||||
* uint8_t ucArrayToSend[] = { 0, 1, 2, 3 };
|
||||
* char *pcStringToSend = "String to send";
|
||||
* const TickType_t x100ms = pdMS_TO_TICKS( 100 );
|
||||
*
|
||||
* // Send an array to the message buffer, blocking for a maximum of 100ms to
|
||||
* // wait for enough space to be available in the message buffer.
|
||||
* xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms );
|
||||
*
|
||||
* if( xBytesSent != sizeof( ucArrayToSend ) )
|
||||
* {
|
||||
* // The call to xMessageBufferSend() times out before there was enough
|
||||
* // space in the buffer for the data to be written.
|
||||
* }
|
||||
*
|
||||
* // Send the string to the message buffer. Return immediately if there is
|
||||
* // not enough space in the buffer.
|
||||
* xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 );
|
||||
*
|
||||
* if( xBytesSent != strlen( pcStringToSend ) )
|
||||
* {
|
||||
* // The string could not be added to the message buffer because there was
|
||||
* // not enough free space in the buffer.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xMessageBufferSend xMessageBufferSend
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) \
|
||||
xStreamBufferSend( ( xMessageBuffer ), ( pvTxData ), ( xDataLengthBytes ), ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer,
|
||||
* const void *pvTxData,
|
||||
* size_t xDataLengthBytes,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
* @endcode
|
||||
*
|
||||
* Interrupt safe version of the API function that sends a discrete message to
|
||||
* the message buffer. The message can be any length that fits within the
|
||||
* buffer's free space, and is copied into the buffer.
|
||||
*
|
||||
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
|
||||
* implementation (so also the message buffer implementation, as message buffers
|
||||
* are built on top of stream buffers) assumes there is only one task or
|
||||
* interrupt that will write to the buffer (the writer), and only one task or
|
||||
* interrupt that will read from the buffer (the reader). It is safe for the
|
||||
* writer and reader to be different tasks or interrupts, but, unlike other
|
||||
* FreeRTOS objects, it is not safe to have multiple different writers or
|
||||
* multiple different readers. If there are to be multiple different writers
|
||||
* then the application writer must place each call to a writing API function
|
||||
* (such as xMessageBufferSend()) inside a critical section and set the send
|
||||
* block time to 0. Likewise, if there are to be multiple different readers
|
||||
* then the application writer must place each call to a reading API function
|
||||
* (such as xMessageBufferRead()) inside a critical section and set the receive
|
||||
* block time to 0.
|
||||
*
|
||||
* Use xMessageBufferSend() to write to a message buffer from a task. Use
|
||||
* xMessageBufferSendFromISR() to write to a message buffer from an interrupt
|
||||
* service routine (ISR).
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer to which a message is
|
||||
* being sent.
|
||||
*
|
||||
* @param pvTxData A pointer to the message that is to be copied into the
|
||||
* message buffer.
|
||||
*
|
||||
* @param xDataLengthBytes The length of the message. That is, the number of
|
||||
* bytes to copy from pvTxData into the message buffer. When a message is
|
||||
* written to the message buffer an additional sizeof( size_t ) bytes are also
|
||||
* written to store the message's length. sizeof( size_t ) is typically 4 bytes
|
||||
* on a 32-bit architecture, so on most 32-bit architecture setting
|
||||
* xDataLengthBytes to 20 will reduce the free space in the message buffer by 24
|
||||
* bytes (20 bytes of message data and 4 bytes to hold the message length).
|
||||
*
|
||||
* @param pxHigherPriorityTaskWoken It is possible that a message buffer will
|
||||
* have a task blocked on it waiting for data. Calling
|
||||
* xMessageBufferSendFromISR() can make data available, and so cause a task that
|
||||
* was waiting for data to leave the Blocked state. If calling
|
||||
* xMessageBufferSendFromISR() causes a task to leave the Blocked state, and the
|
||||
* unblocked task has a priority higher than the currently executing task (the
|
||||
* task that was interrupted), then, internally, xMessageBufferSendFromISR()
|
||||
* will set *pxHigherPriorityTaskWoken to pdTRUE. If
|
||||
* xMessageBufferSendFromISR() sets this value to pdTRUE, then normally a
|
||||
* context switch should be performed before the interrupt is exited. This will
|
||||
* ensure that the interrupt returns directly to the highest priority Ready
|
||||
* state task. *pxHigherPriorityTaskWoken should be set to pdFALSE before it
|
||||
* is passed into the function. See the code example below for an example.
|
||||
*
|
||||
* @return The number of bytes actually written to the message buffer. If the
|
||||
* message buffer didn't have enough free space for the message to be stored
|
||||
* then 0 is returned, otherwise xDataLengthBytes is returned.
|
||||
*
|
||||
* Example use:
|
||||
* @code{c}
|
||||
* // A message buffer that has already been created.
|
||||
* MessageBufferHandle_t xMessageBuffer;
|
||||
*
|
||||
* void vAnInterruptServiceRoutine( void )
|
||||
* {
|
||||
* size_t xBytesSent;
|
||||
* char *pcStringToSend = "String to send";
|
||||
* BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE.
|
||||
*
|
||||
* // Attempt to send the string to the message buffer.
|
||||
* xBytesSent = xMessageBufferSendFromISR( xMessageBuffer,
|
||||
* ( void * ) pcStringToSend,
|
||||
* strlen( pcStringToSend ),
|
||||
* &xHigherPriorityTaskWoken );
|
||||
*
|
||||
* if( xBytesSent != strlen( pcStringToSend ) )
|
||||
* {
|
||||
* // The string could not be added to the message buffer because there was
|
||||
* // not enough free space in the buffer.
|
||||
* }
|
||||
*
|
||||
* // If xHigherPriorityTaskWoken was set to pdTRUE inside
|
||||
* // xMessageBufferSendFromISR() then a task that has a priority above the
|
||||
* // priority of the currently executing task was unblocked and a context
|
||||
* // switch should be performed to ensure the ISR returns to the unblocked
|
||||
* // task. In most FreeRTOS ports this is done by simply passing
|
||||
* // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the
|
||||
* // variables value, and perform the context switch if necessary. Check the
|
||||
* // documentation for the port in use for port specific instructions.
|
||||
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xMessageBufferSendFromISR xMessageBufferSendFromISR
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) \
|
||||
xStreamBufferSendFromISR( ( xMessageBuffer ), ( pvTxData ), ( xDataLengthBytes ), ( pxHigherPriorityTaskWoken ) )
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer,
|
||||
* void *pvRxData,
|
||||
* size_t xBufferLengthBytes,
|
||||
* TickType_t xTicksToWait );
|
||||
* @endcode
|
||||
*
|
||||
* Receives a discrete message from a message buffer. Messages can be of
|
||||
* variable length and are copied out of the buffer.
|
||||
*
|
||||
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
|
||||
* implementation (so also the message buffer implementation, as message buffers
|
||||
* are built on top of stream buffers) assumes there is only one task or
|
||||
* interrupt that will write to the buffer (the writer), and only one task or
|
||||
* interrupt that will read from the buffer (the reader). It is safe for the
|
||||
* writer and reader to be different tasks or interrupts, but, unlike other
|
||||
* FreeRTOS objects, it is not safe to have multiple different writers or
|
||||
* multiple different readers. If there are to be multiple different writers
|
||||
* then the application writer must place each call to a writing API function
|
||||
* (such as xMessageBufferSend()) inside a critical section and set the send
|
||||
* block time to 0. Likewise, if there are to be multiple different readers
|
||||
* then the application writer must place each call to a reading API function
|
||||
* (such as xMessageBufferRead()) inside a critical section and set the receive
|
||||
* block time to 0.
|
||||
*
|
||||
* Use xMessageBufferReceive() to read from a message buffer from a task. Use
|
||||
* xMessageBufferReceiveFromISR() to read from a message buffer from an
|
||||
* interrupt service routine (ISR).
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer from which a message
|
||||
* is being received.
|
||||
*
|
||||
* @param pvRxData A pointer to the buffer into which the received message is
|
||||
* to be copied.
|
||||
*
|
||||
* @param xBufferLengthBytes The length of the buffer pointed to by the pvRxData
|
||||
* parameter. This sets the maximum length of the message that can be received.
|
||||
* If xBufferLengthBytes is too small to hold the next message then the message
|
||||
* will be left in the message buffer and 0 will be returned.
|
||||
*
|
||||
* @param xTicksToWait The maximum amount of time the task should remain in the
|
||||
* Blocked state to wait for a message, should the message buffer be empty.
|
||||
* xMessageBufferReceive() will return immediately if xTicksToWait is zero and
|
||||
* the message buffer is empty. The block time is specified in tick periods, so
|
||||
* the absolute time it represents is dependent on the tick frequency. The
|
||||
* macro pdMS_TO_TICKS() can be used to convert a time specified in milliseconds
|
||||
* into a time specified in ticks. Setting xTicksToWait to portMAX_DELAY will
|
||||
* cause the task to wait indefinitely (without timing out), provided
|
||||
* INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h. Tasks do not use any
|
||||
* CPU time when they are in the Blocked state.
|
||||
*
|
||||
* @return The length, in bytes, of the message read from the message buffer, if
|
||||
* any. If xMessageBufferReceive() times out before a message became available
|
||||
* then zero is returned. If the length of the message is greater than
|
||||
* xBufferLengthBytes then the message will be left in the message buffer and
|
||||
* zero is returned.
|
||||
*
|
||||
* Example use:
|
||||
* @code{c}
|
||||
* void vAFunction( MessageBuffer_t xMessageBuffer )
|
||||
* {
|
||||
* uint8_t ucRxData[ 20 ];
|
||||
* size_t xReceivedBytes;
|
||||
* const TickType_t xBlockTime = pdMS_TO_TICKS( 20 );
|
||||
*
|
||||
* // Receive the next message from the message buffer. Wait in the Blocked
|
||||
* // state (so not using any CPU processing time) for a maximum of 100ms for
|
||||
* // a message to become available.
|
||||
* xReceivedBytes = xMessageBufferReceive( xMessageBuffer,
|
||||
* ( void * ) ucRxData,
|
||||
* sizeof( ucRxData ),
|
||||
* xBlockTime );
|
||||
*
|
||||
* if( xReceivedBytes > 0 )
|
||||
* {
|
||||
* // A ucRxData contains a message that is xReceivedBytes long. Process
|
||||
* // the message here....
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xMessageBufferReceive xMessageBufferReceive
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) \
|
||||
xStreamBufferReceive( ( xMessageBuffer ), ( pvRxData ), ( xBufferLengthBytes ), ( xTicksToWait ) )
|
||||
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer,
|
||||
* void *pvRxData,
|
||||
* size_t xBufferLengthBytes,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
* @endcode
|
||||
*
|
||||
* An interrupt safe version of the API function that receives a discrete
|
||||
* message from a message buffer. Messages can be of variable length and are
|
||||
* copied out of the buffer.
|
||||
*
|
||||
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
|
||||
* implementation (so also the message buffer implementation, as message buffers
|
||||
* are built on top of stream buffers) assumes there is only one task or
|
||||
* interrupt that will write to the buffer (the writer), and only one task or
|
||||
* interrupt that will read from the buffer (the reader). It is safe for the
|
||||
* writer and reader to be different tasks or interrupts, but, unlike other
|
||||
* FreeRTOS objects, it is not safe to have multiple different writers or
|
||||
* multiple different readers. If there are to be multiple different writers
|
||||
* then the application writer must place each call to a writing API function
|
||||
* (such as xMessageBufferSend()) inside a critical section and set the send
|
||||
* block time to 0. Likewise, if there are to be multiple different readers
|
||||
* then the application writer must place each call to a reading API function
|
||||
* (such as xMessageBufferRead()) inside a critical section and set the receive
|
||||
* block time to 0.
|
||||
*
|
||||
* Use xMessageBufferReceive() to read from a message buffer from a task. Use
|
||||
* xMessageBufferReceiveFromISR() to read from a message buffer from an
|
||||
* interrupt service routine (ISR).
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer from which a message
|
||||
* is being received.
|
||||
*
|
||||
* @param pvRxData A pointer to the buffer into which the received message is
|
||||
* to be copied.
|
||||
*
|
||||
* @param xBufferLengthBytes The length of the buffer pointed to by the pvRxData
|
||||
* parameter. This sets the maximum length of the message that can be received.
|
||||
* If xBufferLengthBytes is too small to hold the next message then the message
|
||||
* will be left in the message buffer and 0 will be returned.
|
||||
*
|
||||
* @param pxHigherPriorityTaskWoken It is possible that a message buffer will
|
||||
* have a task blocked on it waiting for space to become available. Calling
|
||||
* xMessageBufferReceiveFromISR() can make space available, and so cause a task
|
||||
* that is waiting for space to leave the Blocked state. If calling
|
||||
* xMessageBufferReceiveFromISR() causes a task to leave the Blocked state, and
|
||||
* the unblocked task has a priority higher than the currently executing task
|
||||
* (the task that was interrupted), then, internally,
|
||||
* xMessageBufferReceiveFromISR() will set *pxHigherPriorityTaskWoken to pdTRUE.
|
||||
* If xMessageBufferReceiveFromISR() sets this value to pdTRUE, then normally a
|
||||
* context switch should be performed before the interrupt is exited. That will
|
||||
* ensure the interrupt returns directly to the highest priority Ready state
|
||||
* task. *pxHigherPriorityTaskWoken should be set to pdFALSE before it is
|
||||
* passed into the function. See the code example below for an example.
|
||||
*
|
||||
* @return The length, in bytes, of the message read from the message buffer, if
|
||||
* any.
|
||||
*
|
||||
* Example use:
|
||||
* @code{c}
|
||||
* // A message buffer that has already been created.
|
||||
* MessageBuffer_t xMessageBuffer;
|
||||
*
|
||||
* void vAnInterruptServiceRoutine( void )
|
||||
* {
|
||||
* uint8_t ucRxData[ 20 ];
|
||||
* size_t xReceivedBytes;
|
||||
* BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE.
|
||||
*
|
||||
* // Receive the next message from the message buffer.
|
||||
* xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer,
|
||||
* ( void * ) ucRxData,
|
||||
* sizeof( ucRxData ),
|
||||
* &xHigherPriorityTaskWoken );
|
||||
*
|
||||
* if( xReceivedBytes > 0 )
|
||||
* {
|
||||
* // A ucRxData contains a message that is xReceivedBytes long. Process
|
||||
* // the message here....
|
||||
* }
|
||||
*
|
||||
* // If xHigherPriorityTaskWoken was set to pdTRUE inside
|
||||
* // xMessageBufferReceiveFromISR() then a task that has a priority above the
|
||||
* // priority of the currently executing task was unblocked and a context
|
||||
* // switch should be performed to ensure the ISR returns to the unblocked
|
||||
* // task. In most FreeRTOS ports this is done by simply passing
|
||||
* // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the
|
||||
* // variables value, and perform the context switch if necessary. Check the
|
||||
* // documentation for the port in use for port specific instructions.
|
||||
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
* }
|
||||
* @endcode
|
||||
* \defgroup xMessageBufferReceiveFromISR xMessageBufferReceiveFromISR
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) \
|
||||
xStreamBufferReceiveFromISR( ( xMessageBuffer ), ( pvRxData ), ( xBufferLengthBytes ), ( pxHigherPriorityTaskWoken ) )
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer );
|
||||
* @endcode
|
||||
*
|
||||
* Deletes a message buffer that was previously created using a call to
|
||||
* xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message
|
||||
* buffer was created using dynamic memory (that is, by xMessageBufferCreate()),
|
||||
* then the allocated memory is freed.
|
||||
*
|
||||
* A message buffer handle must not be used after the message buffer has been
|
||||
* deleted.
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer to be deleted.
|
||||
*
|
||||
*/
|
||||
#define vMessageBufferDelete( xMessageBuffer ) \
|
||||
vStreamBufferDelete( xMessageBuffer )
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
* @code{c}
|
||||
* BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer );
|
||||
* @endcode
|
||||
*
|
||||
* Tests to see if a message buffer is full. A message buffer is full if it
|
||||
* cannot accept any more messages, of any size, until space is made available
|
||||
* by a message being removed from the message buffer.
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer being queried.
|
||||
*
|
||||
* @return If the message buffer referenced by xMessageBuffer is full then
|
||||
* pdTRUE is returned. Otherwise pdFALSE is returned.
|
||||
*/
|
||||
#define xMessageBufferIsFull( xMessageBuffer ) \
|
||||
xStreamBufferIsFull( xMessageBuffer )
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
* @code{c}
|
||||
* BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer );
|
||||
* @endcode
|
||||
*
|
||||
* Tests to see if a message buffer is empty (does not contain any messages).
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer being queried.
|
||||
*
|
||||
* @return If the message buffer referenced by xMessageBuffer is empty then
|
||||
* pdTRUE is returned. Otherwise pdFALSE is returned.
|
||||
*
|
||||
*/
|
||||
#define xMessageBufferIsEmpty( xMessageBuffer ) \
|
||||
xStreamBufferIsEmpty( xMessageBuffer )
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
* @code{c}
|
||||
* BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer );
|
||||
* @endcode
|
||||
*
|
||||
* Resets a message buffer to its initial empty state, discarding any message it
|
||||
* contained.
|
||||
*
|
||||
* A message buffer can only be reset if there are no tasks blocked on it.
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer being reset.
|
||||
*
|
||||
* @return If the message buffer was reset then pdPASS is returned. If the
|
||||
* message buffer could not be reset because either there was a task blocked on
|
||||
* the message queue to wait for space to become available, or to wait for a
|
||||
* a message to be available, then pdFAIL is returned.
|
||||
*
|
||||
* \defgroup xMessageBufferReset xMessageBufferReset
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferReset( xMessageBuffer ) \
|
||||
xStreamBufferReset( xMessageBuffer )
|
||||
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
* @code{c}
|
||||
* size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer );
|
||||
* @endcode
|
||||
* Returns the number of bytes of free space in the message buffer.
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer being queried.
|
||||
*
|
||||
* @return The number of bytes that can be written to the message buffer before
|
||||
* the message buffer would be full. When a message is written to the message
|
||||
* buffer an additional sizeof( size_t ) bytes are also written to store the
|
||||
* message's length. sizeof( size_t ) is typically 4 bytes on a 32-bit
|
||||
* architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size
|
||||
* of the largest message that can be written to the message buffer is 6 bytes.
|
||||
*
|
||||
* \defgroup xMessageBufferSpaceAvailable xMessageBufferSpaceAvailable
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferSpaceAvailable( xMessageBuffer ) \
|
||||
xStreamBufferSpacesAvailable( xMessageBuffer )
|
||||
#define xMessageBufferSpacesAvailable( xMessageBuffer ) \
|
||||
xStreamBufferSpacesAvailable( xMessageBuffer ) /* Corrects typo in original macro name. */
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
* @code{c}
|
||||
* size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer );
|
||||
* @endcode
|
||||
* Returns the length (in bytes) of the next message in a message buffer.
|
||||
* Useful if xMessageBufferReceive() returned 0 because the size of the buffer
|
||||
* passed into xMessageBufferReceive() was too small to hold the next message.
|
||||
*
|
||||
* @param xMessageBuffer The handle of the message buffer being queried.
|
||||
*
|
||||
* @return The length (in bytes) of the next message in the message buffer, or 0
|
||||
* if the message buffer is empty.
|
||||
*
|
||||
* \defgroup xMessageBufferNextLengthBytes xMessageBufferNextLengthBytes
|
||||
* \ingroup MessageBufferManagement
|
||||
*/
|
||||
#define xMessageBufferNextLengthBytes( xMessageBuffer ) \
|
||||
xStreamBufferNextMessageLengthBytes( xMessageBuffer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* BaseType_t xMessageBufferSendCompletedFromISR( MessageBufferHandle_t xMessageBuffer, BaseType_t *pxHigherPriorityTaskWoken );
|
||||
* @endcode
|
||||
*
|
||||
* For advanced users only.
|
||||
*
|
||||
* The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when
|
||||
* data is sent to a message buffer or stream buffer. If there was a task that
|
||||
* was blocked on the message or stream buffer waiting for data to arrive then
|
||||
* the sbSEND_COMPLETED() macro sends a notification to the task to remove it
|
||||
* from the Blocked state. xMessageBufferSendCompletedFromISR() does the same
|
||||
* thing. It is provided to enable application writers to implement their own
|
||||
* version of sbSEND_COMPLETED(), and MUST NOT BE USED AT ANY OTHER TIME.
|
||||
*
|
||||
* See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for
|
||||
* additional information.
|
||||
*
|
||||
* @param xMessageBuffer The handle of the stream buffer to which data was
|
||||
* written.
|
||||
*
|
||||
* @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be
|
||||
* initialised to pdFALSE before it is passed into
|
||||
* xMessageBufferSendCompletedFromISR(). If calling
|
||||
* xMessageBufferSendCompletedFromISR() removes a task from the Blocked state,
|
||||
* and the task has a priority above the priority of the currently running task,
|
||||
* then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a
|
||||
* context switch should be performed before exiting the ISR.
|
||||
*
|
||||
* @return If a task was removed from the Blocked state then pdTRUE is returned.
|
||||
* Otherwise pdFALSE is returned.
|
||||
*
|
||||
* \defgroup xMessageBufferSendCompletedFromISR xMessageBufferSendCompletedFromISR
|
||||
* \ingroup StreamBufferManagement
|
||||
*/
|
||||
#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \
|
||||
xStreamBufferSendCompletedFromISR( ( xMessageBuffer ), ( pxHigherPriorityTaskWoken ) )
|
||||
|
||||
/**
|
||||
* message_buffer.h
|
||||
*
|
||||
* @code{c}
|
||||
* BaseType_t xMessageBufferReceiveCompletedFromISR( MessageBufferHandle_t xMessageBuffer, BaseType_t *pxHigherPriorityTaskWoken );
|
||||
* @endcode
|
||||
*
|
||||
* For advanced users only.
|
||||
*
|
||||
* The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when
|
||||
* data is read out of a message buffer or stream buffer. If there was a task
|
||||
* that was blocked on the message or stream buffer waiting for data to arrive
|
||||
* then the sbRECEIVE_COMPLETED() macro sends a notification to the task to
|
||||
* remove it from the Blocked state. xMessageBufferReceiveCompletedFromISR()
|
||||
* does the same thing. It is provided to enable application writers to
|
||||
* implement their own version of sbRECEIVE_COMPLETED(), and MUST NOT BE USED AT
|
||||
* ANY OTHER TIME.
|
||||
*
|
||||
* See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for
|
||||
* additional information.
|
||||
*
|
||||
* @param xMessageBuffer The handle of the stream buffer from which data was
|
||||
* read.
|
||||
*
|
||||
* @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be
|
||||
* initialised to pdFALSE before it is passed into
|
||||
* xMessageBufferReceiveCompletedFromISR(). If calling
|
||||
* xMessageBufferReceiveCompletedFromISR() removes a task from the Blocked state,
|
||||
* and the task has a priority above the priority of the currently running task,
|
||||
* then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a
|
||||
* context switch should be performed before exiting the ISR.
|
||||
*
|
||||
* @return If a task was removed from the Blocked state then pdTRUE is returned.
|
||||
* Otherwise pdFALSE is returned.
|
||||
*
|
||||
* \defgroup xMessageBufferReceiveCompletedFromISR xMessageBufferReceiveCompletedFromISR
|
||||
* \ingroup StreamBufferManagement
|
||||
*/
|
||||
#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \
|
||||
xStreamBufferReceiveCompletedFromISR( ( xMessageBuffer ), ( pxHigherPriorityTaskWoken ) )
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#if defined( __cplusplus )
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */
|
||||
@@ -0,0 +1,476 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* When the MPU is used the standard (non MPU) API functions are mapped to
|
||||
* equivalents that start "MPU_", the prototypes for which are defined in this
|
||||
* header files. This will cause the application code to call the MPU_ version
|
||||
* which wraps the non-MPU version with privilege promoting then demoting code,
|
||||
* so the kernel code always runs will full privileges.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MPU_PROTOTYPES_H
|
||||
#define MPU_PROTOTYPES_H
|
||||
|
||||
typedef struct xTaskGenericNotifyParams
|
||||
{
|
||||
TaskHandle_t xTaskToNotify;
|
||||
UBaseType_t uxIndexToNotify;
|
||||
uint32_t ulValue;
|
||||
eNotifyAction eAction;
|
||||
uint32_t * pulPreviousNotificationValue;
|
||||
} xTaskGenericNotifyParams_t;
|
||||
|
||||
typedef struct xTaskGenericNotifyWaitParams
|
||||
{
|
||||
UBaseType_t uxIndexToWaitOn;
|
||||
uint32_t ulBitsToClearOnEntry;
|
||||
uint32_t ulBitsToClearOnExit;
|
||||
uint32_t * pulNotificationValue;
|
||||
TickType_t xTicksToWait;
|
||||
} xTaskGenericNotifyWaitParams_t;
|
||||
|
||||
typedef struct xTimerGenericCommandParams
|
||||
{
|
||||
TimerHandle_t xTimer;
|
||||
BaseType_t xCommandID;
|
||||
TickType_t xOptionalValue;
|
||||
BaseType_t * pxHigherPriorityTaskWoken;
|
||||
TickType_t xTicksToWait;
|
||||
} xTimerGenericCommandParams_t;
|
||||
|
||||
typedef struct xEventGroupWaitBitsParams
|
||||
{
|
||||
EventGroupHandle_t xEventGroup;
|
||||
EventBits_t uxBitsToWaitFor;
|
||||
BaseType_t xClearOnExit;
|
||||
BaseType_t xWaitForAllBits;
|
||||
TickType_t xTicksToWait;
|
||||
} xEventGroupWaitBitsParams_t;
|
||||
|
||||
/* MPU versions of task.h API functions. */
|
||||
void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
|
||||
const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskGetInfo( TaskHandle_t xTask,
|
||||
TaskStatus_t * pxTaskStatus,
|
||||
BaseType_t xGetFreeStackSpace,
|
||||
eTaskState eState ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskResume( TaskHandle_t xTaskToResume ) FREERTOS_SYSTEM_CALL;
|
||||
TickType_t MPU_xTaskGetTickCount( void ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) FREERTOS_SYSTEM_CALL;
|
||||
char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask,
|
||||
TaskHookFunction_t pxHookFunction ) FREERTOS_SYSTEM_CALL;
|
||||
TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
|
||||
BaseType_t xIndex,
|
||||
void * pvValue ) FREERTOS_SYSTEM_CALL;
|
||||
void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
|
||||
BaseType_t xIndex ) FREERTOS_SYSTEM_CALL;
|
||||
TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
|
||||
const UBaseType_t uxArraySize,
|
||||
configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL;
|
||||
configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounter( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercent( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
|
||||
configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL;
|
||||
configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercent( void ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
|
||||
UBaseType_t uxIndexToNotify,
|
||||
uint32_t ulValue,
|
||||
eNotifyAction eAction,
|
||||
uint32_t * pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskGenericNotifyEntry( const xTaskGenericNotifyParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
|
||||
uint32_t ulBitsToClearOnEntry,
|
||||
uint32_t ulBitsToClearOnExit,
|
||||
uint32_t * pulNotificationValue,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskGenericNotifyWaitEntry( const xTaskGenericNotifyWaitParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
|
||||
uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
|
||||
BaseType_t xClearCountOnExit,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask,
|
||||
UBaseType_t uxIndexToClear ) FREERTOS_SYSTEM_CALL;
|
||||
uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
|
||||
UBaseType_t uxIndexToClear,
|
||||
uint32_t ulBitsToClear ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
|
||||
TickType_t * const pxTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
/* Privileged only wrappers for Task APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
|
||||
|
||||
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
|
||||
const char * const pcName,
|
||||
const uint16_t usStackDepth,
|
||||
void * const pvParameters,
|
||||
UBaseType_t uxPriority,
|
||||
TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL;
|
||||
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
|
||||
const char * const pcName,
|
||||
const uint32_t ulStackDepth,
|
||||
void * const pvParameters,
|
||||
UBaseType_t uxPriority,
|
||||
StackType_t * const puxStackBuffer,
|
||||
StaticTask_t * const pxTaskBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskPrioritySet( TaskHandle_t xTask,
|
||||
UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL;
|
||||
TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
|
||||
void * pvParameter ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
|
||||
const char * const pcName,
|
||||
const uint16_t usStackDepth,
|
||||
void * const pvParameters,
|
||||
UBaseType_t uxPriority,
|
||||
TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
|
||||
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
|
||||
const char * const pcName,
|
||||
const uint32_t ulStackDepth,
|
||||
void * const pvParameters,
|
||||
UBaseType_t uxPriority,
|
||||
StackType_t * const puxStackBuffer,
|
||||
StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
|
||||
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
|
||||
void MPU_vTaskPrioritySet( TaskHandle_t xTask,
|
||||
UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
|
||||
TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
|
||||
void * pvParameter ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
|
||||
TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
|
||||
TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
|
||||
void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
|
||||
const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xTaskGetStaticBuffers( TaskHandle_t xTask,
|
||||
StackType_t ** ppuxStackBuffer,
|
||||
StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
|
||||
UBaseType_t MPU_uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
|
||||
TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
|
||||
UBaseType_t uxIndexToNotify,
|
||||
uint32_t ulValue,
|
||||
eNotifyAction eAction,
|
||||
uint32_t * pulPreviousNotificationValue,
|
||||
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
void MPU_vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
|
||||
UBaseType_t uxIndexToNotify,
|
||||
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/* MPU versions of queue.h API functions. */
|
||||
BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue,
|
||||
const void * const pvItemToQueue,
|
||||
TickType_t xTicksToWait,
|
||||
const BaseType_t xCopyPosition ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue,
|
||||
void * const pvBuffer,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue,
|
||||
void * const pvBuffer,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
|
||||
TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vQueueAddToRegistry( QueueHandle_t xQueue,
|
||||
const char * pcName ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
|
||||
const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
|
||||
QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL;
|
||||
QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
|
||||
const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue,
|
||||
UBaseType_t uxQueueNumber ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
|
||||
uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
/* Privileged only wrappers for Queue APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
|
||||
|
||||
void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
|
||||
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
|
||||
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
|
||||
StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
|
||||
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
|
||||
const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL;
|
||||
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
|
||||
const UBaseType_t uxInitialCount,
|
||||
StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
|
||||
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
|
||||
const UBaseType_t uxItemSize,
|
||||
const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
|
||||
QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
|
||||
const UBaseType_t uxItemSize,
|
||||
uint8_t * pucQueueStorage,
|
||||
StaticQueue_t * pxStaticQueue,
|
||||
const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
|
||||
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
|
||||
QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
|
||||
BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
void MPU_vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
|
||||
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
|
||||
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
|
||||
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
|
||||
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
|
||||
const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
|
||||
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
|
||||
const UBaseType_t uxInitialCount,
|
||||
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
|
||||
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
|
||||
const UBaseType_t uxItemSize,
|
||||
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
|
||||
QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
|
||||
const UBaseType_t uxItemSize,
|
||||
uint8_t * pucQueueStorage,
|
||||
StaticQueue_t * pxStaticQueue,
|
||||
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
|
||||
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
|
||||
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
|
||||
BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
|
||||
uint8_t ** ppucQueueStorage,
|
||||
StaticQueue_t ** ppxStaticQueue ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueueGenericSendFromISR( QueueHandle_t xQueue,
|
||||
const void * const pvItemToQueue,
|
||||
BaseType_t * const pxHigherPriorityTaskWoken,
|
||||
const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueueGiveFromISR( QueueHandle_t xQueue,
|
||||
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t xQueue,
|
||||
void * const pvBuffer ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueueReceiveFromISR( QueueHandle_t xQueue,
|
||||
void * const pvBuffer,
|
||||
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
|
||||
UBaseType_t MPU_uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
|
||||
TaskHandle_t MPU_xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
|
||||
QueueSetMemberHandle_t MPU_xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/* MPU versions of timers.h API functions. */
|
||||
void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTimerSetTimerID( TimerHandle_t xTimer,
|
||||
void * pvNewID ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
|
||||
TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer,
|
||||
const BaseType_t xCommandID,
|
||||
const TickType_t xOptionalValue,
|
||||
BaseType_t * const pxHigherPriorityTaskWoken,
|
||||
const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTimerGenericCommandEntry( const xTimerGenericCommandParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
|
||||
const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vTimerSetReloadMode( TimerHandle_t xTimer,
|
||||
const BaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
|
||||
UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
|
||||
TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
|
||||
TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
/* Privileged only wrappers for Timer APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName,
|
||||
const TickType_t xTimerPeriodInTicks,
|
||||
const UBaseType_t uxAutoReload,
|
||||
void * const pvTimerID,
|
||||
TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION;
|
||||
TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName,
|
||||
const TickType_t xTimerPeriodInTicks,
|
||||
const UBaseType_t uxAutoReload,
|
||||
void * const pvTimerID,
|
||||
TimerCallbackFunction_t pxCallbackFunction,
|
||||
StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xTimerGetStaticBuffer( TimerHandle_t xTimer,
|
||||
StaticTimer_t ** ppxTimerBuffer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/* MPU versions of event_group.h API functions. */
|
||||
EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
const BaseType_t xClearOnExit,
|
||||
const BaseType_t xWaitForAllBits,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
EventBits_t MPU_xEventGroupWaitBitsEntry( const xEventGroupWaitBitsParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
|
||||
EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL;
|
||||
EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet ) FREERTOS_SYSTEM_CALL;
|
||||
EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t MPU_uxEventGroupGetNumber( void * xEventGroup ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vEventGroupSetNumber( void * xEventGroup,
|
||||
UBaseType_t uxEventGroupNumber ) FREERTOS_SYSTEM_CALL;
|
||||
#endif /* #if ( configUSE_TRACE_FACILITY == 1 ) */
|
||||
|
||||
/* Privileged only wrappers for Event Group APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
|
||||
|
||||
EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL;
|
||||
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
EventGroupHandle_t MPU_xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
|
||||
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
|
||||
void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
|
||||
StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
EventBits_t MPU_xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/* MPU versions of message/stream_buffer.h API functions. */
|
||||
size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
|
||||
const void * pvTxData,
|
||||
size_t xDataLengthBytes,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
|
||||
void * pvRxData,
|
||||
size_t xBufferLengthBytes,
|
||||
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
|
||||
size_t xTriggerLevel ) FREERTOS_SYSTEM_CALL;
|
||||
size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
/* Privileged only wrappers for Stream Buffer APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
|
||||
|
||||
StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
|
||||
size_t xTriggerLevelBytes,
|
||||
BaseType_t xStreamBufferType,
|
||||
StreamBufferCallbackFunction_t pxSendCompletedCallback,
|
||||
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
|
||||
StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
|
||||
size_t xTriggerLevelBytes,
|
||||
BaseType_t xStreamBufferType,
|
||||
uint8_t * const pucStreamBufferStorageArea,
|
||||
StaticStreamBuffer_t * const pxStaticStreamBuffer,
|
||||
StreamBufferCallbackFunction_t pxSendCompletedCallback,
|
||||
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
|
||||
void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
|
||||
|
||||
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
|
||||
size_t xTriggerLevelBytes,
|
||||
BaseType_t xStreamBufferType,
|
||||
StreamBufferCallbackFunction_t pxSendCompletedCallback,
|
||||
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
|
||||
StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
|
||||
size_t xTriggerLevelBytes,
|
||||
BaseType_t xStreamBufferType,
|
||||
uint8_t * const pucStreamBufferStorageArea,
|
||||
StaticStreamBuffer_t * const pxStaticStreamBuffer,
|
||||
StreamBufferCallbackFunction_t pxSendCompletedCallback,
|
||||
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
|
||||
void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers,
|
||||
uint8_t * ppucStreamBufferStorageArea,
|
||||
StaticStreamBuffer_t * ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
|
||||
size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
|
||||
const void * pvTxData,
|
||||
size_t xDataLengthBytes,
|
||||
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
|
||||
void * pvRxData,
|
||||
size_t xBufferLengthBytes,
|
||||
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
|
||||
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t MPU_xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
|
||||
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#endif /* MPU_PROTOTYPES_H */
|
||||
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MPU_WRAPPERS_H
|
||||
#define MPU_WRAPPERS_H
|
||||
|
||||
/* This file redefines API functions to be called through a wrapper macro, but
|
||||
* only for ports that are using the MPU. */
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
|
||||
/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
|
||||
* included from queue.c or task.c to prevent it from having an effect within
|
||||
* those files. */
|
||||
#ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
|
||||
|
||||
/*
|
||||
* Map standard (non MPU) API functions to equivalents that start
|
||||
* "MPU_". This will cause the application code to call the MPU_
|
||||
* version, which wraps the non-MPU version with privilege promoting
|
||||
* then demoting code, so the kernel code always runs will full
|
||||
* privileges.
|
||||
*/
|
||||
|
||||
/* Map standard task.h API functions to the MPU equivalents. */
|
||||
#define vTaskDelay MPU_vTaskDelay
|
||||
#define xTaskDelayUntil MPU_xTaskDelayUntil
|
||||
#define xTaskAbortDelay MPU_xTaskAbortDelay
|
||||
#define uxTaskPriorityGet MPU_uxTaskPriorityGet
|
||||
#define eTaskGetState MPU_eTaskGetState
|
||||
#define vTaskGetInfo MPU_vTaskGetInfo
|
||||
#define vTaskSuspend MPU_vTaskSuspend
|
||||
#define vTaskResume MPU_vTaskResume
|
||||
#define xTaskGetTickCount MPU_xTaskGetTickCount
|
||||
#define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
|
||||
#define pcTaskGetName MPU_pcTaskGetName
|
||||
#define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
|
||||
#define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2
|
||||
#define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag
|
||||
#define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag
|
||||
#define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer
|
||||
#define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer
|
||||
#define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle
|
||||
#define uxTaskGetSystemState MPU_uxTaskGetSystemState
|
||||
#define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter
|
||||
#define ulTaskGetIdleRunTimePercent MPU_ulTaskGetIdleRunTimePercent
|
||||
#define xTaskGenericNotify MPU_xTaskGenericNotify
|
||||
#define xTaskGenericNotifyWait MPU_xTaskGenericNotifyWait
|
||||
#define ulTaskGenericNotifyTake MPU_ulTaskGenericNotifyTake
|
||||
#define xTaskGenericNotifyStateClear MPU_xTaskGenericNotifyStateClear
|
||||
#define ulTaskGenericNotifyValueClear MPU_ulTaskGenericNotifyValueClear
|
||||
#define vTaskSetTimeOutState MPU_vTaskSetTimeOutState
|
||||
#define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut
|
||||
#define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle
|
||||
#define xTaskGetSchedulerState MPU_xTaskGetSchedulerState
|
||||
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
|
||||
#define ulTaskGetRunTimeCounter MPU_ulTaskGetRunTimeCounter
|
||||
#define ulTaskGetRunTimePercent MPU_ulTaskGetRunTimePercent
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
|
||||
|
||||
/* Privileged only wrappers for Task APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
|
||||
/* These are not needed in v2 because they do not take a task
|
||||
* handle and therefore, no lookup is needed. Needed in v1 because
|
||||
* these are available as system calls in v1. */
|
||||
#define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
|
||||
#define vTaskList MPU_vTaskList
|
||||
#define vTaskSuspendAll MPU_vTaskSuspendAll
|
||||
#define xTaskCatchUpTicks MPU_xTaskCatchUpTicks
|
||||
#define xTaskResumeAll MPU_xTaskResumeAll
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
|
||||
|
||||
#define xTaskCreate MPU_xTaskCreate
|
||||
#define xTaskCreateStatic MPU_xTaskCreateStatic
|
||||
#define vTaskDelete MPU_vTaskDelete
|
||||
#define vTaskPrioritySet MPU_vTaskPrioritySet
|
||||
#define xTaskGetHandle MPU_xTaskGetHandle
|
||||
#define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook
|
||||
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
|
||||
#define xTaskCreateRestricted MPU_xTaskCreateRestricted
|
||||
#define xTaskCreateRestrictedStatic MPU_xTaskCreateRestrictedStatic
|
||||
#define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
|
||||
#define xTaskGetStaticBuffers MPU_xTaskGetStaticBuffers
|
||||
#define uxTaskPriorityGetFromISR MPU_uxTaskPriorityGetFromISR
|
||||
#define xTaskResumeFromISR MPU_xTaskResumeFromISR
|
||||
#define xTaskGetApplicationTaskTagFromISR MPU_xTaskGetApplicationTaskTagFromISR
|
||||
#define xTaskGenericNotifyFromISR MPU_xTaskGenericNotifyFromISR
|
||||
#define vTaskGenericNotifyGiveFromISR MPU_vTaskGenericNotifyGiveFromISR
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
|
||||
|
||||
/* Map standard queue.h API functions to the MPU equivalents. */
|
||||
#define xQueueGenericSend MPU_xQueueGenericSend
|
||||
#define xQueueReceive MPU_xQueueReceive
|
||||
#define xQueuePeek MPU_xQueuePeek
|
||||
#define xQueueSemaphoreTake MPU_xQueueSemaphoreTake
|
||||
#define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting
|
||||
#define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable
|
||||
#define xQueueGetMutexHolder MPU_xQueueGetMutexHolder
|
||||
#define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive
|
||||
#define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive
|
||||
#define xQueueAddToSet MPU_xQueueAddToSet
|
||||
#define xQueueSelectFromSet MPU_xQueueSelectFromSet
|
||||
|
||||
#if ( configQUEUE_REGISTRY_SIZE > 0 )
|
||||
#define vQueueAddToRegistry MPU_vQueueAddToRegistry
|
||||
#define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
|
||||
#define pcQueueGetName MPU_pcQueueGetName
|
||||
#endif /* #if ( configQUEUE_REGISTRY_SIZE > 0 ) */
|
||||
|
||||
/* Privileged only wrappers for Queue APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#define vQueueDelete MPU_vQueueDelete
|
||||
#define xQueueCreateMutex MPU_xQueueCreateMutex
|
||||
#define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic
|
||||
#define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore
|
||||
#define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic
|
||||
#define xQueueGenericCreate MPU_xQueueGenericCreate
|
||||
#define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic
|
||||
#define xQueueGenericReset MPU_xQueueGenericReset
|
||||
#define xQueueCreateSet MPU_xQueueCreateSet
|
||||
#define xQueueRemoveFromSet MPU_xQueueRemoveFromSet
|
||||
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
|
||||
#define xQueueGenericGetStaticBuffers MPU_xQueueGenericGetStaticBuffers
|
||||
#define xQueueGenericSendFromISR MPU_xQueueGenericSendFromISR
|
||||
#define xQueueGiveFromISR MPU_xQueueGiveFromISR
|
||||
#define xQueuePeekFromISR MPU_xQueuePeekFromISR
|
||||
#define xQueueReceiveFromISR MPU_xQueueReceiveFromISR
|
||||
#define xQueueIsQueueEmptyFromISR MPU_xQueueIsQueueEmptyFromISR
|
||||
#define xQueueIsQueueFullFromISR MPU_xQueueIsQueueFullFromISR
|
||||
#define uxQueueMessagesWaitingFromISR MPU_uxQueueMessagesWaitingFromISR
|
||||
#define xQueueGetMutexHolderFromISR MPU_xQueueGetMutexHolderFromISR
|
||||
#define xQueueSelectFromSetFromISR MPU_xQueueSelectFromSetFromISR
|
||||
#endif /* if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
|
||||
|
||||
/* Map standard timer.h API functions to the MPU equivalents. */
|
||||
#define pvTimerGetTimerID MPU_pvTimerGetTimerID
|
||||
#define vTimerSetTimerID MPU_vTimerSetTimerID
|
||||
#define xTimerIsTimerActive MPU_xTimerIsTimerActive
|
||||
#define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle
|
||||
#define xTimerGenericCommand MPU_xTimerGenericCommand
|
||||
#define pcTimerGetName MPU_pcTimerGetName
|
||||
#define vTimerSetReloadMode MPU_vTimerSetReloadMode
|
||||
#define uxTimerGetReloadMode MPU_uxTimerGetReloadMode
|
||||
#define xTimerGetPeriod MPU_xTimerGetPeriod
|
||||
#define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
|
||||
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
|
||||
#define xTimerGetReloadMode MPU_xTimerGetReloadMode
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
|
||||
|
||||
/* Privileged only wrappers for Timer APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
|
||||
#define xTimerCreate MPU_xTimerCreate
|
||||
#define xTimerCreateStatic MPU_xTimerCreateStatic
|
||||
#define xTimerGetStaticBuffer MPU_xTimerGetStaticBuffer
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
|
||||
|
||||
/* Map standard event_group.h API functions to the MPU equivalents. */
|
||||
#define xEventGroupWaitBits MPU_xEventGroupWaitBits
|
||||
#define xEventGroupClearBits MPU_xEventGroupClearBits
|
||||
#define xEventGroupSetBits MPU_xEventGroupSetBits
|
||||
#define xEventGroupSync MPU_xEventGroupSync
|
||||
|
||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )
|
||||
#define uxEventGroupGetNumber MPU_uxEventGroupGetNumber
|
||||
#define vEventGroupSetNumber MPU_vEventGroupSetNumber
|
||||
#endif /* #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) */
|
||||
|
||||
/* Privileged only wrappers for Event Group APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
#define xEventGroupCreate MPU_xEventGroupCreate
|
||||
#define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
|
||||
#define vEventGroupDelete MPU_vEventGroupDelete
|
||||
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
|
||||
#define xEventGroupGetStaticBuffer MPU_xEventGroupGetStaticBuffer
|
||||
#define xEventGroupClearBitsFromISR MPU_xEventGroupClearBitsFromISR
|
||||
#define xEventGroupSetBitsFromISR MPU_xEventGroupSetBitsFromISR
|
||||
#define xEventGroupGetBitsFromISR MPU_xEventGroupGetBitsFromISR
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
|
||||
|
||||
/* Map standard message/stream_buffer.h API functions to the MPU
|
||||
* equivalents. */
|
||||
#define xStreamBufferSend MPU_xStreamBufferSend
|
||||
#define xStreamBufferReceive MPU_xStreamBufferReceive
|
||||
#define xStreamBufferIsFull MPU_xStreamBufferIsFull
|
||||
#define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty
|
||||
#define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable
|
||||
#define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable
|
||||
#define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel
|
||||
#define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes
|
||||
|
||||
/* Privileged only wrappers for Stream Buffer APIs. These are needed so that
|
||||
* the application can use opaque handles maintained in mpu_wrappers.c
|
||||
* with all the APIs. */
|
||||
|
||||
#define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate
|
||||
#define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic
|
||||
#define vStreamBufferDelete MPU_vStreamBufferDelete
|
||||
#define xStreamBufferReset MPU_xStreamBufferReset
|
||||
|
||||
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
|
||||
#define xStreamBufferGetStaticBuffers MPU_xStreamBufferGetStaticBuffers
|
||||
#define xStreamBufferSendFromISR MPU_xStreamBufferSendFromISR
|
||||
#define xStreamBufferReceiveFromISR MPU_xStreamBufferReceiveFromISR
|
||||
#define xStreamBufferSendCompletedFromISR MPU_xStreamBufferSendCompletedFromISR
|
||||
#define xStreamBufferReceiveCompletedFromISR MPU_xStreamBufferReceiveCompletedFromISR
|
||||
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
|
||||
|
||||
/* Remove the privileged function macro, but keep the PRIVILEGED_DATA
|
||||
* macro so applications can place data in privileged access sections
|
||||
* (useful when using statically allocated objects). */
|
||||
#define PRIVILEGED_FUNCTION
|
||||
#define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
|
||||
#define FREERTOS_SYSTEM_CALL
|
||||
|
||||
|
||||
#if ( ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
|
||||
|
||||
#define vGrantAccessToTask( xTask, xTaskToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xTaskToGrantAccess ) )
|
||||
#define vRevokeAccessToTask( xTask, xTaskToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xTaskToRevokeAccess ) )
|
||||
|
||||
#define vGrantAccessToSemaphore( xTask, xSemaphoreToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xSemaphoreToGrantAccess ) )
|
||||
#define vRevokeAccessToSemaphore( xTask, xSemaphoreToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xSemaphoreToRevokeAccess ) )
|
||||
|
||||
#define vGrantAccessToQueue( xTask, xQueueToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xQueueToGrantAccess ) )
|
||||
#define vRevokeAccessToQueue( xTask, xQueueToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xQueueToRevokeAccess ) )
|
||||
|
||||
#define vGrantAccessToQueueSet( xTask, xQueueSetToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xQueueSetToGrantAccess ) )
|
||||
#define vRevokeAccessToQueueSet( xTask, xQueueSetToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xQueueSetToRevokeAccess ) )
|
||||
|
||||
#define vGrantAccessToEventGroup( xTask, xEventGroupToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xEventGroupToGrantAccess ) )
|
||||
#define vRevokeAccessToEventGroup( xTask, xEventGroupToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xEventGroupToRevokeAccess ) )
|
||||
|
||||
#define vGrantAccessToStreamBuffer( xTask, xStreamBufferToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xStreamBufferToGrantAccess ) )
|
||||
#define vRevokeAccessToStreamBuffer( xTask, xStreamBufferToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xStreamBufferToRevokeAccess ) )
|
||||
|
||||
#define vGrantAccessToMessageBuffer( xTask, xMessageBufferToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xMessageBufferToGrantAccess ) )
|
||||
#define vRevokeAccessToMessageBuffer( xTask, xMessageBufferToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xMessageBufferToRevokeAccess ) )
|
||||
|
||||
#define vGrantAccessToTimer( xTask, xTimerToGrantAccess ) vGrantAccessToKernelObject( ( xTask ), ( int32_t ) ( xTimerToGrantAccess ) )
|
||||
#define vRevokeAccessToTimer( xTask, xTimerToRevokeAccess ) vRevokeAccessToKernelObject( ( xTask ), ( int32_t ) ( xTimerToRevokeAccess ) )
|
||||
|
||||
#endif /* #if ( ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) ) */
|
||||
|
||||
#else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
|
||||
|
||||
/* Ensure API functions go in the privileged execution section. */
|
||||
#define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) )
|
||||
#define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
|
||||
#define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) )
|
||||
|
||||
#endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
|
||||
|
||||
#else /* portUSING_MPU_WRAPPERS */
|
||||
|
||||
#define PRIVILEGED_FUNCTION
|
||||
#define PRIVILEGED_DATA
|
||||
#define FREERTOS_SYSTEM_CALL
|
||||
|
||||
#endif /* portUSING_MPU_WRAPPERS */
|
||||
|
||||
|
||||
#endif /* MPU_WRAPPERS_H */
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INC_NEWLIB_FREERTOS_H
|
||||
#define INC_NEWLIB_FREERTOS_H
|
||||
|
||||
/* Note Newlib support has been included by popular demand, but is not
|
||||
* used by the FreeRTOS maintainers themselves. FreeRTOS is not
|
||||
* responsible for resulting newlib operation. User must be familiar with
|
||||
* newlib and must provide system-wide implementations of the necessary
|
||||
* stubs. Be warned that (at the time of writing) the current newlib design
|
||||
* implements a system-wide malloc() that must be provided with locks.
|
||||
*
|
||||
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
|
||||
* for additional information. */
|
||||
|
||||
#include <reent.h>
|
||||
|
||||
#define configUSE_C_RUNTIME_TLS_SUPPORT 1
|
||||
|
||||
#ifndef configTLS_BLOCK_TYPE
|
||||
#define configTLS_BLOCK_TYPE struct _reent
|
||||
#endif
|
||||
|
||||
#ifndef configINIT_TLS_BLOCK
|
||||
#define configINIT_TLS_BLOCK( xTLSBlock, pxTopOfStack ) _REENT_INIT_PTR( &( xTLSBlock ) )
|
||||
#endif
|
||||
|
||||
#ifndef configSET_TLS_BLOCK
|
||||
#define configSET_TLS_BLOCK( xTLSBlock ) ( _impure_ptr = &( xTLSBlock ) )
|
||||
#endif
|
||||
|
||||
#ifndef configDEINIT_TLS_BLOCK
|
||||
#define configDEINIT_TLS_BLOCK( xTLSBlock ) _reclaim_reent( &( xTLSBlock ) )
|
||||
#endif
|
||||
|
||||
#endif /* INC_NEWLIB_FREERTOS_H */
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INC_PICOLIBC_FREERTOS_H
|
||||
#define INC_PICOLIBC_FREERTOS_H
|
||||
|
||||
/* Use picolibc TLS support to allocate space for __thread variables,
|
||||
* initialize them at thread creation and set the TLS context at
|
||||
* thread switch time.
|
||||
*
|
||||
* See the picolibc TLS docs:
|
||||
* https://github.com/picolibc/picolibc/blob/main/doc/tls.md
|
||||
* for additional information. */
|
||||
|
||||
#include <picotls.h>
|
||||
|
||||
#define configUSE_C_RUNTIME_TLS_SUPPORT 1
|
||||
|
||||
#define configTLS_BLOCK_TYPE void *
|
||||
|
||||
#define picolibcTLS_SIZE ( ( portPOINTER_SIZE_TYPE ) _tls_size() )
|
||||
#define picolibcSTACK_ALIGNMENT_MASK ( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK )
|
||||
|
||||
#if __PICOLIBC_MAJOR__ > 1 || __PICOLIBC_MINOR__ >= 8
|
||||
|
||||
/* Picolibc 1.8 and newer have explicit alignment values provided
|
||||
* by the _tls_align() inline */
|
||||
#define picolibcTLS_ALIGNMENT_MASK ( ( portPOINTER_SIZE_TYPE ) ( _tls_align() - 1 ) )
|
||||
#else
|
||||
|
||||
/* For older Picolibc versions, use the general port alignment value */
|
||||
#define picolibcTLS_ALIGNMENT_MASK ( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK )
|
||||
#endif
|
||||
|
||||
/* Allocate thread local storage block off the end of the
|
||||
* stack. The _tls_size() function returns the size (in
|
||||
* bytes) of the total TLS area used by the application */
|
||||
#if ( portSTACK_GROWTH < 0 )
|
||||
|
||||
#define configINIT_TLS_BLOCK( xTLSBlock, pxTopOfStack ) \
|
||||
do { \
|
||||
pxTopOfStack = ( StackType_t * ) ( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) \
|
||||
- picolibcTLS_SIZE ) & ~ \
|
||||
configMAX( picolibcSTACK_ALIGNMENT_MASK, \
|
||||
picolibcTLS_ALIGNMENT_MASK ) ); \
|
||||
xTLSBlock = pxTopOfStack; \
|
||||
_init_tls( xTLSBlock ); \
|
||||
} while( 0 )
|
||||
#else /* portSTACK_GROWTH */
|
||||
#define configINIT_TLS_BLOCK( xTLSBlock, pxTopOfStack ) \
|
||||
do { \
|
||||
xTLSBlock = ( void * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack + \
|
||||
picolibcTLS_ALIGNMENT_MASK ) & ~picolibcTLS_ALIGNMENT_MASK ); \
|
||||
pxTopOfStack = ( StackType_t * ) ( ( ( ( ( portPOINTER_SIZE_TYPE ) xTLSBlock ) + \
|
||||
picolibcTLS_SIZE ) + picolibcSTACK_ALIGNMENT_MASK ) & \
|
||||
~picolibcSTACK_ALIGNMENT_MASK ); \
|
||||
_init_tls( xTLSBlock ); \
|
||||
} while( 0 )
|
||||
#endif /* portSTACK_GROWTH */
|
||||
|
||||
#define configSET_TLS_BLOCK( xTLSBlock ) _set_tls( xTLSBlock )
|
||||
|
||||
#define configDEINIT_TLS_BLOCK( xTLSBlock )
|
||||
|
||||
#endif /* INC_PICOLIBC_FREERTOS_H */
|
||||
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Portable layer API. Each function must be defined for each port.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#ifndef PORTABLE_H
|
||||
#define PORTABLE_H
|
||||
|
||||
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a
|
||||
* pre-processor definition was used to ensure the pre-processor found the correct
|
||||
* portmacro.h file for the port being used. That scheme was deprecated in favour
|
||||
* of setting the compiler's include path such that it found the correct
|
||||
* portmacro.h file - removing the need for the constant and allowing the
|
||||
* portmacro.h file to be located anywhere in relation to the port being used.
|
||||
* Purely for reasons of backward compatibility the old method is still valid, but
|
||||
* to make it clear that new projects should not use it, support for the port
|
||||
* specific constants has been moved into the deprecated_definitions.h header
|
||||
* file. */
|
||||
#include "deprecated_definitions.h"
|
||||
|
||||
/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
|
||||
* did not result in a portmacro.h header file being included - and it should be
|
||||
* included here. In this case the path to the correct portmacro.h header file
|
||||
* must be set in the compiler's include path. */
|
||||
#ifndef portENTER_CRITICAL
|
||||
#include "portmacro.h"
|
||||
#endif
|
||||
|
||||
#if portBYTE_ALIGNMENT == 32
|
||||
#define portBYTE_ALIGNMENT_MASK ( 0x001f )
|
||||
#elif portBYTE_ALIGNMENT == 16
|
||||
#define portBYTE_ALIGNMENT_MASK ( 0x000f )
|
||||
#elif portBYTE_ALIGNMENT == 8
|
||||
#define portBYTE_ALIGNMENT_MASK ( 0x0007 )
|
||||
#elif portBYTE_ALIGNMENT == 4
|
||||
#define portBYTE_ALIGNMENT_MASK ( 0x0003 )
|
||||
#elif portBYTE_ALIGNMENT == 2
|
||||
#define portBYTE_ALIGNMENT_MASK ( 0x0001 )
|
||||
#elif portBYTE_ALIGNMENT == 1
|
||||
#define portBYTE_ALIGNMENT_MASK ( 0x0000 )
|
||||
#else /* if portBYTE_ALIGNMENT == 32 */
|
||||
#error "Invalid portBYTE_ALIGNMENT definition"
|
||||
#endif /* if portBYTE_ALIGNMENT == 32 */
|
||||
|
||||
#ifndef portUSING_MPU_WRAPPERS
|
||||
#define portUSING_MPU_WRAPPERS 0
|
||||
#endif
|
||||
|
||||
#ifndef portNUM_CONFIGURABLE_REGIONS
|
||||
#define portNUM_CONFIGURABLE_REGIONS 1
|
||||
#endif
|
||||
|
||||
#ifndef portHAS_STACK_OVERFLOW_CHECKING
|
||||
#define portHAS_STACK_OVERFLOW_CHECKING 0
|
||||
#endif
|
||||
|
||||
#ifndef portARCH_NAME
|
||||
#define portARCH_NAME NULL
|
||||
#endif
|
||||
|
||||
#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP
|
||||
/* Defaults to 0 for backward compatibility. */
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#include "mpu_wrappers.h"
|
||||
|
||||
/*
|
||||
* Setup the stack of a new task so it is ready to be placed under the
|
||||
* scheduler control. The registers have to be placed on the stack in
|
||||
* the order that the port expects to find them.
|
||||
*
|
||||
*/
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
#if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
|
||||
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
StackType_t * pxEndOfStack,
|
||||
TaskFunction_t pxCode,
|
||||
void * pvParameters,
|
||||
BaseType_t xRunPrivileged,
|
||||
xMPU_SETTINGS * xMPUSettings ) PRIVILEGED_FUNCTION;
|
||||
#else
|
||||
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
TaskFunction_t pxCode,
|
||||
void * pvParameters,
|
||||
BaseType_t xRunPrivileged,
|
||||
xMPU_SETTINGS * xMPUSettings ) PRIVILEGED_FUNCTION;
|
||||
#endif /* if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) */
|
||||
#else /* if ( portUSING_MPU_WRAPPERS == 1 ) */
|
||||
#if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
|
||||
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
StackType_t * pxEndOfStack,
|
||||
TaskFunction_t pxCode,
|
||||
void * pvParameters ) PRIVILEGED_FUNCTION;
|
||||
#else
|
||||
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
||||
TaskFunction_t pxCode,
|
||||
void * pvParameters ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
#endif /* if ( portUSING_MPU_WRAPPERS == 1 ) */
|
||||
|
||||
/* Used by heap_5.c to define the start address and size of each memory region
|
||||
* that together comprise the total FreeRTOS heap space. */
|
||||
typedef struct HeapRegion
|
||||
{
|
||||
uint8_t * pucStartAddress;
|
||||
size_t xSizeInBytes;
|
||||
} HeapRegion_t;
|
||||
|
||||
/* Used to pass information about the heap out of vPortGetHeapStats(). */
|
||||
typedef struct xHeapStats
|
||||
{
|
||||
size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */
|
||||
size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
|
||||
size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
|
||||
size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */
|
||||
size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */
|
||||
size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */
|
||||
size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */
|
||||
} HeapStats_t;
|
||||
|
||||
/*
|
||||
* Used to define multiple heap regions for use by heap_5.c. This function
|
||||
* must be called before any calls to pvPortMalloc() - not creating a task,
|
||||
* queue, semaphore, mutex, software timer, event group, etc. will result in
|
||||
* pvPortMalloc being called.
|
||||
*
|
||||
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
|
||||
* defines a region of memory that can be used as the heap. The array is
|
||||
* terminated by a HeapRegions_t structure that has a size of 0. The region
|
||||
* with the lowest start address must appear first in the array.
|
||||
*/
|
||||
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* Returns a HeapStats_t structure filled with information about the current
|
||||
* heap state.
|
||||
*/
|
||||
void vPortGetHeapStats( HeapStats_t * pxHeapStats );
|
||||
|
||||
/*
|
||||
* Map to the memory management routines required for the port.
|
||||
*/
|
||||
void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
|
||||
void * pvPortCalloc( size_t xNum,
|
||||
size_t xSize ) PRIVILEGED_FUNCTION;
|
||||
void vPortFree( void * pv ) PRIVILEGED_FUNCTION;
|
||||
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
|
||||
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
|
||||
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#if ( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 )
|
||||
void * pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION;
|
||||
void vPortFreeStack( void * pv ) PRIVILEGED_FUNCTION;
|
||||
#else
|
||||
#define pvPortMallocStack pvPortMalloc
|
||||
#define vPortFreeStack vPortFree
|
||||
#endif
|
||||
|
||||
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
|
||||
|
||||
/**
|
||||
* task.h
|
||||
* @code{c}
|
||||
* void vApplicationMallocFailedHook( void )
|
||||
* @endcode
|
||||
*
|
||||
* This hook function is called when allocation failed.
|
||||
*/
|
||||
void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Setup the hardware ready for the scheduler to take control. This generally
|
||||
* sets up a tick interrupt and sets timers for the correct tick frequency.
|
||||
*/
|
||||
BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
|
||||
* the hardware is left in its original condition after the scheduler stops
|
||||
* executing.
|
||||
*/
|
||||
void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/*
|
||||
* The structures and methods of manipulating the MPU are contained within the
|
||||
* port layer.
|
||||
*
|
||||
* Fills the xMPUSettings structure with the memory region information
|
||||
* contained in xRegions.
|
||||
*/
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
struct xMEMORY_REGION;
|
||||
void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
|
||||
const struct xMEMORY_REGION * const xRegions,
|
||||
StackType_t * pxBottomOfStack,
|
||||
uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Checks if the calling task is authorized to access the given buffer.
|
||||
*
|
||||
* @param pvBuffer The buffer which the calling task wants to access.
|
||||
* @param ulBufferLength The length of the pvBuffer.
|
||||
* @param ulAccessRequested The permissions that the calling task wants.
|
||||
*
|
||||
* @return pdTRUE if the calling task is authorized to access the buffer,
|
||||
* pdFALSE otherwise.
|
||||
*/
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer,
|
||||
uint32_t ulBufferLength,
|
||||
uint32_t ulAccessRequested ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Checks if the calling task is authorized to access the given kernel object.
|
||||
*
|
||||
* @param lInternalIndexOfKernelObject The index of the kernel object in the kernel
|
||||
* object handle pool.
|
||||
*
|
||||
* @return pdTRUE if the calling task is authorized to access the kernel object,
|
||||
* pdFALSE otherwise.
|
||||
*/
|
||||
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )
|
||||
|
||||
BaseType_t xPortIsAuthorizedToAccessKernelObject( int32_t lInternalIndexOfKernelObject ) PRIVILEGED_FUNCTION;
|
||||
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* PORTABLE_H */
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.6.2
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PROJDEFS_H
|
||||
#define PROJDEFS_H
|
||||
|
||||
/*
|
||||
* Defines the prototype to which task functions must conform. Defined in this
|
||||
* file to ensure the type is known before portable.h is included.
|
||||
*/
|
||||
typedef void (* TaskFunction_t)( void * );
|
||||
|
||||
/* Converts a time in milliseconds to a time in ticks. This macro can be
|
||||
* overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
|
||||
* definition here is not suitable for your application. */
|
||||
#ifndef pdMS_TO_TICKS
|
||||
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) )
|
||||
#endif
|
||||
|
||||
#define pdFALSE ( ( BaseType_t ) 0 )
|
||||
#define pdTRUE ( ( BaseType_t ) 1 )
|
||||
#define pdFALSE_SIGNED ( ( BaseType_t ) 0 )
|
||||
#define pdTRUE_SIGNED ( ( BaseType_t ) 1 )
|
||||
#define pdFALSE_UNSIGNED ( ( UBaseType_t ) 0 )
|
||||
#define pdTRUE_UNSIGNED ( ( UBaseType_t ) 1 )
|
||||
|
||||
#define pdPASS ( pdTRUE )
|
||||
#define pdFAIL ( pdFALSE )
|
||||
#define errQUEUE_EMPTY ( ( BaseType_t ) 0 )
|
||||
#define errQUEUE_FULL ( ( BaseType_t ) 0 )
|
||||
|
||||
/* FreeRTOS error definitions. */
|
||||
#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
|
||||
#define errQUEUE_BLOCKED ( -4 )
|
||||
#define errQUEUE_YIELD ( -5 )
|
||||
|
||||
/* Macros used for basic data corruption checks. */
|
||||
#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES
|
||||
#define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
|
||||
#endif
|
||||
|
||||
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
|
||||
#define pdINTEGRITY_CHECK_VALUE 0x5a5a
|
||||
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
|
||||
#define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL
|
||||
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
|
||||
#define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5a5a5a5a5aULL
|
||||
#else
|
||||
#error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
|
||||
#endif
|
||||
|
||||
/* The following errno values are used by FreeRTOS+ components, not FreeRTOS
|
||||
* itself. */
|
||||
#define pdFREERTOS_ERRNO_NONE 0 /* No errors */
|
||||
#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */
|
||||
#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */
|
||||
#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */
|
||||
#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */
|
||||
#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */
|
||||
#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */
|
||||
#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */
|
||||
#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */
|
||||
#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */
|
||||
#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */
|
||||
#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */
|
||||
#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */
|
||||
#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */
|
||||
#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */
|
||||
#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */
|
||||
#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */
|
||||
#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */
|
||||
#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */
|
||||
#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */
|
||||
#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */
|
||||
#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */
|
||||
#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */
|
||||
#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */
|
||||
#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */
|
||||
#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */
|
||||
#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */
|
||||
#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define pdFREERTOS_ERRNO_EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */
|
||||
#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */
|
||||
#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */
|
||||
#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */
|
||||
#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */
|
||||
#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */
|
||||
#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */
|
||||
#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */
|
||||
#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */
|
||||
#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */
|
||||
#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */
|
||||
#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */
|
||||
|
||||
/* The following endian values are used by FreeRTOS+ components, not FreeRTOS
|
||||
* itself. */
|
||||
#define pdFREERTOS_LITTLE_ENDIAN 0
|
||||
#define pdFREERTOS_BIG_ENDIAN 1
|
||||
|
||||
/* Re-defining endian values for generic naming. */
|
||||
#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN
|
||||
#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN
|
||||
|
||||
|
||||
#endif /* PROJDEFS_H */
|
||||
+1764
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user