选择我们的16合1按钮集成解决方案,最大化空间和功能,满足您的控制需求。
A
A
硬件概览
它是如何工作的?
4x4 Key Click基于16个带消抖电路的按钮和两个ON Semiconductor生产的MC74HC165A,8位并行输入/串行输出移位寄存器。键盘的最右侧一列标有A至D的字母,而其他12个按钮则标记得像电话键盘一样,因此很容易将这个4x4 Click板集成到任何设计中。16个按钮的输出线 直接连接到串联(串接)链中的两个移位寄存
器的并行数据输入,因此在主控MCU上占用的引脚更少。移位寄存器允许同时按下所有16个按钮,并且每个按钮都会被注册。4X4 Click板通过 mikroBUS™插座上的SPI串行接口与主控MCU通信。在这种情况下,SPI接口使用移位寄存器尽可能地节省MCU的IO引脚。移位寄存器的时 钟使能引脚不可用户配置,且被固定接
地,因此移位寄存器始终处于使能状态。这个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™ 原理图

一步一步来
项目组装
软件支持
库描述
这个库包含4x4 Key Click驱动程序的API。
关键功能:
c4x4key_get_data- 获取16位数据的函数。c4x4key_get_btn_position- 获取按下按钮位置的函数。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* \file
* \brief 4x4Key Click example
*
* # Description
* The library covers all the necessary functions to control the 4x4 Key Click.
* 4x4 Key Click communicates with the target board via SPI interface.
* This library contains drivers for reading data from a sensor and get
* the position of the pressed button.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Configuring Clicks and log objects.
*
* ## Application Task
* This is a example which demonstrates the use of 4x4 Key Click board.
* Detects and logs whether any of the buttons is pressed.
* Results are being sent to the Usart Terminal
* where you can track their changes.
* All data logs on usb uart when the button is triggered.
*
* \author Nenad Filipovic
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "c4x4key.h"
// ------------------------------------------------------------------ VARIABLES
static c4x4key_t c4x4key;
static log_t logger;
static uint16_t btn_data_old;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
c4x4key_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.
c4x4key_cfg_setup( &cfg );
C4X4KEY_MAP_MIKROBUS( cfg, MIKROBUS_1 );
c4x4key_init( &c4x4key, &cfg );
btn_data_old = 0;
log_printf( &logger, " 4x4 Key Click\r\n" );
log_printf( &logger, "--------------------\r\n" );
log_printf( &logger, " Press any button\r\n" );
log_printf( &logger, "--------------------\r\n" );
}
void application_task ( void )
{
uint16_t btn_data;
btn_data = c4x4key_get_data( &c4x4key );
if ( btn_data_old != btn_data )
{
if ( btn_data == C4X4KEY_BUTTON_0 )
{
log_printf( &logger, " 0\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_1 )
{
log_printf( &logger, " 1\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_2 )
{
log_printf( &logger, " 2\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_3 )
{
log_printf( &logger, " 3\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_4 )
{
log_printf( &logger, " 4\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_5 )
{
log_printf( &logger, " 5\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_6 )
{
log_printf( &logger, " 6\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_7 )
{
log_printf( &logger, " 7\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_8 )
{
log_printf( &logger, " 8\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_9 )
{
log_printf( &logger, " 9\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_A )
{
log_printf( &logger, " A\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_B )
{
log_printf( &logger, " B\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_C )
{
log_printf( &logger, " C\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_D )
{
log_printf( &logger, " D\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_STAR )
{
log_printf( &logger, " *\r\n" );
}
if ( btn_data == C4X4KEY_BUTTON_HASH )
{
log_printf( &logger, " #\r\n" );
}
btn_data_old = btn_data;
}
Delay_10ms();
}
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
额外支持
资源
类别:按钮/开关






























