This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF24LU1+ HID programming descriptor question.

HI

I'm studying how to control mouse and keyboard via HID with nRF24LU1+ module referring to firmware of nAN-22.

Even though I set Descriptor as appropriate for mouse and send dates to USB, it has no response. I have no idea why..

To send dates, I used this function : “hal_usb_send_data(uint8_t ep_num, uint8_t* array, uint8_t count)” which is a code of nAN-22. Is it correct function to send packet?

void hal_usb_send_data(uint8_t ep_num, uint8_t* array, uint8_t count)
{
 uint8_t i;
 
 uint8_t xdata *buf_ptr;
 uint8_t xdata *bc_ptr;
 
 // Calculate the buffer pointer and byte count pointer
 buf_ptr = CALCULATE_BUF_IN_PTR(ep_num);
 bc_ptr = CALCULATE_BC_IN_PTR(ep_num);
 
 // Copy the data into the USB controller
 for( i = 0; i < count; i++ )
 {
   buf_ptr[i] = array[i];
 }
 
 // Set the number of bytes we want to send to USB-host. This also trigger sending of data to USB-host.
 *bc_ptr = count;
}

If that function is correct, how much total bytes of data are required for controlling mouse movement and button click? ( Report ID is defined as 1)

Parents
  • It depends on your mouse descriptor how many bytes of data you need to send mouse inputs. A simple mouse is 3-4 bytes + report id.

  • 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x02, // USAGE (mouse) 0xa1, 0x01, // COLLECTION (Application)

      0x09, 0x01,    // USAGE (Pointer) 
    	0xa1, 0x00,    // COLLECTION (physical)
    
    	0x95, 0x03,    // Report_count(3)
    	0x75, 0x01,    // Report_Size(1)
    	0x05, 0x09,    // USAGE_PAGE (button)
    	0x19, 0x01,	   // Usage_MINIMUM (Button 1)
      0x29, 0x03,    // Usage_MAXIMUM (Button 3)
    	0x15, 0x00,	   // LOGICAL_MINIMUM (0)
    	0x25, 0x01,    // LOGICAL_MAXIMUM (1)
    	0x81, 0x02,    // INPUT (Data,Var,Abs) 
    	
    	0x95, 0x01,    // Report_count(1)
    	0x75, 0x05,    // Report_Size(5)
    	0x81, 0x01,    // INPUT (Data,Var,Abs) 
    	
    	0x75, 0x08,    //   REPORT_SIZE (8 bit)
      0x95, 0x03,    //   REPORT_COUNT (EP1_2_PACKET_SIZE) pre EP1_2_PACKET_SIZE
    	0x05, 0x01,    // USAGE_PAGE (Generic Desktop)
    	0x09, 0x30,    // USAGE (X)
    	0x09, 0x31,    // USAGE (Y)
    	0x09, 0x38,    // USAGE (Wheel)
    	0x15, 0x81,	   //   LOGICAL_MINIMUM (-127)
    	0x25, 0x7F,    //   LOGICAL_MAXIMUM (127)
      0x81, 0x06,    //   INPUT (Data,Var,Abs)  
    
      0xc0,             // END_COLLECTION
    	0xc0
    

    Report descriptor mouse setting. I don't know report ID set.

Reply
  • 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x02, // USAGE (mouse) 0xa1, 0x01, // COLLECTION (Application)

      0x09, 0x01,    // USAGE (Pointer) 
    	0xa1, 0x00,    // COLLECTION (physical)
    
    	0x95, 0x03,    // Report_count(3)
    	0x75, 0x01,    // Report_Size(1)
    	0x05, 0x09,    // USAGE_PAGE (button)
    	0x19, 0x01,	   // Usage_MINIMUM (Button 1)
      0x29, 0x03,    // Usage_MAXIMUM (Button 3)
    	0x15, 0x00,	   // LOGICAL_MINIMUM (0)
    	0x25, 0x01,    // LOGICAL_MAXIMUM (1)
    	0x81, 0x02,    // INPUT (Data,Var,Abs) 
    	
    	0x95, 0x01,    // Report_count(1)
    	0x75, 0x05,    // Report_Size(5)
    	0x81, 0x01,    // INPUT (Data,Var,Abs) 
    	
    	0x75, 0x08,    //   REPORT_SIZE (8 bit)
      0x95, 0x03,    //   REPORT_COUNT (EP1_2_PACKET_SIZE) pre EP1_2_PACKET_SIZE
    	0x05, 0x01,    // USAGE_PAGE (Generic Desktop)
    	0x09, 0x30,    // USAGE (X)
    	0x09, 0x31,    // USAGE (Y)
    	0x09, 0x38,    // USAGE (Wheel)
    	0x15, 0x81,	   //   LOGICAL_MINIMUM (-127)
    	0x25, 0x7F,    //   LOGICAL_MAXIMUM (127)
      0x81, 0x06,    //   INPUT (Data,Var,Abs)  
    
      0xc0,             // END_COLLECTION
    	0xc0
    

    Report descriptor mouse setting. I don't know report ID set.

Children
No Data
Related