This commit is contained in:
Bertrand Songis
2016-01-29 16:11:51 +01:00
parent 364bf6ac23
commit 7ebebb312a
7 changed files with 50 additions and 14 deletions
+1 -1
View File
@@ -841,7 +841,7 @@ endif()
if(CPU_FAMILY STREQUAL STM32)
add_custom_target(flash
COMMAND dfu-util --alt 0 --dfuse-address 0x08000000 -D firmware.bin
DEPENDS firmware.bin
DEPENDS firmware
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
+9 -2
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* 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
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -280,6 +280,13 @@ int cliDisplay(const char ** argv)
else if (!strcmp(argv[1], "volume")) {
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)
else if (!strcmp(argv[1], "bq24195")) {
{
@@ -379,7 +386,7 @@ const CliCommand cliCommands[] = {
};
int cliHelp(const char ** argv)
{
{
for (const CliCommand * command = cliCommands; command->name != NULL; command++) {
if (argv[1][0] == '\0' || !strcmp(command->name, argv[0])) {
serialPrint("%s %s", command->name, command->args);
+5 -4
View File
@@ -155,13 +155,14 @@ char * strAppendNumber(char * dest, unsigned int value, uint8_t digits, uint8_t
tmp /= radix;
}
}
dest[digits] = '\0';
while(digits > 0) {
uint8_t idx = digits;
while(idx > 0) {
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;
}
return dest + digits;
dest[digits] = '\0';
return &dest[digits];
}
#if defined(CPUARM) || defined(SDCARD)
+16 -6
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* 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
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -39,6 +39,16 @@ void watchdogInit(unsigned int duration)
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
void init2MhzTimer()
{
@@ -144,19 +154,19 @@ extern USB_OTG_CORE_HANDLE USB_OTG_dev;
Prepare and send new USB data packet
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
*/
void usbJoystickUpdate(void)
{
static uint8_t HID_Buffer[HID_IN_PACKET];
//buttons
HID_Buffer[0] = 0; //buttons
for (int i = 0; i < 8; ++i) {
if ( channelOutputs[i+8] > 0 ) {
HID_Buffer[0] |= (1 << i);
}
}
}
//analog values
@@ -165,7 +175,7 @@ void usbJoystickUpdate(void)
int16_t value = channelOutputs[i] / 8;
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 );
@@ -220,4 +230,4 @@ void checkTrainerSettings()
break;
}
}
}
}
+5 -1
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* 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
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -116,6 +116,10 @@ void delay_ms(uint16_t nb);
}
#endif
// CPU Unique ID
#define LEN_CPU_UID (3*8+2)
void getCPUUniqueID(char * s);
// SD driver
#if !defined(SIMU) || defined(SIMU_DISKIO)
uint32_t sdIsHC(void);
@@ -39,6 +39,16 @@ void watchdogInit(unsigned int duration)
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
void init2MhzTimer()
{
@@ -144,6 +144,10 @@ void delay(uint32_t ms);
}
#endif
// CPU Unique ID
#define LEN_CPU_UID (3*8+2)
void getCPUUniqueID(char * s);
// SD driver
#if !defined(SIMU) || defined(SIMU_DISKIO)
uint32_t sdIsHC(void);