ML Middleware
ModusToolbox Machine Learning Middleware Library
All Data Structures Functions Variables Modules
mtb_ml_stream.h
1 /***************************************************************************/
39 #if !defined(__MTB_ML_STREAM_H__)
40 #define __MTB_ML_STREAM_H__
41 
42 #include "mtb_ml_model.h"
43 #include "mtb_ml_dataset.h"
44 
45 
46 #if defined(__cplusplus)
47 extern "C" {
48 #endif
49 
50 #if !defined(COMPONENT_MTB_HAL)
51 #include "cyhal.h"
52 #else
53 #include "mtb_hal.h"
54 #endif
55 
56 /******************************************************************************
57 * Compile-time flags
58 *****************************************************************************/
59 
60 /******************************************************************************
61 * Enums
62 *****************************************************************************/
63 
64 /******************************************************************************
65 * Macros
66 *****************************************************************************/
67 
68 /*******************************************************************************
69 * extern variables
70 ******************************************************************************/
71 
72 /*******************************************************************************
73 * Structures and enumerations
74 ******************************************************************************/
78 typedef struct
79 {
80  void* placeholder[3];
82 
86 typedef cy_rslt_t (* mtb_data_streaming_send_t)(mtb_data_streaming_vcontext_t* context,
87  void *data, size_t count, void* tag);
88 
92 typedef cy_rslt_t (* mtb_data_streaming_receive_t)(mtb_data_streaming_vcontext_t* context,
93  uint8_t* data, size_t count, void* tag);
94 
98 typedef void (* mtb_data_streaming_xfer_done_t)(void* tag, cy_rslt_t rslt);
99 
103 typedef struct
104 {
105 #if !defined(COMPONENT_MTB_HAL)
106  cyhal_uart_t* uart;
107 #else
108  mtb_hal_uart_t* uart;
109 #endif
111 
115 typedef struct
116 {
118  mtb_data_streaming_xfer_done_t callback;
119  void* call_tag;
121 
122 
126 typedef struct
127 {
128  mtb_data_streaming_send_t send;
129  mtb_data_streaming_receive_t receive;
132 
133 
137 typedef struct
138 {
139  bool stream_done;
140  cy_rslt_t stream_status;
142 
143 
147 typedef struct
148 {
151  mtb_ml_x_file_header_t x_data_info;
152  size_t input_size;
153  size_t output_size;
155 
156 /*******************************************************************************
157 * Function prototypes
158 ******************************************************************************/
176 cy_rslt_t mtb_ml_stream_init(mtb_ml_stream_interface_t *interface,
177  const mtb_ml_model_t *model_object);
189  void *tx_buf,
190  uint32_t timeout_ms);
202  void *rx_buf,
203  uint32_t timeout_ms);
213 cy_rslt_t mtb_ml_inform_host_done( mtb_ml_stream_interface_t *interface, uint32_t timeout_ms);
221 void mtb_ml_stream_cb(void* tag, cy_rslt_t rslt);
222 
227 #if defined(__cplusplus)
228 }
229 #endif
230 
231 #endif /* __MTB_ML_STREAM_H__ */
mtb_ml_x_file_header_t x_data_info
Definition: mtb_ml_stream.h:151
mtb_ml_stream_tag_t * stream_tag
Definition: mtb_ml_stream.h:150
mtb_data_streaming_obj_t obj_inst
Definition: mtb_ml_stream.h:117
mtb_data_streaming_send_t send
Definition: mtb_ml_stream.h:128
void mtb_ml_stream_cb(void *tag, cy_rslt_t rslt)
: TX/RX callback function.
mtb_data_streaming_vcontext_t context
Definition: mtb_ml_stream.h:130
size_t output_size
Definition: mtb_ml_stream.h:153
cy_rslt_t mtb_ml_stream_output_data(mtb_ml_stream_interface_t *interface, void *tx_buf, uint32_t timeout_ms)
: Streams output test data via interface.
cy_rslt_t mtb_ml_stream_input_data(mtb_ml_stream_interface_t *interface, void *rx_buf, uint32_t timeout_ms)
: Streams input test data via interface.
Definition: mtb_ml_model.h:119
void * call_tag
Definition: mtb_ml_stream.h:119
Definition: mtb_ml_stream.h:126
Definition: mtb_ml_stream.h:147
cy_rslt_t mtb_ml_stream_init(mtb_ml_stream_interface_t *interface, const mtb_ml_model_t *model_object)
: Prepare for data streaming: initialize members of interface, validate input test data matches dimen...
cyhal_uart_t * uart
Definition: mtb_ml_stream.h:106
Definition: mtb_ml_stream.h:78
cy_rslt_t stream_status
Definition: mtb_ml_stream.h:140
mtb_data_streaming_xfer_done_t callback
Definition: mtb_ml_stream.h:118
mtb_data_streaming_receive_t receive
Definition: mtb_ml_stream.h:129
bool stream_done
Definition: mtb_ml_stream.h:139
Definition: mtb_ml_stream.h:115
size_t input_size
Definition: mtb_ml_stream.h:152
Definition: mtb_ml_stream.h:103
Definition: mtb_ml_stream.h:137
mtb_data_streaming_interface_t * interface_obj
Definition: mtb_ml_stream.h:149
cy_rslt_t mtb_ml_inform_host_done(mtb_ml_stream_interface_t *interface, uint32_t timeout_ms)
: API to inform host application when the device task is complete