Solenoid Driver Click
Solenoid Driver 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 Filipovic
- Date : Apr 2025.
- Type : SPI type
Software Support
Example Description
This example demonstrates the use of the Solenoid Driver Click board by enabling output channels one by one in a round-robin fashion and parsing the diagnostic status after each update. The diagnosis includes undervoltage detection, output fault status, and operation mode.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.SolenoidDriver
Example Key Functions
- solenoiddriver_cfg_setup This function initializes Click configuration structure to initial values.
void solenoiddriver_cfg_setup(solenoiddriver_cfg_t *cfg)
Solenoid Driver configuration object setup function.
Solenoid Driver Click configuration object.
Definition solenoiddriver.h:264
- solenoiddriver_init This function initializes all necessary pins and peripherals used for this Click board.
err_t solenoiddriver_init(solenoiddriver_t *ctx, solenoiddriver_cfg_t *cfg)
Solenoid Driver initialization function.
Solenoid Driver Click context object.
Definition solenoiddriver.h:244
- solenoiddriver_default_cfg This function executes a default configuration of Solenoid Driver Click board.
err_t solenoiddriver_default_cfg(solenoiddriver_t *ctx)
Solenoid Driver default configuration function.
- solenoiddriver_set_output This function sets the desired output control configuration to the output control register.
err_t solenoiddriver_set_output(solenoiddriver_t *ctx, uint8_t out_ctrl)
Solenoid Driver set output function.
- solenoiddriver_clear_latch This function clears all latch output states via register write.
err_t solenoiddriver_clear_latch(solenoiddriver_t *ctx)
Solenoid Driver clear latch outputs function.
Application Init
Initializes the logger and the Click board driver, and applies the default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define SOLENOIDDRIVER_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition solenoiddriver.h:227
void application_init(void)
Definition main.c:42
@ SOLENOIDDRIVER_ERROR
Definition solenoiddriver.h:290
Application Task
Sequentially enables each output channel with a 1-second delay, checks the diagnostic register, logs operation status, and clears the latch register.
{
{
solenoiddriver_parse_diag ( &solenoiddriver );
log_printf ( &logger, " OUT0: %u\r\n", ( uint16_t )
log_printf ( &logger, " OUT1: %u\r\n", ( uint16_t )
log_printf ( &logger, " OUT2: %u\r\n", ( uint16_t )
log_printf ( &logger, " OUT3: %u\r\n\n", ( uint16_t )
out_en <<= 1;
{
}
}
Delay_ms ( 1000 );
}
#define SOLENOIDDRIVER_OUT_CTRL_EN0
Definition solenoiddriver.h:120
#define SOLENOIDDRIVER_OUT_CTRL_EN1
Definition solenoiddriver.h:119
#define SOLENOIDDRIVER_OUT_CTRL_EN2
Definition solenoiddriver.h:118
#define SOLENOIDDRIVER_OUT_CTRL_EN3
Solenoid Driver OUT_CTRL register setting.
Definition solenoiddriver.h:117
void application_task(void)
Definition main.c:78
@ SOLENOIDDRIVER_OK
Definition solenoiddriver.h:289
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.