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 {
120 DAP_PIPELINE_MODE_UNINITIALIZED = 0x00,
122 DAP_PIPELINE_MODE_DATA_ACQUISITION = 0x01,
124 DAP_PIPELINE_MODE_SENSOR_INFERENCING = 0x02,
126 DAP_PIPELINE_MODE_HOST_INFERENCING = 0x03,
128 DAP_PIPELINE_MODE_LOOPBACK = 0x04,
129 } DAP_PipelineMode;
130
137 typedef struct
138 {
139 /* Mode of operation. */
140 DAP_PipelineMode mode;
141 /* Index of the model to use for Sensor and Host Inferencing modes. */
142 uint8_t inferenceModelIndex;
143 /* Indices of the sensors to be used for Data Acquisition and Sensor
144 * Inferencing modes.
145 */
146 uint8_t inferenceSensorsIndex[10];
147 } DAP_PipelineConfiguration;
148
156 typedef struct
157 {
159 UART2_Handle uartHandle;
160
162 MessageQueueP_Handle messageQueueHandle;
163
164 bool isCrc;
165
166 bool startStreamingFlag;
167
168 DAP_PipelineConfiguration pipelineConfig;
169 } DAP_Handle;
170
171 typedef enum
172 {
174 DAP_SEND_DATA_TYPE_SENSOR_SIGNAL = 0x01,
176 DAP_SEND_DATA_TYPE_INFERENCING_SIGNAL = 0x03,
180 DAP_SEND_DATA_TYPE_INFERENCING_RESULT = 0x04,
182 DAP_SEND_DATA_TYPE_INFERENCING_VALUE = 0x05,
184 DAP_SEND_DATA_TYPE_INFERENCING_LOG = 0x06,
185
186 } DAP_SendDataType;
187
195 float DAP_swapEndianness(float value);
196
200 void DAP_init(void);
201
207 void DAP_open(void);
208
214 DAP_PipelineConfiguration DAP_getPipelineConfiguration(void);
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 */
DAP_swapEndianness
float DAP_swapEndianness(float value)
Swap Endianess value to support the endianess format expected by EdgeAI Studio.
DAP_SEND_DATA_TYPE_INFERENCING_VALUE
Definition: DAP.h:182
DAP_PipelineMode
DAP_PipelineMode
DAP pipeline modes.
Definition: DAP.h:117
DAP_getSamplingFrequency
uint32_t DAP_getSamplingFrequency(void)
Get samplign frequency.
DAP_Handle
DAP configuration.
Definition: DAP.h:156
DAP_Handle::uartHandle
UART2_Handle uartHandle
Definition: DAP.h:159
DAP_Handle::messageQueueHandle
MessageQueueP_Handle messageQueueHandle
Definition: DAP.h:162
DAP_PIPELINE_MODE_SENSOR_INFERENCING
Definition: DAP.h:124
DAP_SEND_DATA_TYPE_INFERENCING_RESULT
Definition: DAP.h:180
DAP_getPipelineConfiguration
DAP_PipelineConfiguration DAP_getPipelineConfiguration(void)
Get Pipeline Configuration.
DAP_SendDataType
DAP_SendDataType
Definition: DAP.h:171
DAP_SEND_DATA_TYPE_SENSOR_SIGNAL
Definition: DAP.h:174
DAP_sendData
void DAP_sendData(DAP_SendDataType sendDataType, void *data, size_t dataSize)
Send Data to host.
DAP_PipelineConfiguration::mode
DAP_PipelineMode mode
Definition: DAP.h:140
DAP_PIPELINE_MODE_UNINITIALIZED
Definition: DAP.h:120
DAP_PipelineConfiguration
DAP pipeline configuration.
Definition: DAP.h:137
DAP_init
void DAP_init(void)
Initialize the DAP.
DAP_PipelineConfiguration::inferenceModelIndex
uint8_t inferenceModelIndex
Definition: DAP.h:142
DAP_SEND_DATA_TYPE_INFERENCING_LOG
Definition: DAP.h:184
DAP_open
void DAP_open(void)
Open the DAP.
DAP_PIPELINE_MODE_LOOPBACK
Definition: DAP.h:128
DAP_isReadyToStartStreaming
bool DAP_isReadyToStartStreaming(void)
Check if the DAP is ready for data streaming.
DAP_getSamplesToSend
uint32_t DAP_getSamplesToSend(void)
Get samples to send.
DAP_Handle::pipelineConfig
DAP_PipelineConfiguration pipelineConfig
Definition: DAP.h:168
DAP_PIPELINE_MODE_HOST_INFERENCING
Definition: DAP.h:126
DAP_Handle::startStreamingFlag
bool startStreamingFlag
Definition: DAP.h:166
DAP_PIPELINE_MODE_DATA_ACQUISITION
Definition: DAP.h:122
DAP_SEND_DATA_TYPE_INFERENCING_SIGNAL
Definition: DAP.h:176
DAP_Handle::isCrc
bool isCrc
Definition: DAP.h:164

© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale