/**
 * \file firmware/modelinterface.h
 * \brief Interface for hardware specific functions
 * \author Ronald Schaten <ronald@schatenseite.de>
 * \version $Id$
 *
 * License: GNU GPL v2 (see License.txt)
 */

#include <stdint.h>

/**
 * Initialize hardware. Configure ports as inputs and outputs, set USB reset
 * condition, start timer and blink LEDs.
 */
void hardwareInit(void);

/**
 * Print the current state of the keyboard in a readable form. This function
 * is used for debug-purposes only.
 */
void printMatrix(void);

/**
 * Toggle-function is called as a command, doesn't have to be implemented.
 */
void toggle(void);

/**
 * This tells the current writing speed to the keyboard, for whatever it will
 * do with the value.
 * \param speed speed value between 0 and 255
 */
void setSpeed(uint8_t speed);

/**
 * This function sets the LEDs according to the given data.
 * \param LEDstate bitfield with LED info
 */
void setLeds(uint8_t LEDstate);

/**
 * Scan and debounce keypresses. This is the main worker function for normal
 * keyboard operation, the code contains lot of comments. Basically, it first
 * scans the keyboard state. If a change is detected, it initializes a counter
 * that is decreased each time this function is called. If the counter reaches
 * 1, that means that the same scan result has been scanned ten times in a row,
 * so we can be pretty sure that the keys are in a certain state (as in: not
 * bouncing). Then, the codes for keys and modifiers are searched from the two
 * arrays, the USB-message to send the state is prepared. The return value of
 * this function indicates if the message has to be sent.
 * \param reportBuffer array with the current USB report
 * \param oldReportBuffer array with the last USB report
 * \return flag to indicate whether something has changed
 */
uint8_t scankeys(uint8_t* reportBuffer, uint8_t* oldReportBuffer, uint8_t sizeOfReportBuffer);
