solenoiddriver 2.2.0
Loading...
Searching...
No Matches
solenoiddriver


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

Application Init

Initializes the logger and the Click board driver, and applies the default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
solenoiddriver_cfg_t solenoiddriver_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
solenoiddriver_cfg_setup( &solenoiddriver_cfg );
SOLENOIDDRIVER_MAP_MIKROBUS( solenoiddriver_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == solenoiddriver_init( &solenoiddriver, &solenoiddriver_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( SOLENOIDDRIVER_ERROR == solenoiddriver_default_cfg ( &solenoiddriver ) )
{
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.

void application_task ( void )
{
static uint8_t out_en = SOLENOIDDRIVER_OUT_CTRL_EN0;
if ( SOLENOIDDRIVER_OK == solenoiddriver_set_output ( &solenoiddriver, out_en ) )
{
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;
{
}
solenoiddriver_clear_latch ( &solenoiddriver );
}
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.