mirror of
https://github.com/brmlab/edubrm.git
synced 2025-06-08 21:03:59 +02:00
firmware wip3
This commit is contained in:
parent
bd82084531
commit
e1cc9144ee
2 changed files with 24 additions and 21 deletions
|
@ -32,25 +32,27 @@ USB_DEV_INFO DeviceInfo;
|
||||||
HID_DEVICE_INFO HidDevInfo;
|
HID_DEVICE_INFO HidDevInfo;
|
||||||
ROM ** rom = (ROM **)0x1fff1ff8;
|
ROM ** rom = (ROM **)0x1fff1ff8;
|
||||||
|
|
||||||
/*
|
|
||||||
* Get HID Input Report -> InReport
|
|
||||||
*/
|
|
||||||
|
|
||||||
static uint8_t buffer[64];
|
/* --------------------------------------------------- */
|
||||||
|
|
||||||
|
#define INSIZE 8
|
||||||
|
#define OUTSIZE 2
|
||||||
|
|
||||||
void GetInReport (uint8_t src[], uint32_t length)
|
void GetInReport (uint8_t src[], uint32_t length)
|
||||||
{
|
{
|
||||||
memcpy(src, buffer, length);
|
int i;
|
||||||
|
for (i = 0; i < INSIZE; ++i) {
|
||||||
|
src[i] = 'A' + i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Set HID Output Report <- OutReport
|
|
||||||
*/
|
|
||||||
void SetOutReport (uint8_t dst[], uint32_t length)
|
void SetOutReport (uint8_t dst[], uint32_t length)
|
||||||
{
|
{
|
||||||
memcpy(buffer, dst, length);
|
// TODO: parse dst
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------- */
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
/* for delay loop */
|
/* for delay loop */
|
||||||
|
@ -66,8 +68,8 @@ int main (void)
|
||||||
HidDevInfo.idProduct = USB_PROD_ID;
|
HidDevInfo.idProduct = USB_PROD_ID;
|
||||||
HidDevInfo.bcdDevice = USB_DEVICE;
|
HidDevInfo.bcdDevice = USB_DEVICE;
|
||||||
HidDevInfo.StrDescPtr = (uint32_t)&USB_StringDescriptor[0];
|
HidDevInfo.StrDescPtr = (uint32_t)&USB_StringDescriptor[0];
|
||||||
HidDevInfo.InReportCount = 1;
|
HidDevInfo.InReportCount = INSIZE;
|
||||||
HidDevInfo.OutReportCount = 1;
|
HidDevInfo.OutReportCount = OUTSIZE;
|
||||||
HidDevInfo.SampleInterval = 0x20;
|
HidDevInfo.SampleInterval = 0x20;
|
||||||
HidDevInfo.InReport = GetInReport;
|
HidDevInfo.InReport = GetInReport;
|
||||||
HidDevInfo.OutReport = SetOutReport;
|
HidDevInfo.OutReport = SetOutReport;
|
||||||
|
|
|
@ -30,7 +30,8 @@ static const int PRODUCT_ID = 0x0003;
|
||||||
|
|
||||||
// Values for bmRequestType in the Setup transaction's Data packet.
|
// Values for bmRequestType in the Setup transaction's Data packet.
|
||||||
|
|
||||||
static const int INTERRUPT_ENDPOINT_PACKET_SIZE = 16;
|
static const int INSIZE = 8;
|
||||||
|
static const int OUTSIZE = 2;
|
||||||
static const int INTERFACE_NUMBER = 0;
|
static const int INTERFACE_NUMBER = 0;
|
||||||
|
|
||||||
// Uses interrupt endpoint 1 IN and OUT:
|
// Uses interrupt endpoint 1 IN and OUT:
|
||||||
|
@ -108,16 +109,16 @@ int main(void)
|
||||||
int exchange_input_and_output_reports_via_interrupt_transfers(libusb_device_handle *devh)
|
int exchange_input_and_output_reports_via_interrupt_transfers(libusb_device_handle *devh)
|
||||||
{
|
{
|
||||||
int bytes_transferred;
|
int bytes_transferred;
|
||||||
unsigned char data_in[INTERRUPT_ENDPOINT_PACKET_SIZE-1];
|
unsigned char data_in[INSIZE-1];
|
||||||
unsigned char data_out[INTERRUPT_ENDPOINT_PACKET_SIZE-1];
|
unsigned char data_out[OUTSIZE-1];
|
||||||
int i = 0;;
|
int i = 0;;
|
||||||
int result = 0;;
|
int result = 0;;
|
||||||
|
|
||||||
// Store data in the output buffer for sending.
|
// Store data in the output buffer for sending.
|
||||||
|
|
||||||
for (i=0;i<INTERRUPT_ENDPOINT_PACKET_SIZE; i++)
|
for (i=0;i<OUTSIZE; i++)
|
||||||
{
|
{
|
||||||
data_out[i]=0x40+i;
|
data_out[i] = 0x40+i;
|
||||||
}
|
}
|
||||||
// Write an Output report to the device.
|
// Write an Output report to the device.
|
||||||
|
|
||||||
|
@ -125,14 +126,14 @@ int exchange_input_and_output_reports_via_interrupt_transfers(libusb_device_hand
|
||||||
devh,
|
devh,
|
||||||
INTERRUPT_OUT_ENDPOINT,
|
INTERRUPT_OUT_ENDPOINT,
|
||||||
data_out,
|
data_out,
|
||||||
INTERRUPT_ENDPOINT_PACKET_SIZE,
|
OUTSIZE,
|
||||||
&bytes_transferred,
|
&bytes_transferred,
|
||||||
TIMEOUT_MS);
|
TIMEOUT_MS);
|
||||||
|
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
{
|
{
|
||||||
printf("Output report data sent via interrupt transfer:\n");
|
printf("Output report data sent via interrupt transfer:\n");
|
||||||
for(i = 0; i < INTERRUPT_ENDPOINT_PACKET_SIZE; i++)
|
for(i = 0; i < OUTSIZE; i++)
|
||||||
{
|
{
|
||||||
printf("%02x ",data_out[i]);
|
printf("%02x ",data_out[i]);
|
||||||
}
|
}
|
||||||
|
@ -144,16 +145,16 @@ int exchange_input_and_output_reports_via_interrupt_transfers(libusb_device_hand
|
||||||
devh,
|
devh,
|
||||||
INTERRUPT_IN_ENDPOINT,
|
INTERRUPT_IN_ENDPOINT,
|
||||||
data_in,
|
data_in,
|
||||||
INTERRUPT_ENDPOINT_PACKET_SIZE,
|
INSIZE,
|
||||||
&bytes_transferred,
|
&bytes_transferred,
|
||||||
TIMEOUT_MS);
|
TIMEOUT_MS);
|
||||||
|
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
{
|
{
|
||||||
if (bytes_transferred == INTERRUPT_ENDPOINT_PACKET_SIZE)
|
if (bytes_transferred == INSIZE)
|
||||||
{
|
{
|
||||||
printf("Input report received via interrupt transfer:\n");
|
printf("Input report received via interrupt transfer:\n");
|
||||||
for(i = 0; i < INTERRUPT_ENDPOINT_PACKET_SIZE; i++)
|
for(i = 0; i < INSIZE; i++)
|
||||||
{
|
{
|
||||||
printf("%02x ",data_in[i]);
|
printf("%02x ",data_in[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue