AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
Loading...
Searching...
No Matches
CAN Application

AFBR-S50 Reference Board CAN-bus example application. More...

Collaboration diagram for CAN Application:

Modules

 CAN API interface
 CAN interface for the AFBR-S50 Reference Board CAN application.
 
 CAN Application Version
 AFBR-S50 CAN Application version number.
 
 UART API interface
 UART interface for the AFBR-S50 Reference Board CAN application.
 

Macros

#define SPI_SLAVE   1
 
#define SPI_BAUD_RATE   6000000
 

Functions

static void print_help (void)
 Prints a help string to the serial interface.
 
status_t measurement_ready_callback (status_t status, argus_hnd_t *device)
 Measurement data ready callback function.
 
int main (void)
 Application entry point.
 
void start_measurements (void)
 Starts measurements via the AFBR-S50 API.
 
void stop_measurements (void)
 Stops the currently ongoing measurements via the AFBR-S50 API.
 
void handle_error (status_t status, char const *msg)
 A very brief example for error handling.
 

Variables

static volatile uint8_t myDataReadyEvents = 0
 
argus_hnd_thnd = 0
 

Detailed Description

AFBR-S50 Reference Board CAN-bus example application.



This is the CAN interface example application that can be run in the AFBR-S50 Reference Board by MikroElektronika based on the Renesas RA4M2 micro controller.

The application provides a simple CAN interface as an reference for the customers own implementation.

See the following documentation for more information:

Macro Definition Documentation

◆ SPI_BAUD_RATE

#define SPI_BAUD_RATE   6000000

Define the SPI baud rate (to be used in the SPI module).

◆ SPI_SLAVE

#define SPI_SLAVE   1

Define the SPI slave (to be used in the SPI module).

Function Documentation

◆ handle_error()

void handle_error ( status_t  status,
char const *  msg 
)

A very brief example for error handling.


Checks the specified status for errors (i.e. negative values) and prints a specified error message if any. An endless loop is entered to halt program execution.

Parameters
statusThe specified status to be checked for errors.
msgThe associated error message to be printed in case of errors.

◆ main()

int main ( void  )

Application entry point.


The main function of the program, called after startup code This function should never be exited.

Returns
Function never returns...

◆ measurement_ready_callback()

status_t measurement_ready_callback ( status_t  status,
argus_hnd_t device 
)

Measurement data ready callback function.


Parameters
statusThe measurement/device status from the last measurement cycle.
deviceThe pointer to the handle of the calling API instance. Used to identify the calling instance in case of multiple devices.
Returns
Returns the status (STATUS_OK on success).

◆ print_help()

void print_help ( void  )
static

Prints a help string to the serial interface.


◆ start_measurements()

void start_measurements ( void  )

Starts measurements via the AFBR-S50 API.


The measurements are started via the AFBR-S50 API using the current device configuration. Nothing happens if the device is already executing measurements.

In case of error, the handle_error method is called.

◆ stop_measurements()

void stop_measurements ( void  )

Stops the currently ongoing measurements via the AFBR-S50 API.


The measurements are stopped via the AFBR-S50 API. Nothing happens if the device does not currently execute measurements.

In case of error, the handle_error method is called.

Variable Documentation

◆ hnd

argus_hnd_t* hnd = 0

The AFBR-S50 Data Handle.

◆ myDataReadyEvents

volatile uint8_t myDataReadyEvents = 0
static

Global measurement data ready event counter.

Determines the number of measurement data ready events happened and thus the number of timer the Argus_EvaluateData function must be called to free API internal date structures that buffer the raw sensor readout data.

The Argus_EvaluateData function must be called outside of the interrupt callback scope (i.e. from the main thread/task) to avoid huge delays due to the heavy data evaluation.

Note that the Argus_EvaluateData function must be called once for each callback event since it clears the internal state of the raw data buffer. If not called, the API gets stuck waiting for the raw data buffer to be freed and ready to be filled with new measurement data.

In automatic measurement mode, i.e. if the measurements are automatically triggered on a time based schedule from the periodic interrupt timer (PIT), the callback may occur faster than the Argus_EvaluateData function gets called from the main thread/task. This usually happens at high frame rates or too much CPU load on the main thread/task. In that case, the API delays new measurements until the previous buffers are cleared. Since the API contains two distinct raw data buffers, this counter raises up to 2 in the worst case scenario.

Examples
02_advanced_example.c, 02_advanced_example_with_hal_self_test.c, and 03_high_speed_example.c.