Spectral Click
Spectral 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 : MikroE Team
- Date : Mar 2020.
- Type : UART type
Software Support
Example Description
This example reads and processes data from Spectral Clicks.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Spectral
Example Key Functions
- spectral_cfg_setup Config Object Initialization function.
void spectral_cfg_setup(spectral_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition spectral.h:118
- spectral_init Initialization function.
err_t spectral_init(spectral_t *ctx, spectral_cfg_t *cfg)
Initialization function.
Click ctx object definition.
Definition spectral.h:99
- spectral_uart_read Generic read function.
int32_t spectral_uart_read(spectral_t *ctx, uint8_t *data_buf, uint16_t max_len)
Generic read function.
- spectral_send_command Send Command
void spectral_send_command(spectral_t *ctx, uint8_t *command)
Send Command.
- spectral_get_data Read raw X, Y, Z and NIR data as well as two special internal registers D, & C.
void spectral_get_data(uint8_t *rsp, uint16_t *c_data)
Read raw X, Y, Z and NIR data as well as two special internal registers D, & C.
Application Init
Initializes the driver and configures the sensor.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
Delay_ms ( 500 );
log_printf( &logger, "Configuring the sensor...\r\n" );
log_printf( &logger, "The sensor has been configured!\r\n" );
Delay_ms ( 1000 );
}
#define SPECTRAL_MAP_MIKROBUS(cfg, mikrobus)
Definition spectral.h:66
void spectral_module_reset(spectral_t *ctx)
Reset module.
void application_init(void)
Definition main.c:113
#define SPECTRAL_CMD_GAIN
Definition main.c:35
#define SPECTRAL_CMD_AT
Definition main.c:34
void spectral_process(void)
Definition main.c:47
#define SPECTRAL_CMD_MODE
Definition main.c:36
Application Task
Reads the values of all 6 channels and parses it to the USB UART each second.
{
}
void parser_application()
Definition main.c:94
void application_task(void)
Definition main.c:150
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.