Merge branch 'sam_python_fixes' into sam_testing

This commit is contained in:
Samuel Sadok
2018-04-03 17:27:19 -07:00
40 changed files with 1144 additions and 719 deletions
+30
View File
@@ -12,6 +12,7 @@
#include "protocol.hpp"
#include "freertos_vars.h"
#include "utils.h"
#include "../build/version.h" // autogenerated based on Git state
#ifdef ENABLE_LEGACY_PROTOCOL
#include "legacy_commands.h"
@@ -37,6 +38,28 @@ extern USBD_HandleTypeDef hUsbDeviceFS;
uint64_t serial_number;
/* Private constant data -----------------------------------------------------*/
#if HW_VERSION_MAJOR == 3
const uint8_t* otp_ptr =
*(uint8_t*)0x1fff7800 == 0xfe ? (uint8_t*)0x1fff7800 :
*(uint8_t*)0x1fff7800 != 0x00 ? NULL :
*(uint8_t*)0x1fff7810 == 0xfe ? (uint8_t*)0x1fff7810 : NULL;
// Read hardware version from OTP if available, otherwise fall back
// to software defined version.
const uint8_t board_version_major = otp_ptr ? otp_ptr[3] : HW_VERSION_MAJOR;
const uint8_t board_version_minor = otp_ptr ? otp_ptr[4] : HW_VERSION_MINOR;
const uint8_t board_version_variant = otp_ptr ? otp_ptr[5] : (HW_VERSION_VOLTAGE == 24 ? 0 : 1);
#else
#error "not implemented"
#endif
// the corresponding macros are defined in the autogenerated version.h
const uint8_t fw_version_major = FW_VERSION_MAJOR;
const uint8_t fw_version_minor = FW_VERSION_MINOR;
const uint8_t fw_version_revision = FW_VERSION_REVISION;
const uint8_t fw_version_unreleased = FW_VERSION_UNRELEASED; // 0 for official releases, 1 otherwise
/* Private variables ---------------------------------------------------------*/
static uint8_t* usb_buf;
@@ -172,6 +195,13 @@ static inline auto make_obj_tree() {
make_protocol_ro_property("vbus_voltage", &vbus_voltage),
make_protocol_ro_property("comm_stack_info", &comm_stack_info),
make_protocol_ro_property("serial_number", &serial_number),
make_protocol_ro_property("board_version_major", &board_version_major),
make_protocol_ro_property("board_version_minor", &board_version_minor),
make_protocol_ro_property("board_version_variant", &board_version_variant),
make_protocol_ro_property("fw_version_major", &fw_version_major),
make_protocol_ro_property("fw_version_minor", &fw_version_minor),
make_protocol_ro_property("fw_version_revision", &fw_version_revision),
make_protocol_ro_property("fw_version_unreleased", &fw_version_unreleased),
make_protocol_object("config",
make_protocol_property("brake_resistance", &board_config.brake_resistance),
// TODO: changing this currently requires a reboot - fix this