cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-F429ZI -- Cannot get a USB HID device to send keystrokes to the system

CatChips
Associate

Hi Everyone!

I am pretty new to the community and STM32.  I have been trying to set up the Nucleo F429ZI board to act like a an HID keyboard and send keystrokes.  I have initialized the USB_OTG_FS to Device Only, USB_DEVICE to HID, and as far as I can tell configured the clock correctly.  My board is connected to the PC's USB port via the same port as the port I use for flashing the board.

As far as I can tell, nothing is conflict with the documentation at https://www.st.com/en/evaluation-tools/nucleo-f429zi.html

I tried multiple tutorials, with the latest one being: https://www.youtube.com/watch?v=tj1_hsQ5PR0

adjusting to my board and make as necessary.

However, the system does not seem to detect the device as a keyboard nor are the keystrokes received.  Attached is my project.

This is part of the code I use to send the reports.  Any guidance is much appreciated.

extern USBD_HandleTypeDef hUsbDeviceFS;

typedef struct
{
	uint8_t MODIFIER;
	uint8_t RESERVED;
	uint8_t KEYCODE1;
	uint8_t KEYCODE2;
	uint8_t KEYCODE3;
	uint8_t KEYCODE4;
	uint8_t KEYCODE6;
} keyboardHID;

keyboardHID keyboardhid = {0,0,0,0,0,0,0,0};

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USB_DEVICE_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
	  keyboardhid.KEYCODE1 = 0x04;
	  USBD_HID_SendReport(&hUsbDeviceFS, &keyboardhid, sizeof(keyboardhid));
	  HAL_Delay(50);
	  keyboardhid.KEYCODE1 = 0x00;
	  USBD_HID_SendReport(&hUsbDeviceFS, &keyboardhid, sizeof(keyboardhid));
	  HAL_Delay(1000);

  }
  /* USER CODE END 3 */
}

 

0 REPLIES 0