毫不费力地将传感器、驱动程序和其他组件集成到您的项目设置中。
A
A
硬件概览
它是如何工作的?
Adapter Click是一个适配器板,简化了将具有IDC10头部的附加组件连接到mikroBUS™插座的过程。一个2x5位置、2.54mm间距的连接器头部允许您以符合项目需求的方式添加传感器、驱动程序和各种组件。每个头部引脚对应于mikroBUS™插座上的一个引脚(除了AN和RST引脚)。多亏了这些引脚,与Click板™的连接始终牢固稳定,始终保持完美的连接质量。建立 这种连接有两种方式:男性或女性IDC10连接器。两
者都包含在包装中。您可以将男性IDC10连接器焊接在Adapter Click的顶部,并直接连接附加板或通过IDC10平线电缆连接。在某些情况下,女性头部插座可能是更好的选择。根据实际情况的方便程度,将其焊接在顶部或底部。Adapter Click允许使用I2C和SPI接口,其中每个mikroBUS™线都覆盖,除了如前所述 的AN和RST线。可以通过将标记为INTERFACE SELECTION的跳线放置在标记为SPI或I2C的适当位
置来进行选择。请注意,所有跳线的位置必须在同一侧,否则Click板™可能会失去响应。这个Click板™可以通过PWR SEL跳线选择3.3V和5V逻辑电压电平。这样,既支持3.3V又支持5V的MCU可以正确地使用通信线路。此外,这个Click板™配备了一个包含易于使用的函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
32L496GDISCOVERY Discovery 套件是一款功能全面的演示和开发平台,专为搭载 Arm® Cortex®-M4 内核的 STM32L496AG 微控制器设计。该套件适用于需要在高性能、先进图形处理和超低功耗之间取得平衡的应用,支持无缝原型开发,适用于各种嵌入式解决方案。STM32L496AG 采用创新的节能架构,集成
了扩展 RAM 和 Chrom-ART 图形加速器,在提升图形性能的同时保持低功耗,使其特别适用于音频处理、图形用户界面和实时数据采集等对能效要求较高的应用。为了简化开发流程,该开发板配备了板载 ST-LINK/V2-1 调试器/编程器,提供即插即用的调试和编程体验,使用户无需额外硬件即可轻松加载、调
试和测试应用程序。凭借低功耗特性、增强的内存能力以及内置调试工具,32L496GDISCOVERY 套件是开发先进嵌入式系统、实现高效能解决方案的理想选择。
微控制器概述
MCU卡片 / MCU

建筑
ARM Cortex-M4
MCU 内存 (KB)
1024
硅供应商
STMicroelectronics
引脚数
169
RAM (字节)
327680
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
软件支持
库描述
这个库包含Adapter Click驱动程序的API。
关键功能:
adapter_generic_write- 将数据写入到指定的寄存器。adapter_generic_read- 从指定的寄存器读取数据。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* \file
* \brief Adapter Click example
*
* # Description
* Adapter Click is a breakout board which simplifies connection of add-on boards.
* There are two ways of establishing connection: using male or female IDC10 connectors.
* Male header must be soldered on the top side of Adapter Click to connect the add-on board
* directly or via flat cable. Female header can be soldered either on the top, or the bottom
* side, depending on which one is more convenient in given circumstances.
* There are two jumpers for SPI/I2C selection and one for selection of power supply range.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initalizes I2C or SPI driver and makes an initial log.
*
* ## Application Task
* This is an example that shows the use of the Adapter Click board (SPI mode - set as default).
* In I2C mode we are reading internal temperature from another device (THERMO 5 Click board).
* In SPI mode example we are writing "mikroElektronika" to SRAM Click board,
* and then reading from the same memory location.
*
* ## Additional Functions
* - float thermo5_read_inter_temp ( adapter_t *ctx ) -
* @description Function reads measurements made by internal diode.
* - void sram_write_byte ( adapter_t *ctx, uint32_t reg_address, uint8_t write_data ) -
* @description Function writes the 8-bit data to the target 24-bit register address of 23LC1024 chip.
* - uint8_t sram_read_byte ( adapter_t *ctx, uint32_t reg_address ) -
* @description Function reads the 8-bit data to the target 24-bit register address of 23LC1024 chip.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "adapter.h"
#define THERMO5_INTER_DIO_DATA_HI_BYTE 0x00
#define THERMO5_INTER_DIO_DATA_LO_BYTE 0x29
#define SRAM_24BIT_DATA 0x00FFFFFF
#define SRAM_CMD_WRITE 0x02
#define SRAM_CMD_READ 0x03
// ------------------------------------------------------------------ VARIABLES
static adapter_t adapter;
static log_t logger;
char send_buffer[ 17 ] = { 'm', 'i', 'k', 'r', 'o', 'E', 'l', 'e', 'k', 't', 'r', 'o', 'n', 'i', 'k', 'a', ' ' };
char mem_data[ 17 ];
uint8_t n_cnt;
// ------------------------------------------------------ ADDITIONAL FUNCTIONS
float thermo5_read_inter_temp ( adapter_t *ctx )
{
uint16_t inter_temp;
uint8_t high_byte;
uint8_t low_byte;
float output;
output = 0.0;
adapter_generic_read ( ctx, THERMO5_INTER_DIO_DATA_HI_BYTE, &high_byte, 1 );
adapter_generic_read ( ctx, THERMO5_INTER_DIO_DATA_LO_BYTE, &low_byte, 1 );
inter_temp = high_byte;
inter_temp <<= 8;
inter_temp |= low_byte;
inter_temp >>= 5;
output = ( float )inter_temp;
output *= 0.125;
return output;
}
void sram_write_byte ( adapter_t *ctx, uint32_t reg_address, uint8_t write_data )
{
uint8_t tx_buf[ 4 ];
uint8_t rx_buf;
reg_address &= SRAM_24BIT_DATA;
tx_buf[ 0 ] = ( uint8_t ) ( reg_address >> 16 );
tx_buf[ 1 ] = ( uint8_t ) ( reg_address >> 8 );
tx_buf[ 2 ] = ( uint8_t ) reg_address;
tx_buf[ 3 ] = write_data;
adapter_generic_write( ctx, SRAM_CMD_WRITE, tx_buf, 4 );
}
uint8_t sram_read_byte ( adapter_t *ctx, uint32_t reg_address )
{
uint8_t tx_buf[ 5 ];
uint8_t rx_buf[ 5 ];
uint8_t read_data;
reg_address &= SRAM_24BIT_DATA;
tx_buf[ 0 ] = SRAM_CMD_READ;
tx_buf[ 1 ] = ( uint8_t ) ( reg_address >> 16 );
tx_buf[ 2 ] = ( uint8_t ) ( reg_address >> 8 );
tx_buf[ 3 ] = ( uint8_t ) reg_address;
adapter_generic_transfer( ctx, tx_buf, 4, rx_buf, 1 );
read_data = rx_buf[ 0 ];
return read_data;
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
adapter_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
adapter_cfg_setup( &cfg );
ADAPTER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
adapter_init( &adapter, &cfg );
}
void application_task ( void )
{
float temp_value;
if ( adapter.master_sel == ADAPTER_MASTER_SPI )
{
log_printf( &logger, " Writing text :\r\n" );
for ( n_cnt = 0; n_cnt < 16; n_cnt++ )
{
sram_write_byte( &adapter, n_cnt, send_buffer[ n_cnt ] );
Delay_ms ( 100 );
log_printf( &logger, "%c", send_buffer[ n_cnt ] );
}
log_printf( &logger, "\r\n" );
log_printf( &logger, " Read text :\r\n" );
for ( n_cnt = 0; n_cnt < 16; n_cnt++ )
{
mem_data[ n_cnt ] = sram_read_byte( &adapter, n_cnt );
Delay_ms ( 100 );
log_printf( &logger, "%c", mem_data[ n_cnt ] );
}
log_printf( &logger, "\r\n" );
log_printf( &logger, "--------------------------\r\n" );
Delay_ms ( 1000 );
}
else if ( adapter.master_sel == ADAPTER_MASTER_I2C )
{
temp_value = thermo5_read_inter_temp( &adapter );
log_printf( &logger, " Thermo 5 internal temperature : %.2f\r\n", temp_value );
log_printf( &logger, "--------------------------\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
额外支持
资源
类别:适配器































