EDGEAI API
DAP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2025, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33  * @file DAP.h
34  * @brief <b>PRELIMINARY</b> DAP for EdgeAI
35  *
36  * <b>WARNING</b> These APIs are <b>PRELIMINARY</b>, and subject to change in
37  * the next few months.
38  *
39  * To use the DAP, include this header file in the application as follows:
40  * @code
41  * #include <ti/ai/edge_ai/DAP.h>
42  * @endcode
43  *
44  * @anchor ti_edgeai_DAP_Overview
45  * # Overview #
46  * The Device Agent Protocol (DAP) is a serial communication protocol using
47  * packets that facilitates interaction between Edge AI Studio (the host) and
48  * TI Microcontrollers (the target devices). This protocol is specifically
49  * designed to support edge AI applications.
50  *
51  * Communication follows a controller-responder model where the host initiates
52  * all transfers or commands, and the target device must acknowledge each
53  * command with a response. Depending on the command type, the target may send
54  * additional responses.
55  *
56  * Application execution is controlled by the host through a variety of
57  * commands. The application can be configured to operate in one of four
58  * distinct pipeline modes, as specified in the #DAP_PipelineMode enumeration.
59  *
60  * Configuration details specific to each pipeline mode are maintained in the
61  * #DAP_PipelineConfiguration structure. To retrieve this configuration
62  * information, the #DAP_getPipelineConfiguration() function can be utilized.
63  *
64  * Depending on the active operation mode, the host may request various types
65  * of data from the target device. The readiness for data streaming can be
66  * determined using the DAP_isReadyToStartStreaming function. When streaming is
67  * available, data transmission is performed via the #DAP_sendData() function.
68  * The #DAP_SendDataType enumeration defines the supported data types for
69  * transmission.
70  *
71  * # Design Architecture
72  * This protocol operates in duplex mode, enabling simultaneous transmission
73  * and reception of data packets. The implementation achieves this capability
74  * by separating functionality into dedicated RX (receiving) and TX
75  * (transmitting) tasks.
76  *
77  * The RX task is in charge of receiving the packets, decoding them and
78  * constructing the response packet. The response packet is then posted in a
79  * message queue shared with the TX task.
80  *
81  * The TX task is in charge of reading packets from the message queue and
82  * sending them over to the host through the transport layer.
83  *
84  * The transport layer utilizes a serial communication protocol, with its
85  * backend implementation located in the ti/ai/edge_ai/dap/core/DAP_core.h
86  * file.
87  *
88  * <hr>
89  * # Usage
90  * To use the DAP the application calls the following APIs:
91  * - DAP_init(): One time initialization of the DAP.
92  * - DAP_open(): Initializes the serial protocol, the message queue, and the
93  * RX and TX tasks.
94  *
95  ******************************************************************************
96  */
97 
98 #ifndef ti_edgeai_DAP__include
99 #define ti_edgeai_DAP__include
100 
101 #include <stdint.h>
102 #include <stdbool.h>
103 
104 #include <ti/drivers/UART2.h>
105 #include <ti/drivers/dpl/MessageQueueP.h>
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
117 typedef enum
118 {
130 
137 typedef struct
138 {
139  /* Mode of operation. */
141  /* Index of the model to use for Sensor and Host Inferencing modes. */
143  /* Indices of the sensors to be used for Data Acquisition and Sensor
144  * Inferencing modes.
145  */
146  uint8_t inferenceSensorsIndex[10];
148 
156 typedef struct
157 {
159  UART2_Handle uartHandle;
160 
162  MessageQueueP_Handle messageQueueHandle;
163 
164  bool isCrc;
165 
167 
169 } DAP_Handle;
170 
171 typedef enum
172 {
185 
187 
195 float DAP_swapEndianness(float value);
196 
200 void DAP_init(void);
201 
207 void DAP_open(void);
208 
215 
221 uint32_t DAP_getSamplesToSend(void);
222 
228 uint32_t DAP_getSamplingFrequency(void);
229 
235 bool DAP_isReadyToStartStreaming(void);
236 
246 void DAP_sendData(DAP_SendDataType sendDataType, void *data, size_t dataSize);
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 #endif /* ti_edgeai_DAP__include */
float DAP_swapEndianness(float value)
Swap Endianess value to support the endianess format expected by EdgeAI Studio.
DAP_PipelineMode
DAP pipeline modes.
Definition: DAP.h:117
uint32_t DAP_getSamplingFrequency(void)
Get samplign frequency.
DAP configuration.
Definition: DAP.h:156
UART2_Handle uartHandle
Definition: DAP.h:159
MessageQueueP_Handle messageQueueHandle
Definition: DAP.h:162
DAP_PipelineConfiguration DAP_getPipelineConfiguration(void)
Get Pipeline Configuration.
DAP_SendDataType
Definition: DAP.h:171
void DAP_sendData(DAP_SendDataType sendDataType, void *data, size_t dataSize)
Send Data to host.
DAP_PipelineMode mode
Definition: DAP.h:140
Definition: DAP.h:120
DAP pipeline configuration.
Definition: DAP.h:137
void DAP_init(void)
Initialize the DAP.
uint8_t inferenceModelIndex
Definition: DAP.h:142
void DAP_open(void)
Open the DAP.
Definition: DAP.h:128
bool DAP_isReadyToStartStreaming(void)
Check if the DAP is ready for data streaming.
uint32_t DAP_getSamplesToSend(void)
Get samples to send.
DAP_PipelineConfiguration pipelineConfig
Definition: DAP.h:168
bool startStreamingFlag
Definition: DAP.h:166
bool isCrc
Definition: DAP.h:164
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale