Fan 9 click
PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU
[click Product page](CLICK_PRODUCT_PAGE_LINK)
Click library
- Author : Stefan Ilic
- Date : Jan 2024.
- Type : I2C type
Software Support
We provide a library for the Fan 9 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 Fan 9 Click driver.
Standard key functions :
fan9_cfg_setup
Config Object Initialization function.
void fan9_cfg_setup(fan9_cfg_t *cfg)
Fan 9 configuration object setup function.
Fan 9 Click configuration object.
Definition: fan9.h:241
fan9_init
Initialization function.
err_t fan9_init(fan9_t *ctx, fan9_cfg_t *cfg)
Fan 9 initialization function.
Fan 9 Click context object.
Definition: fan9.h:218
fan9_default_cfg
Click Default Configuration function.
err_t fan9_default_cfg(fan9_t *ctx)
Fan 9 default configuration function.
Example key functions :
fan9_set_direcrion
This function is used to set direction of Fan 9 click board.
void fan9_set_direcrion(fan9_t *ctx, uint8_t dir)
Fan 9 set direction function.
fan9_write_reg
This function reads a data bytes from the selected register by using I2C serial interface.
err_t fan9_write_reg(fan9_t *ctx, uint8_t reg, uint16_t data_in)
Fan 9 register writing function.
fan9_set_pwm
This function is used to get PWM value of Fan 9 click board.
err_t fan9_set_pwm(fan9_t *ctx, uint8_t pwm_val)
Fan 9 set PWM value function.
Example Description
This example demonstrates the use of FAN 9 click board.
The demo application is composed of two sections :
Application Init
Initializes the driver 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 ==
fan9_init( &fan9, &fan9_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ FAN9_ERROR
Definition: fan9.h:262
#define FAN9_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: fan9.h:202
uint8_t fan9_get_rd_pin(fan9_t *ctx)
Fan 9 get RD pin state function.
void application_init(void)
Definition: main.c:28
Application Task
Changes the speed of fans by changing the PWM duty cycle.
The results are being displayed via USB UART where you can track their changes.
{
uint8_t pwm_val = 0;
static int8_t duty_cnt = 10;
static int8_t duty_inc = 10;
log_printf( &logger, " Set PWM: %d%% \r\n", ( uint16_t ) pwm_val );
if ( 100 == duty_cnt )
{
duty_inc = -10;
}
else if ( 0 == duty_cnt )
{
duty_inc = 10;
}
duty_cnt += duty_inc;
Delay_ms( 2000 );
}
#define FAN9_DIRECTION_CW
Fan 9 direction setting.
Definition: fan9.h:162
err_t fan9_get_pwm(fan9_t *ctx, uint8_t *pwm_val)
Fan 9 get PWM value function.
void application_task(void)
Definition: main.c:69
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.Fan9
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.