User-defined functions

These functions are required to be implemented by the user for the target platform. See this porting guide for more information. They are declared internally in the Edge Impulse C++ SDK library, and they must be defined by the user.

Source: porting/ei_classifier_porting.h

Examples: The following examples demonstrate possible implementations of this function for various platforms. Note the __attribute__((weak)) in most of the definitions, which means that a user could override the implementation elsewhere in the program:

ei_sleep

public EI_IMPULSE_ERROR ei_sleep(
    int32_t time_ms
) 

Brief: Cancellable sleep, can be triggered with signal from other thread.

Description: Cancelable sleep, can be triggered with signal from other thread Allow the processor or thread to sleep or block for the given time.

Parameters

  • time_ms Time in milliseconds to sleep

Returns

EI_IMPULSE_OK if successful, error code otherwise

ei_read_timer_ms

public uint64_t ei_read_timer_ms(

) 

Brief: Read the millisecond timer.

Description: Read the millisecond timer This function should return the number of milliseconds that have passed since the start of the program. If you do not need to determine the run times for DSP and inference blocks, you can simply return 0 from this function. Your impulse will still work correctly without timing information.

Returns

The number of milliseconds that have passed since the start of the program

ei_read_timer_us

public uint64_t ei_read_timer_us(

) 

Brief: Read the microsecond timer.

Description: This function should return the number of milliseconds that have passed since the start of the program. If you do not need to determine the run times for DSP and inference blocks, you can simply return 0 from this function. Your impulse will still work correctly without timing information.

Returns

The number of microseconds that have passed since the start of the program

ei_putchar

public void ei_putchar(
    char c
) 

Brief: Send a single character to the serial port.

Description:

Parameters

  • c The chararater to send

ei_getchar

public char ei_getchar(
    void
) 

Brief: Read a single character from the serial port.

Description:

Returns

The character read from the serial port

ei_printf

public void ei_printf(
    const char