Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDC_ACM + Hid keyboard issue #21

Open
nckpln opened this issue Oct 8, 2022 · 2 comments
Open

CDC_ACM + Hid keyboard issue #21

nckpln opened this issue Oct 8, 2022 · 2 comments

Comments

@nckpln
Copy link

nckpln commented Oct 8, 2022

My setup:
MCU stm32f103c8
CubeMX v.6.3.0
AL94.I-CUBE-USBD-COMPOSITE v.1.0.3

app.c

#include "main.h"
#include "usbd_def.h"

extern USBD_HandleTypeDef hUsbDevice;



uint8_t kbdPress[8] = {0,0,4,0,0,0,0,0};
uint8_t kbdRelease[8] = {0,0,0,0,0,0,0,0};


#define LED_ON() LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin)
#define LED_OFF() LL_GPIO_SetOutputPin(LED_GPIO_Port, LED_Pin)
#define LED_TOGGLE() LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin)
#define GET_PTT() LL_GPIO_IsInputPinSet(PTT_GPIO_Port, PTT_Pin)



void print(char *str)
{
    uint16_t c = 0;
    while (str[c] != '\0')
        c++;
    CDC_Transmit(0, (uint8_t *) str, c);
}


void KeyDown(void)
{

    uint8_t res = USBD_HID_Keybaord_SendReport(&hUsbDevice, kbdPress, 8);
    if(res)
        print("KEY DOWN FAIL\r\n");
    else
        print("KEY DOWN OK\r\n");        
}

void KeyUp(void)
{
    uint8_t res = USBD_HID_Keybaord_SendReport(&hUsbDevice, kbdRelease, 8);
    if(res)
        print("KEY UP FAIL\r\n");
    else
        print("KEY UP OK\r\n"); 
}


void app_init(void)
{
    LED_OFF();
}

void app_loop(void)
{
    KeyDown();
    LED_ON();
    LL_mDelay(1000);
    KeyUp();
    LED_OFF();
    LL_mDelay(3000);
}

LED blinks, both devices HID and COM7 appear in device manager, serial terminal prints "KEY DOWN OK/KEY UP OK" but no input comes from keyboard
Issues #17 and #19 are kind of similar to mine, but both them resolved without clear explanation.

@pitman75
Copy link

More information about my changes for HID keyboard added.

@andolon
Copy link

andolon commented Jan 18, 2023

@nckpln : It was not working for me. So, I used a working Keyboard Report Descriptor extracted from here:
https://www.instructables.com/STM32-As-HID-USB-Keyboard-STM32-Tutorials/
and it works. Receiving chars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants