rfswitch 2.2.0
Loading...
Searching...
No Matches
rfswitch


RF Switch Click

RF Switch 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 : Sep 2021.
  • Type : GPIO type

Software Support

Example Description

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

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.RFSwitch

Example Key Functions

Application Init

Initialization driver enable's - GPIO, also write log and powers on device.

void application_init ( void )
{
log_cfg_t log_cfg;
rfswitch_cfg_t rfswitch_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
rfswitch_cfg_setup( &rfswitch_cfg );
RFSWITCH_MAP_MIKROBUS( rfswitch_cfg, MIKROBUS_1 );
if ( DIGITAL_OUT_UNSUPPORTED_PIN == rfswitch_init( &rfswitch, &rfswitch_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, "------------------------\r\n" );
log_printf( &logger, " Powering device on \r\n" );
rfswitch_power_on( &rfswitch );
Delay_ms ( 100 );
log_printf( &logger, "------------------------\r\n" );
log_printf( &logger, " Select option to \r\n" );
log_printf( &logger, " select channel \r\n" );
log_printf( &logger, "------------------------\r\n" );
log_printf( &logger, " 1. Channel 1 selected \r\n" );
log_printf( &logger, " 2. Channel 2 selected \r\n" );
log_printf( &logger, " 3. Switching channel \r\n" );
log_printf( &logger, "------------------------\r\n" );
}
#define RFSWITCH_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition rfswitch.h:95
void application_init(void)
Definition main.c:28

Application Task

Waiting for valid user input and executes functions based on set of valid commands. Results are being sent to the Usart Terminal where you can track their changes.

void application_task ( void )
{
uint8_t tx_buf;
if ( log_read( &logger, &tx_buf, 1 ) ) {
switch ( tx_buf ) {
case '1' : {
log_printf( &logger, " Switching to RF port 1 \r\n" );
log_printf( &logger, "------------------------\r\n" );
break;
}
case '2' : {
log_printf( &logger, " Switching to RF port 2 \r\n" );
log_printf( &logger, "------------------------\r\n" );
break;
}
case '3' : {
log_printf( &logger, " Switching RF port \r\n" );
log_printf( &logger, "------------------------\r\n" );
break;
}
default : {
log_printf( &logger, " Select option to \r\n" );
log_printf( &logger, " select channel \r\n" );
log_printf( &logger, "------------------------\r\n" );
log_printf( &logger, " 1. Channel 1 selected \r\n" );
log_printf( &logger, " 2. Channel 2 selected \r\n" );
log_printf( &logger, " 3. Switching channel \r\n" );
log_printf( &logger, "------------------------\r\n" );
}
}
}
}
#define RFSWITCH_SELECT_CHANNEL_2
Definition rfswitch.h:77
#define RFSWITCH_SELECT_CHANNEL_1
Definition rfswitch.h:76
void application_task(void)
Definition main.c:68

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.