mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-25 01:05:08 +03:00
Fixes #3255
This commit is contained in:
parent
364bf6ac23
commit
7ebebb312a
7 changed files with 50 additions and 14 deletions
|
@ -841,7 +841,7 @@ endif()
|
||||||
if(CPU_FAMILY STREQUAL STM32)
|
if(CPU_FAMILY STREQUAL STM32)
|
||||||
add_custom_target(flash
|
add_custom_target(flash
|
||||||
COMMAND dfu-util --alt 0 --dfuse-address 0x08000000 -D firmware.bin
|
COMMAND dfu-util --alt 0 --dfuse-address 0x08000000 -D firmware.bin
|
||||||
DEPENDS firmware.bin
|
DEPENDS firmware
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) OpenTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* Based on code named
|
||||||
* th9x - http://code.google.com/p/th9x
|
* th9x - http://code.google.com/p/th9x
|
||||||
* er9x - http://code.google.com/p/er9x
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
*
|
*
|
||||||
|
@ -280,6 +280,13 @@ int cliDisplay(const char ** argv)
|
||||||
else if (!strcmp(argv[1], "volume")) {
|
else if (!strcmp(argv[1], "volume")) {
|
||||||
serialPrint("volume = %d", getVolume());
|
serialPrint("volume = %d", getVolume());
|
||||||
}
|
}
|
||||||
|
#if defined(CPUSTM32)
|
||||||
|
else if (!strcmp(argv[1], "uid")) {
|
||||||
|
char str[LEN_CPU_UID+1];
|
||||||
|
getCPUUniqueID(str);
|
||||||
|
serialPrint("uid = %s", str);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if defined(PCBFLAMENCO)
|
#if defined(PCBFLAMENCO)
|
||||||
else if (!strcmp(argv[1], "bq24195")) {
|
else if (!strcmp(argv[1], "bq24195")) {
|
||||||
{
|
{
|
||||||
|
@ -379,7 +386,7 @@ const CliCommand cliCommands[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int cliHelp(const char ** argv)
|
int cliHelp(const char ** argv)
|
||||||
{
|
{
|
||||||
for (const CliCommand * command = cliCommands; command->name != NULL; command++) {
|
for (const CliCommand * command = cliCommands; command->name != NULL; command++) {
|
||||||
if (argv[1][0] == '\0' || !strcmp(command->name, argv[0])) {
|
if (argv[1][0] == '\0' || !strcmp(command->name, argv[0])) {
|
||||||
serialPrint("%s %s", command->name, command->args);
|
serialPrint("%s %s", command->name, command->args);
|
||||||
|
|
|
@ -155,13 +155,14 @@ char * strAppendNumber(char * dest, unsigned int value, uint8_t digits, uint8_t
|
||||||
tmp /= radix;
|
tmp /= radix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dest[digits] = '\0';
|
uint8_t idx = digits;
|
||||||
while(digits > 0) {
|
while(idx > 0) {
|
||||||
div_t qr = div(value, radix);
|
div_t qr = div(value, radix);
|
||||||
dest[--digits] = (qr.rem >= 10 ? 'A' : '0') + qr.rem;
|
dest[--idx] = (qr.rem >= 10 ? 'A'-10 : '0') + qr.rem;
|
||||||
value = qr.quot;
|
value = qr.quot;
|
||||||
}
|
}
|
||||||
return dest + digits;
|
dest[digits] = '\0';
|
||||||
|
return &dest[digits];
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CPUARM) || defined(SDCARD)
|
#if defined(CPUARM) || defined(SDCARD)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) OpenTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* Based on code named
|
||||||
* th9x - http://code.google.com/p/th9x
|
* th9x - http://code.google.com/p/th9x
|
||||||
* er9x - http://code.google.com/p/er9x
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
*
|
*
|
||||||
|
@ -39,6 +39,16 @@ void watchdogInit(unsigned int duration)
|
||||||
IWDG->KR = 0xCCCC ; // start
|
IWDG->KR = 0xCCCC ; // start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getCPUUniqueID(char * s)
|
||||||
|
{
|
||||||
|
uint32_t * cpu_uid = (uint32_t *)0x1FFF7A10;
|
||||||
|
char * tmp = strAppendNumber(s, cpu_uid[0], 8, 16);
|
||||||
|
*tmp = ' ';
|
||||||
|
tmp = strAppendNumber(tmp+1, cpu_uid[1], 8, 16);
|
||||||
|
*tmp = ' ';
|
||||||
|
strAppendNumber(tmp+1, cpu_uid[2], 8, 16);
|
||||||
|
}
|
||||||
|
|
||||||
// Start TIMER7 at 2000000Hz
|
// Start TIMER7 at 2000000Hz
|
||||||
void init2MhzTimer()
|
void init2MhzTimer()
|
||||||
{
|
{
|
||||||
|
@ -144,19 +154,19 @@ extern USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||||
Prepare and send new USB data packet
|
Prepare and send new USB data packet
|
||||||
|
|
||||||
The format of HID_Buffer is defined by
|
The format of HID_Buffer is defined by
|
||||||
USB endpoint description can be found in
|
USB endpoint description can be found in
|
||||||
file usb_hid_joystick.c, variable HID_JOYSTICK_ReportDesc
|
file usb_hid_joystick.c, variable HID_JOYSTICK_ReportDesc
|
||||||
*/
|
*/
|
||||||
void usbJoystickUpdate(void)
|
void usbJoystickUpdate(void)
|
||||||
{
|
{
|
||||||
static uint8_t HID_Buffer[HID_IN_PACKET];
|
static uint8_t HID_Buffer[HID_IN_PACKET];
|
||||||
|
|
||||||
//buttons
|
//buttons
|
||||||
HID_Buffer[0] = 0; //buttons
|
HID_Buffer[0] = 0; //buttons
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
if ( channelOutputs[i+8] > 0 ) {
|
if ( channelOutputs[i+8] > 0 ) {
|
||||||
HID_Buffer[0] |= (1 << i);
|
HID_Buffer[0] |= (1 << i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//analog values
|
//analog values
|
||||||
|
@ -165,7 +175,7 @@ void usbJoystickUpdate(void)
|
||||||
int16_t value = channelOutputs[i] / 8;
|
int16_t value = channelOutputs[i] / 8;
|
||||||
if ( value > 127 ) value = 127;
|
if ( value > 127 ) value = 127;
|
||||||
else if ( value < -127 ) value = -127;
|
else if ( value < -127 ) value = -127;
|
||||||
HID_Buffer[i+1] = static_cast<int8_t>(value);
|
HID_Buffer[i+1] = static_cast<int8_t>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
USBD_HID_SendReport (&USB_OTG_dev, HID_Buffer, HID_IN_PACKET );
|
USBD_HID_SendReport (&USB_OTG_dev, HID_Buffer, HID_IN_PACKET );
|
||||||
|
@ -220,4 +230,4 @@ void checkTrainerSettings()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) OpenTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* Based on code named
|
||||||
* th9x - http://code.google.com/p/th9x
|
* th9x - http://code.google.com/p/th9x
|
||||||
* er9x - http://code.google.com/p/er9x
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
*
|
*
|
||||||
|
@ -116,6 +116,10 @@ void delay_ms(uint16_t nb);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// CPU Unique ID
|
||||||
|
#define LEN_CPU_UID (3*8+2)
|
||||||
|
void getCPUUniqueID(char * s);
|
||||||
|
|
||||||
// SD driver
|
// SD driver
|
||||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||||
uint32_t sdIsHC(void);
|
uint32_t sdIsHC(void);
|
||||||
|
|
|
@ -39,6 +39,16 @@ void watchdogInit(unsigned int duration)
|
||||||
IWDG->KR = 0xCCCC ; // start
|
IWDG->KR = 0xCCCC ; // start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getCPUUniqueID(char * s)
|
||||||
|
{
|
||||||
|
uint32_t * cpu_uid = (uint32_t *)0x1FFF7A10;
|
||||||
|
char * tmp = strAppendNumber(s, cpu_uid[0], 8, 16);
|
||||||
|
*tmp = ' ';
|
||||||
|
tmp = strAppendNumber(tmp+1, cpu_uid[1], 8, 16);
|
||||||
|
*tmp = ' ';
|
||||||
|
strAppendNumber(tmp+1, cpu_uid[2], 8, 16);
|
||||||
|
}
|
||||||
|
|
||||||
// Starts TIMER at 2MHz
|
// Starts TIMER at 2MHz
|
||||||
void init2MhzTimer()
|
void init2MhzTimer()
|
||||||
{
|
{
|
||||||
|
|
|
@ -144,6 +144,10 @@ void delay(uint32_t ms);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// CPU Unique ID
|
||||||
|
#define LEN_CPU_UID (3*8+2)
|
||||||
|
void getCPUUniqueID(char * s);
|
||||||
|
|
||||||
// SD driver
|
// SD driver
|
||||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||||
uint32_t sdIsHC(void);
|
uint32_t sdIsHC(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue