SAMV71 Xplained Ultra Software Package 1.3

HIDDKeyboardDriver.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2014, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /**
00031  * \file
00032  * 
00033  * \section Purpose
00034  * 
00035  * Definition of methods for using a HID keyboard device driver.
00036  * 
00037  * \section Usage
00038  * 
00039  * -# Re-implement the USBDCallbacks_RequestReceived callback to forward
00040  *    requests to HIDDKeyboardDriver_RequestHandler. This is done
00041  *    automatically unless the NOAUTOCALLBACK symbol is defined during
00042  *    compilation.
00043  * -# Initialize the driver using HIDDKeyboardDriver_Initialize. The
00044  *    USB driver is automatically initialized by this method.
00045  * -# Call the HIDDKeyboardDriver_ChangeKeys method when one or more
00046  *    keys are pressed/released.
00047  */
00048 
00049 #ifndef HIDDKEYBOARDDRIVER_H
00050 #define HIDDKEYBOARDDRIVER_H
00051 
00052 /** \addtogroup usbd_hid_key
00053  *@{
00054  */
00055 
00056 /*------------------------------------------------------------------------------
00057  *         Headers
00058  *------------------------------------------------------------------------------*/
00059 
00060 #include <USBDescriptors.h>
00061 #include <USBRequests.h>
00062 
00063 #include <HIDDescriptors.h>
00064 
00065 #include <HIDDKeyboard.h>
00066 
00067 #include <USBDDriver.h>
00068 
00069 /*------------------------------------------------------------------------------
00070  *         Definitions
00071  *------------------------------------------------------------------------------*/
00072 
00073 /*------------------------------------------------------------------------------
00074  *         Types
00075  *------------------------------------------------------------------------------*/
00076 
00077 /*------------------------------------------------------------------------------
00078  *         Exported functions
00079  *------------------------------------------------------------------------------*/
00080 
00081 extern void HIDDKeyboardDriver_Initialize(
00082     const USBDDriverDescriptors *pDescriptors);
00083 
00084 extern void HIDDKeyboardDriver_ConfigurationChangedHandler(
00085     uint8_t cfgnum);
00086 
00087 extern void HIDDKeyboardDriver_RequestHandler(
00088     const USBGenericRequest *request);
00089 
00090 /**
00091  * Reports a change in which keys are currently pressed or release to the
00092  * host.
00093  *
00094  * \param pressedKeys Pointer to an array of key codes indicating keys that have
00095  *                    been pressed since the last call to
00096  *                    HIDDKeyboardDriver_ChangeKeys().
00097  * \param pressedKeysSize Number of key codes in the pressedKeys array.
00098  * \param releasedKeys Pointer to an array of key codes indicates keys that have
00099  *                     been released since the last call to
00100  *                     HIDDKeyboardDriver_ChangeKeys().
00101  * \param releasedKeysSize Number of key codes in the releasedKeys array.
00102  * \return USBD_STATUS_SUCCESS if the report has been sent to the host;
00103  *        otherwise an error code.
00104  */
00105 static inline uint32_t HIDDKeyboardDriver_ChangeKeys(
00106     uint8_t *pressedKeys,
00107     uint8_t pressedKeysSize,
00108     uint8_t *releasedKeys,
00109     uint8_t releasedKeysSize){
00110     return HIDDKeyboard_ChangeKeys(pressedKeys, pressedKeysSize,
00111                                    releasedKeys, releasedKeysSize);
00112 }
00113 
00114 /**
00115  * Starts a remote wake-up sequence if the host has explicitly enabled it
00116  * by sending the appropriate SET_FEATURE request.
00117  */
00118 static inline void HIDDKeyboardDriver_RemoteWakeUp(void) {
00119     HIDDKeyboard_RemoteWakeUp();
00120 }
00121 
00122 /**@}*/
00123 
00124 #endif /*#ifndef HIDDKEYBOARDDRIVER_H*/
00125 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines