cancel
Showing results for 
Search instead for 
Did you mean: 

API-manual for ST Edge AI Developer Cloud generated C file for ISPU

Amith_lal
Associate III

In ST Edge AI Developer Cloud I generated the C library of a ST_LSM6DSO16IS_ispu_wand_dataset with platform selected as ISPU. I got many library files in which the major APIs are in the network.h and its c file. I need an API manual or documentation to apply this in tho my program or an example of implementation is enough.

11 REPLIES 11

Your idea on how to fill the input buffer is correct, however the algo_00 function (where I guess you wrote your code), is executed each time a new sample is generated by the sensor.

So, while it might technically work, you should not loop inside the function with "while(count < STAI_NETWORK_IN_1_SIZE)" and "delay_ms(38);". The code should be something like this:

 

uint32_t class;
float *input = (float *)input_buffers[0];
float *output = (float *)output_buffers[0];
 
input[count + 0] = (float)cast_sint16_t(ISPU_ARAW_X) * ACC_SENS;
input[count + 1] = (float)cast_sint16_t(ISPU_ARAW_Y) * ACC_SENS;
input[count + 2] = (float)cast_sint16_t(ISPU_ARAW_Z) * ACC_SENS;
count += 3;

if (count == STAI_NETWORK_IN_1_SIZE) {
    count = 0;

    stai_return_code res = stai_network_run(net, STAI_MODE_SYNC);
    class = argmax(output, STAI_NETWORK_OUT_1_SIZE); // to find the highest among the 3 output
    cast_float(ISPU_DOUT_06) = output[0];
    cast_float(ISPU_DOUT_08) = output[1];
    cast_float(ISPU_DOUT_10) = output[2];
    cast_float(ISPU_DOUT_12) = class;
}

 

You can define "count" as a static global variable and you should initialize it to 0 in the "algo_00_init" function.

It seems you want to run use data at 26 Hz, so make sure that in the "conf.txt" in your project folder both "acc_odr" and "ispu_irq_rate" are set to 26.

Regarding the output, if you are using MEMS Studio or Unicleo-GUI to display them, make sure to also have a ".json" file as explained in the readme of the generic template here: https://github.com/STMicroelectronics/ispu-examples/tree/master/ism330is_lsm6dso16is/template. This file will tell to the desktop application how to interpret the outputs of the ISPU and display them correctly. The ".json" file must have the same name as the ".ucf" one.

By the way, I see you are starting copying the outputs from ISPU_DOUT_06. I guess this is because you have other data before that. Should that not be the case, you should start from ISPU_DOUT_00, because the ".json" indicates the format for contiguous outputs starting from ISPU_DOUT_00.

Hope this helps solve your problems.

Thank you @Lorenzo BRACCO  it worked 😀. The problem was with the loop and delay.