PCR Click
PCR Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Ilic
- Date : Nov 2023.
- Type : I2C type
Software Support
Example Description
This example demonstrates the use of PCR Click board by reading distance between Click board and object.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.PCR
Example Key Functions
- pcr_cfg_setup Config Object Initialization function.
void pcr_cfg_setup(pcr_cfg_t *cfg)
PCR configuration object setup function.
PCR Click configuration object.
Definition pcr.h:245
- pcr_init Initialization function.
err_t pcr_init(pcr_t *ctx, pcr_cfg_t *cfg)
PCR initialization function.
PCR Click context object.
Definition pcr.h:224
- pcr_default_cfg Click Default Configuration function.
err_t pcr_default_cfg(pcr_t *ctx)
PCR default configuration function.
- pcr_write_reg PCR register writing function.
err_t pcr_write_reg(pcr_t *ctx, uint16_t reg, uint32_t data_in)
PCR register writing function.
- pcr_check_if_busy PCR check if device is busy function.
err_t pcr_check_if_busy(pcr_t *ctx)
PCR check if device is busy function.
- pcr_get_distance PCR read distance function.
err_t pcr_get_distance(pcr_t *ctx, uint32_t *distance_data)
PCR read distance function.
Application Init
Initializes the driver and logger and performs the Click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
pcr_init( &pcr, &pcr_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define PCR_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition pcr.h:209
void application_init(void)
Definition main.c:28
@ PCR_ERROR
Definition pcr.h:266
Application Task
Reading distance between Click board and object every 2 seconds and logging it on UART terminal.
{
uint32_t distance_data = 0;
log_printf( &logger, " Distance: %lu mm \r\n", distance_data );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
void application_task(void)
Definition main.c:64
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.