You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Copyright (c) 2014-2015 NicoHood See the readme for credit to other people. Advanced RawHID example Shows how to send bytes via RawHID. Press a button to send some example values. Every received data is mirrored to the host via Serial. See HID Project documentation for more information. https://github.com/NicoHood/HID/wiki/RawHID-API*/
#include"HID-Project.h"constint pinLed = LED_BUILTIN;
// Buffer to hold RawHID data.// If host tries to send more data than this,// it will respond with an error.// If the data is not read until the host sends the next data// it will also respond with an error and the data will be lost.uint8_t rawhidData[64];
constlong FOSC = 16000000L; // Clock Speedconstint BAUD = 9600;
constint MYUBRR = (FOSC / 16 / BAUD - 1);
voidUSART_Init( )
{
/*Set baud rate */
UBRR1H = (unsignedchar)(MYUBRR >> 8);
UBRR1L = (unsignedchar)MYUBRR;
UCSR1B |= (1 << RXEN1) | (1 << TXEN1); // Turn on the transmission and reception circuitry
}
voidUSART_Transmit( unsignedchar data ) {
/* Wait for empty transmit buffer */while ( !( UCSR1A & (1 << UDRE1)) )
{
;
}
/* Put data into buffer, sends the data */
UDR1 = data;
}
charUSART_Receive( void )
{
/* Wait for data to be received */while ( !(UCSR1A & (1 << RXC1)) )
;
/* Get and return received data from buffer */return UDR1;
}
voidsetup() {
pinMode(pinLed, OUTPUT);
USART_Init();
// Set the RawHID OUT report array.// Feature reports are also (parallel) possible, see the other example for this.
RawHID.begin(rawhidData, sizeof(rawhidData));
}
uint8_t i = 0;
uint8_t megabuff[sizeof(rawhidData)];
voidloop() {
digitalWrite(pinLed, HIGH);
// Create buffer with numbers and send itif ( UCSR1A & (1 << RXC1))
megabuff[i++] = UDR1;// Serial1.read();if (i == sizeof(megabuff))
{
RawHID.write(megabuff, sizeof(megabuff));
i = 0;
// delay(300);
}
// Simple debouncedigitalWrite(pinLed, LOW);
}
The text was updated successfully, but these errors were encountered:
Nico, great thank for your job ! Its very usefully. I can't make combination RAW HID + Serial1 for link Uno with PC by HID instead Serial. If remove Serial1 from sketch and replace by UART then work..
The text was updated successfully, but these errors were encountered: