Firmware: Hello World HID IN packet
This commit is contained in:
22
Firmware/Application/Components/TelemetryPacket.hpp
Normal file
22
Firmware/Application/Components/TelemetryPacket.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* TelemetryPacket.hpp
|
||||
*
|
||||
* Created on: Dec 27, 2025
|
||||
* Author: Gabriel
|
||||
*/
|
||||
|
||||
#ifndef COMPONENTS_TELEMETRYPACKET_HPP_
|
||||
#define COMPONENTS_TELEMETRYPACKET_HPP_
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
class __attribute__((packed)) TelemetryPacket {
|
||||
public:
|
||||
uint8_t report_id = 0x01;
|
||||
uint32_t counter; // Increments every send
|
||||
uint32_t timestamp_ms; // HAL_GetTick() value
|
||||
char message[32]; // Text message
|
||||
uint8_t padding[23]; // Pad to 63 bytes
|
||||
};
|
||||
|
||||
#endif /* COMPONENTS_TELEMETRYPACKET_HPP_ */
|
||||
@@ -17,12 +17,21 @@
|
||||
#include "Encoder_STM32.hpp"
|
||||
#include "SoftTimer_STM32.hpp"
|
||||
|
||||
#include "Components/TelemetryPacket.hpp"
|
||||
|
||||
#include "main.h"
|
||||
#include "usb_device.h"
|
||||
#include "usbd_customhid.h"
|
||||
extern USBD_HandleTypeDef hUsbDeviceFS;
|
||||
|
||||
void executableDispatch(void* _executable){
|
||||
Executable* executable = static_cast<Executable*>(_executable);
|
||||
executable->execute();
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
TelemetryPacket pkt;
|
||||
|
||||
void start(){
|
||||
printf("----------------INIT----------------\n");
|
||||
printf("X and Y: %u, %u\n", (uint16_t)HAL_GetUIDw0(), (uint16_t)HAL_GetUIDw0()>>16);
|
||||
@@ -46,6 +55,19 @@ void start(){
|
||||
// Init shared resources
|
||||
|
||||
//Init components
|
||||
pkt.counter = 0;
|
||||
for(uint32_t i=0; i<32; i++){
|
||||
pkt.message[i] = 33 + i;
|
||||
}
|
||||
for(uint32_t i=0; i<23; i++){
|
||||
pkt.padding[i] = 0;
|
||||
}
|
||||
while(true){
|
||||
pkt.counter++;
|
||||
pkt.timestamp_ms = xTaskGetTickCount();
|
||||
uint8_t result = USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, reinterpret_cast<uint8_t*>(&pkt), 64);
|
||||
vTaskDelay(1000);
|
||||
}
|
||||
|
||||
//Init tasks
|
||||
vTaskDelete(nullptr);
|
||||
|
||||
@@ -296,10 +296,16 @@ TIM1.IPParameters=Channel-PWM Generation1 CH1 CH1N,Channel-PWM Generation2 CH2 C
|
||||
TIM1.Prescaler=0
|
||||
TIM1.SourceBRKCOMP5=TIM_BREAKINPUTSOURCE_ENABLE
|
||||
TIM1.SourceBRKCOMP6=TIM_BREAKINPUTSOURCE_ENABLE
|
||||
USB.IPParameters=Sof_enable
|
||||
USB.Sof_enable=ENABLE
|
||||
USB_DEVICE.CLASS_NAME_FS=CUSTOM_HID
|
||||
USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,USBD_CUSTOM_HID_REPORT_DESC_SIZE,USBD_CUSTOMHID_OUTREPORT_BUF_SIZE
|
||||
USB_DEVICE.CUSTOM_HID_FS_BINTERVAL=0x01
|
||||
USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,USBD_CUSTOM_HID_REPORT_DESC_SIZE,USBD_CUSTOMHID_OUTREPORT_BUF_SIZE,MANUFACTURER_STRING,VID,PID_CUSTOMHID_FS,CUSTOM_HID_FS_BINTERVAL
|
||||
USB_DEVICE.MANUFACTURER_STRING=IMBEL - Industria de Material Belico do Brasil
|
||||
USB_DEVICE.PID_CUSTOMHID_FS=\ 0x1997
|
||||
USB_DEVICE.USBD_CUSTOMHID_OUTREPORT_BUF_SIZE=64
|
||||
USB_DEVICE.USBD_CUSTOM_HID_REPORT_DESC_SIZE=38
|
||||
USB_DEVICE.VID=10684
|
||||
USB_DEVICE.VirtualMode=CustomHid
|
||||
USB_DEVICE.VirtualModeFS=Custom_Hid_FS
|
||||
VP_ADC1_TempSens_Input.Mode=IN-TempSens
|
||||
|
||||
@@ -62,10 +62,10 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define USBD_VID 1155
|
||||
#define USBD_VID 10684
|
||||
#define USBD_LANGID_STRING 1033
|
||||
#define USBD_MANUFACTURER_STRING "STMicroelectronics"
|
||||
#define USBD_PID 22352
|
||||
#define USBD_MANUFACTURER_STRING "IMBEL - Industria de Material Belico do Brasil"
|
||||
#define USBD_PID 0x1997
|
||||
#define USBD_PRODUCT_STRING "STM32 Custom Human interface"
|
||||
#define USBD_CONFIGURATION_STRING "Custom HID Config"
|
||||
#define USBD_INTERFACE_STRING "Custom HID Interface"
|
||||
|
||||
@@ -402,7 +402,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
|
||||
hpcd_USB_FS.Init.dev_endpoints = 8;
|
||||
hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
|
||||
hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
|
||||
hpcd_USB_FS.Init.Sof_enable = DISABLE;
|
||||
hpcd_USB_FS.Init.Sof_enable = ENABLE;
|
||||
hpcd_USB_FS.Init.low_power_enable = DISABLE;
|
||||
hpcd_USB_FS.Init.lpm_enable = DISABLE;
|
||||
hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
#define CUSTOM_HID_EPIN_SIZE 0x40U
|
||||
#define CUSTOM_HID_EPOUT_SIZE 0x40U
|
||||
/* USER CODE END PV */
|
||||
/**
|
||||
* @}
|
||||
@@ -81,7 +83,7 @@
|
||||
/*---------- -----------*/
|
||||
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 38U
|
||||
/*---------- -----------*/
|
||||
#define CUSTOM_HID_FS_BINTERVAL 0x5U
|
||||
#define CUSTOM_HID_FS_BINTERVAL 0x01U
|
||||
|
||||
/****************************************/
|
||||
/* #define for FS and HS identification */
|
||||
|
||||
Reference in New Issue
Block a user