⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hid_keyboard.h

📁 蓝牙hid_keyboard的例程
💻 H
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2005-2006
Part of BlueLab 3.5.2-release

FILE NAME
    hid_keyboard.h 
DESCRIPTION
    
*/

#ifndef _HID_KEYBOARD_H_
#define _HID_KEYBOARD_H_

/****************************************************************************
    Header files
*/
#include <hid.h>
#include <connection.h>
#include <message.h>
#include <stream.h>
#include <bdaddr.h>
#include <stdio.h>
#include <source.h>
#include <stdlib.h>
#include <pio.h>
#include <app/vm/vm_if.h>

#include "hid_keyboard_led.h"
#include "hid_keyboard_button.h"

#ifdef APP_DEBUG
#define MAIN_PRINT(x) printf x
#else
#define MAIN_PRINT(x)
#endif

#ifdef HW_CASIRA_UART

/* Defines which PIOs are used for status LEDs */
#define LED_PIO_NUM_LOCK     (2)
#define LED_PIO_CAPS_LOCK    (3)
#define LED_PIO_SCROLL_LOCK  (7)
#define LED_MASK_NUM_LOCK    (1 << LED_PIO_NUM_LOCK)
#define LED_MASK_CAPS_LOCK   (1 << LED_PIO_CAPS_LOCK)
#define LED_MASK_SCROLL_LOCK (1 << LED_PIO_SCROLL_LOCK)

/* PIO to control idle mode (Must match PSKEY_HIDIO_UART) */
#define HID_PIO_IDLE_MODE    (6)
#define HID_MASK_IDLE_MODE   (1 << HID_PIO_IDLE_MODE)

#endif

#ifdef HW_DEV_1163A

/* Defines which PIOs are used for status LEDs */
#define LED_PIO_CAPS_LOCK    (10)
#define LED_PIO_SCROLL_LOCK  (13)
#define LED_MASK_NUM_LOCK    (0)	/* Aux DAC */
#define LED_MASK_CAPS_LOCK   (1 << LED_PIO_CAPS_LOCK)
#define LED_MASK_SCROLL_LOCK (1 << LED_PIO_SCROLL_LOCK)

/* Use Aux DAC for status LED */
#define LED_AUX_DAC

/* PIO to control idle mode (Not used) */
#define HID_MASK_IDLE_MODE   (0)

#endif

/* Persistent store base for device attributes */
#define APP_KEYBOARD_ATTR_PS_BASE    (0)

/* Internal messages */
enum
{
    APP_INTERNAL_PIN_CODE_TIMEOUT_IND = 100,
    APP_INTERNAL_IDLE_TIMEOUT_IND,
    APP_INTERNAL_UNPLUG_TIMEOUT_IND,
    APP_INTERNAL_DISCOVERABLE_TIMEOUT_IND
};

/* Inactivity timeout */
#define APP_IDLE_TIMEOUT            (1200)

/* Virtual unplug timeout */
#define APP_UNPLUG_TIMEOUT          (5)

/* Pin code timeout */
#define APP_PIN_CODE_TIMEOUT        (30)

/* Discoverable timeout */
#define APP_DISCOVERABLE_TIMEOUT    (600)

/* Application states */
typedef enum
{
	appInitialising,
    appDiscoverable,
    appDiscoverableConnecting,
	appDiscoverableConnected,
    appCabledConnecting,
    appCabledConnected,
    appCabledDisconnecting,
    appCabledDisconnected,
    appIdle
} app_state;

/* Authentication states */
typedef enum
{
    appAuthIdle,
    appAuthPinCode,
    appAuthTrusted
} app_auth_state;

/* Application task data */
typedef struct 
{
	TaskData			task;
	HID_LIB            *hid_lib;
	HID                *hid;    
    
    unsigned int        trusted_device_index:4;    
    unsigned int        unplug_pending:1;

	app_state			state;
    app_auth_state      auth_state;
    
    appLedTaskData      led;
    PioState            pioState;
    unsigned int        keyboard_led_state:3;
    unsigned int        keyboard_idle_rate:8;
	uint8				aux_keys_state;
    hid_protocol        keyboard_protocol;
    
    hid_pin             hid_pin;
    
    bdaddr              host_bd_addr;
    bdaddr              auth_bd_addr;
    
    Sink                interrupt_sink;
} appTaskData;

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -