cxpi  2.0.0.0
Main Page

CXPI click

CXPI Click is a compact add-on board that contains a transceiver that supports the next-generation automotive communication protocol. This board features the BD41000AFJ-C, a transceiver for the CXPI (Clock Extension Peripheral Interface) communication from Rohm Semiconductor.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Aug 2021.
  • Type : UART type

Software Support

We provide a library for the CXPI Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for CXPI Click driver.

Standard key functions :

Example key functions :

Example Description

This is an example that demonstrates the use of the CXPI Click board.

The demo application is composed of two sections :

Application Init

Initializes UART driver. In addition to this module is placed inside transmitter/receiver working mode cappable of transmission/receive the data.

void application_init ( void ) {
log_cfg_t log_cfg;
cxpi_cfg_t cxpi_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
// Click initialization.
cxpi_cfg_setup( &cxpi_cfg );
CXPI_MAP_MIKROBUS( cxpi_cfg, MIKROBUS_1 );
err_t init_flag = cxpi_init( &cxpi, &cxpi_cfg );
if ( UART_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
#ifdef DEMO_APP_TRANSMITER
log_printf( &logger, "------------------\r\n" );
log_printf( &logger, " Send data: \r\n" );
log_printf( &logger, " MikroE \r\n" );
Delay_ms ( 1000 );
#endif
#ifdef DEMO_APP_RECEIVER
log_printf( &logger, "------------------\r\n" );
log_printf( &logger, " Receive data \r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
log_printf( &logger, "------------------\r\n" );
}

Application Task

Transmitter/Receiver task depend on uncommented code Receiver logging each received byte to the UART for data logging, while transmitted send messages every 5 seconds.

void application_task ( void ) {
#ifdef DEMO_APP_RECEIVER
cxpi_process( );
if ( current_rsp_buf > 0 ) {
log_printf( &logger, "%s", current_rsp_buf );
cxpi_clear_current_rsp_buf( );
}
#endif
#ifdef DEMO_APP_TRANSMITER
log_printf( &logger, " Sent data : %s", &demo_message[ 0 ] );
log_printf( &logger, "------------------\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.CXPI

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


cxpi_set_through_mode
void cxpi_set_through_mode(cxpi_t *ctx)
Set through mode function.
cxpi_cfg_setup
void cxpi_cfg_setup(cxpi_cfg_t *cfg)
CXPI configuration object setup function.
application_task
void application_task(void)
Definition: main.c:104
cxpi_set_pwm_pin_state
void cxpi_set_pwm_pin_state(cxpi_t *ctx, uint8_t pin_state)
Set PWM pin state function.
CXPI_MAP_MIKROBUS
#define CXPI_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: cxpi.h:99
cxpi_send_command
void cxpi_send_command(cxpi_t *ctx, char *command)
Send command.
application_init
void application_init(void)
Definition: main.c:57
cxpi_init
err_t cxpi_init(cxpi_t *ctx, cxpi_cfg_t *cfg)
CXPI initialization function.
cxpi_cfg_t
CXPI Click configuration object.
Definition: cxpi.h:136
demo_message
unsigned char demo_message[9]
Definition: main.c:43
cxpi_t
CXPI Click context object.
Definition: cxpi.h:114