3593 views|2 replies

5

Posts

0

Resources
The OP
 

HPM6750 Review of Pioneer Semiconductor Step 3 (RT-Thread + TinyUSB) [Copy link]

 

Recently, I saw that RT-Thread Studio has a major version update (V4.1), and added support for the TinyUSB software package. TinyUSB has been used in my previous projects, so this section uses RT-Thread Studio to create a project.

TinyUSB is an open source cross-platform USB host/device stack for embedded systems, designed to achieve memory safety without dynamic allocation and thread safety by delaying all interrupt events, which are then processed in non-ISR task functions. TinyUSB supports chips from many manufacturers such as ST, NXP, MicroChip, etc. Espressif's ESP32 S series also supports USB development using TinyUSB.

The porting and operation of TinyUSB are very simple, and it is even simpler when paired with RT-Thread Studio.

1. Install the required SDK

2. Add TinyUSB software package to the project

3. Enable USB Device in Hardware Configuration

4. Adjust the TinyUSB software package configuration

5. Create a new hid_test file and write the code to test the HID communication

#include <rtthread.h>
#include <rtdevice.h>
#include "rtt_board.h"
#include <tusb.h>

struct __attribute __ ((__packed__) ) reportHID_t {
// uint8_t reportId ;
int8_t







struct reportHID_t reportHID;
static void hid_test_entry(void *parameter)
{
(void) parameter;
static uint32_t send_failed_cnt;
reportHID.X = 127;
reportHID.Y = 127;
reportHID.Z = -127;
reportHID.Rx = 0;
reportHID.Ry = 127;
reportHID.Rz = 127;
reportHID.button = 1;
uint8_t res = false;
while (1)
{
if (tud_suspended())
{
rt_kprintf("tud_suspended!!!\r\n");
tud_remote_wakeup();
}
else
{
res = tud_hid_report(3,(uint8_t*)&reportHID, 11);
if(reportHID.button<2147483648)
{
reportHID.button*=2;
}
else
{
reportHID.button = 1;
}
if(!res)
{
send_failed_cnt++;
rt_kprintf("Send Failed :%d Times\r\n",send_failed_cnt);
}

}
rt_thread_mdelay(500);
}
}

static int init_hid_test(void)
{
rt_thread_t hid_test;

hid_test = rt_thread_create("hid test", hid_test_entry, RT_NULL,
PKG_TINYUSB_STACK_SIZE,
PKG_TINYUSB_THREAD_PRIORITY, 10);
if (hid_test == RT_NULL)
{
rt_kprintf("Fail to create HID Test thread");
return -1;
}
rt_kprintf("init_hid_test create success!!!\r\n");
rt_thread_startup(hid_test);
return 0;
}

MSH_CMD_EXPORT(init_hid_test, init hid test)

6. Compile, download and test

7.HID is working according to our program logic. Done!

This post is from Domestic Chip Exchange

Latest reply

rt supports quite fast.   Details Published on 2022-6-20 20:21
 
 

6555

Posts

0

Resources
2
 

The transplantation and operation of TinyUSB seems to be not complicated

This post is from Domestic Chip Exchange
 
 
 

7422

Posts

2

Resources
3
 

rt supports quite fast.

This post is from Domestic Chip Exchange
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Homemade STEVAL-IPM05F 3Sh board: FOC motor control 400V/8A non-sensing/sensing Hall/sensing encoder and other reference programs...

This post was last edited by music_586 on 2019-4-4 19:06 This content was originally created by EEWORLD forum user musi ...

Based on IPM05F 3Sh board: FOC motor control 400V non-sensing sensory encoder all design data summary (schematic diagram/BOM table...

Based on IPM05F 3Sh board: FOC motor control 400V sensorless and sensory encoder all design data summary (schematic diag ...

"Recommend Chinese chips" + domestic chips

I have used or seen quite a lot of domestic chips. I won't mention Shenwei and Loongson. Basically, anyone who works wit ...

Two highlights of EFM32PG22

I think the M33 core and 16-bit ADC are pretty good.

[HPM-DIY] HPM6750 uses cherryusb to read UVC camera to display VGA resolution

I received the display module from EE last week and finally used it tonight. HPM6750 acts as a host to read the UVC came ...

Is it possible to perform socket communication without IP and port number?

When using socket communication, whether it is internal communication within the local machine or communication betwee ...

全志V853 NPU 转换部署 YOLO V5 模型

# NPU conversion and deployment of YOLO V5 model This article takes the YOLO v5s model as an example to detail the conve ...

What is light load mode?

The technique of improving efficiency when using less output current is called light load mode. It is also called burst ...

[ST NUCLEO-U5A5ZJ-Q development board review] 2. EXTI, PWM and serial port printf

Serial port printf output The serial port 1 of Nucleo-U5A5 is connected to the serial port of STlinkV3 to output the pri ...

What are the functions of the five pins INT, MOSI, MISO, SCK, and NCS of the MPU attitude sensor? Is the waveform correct?

What are the functions of the five pins INT, MOSI, MISO, SCK, and NCS of the MPU attitude sensor? Is the waveform correc ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list