add example Arduino application

This commit is contained in:
Samuel Sadok
2018-04-24 19:35:44 -07:00
parent 5eab09d1f8
commit 2a2b3fbe4e
4 changed files with 910 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
#include <Wire.h>
#include "odrive.h"
// See odrive.h for a description
bool I2C_transaction(uint8_t slave_addr, const uint8_t * tx_buffer, size_t tx_length, uint8_t * rx_buffer, size_t rx_length) {
// transmit
if (tx_buffer) {
Wire.beginTransmission(slave_addr);
if (Wire.write(tx_buffer, tx_length) != tx_length)
return false;
bool should_stop = !rx_buffer;
if (Wire.endTransmission(should_stop) != 0)
return false;
}
// receive
if (rx_buffer) {
while(Wire.available()) Wire.read(); // flush input buffer
if (Wire.requestFrom(slave_addr, (uint8_t)rx_length, (uint8_t)true /* stop after receiving */) != rx_length)
return false;
for (size_t i = 0; i < rx_length; ++i)
rx_buffer[i] = Wire.read();
}
return true;
}
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
}
byte odrive_num = 7;
byte x;
void loop() {
bool success;
float val;
success = odrive::read_property<odrive::VBUS_VOLTAGE>(odrive_num, &val);
if (success) {
Serial.println(val, HEX);
} else {
Serial.println("error");
}
success = odrive::write_property<odrive::TEST_PROPERTY>(odrive_num, x++);
if (!success)
Serial.println("error");
delay(500);
}
+143
View File
@@ -0,0 +1,143 @@
/*
* ODrive I2C communication library
* This file implements I2C communication with the ODrive.
*
* - Implement the C function I2C_transaction to provide low level I2C access.
* - Use read_property<PropertyId>() to read properties from the ODrive.
* - Use write_property<PropertyId>() to modify properties on the ODrive.
* - Use endpoint_type_t<PropertyId> to retrieve the underlying type
* of a given property.
*
* To regenerate the interface definitions, flash an ODrive with the new
* firmware, then run
* ../tools/odrivetool generate-code --output odrive_endpoints.h
*/
#include <limits.h>
#include <stdint.h>
#include "odrive_endpoints.h"
#ifdef __AVR__
// AVR-GCC doesn't ship with the STL, so we use our own little excerpt
#include "type_traits.h"
#else
#include <type_traits>
#endif
extern "C" {
/* @brief Send and receive data to/from an I2C slave
*
* This function carries out the following sequence:
* 1. generate a START condition
* 2. if the tx_buffer is not null:
* a. send 7-bit slave address (with the LSB 0)
* b. send all bytes in the tx_buffer
* 3. if both tx_buffer and rx_buffer are not null, generate a REPEATED START condition
* 4. if the rx_buffer is not null:
* a. send 7-bit slave address (with the LSB 1)
* b. read rx_length bytes into rx_buffer
* 5. send STOP condition
*
* @param slave_addr: 7-bit slave address (the MSB is ignored)
* @return true if all data was transmitted and received as requested by the caller, false otherwise
*/
bool I2C_transaction(uint8_t slave_addr, const uint8_t * tx_buffer, size_t tx_length, uint8_t * rx_buffer, size_t rx_length);
}
namespace odrive {
static constexpr const uint8_t i2c_addr = (0xD << 3); // write: 1101xxx0, read: 1101xxx1
template<typename T>
using bit_width = std::integral_constant<unsigned int, CHAR_BIT * sizeof(T)>;
template<typename T>
using byte_width = std::integral_constant<unsigned int, (bit_width<T>::value + 7) / 8>;
template<unsigned int IBitSize>
struct unsigned_int_of_size;
template<> struct unsigned_int_of_size<32> { typedef uint32_t type; };
template<typename T>
typename std::enable_if<std::is_integral<T>::value, T>::type
read_le(const uint8_t buffer[byte_width<T>::value]) {
T value = 0;
for (size_t i = 0; i < byte_width<T>::value; ++i)
value |= (static_cast<T>(buffer[i]) << (i << 3));
return value;
}
template<typename T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
read_le(const uint8_t buffer[]) {
using T_Int = typename unsigned_int_of_size<bit_width<T>::value>::type;
T_Int value = read_le<T_Int>(buffer);
return *reinterpret_cast<T*>(&value);
}
template<typename T>
typename std::enable_if<std::is_integral<T>::value, void>::type
write_le(uint8_t buffer[byte_width<T>::value], T value) {
for (size_t i = 0; i < byte_width<T>::value; ++i)
buffer[i] = (value >> (i << 3)) & 0xff;
}
template<typename T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
write_le(uint8_t buffer[byte_width<T>::value], T value) {
using T_Int = typename unsigned_int_of_size<bit_width<T>::value>::type;
write_le<T_Int>(buffer, *reinterpret_cast<T_Int*>(&value));
}
/* @brief Read from an endpoint on the ODrive
*
* Usage example:
* float val;
* success = odrive::read_property<odrive::VBUS_VOLTAGE>(0, &val);
*
* @param num Selects the ODrive. For instance the value 4 selects
* the ODrive that has [A2, A1, A0] connected to [VCC, GND, GND].
* @return true if the I2C transaction succeeded, false otherwise
*/
template<int IPropertyId>
bool read_property(uint8_t num, endpoint_type_t<IPropertyId>* value) {
uint8_t i2c_tx_buffer[4];
write_le<uint16_t>(i2c_tx_buffer, IPropertyId);
write_le<uint16_t>(i2c_tx_buffer + sizeof(i2c_tx_buffer) - 2, json_crc);
uint8_t i2c_rx_buffer[byte_width<endpoint_type_t<IPropertyId>>::value];
if (!I2C_transaction(i2c_addr + num,
i2c_tx_buffer, sizeof(i2c_tx_buffer),
i2c_rx_buffer, sizeof(i2c_rx_buffer)))
return false;
if (value)
*value = read_le<endpoint_type_t<IPropertyId>>(i2c_rx_buffer);
return true;
}
/* @brief Write to an endpoint on the ODrive
*
* Usage example:
* success = odrive::write_property<odrive::AXIS0__CONTROLLER__VEL_SETPOINT>(0, 10000);
*
* @param num Selects the ODrive. For instance the value 4 selects
* the ODrive that has [A2, A1, A0] connected to [VCC, GND, GND].
* @return true if the I2C transaction succeeded, false otherwise
*/
template<int IPropertyId>
bool write_property(uint8_t num, endpoint_type_t<IPropertyId> value) {
uint8_t i2c_tx_buffer[4 + byte_width<endpoint_type_t<IPropertyId>>::value];
write_le<uint16_t>(i2c_tx_buffer, IPropertyId);
write_le<endpoint_type_t<IPropertyId>>(i2c_tx_buffer + 2, value);
write_le<uint16_t>(i2c_tx_buffer + sizeof(i2c_tx_buffer) - 2, json_crc);
return I2C_transaction(i2c_addr + num, i2c_tx_buffer, sizeof(i2c_tx_buffer), nullptr, 0);
}
}
+444
View File
@@ -0,0 +1,444 @@
/*
* This file was autogenerated using the "odrivetool generate-code" feature.
*
* The file matches a specific firmware version. If you add/remove/rename any
* properties exposed by the ODrive, this file needs to be regenerated, otherwise
* the ODrive will ignore all commands.
*/
#ifndef __ODRIVE_ENDPOINTS_HPP
#define __ODRIVE_ENDPOINTS_HPP
namespace odrive {
static constexpr const uint16_t json_crc = 0x7199;
enum {
VBUS_VOLTAGE = 1,
SERIAL_NUMBER = 2,
HW_VERSION_MAJOR = 3,
HW_VERSION_MINOR = 4,
HW_VERSION_VARIANT = 5,
FW_VERSION_MAJOR = 6,
FW_VERSION_MINOR = 7,
FW_VERSION_REVISION = 8,
FW_VERSION_UNRELEASED = 9,
USER_CONFIG_LOADED = 10,
BRAKE_RESISTOR_ARMED = 11,
SYSTEM_STATS__UPTIME = 12,
SYSTEM_STATS__MIN_HEAP_SPACE = 13,
SYSTEM_STATS__MIN_STACK_SPACE_AXIS0 = 14,
SYSTEM_STATS__MIN_STACK_SPACE_AXIS1 = 15,
SYSTEM_STATS__MIN_STACK_SPACE_COMMS = 16,
SYSTEM_STATS__MIN_STACK_SPACE_USB = 17,
SYSTEM_STATS__MIN_STACK_SPACE_UART = 18,
SYSTEM_STATS__MIN_STACK_SPACE_USB_IRQ = 19,
SYSTEM_STATS__MIN_STACK_SPACE_STARTUP = 20,
SYSTEM_STATS__USB__RX_CNT = 21,
SYSTEM_STATS__USB__TX_CNT = 22,
SYSTEM_STATS__USB__TX_OVERRUN_CNT = 23,
SYSTEM_STATS__I2C__ADDR = 24,
SYSTEM_STATS__I2C__ADDR_MATCH_CNT = 25,
SYSTEM_STATS__I2C__RX_CNT = 26,
SYSTEM_STATS__I2C__ERROR_CNT = 27,
CONFIG__BRAKE_RESISTANCE = 28,
CONFIG__ENABLE_UART = 29,
CONFIG__ENABLE_I2C_INSTEAD_OF_CAN = 30,
CONFIG__DC_BUS_UNDERVOLTAGE_TRIP_LEVEL = 31,
CONFIG__DC_BUS_OVERVOLTAGE_TRIP_LEVEL = 32,
AXIS0__ERROR = 33,
AXIS0__ENABLE_STEP_DIR = 34,
AXIS0__CURRENT_STATE = 35,
AXIS0__REQUESTED_STATE = 36,
AXIS0__LOOP_COUNTER = 37,
AXIS0__CONFIG__STARTUP_MOTOR_CALIBRATION = 38,
AXIS0__CONFIG__STARTUP_ENCODER_INDEX_SEARCH = 39,
AXIS0__CONFIG__STARTUP_ENCODER_OFFSET_CALIBRATION = 40,
AXIS0__CONFIG__STARTUP_CLOSED_LOOP_CONTROL = 41,
AXIS0__CONFIG__STARTUP_SENSORLESS_CONTROL = 42,
AXIS0__CONFIG__ENABLE_STEP_DIR = 43,
AXIS0__CONFIG__COUNTS_PER_STEP = 44,
AXIS0__CONFIG__RAMP_UP_TIME = 45,
AXIS0__CONFIG__RAMP_UP_DISTANCE = 46,
AXIS0__CONFIG__SPIN_UP_CURRENT = 47,
AXIS0__CONFIG__SPIN_UP_ACCELERATION = 48,
AXIS0__CONFIG__SPIN_UP_TARGET_VEL = 49,
AXIS0__MOTOR__ERROR = 50,
AXIS0__MOTOR__ARMED_STATE = 51,
AXIS0__MOTOR__IS_CALIBRATED = 52,
AXIS0__MOTOR__CURRENT_MEAS_PHB = 53,
AXIS0__MOTOR__CURRENT_MEAS_PHC = 54,
AXIS0__MOTOR__DC_CALIB_PHB = 55,
AXIS0__MOTOR__DC_CALIB_PHC = 56,
AXIS0__MOTOR__PHASE_CURRENT_REV_GAIN = 57,
AXIS0__MOTOR__CURRENT_CONTROL__P_GAIN = 58,
AXIS0__MOTOR__CURRENT_CONTROL__I_GAIN = 59,
AXIS0__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_D = 60,
AXIS0__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_Q = 61,
AXIS0__MOTOR__CURRENT_CONTROL__IBUS = 62,
AXIS0__MOTOR__CURRENT_CONTROL__FINAL_V_ALPHA = 63,
AXIS0__MOTOR__CURRENT_CONTROL__FINAL_V_BETA = 64,
AXIS0__MOTOR__CURRENT_CONTROL__IQ_SETPOINT = 65,
AXIS0__MOTOR__CURRENT_CONTROL__IQ_MEASURED = 66,
AXIS0__MOTOR__CURRENT_CONTROL__MAX_ALLOWED_CURRENT = 67,
AXIS0__MOTOR__GATE_DRIVER__DRV_FAULT = 68,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_GENERAL = 69,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_I = 70,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_DC = 71,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_R = 72,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_L = 73,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_ENC_CALIB = 74,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_IDX_SEARCH = 75,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_FOC_VOLTAGE = 76,
AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_FOC_CURRENT = 77,
AXIS0__MOTOR__CONFIG__PRE_CALIBRATED = 78,
AXIS0__MOTOR__CONFIG__POLE_PAIRS = 79,
AXIS0__MOTOR__CONFIG__CALIBRATION_CURRENT = 80,
AXIS0__MOTOR__CONFIG__RESISTANCE_CALIB_MAX_VOLTAGE = 81,
AXIS0__MOTOR__CONFIG__PHASE_INDUCTANCE = 82,
AXIS0__MOTOR__CONFIG__PHASE_RESISTANCE = 83,
AXIS0__MOTOR__CONFIG__DIRECTION = 84,
AXIS0__MOTOR__CONFIG__MOTOR_TYPE = 85,
AXIS0__MOTOR__CONFIG__CURRENT_LIM = 86,
AXIS0__CONTROLLER__POS_SETPOINT = 87,
AXIS0__CONTROLLER__VEL_SETPOINT = 88,
AXIS0__CONTROLLER__VEL_INTEGRATOR_CURRENT = 89,
AXIS0__CONTROLLER__CURRENT_SETPOINT = 90,
AXIS0__CONTROLLER__CONFIG__CONTROL_MODE = 91,
AXIS0__CONTROLLER__CONFIG__POS_GAIN = 92,
AXIS0__CONTROLLER__CONFIG__VEL_GAIN = 93,
AXIS0__CONTROLLER__CONFIG__VEL_INTEGRATOR_GAIN = 94,
AXIS0__CONTROLLER__CONFIG__VEL_LIMIT = 95,
AXIS0__ENCODER__ERROR = 106,
AXIS0__ENCODER__IS_READY = 107,
AXIS0__ENCODER__INDEX_FOUND = 108,
AXIS0__ENCODER__SHADOW_COUNT = 109,
AXIS0__ENCODER__COUNT_IN_CPR = 110,
AXIS0__ENCODER__OFFSET = 111,
AXIS0__ENCODER__PHASE = 112,
AXIS0__ENCODER__POS_ESTIMATE = 113,
AXIS0__ENCODER__POS_CPR = 114,
AXIS0__ENCODER__PLL_VEL = 115,
AXIS0__ENCODER__PLL_KP = 116,
AXIS0__ENCODER__PLL_KI = 117,
AXIS0__ENCODER__CONFIG__USE_INDEX = 118,
AXIS0__ENCODER__CONFIG__PRE_CALIBRATED = 119,
AXIS0__ENCODER__CONFIG__IDX_SEARCH_SPEED = 120,
AXIS0__ENCODER__CONFIG__CPR = 121,
AXIS0__ENCODER__CONFIG__OFFSET = 122,
AXIS0__ENCODER__CONFIG__CALIB_RANGE = 123,
AXIS0__SENSORLESS_ESTIMATOR__ERROR = 124,
AXIS0__SENSORLESS_ESTIMATOR__PHASE = 125,
AXIS0__SENSORLESS_ESTIMATOR__PLL_POS = 126,
AXIS0__SENSORLESS_ESTIMATOR__PLL_VEL = 127,
AXIS0__SENSORLESS_ESTIMATOR__PLL_KP = 128,
AXIS0__SENSORLESS_ESTIMATOR__PLL_KI = 129,
AXIS1__ERROR = 130,
AXIS1__ENABLE_STEP_DIR = 131,
AXIS1__CURRENT_STATE = 132,
AXIS1__REQUESTED_STATE = 133,
AXIS1__LOOP_COUNTER = 134,
AXIS1__CONFIG__STARTUP_MOTOR_CALIBRATION = 135,
AXIS1__CONFIG__STARTUP_ENCODER_INDEX_SEARCH = 136,
AXIS1__CONFIG__STARTUP_ENCODER_OFFSET_CALIBRATION = 137,
AXIS1__CONFIG__STARTUP_CLOSED_LOOP_CONTROL = 138,
AXIS1__CONFIG__STARTUP_SENSORLESS_CONTROL = 139,
AXIS1__CONFIG__ENABLE_STEP_DIR = 140,
AXIS1__CONFIG__COUNTS_PER_STEP = 141,
AXIS1__CONFIG__RAMP_UP_TIME = 142,
AXIS1__CONFIG__RAMP_UP_DISTANCE = 143,
AXIS1__CONFIG__SPIN_UP_CURRENT = 144,
AXIS1__CONFIG__SPIN_UP_ACCELERATION = 145,
AXIS1__CONFIG__SPIN_UP_TARGET_VEL = 146,
AXIS1__MOTOR__ERROR = 147,
AXIS1__MOTOR__ARMED_STATE = 148,
AXIS1__MOTOR__IS_CALIBRATED = 149,
AXIS1__MOTOR__CURRENT_MEAS_PHB = 150,
AXIS1__MOTOR__CURRENT_MEAS_PHC = 151,
AXIS1__MOTOR__DC_CALIB_PHB = 152,
AXIS1__MOTOR__DC_CALIB_PHC = 153,
AXIS1__MOTOR__PHASE_CURRENT_REV_GAIN = 154,
AXIS1__MOTOR__CURRENT_CONTROL__P_GAIN = 155,
AXIS1__MOTOR__CURRENT_CONTROL__I_GAIN = 156,
AXIS1__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_D = 157,
AXIS1__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_Q = 158,
AXIS1__MOTOR__CURRENT_CONTROL__IBUS = 159,
AXIS1__MOTOR__CURRENT_CONTROL__FINAL_V_ALPHA = 160,
AXIS1__MOTOR__CURRENT_CONTROL__FINAL_V_BETA = 161,
AXIS1__MOTOR__CURRENT_CONTROL__IQ_SETPOINT = 162,
AXIS1__MOTOR__CURRENT_CONTROL__IQ_MEASURED = 163,
AXIS1__MOTOR__CURRENT_CONTROL__MAX_ALLOWED_CURRENT = 164,
AXIS1__MOTOR__GATE_DRIVER__DRV_FAULT = 165,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_GENERAL = 166,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_I = 167,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_DC = 168,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_R = 169,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_L = 170,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_ENC_CALIB = 171,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_IDX_SEARCH = 172,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_FOC_VOLTAGE = 173,
AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_FOC_CURRENT = 174,
AXIS1__MOTOR__CONFIG__PRE_CALIBRATED = 175,
AXIS1__MOTOR__CONFIG__POLE_PAIRS = 176,
AXIS1__MOTOR__CONFIG__CALIBRATION_CURRENT = 177,
AXIS1__MOTOR__CONFIG__RESISTANCE_CALIB_MAX_VOLTAGE = 178,
AXIS1__MOTOR__CONFIG__PHASE_INDUCTANCE = 179,
AXIS1__MOTOR__CONFIG__PHASE_RESISTANCE = 180,
AXIS1__MOTOR__CONFIG__DIRECTION = 181,
AXIS1__MOTOR__CONFIG__MOTOR_TYPE = 182,
AXIS1__MOTOR__CONFIG__CURRENT_LIM = 183,
AXIS1__CONTROLLER__POS_SETPOINT = 184,
AXIS1__CONTROLLER__VEL_SETPOINT = 185,
AXIS1__CONTROLLER__VEL_INTEGRATOR_CURRENT = 186,
AXIS1__CONTROLLER__CURRENT_SETPOINT = 187,
AXIS1__CONTROLLER__CONFIG__CONTROL_MODE = 188,
AXIS1__CONTROLLER__CONFIG__POS_GAIN = 189,
AXIS1__CONTROLLER__CONFIG__VEL_GAIN = 190,
AXIS1__CONTROLLER__CONFIG__VEL_INTEGRATOR_GAIN = 191,
AXIS1__CONTROLLER__CONFIG__VEL_LIMIT = 192,
AXIS1__ENCODER__ERROR = 203,
AXIS1__ENCODER__IS_READY = 204,
AXIS1__ENCODER__INDEX_FOUND = 205,
AXIS1__ENCODER__SHADOW_COUNT = 206,
AXIS1__ENCODER__COUNT_IN_CPR = 207,
AXIS1__ENCODER__OFFSET = 208,
AXIS1__ENCODER__PHASE = 209,
AXIS1__ENCODER__POS_ESTIMATE = 210,
AXIS1__ENCODER__POS_CPR = 211,
AXIS1__ENCODER__PLL_VEL = 212,
AXIS1__ENCODER__PLL_KP = 213,
AXIS1__ENCODER__PLL_KI = 214,
AXIS1__ENCODER__CONFIG__USE_INDEX = 215,
AXIS1__ENCODER__CONFIG__PRE_CALIBRATED = 216,
AXIS1__ENCODER__CONFIG__IDX_SEARCH_SPEED = 217,
AXIS1__ENCODER__CONFIG__CPR = 218,
AXIS1__ENCODER__CONFIG__OFFSET = 219,
AXIS1__ENCODER__CONFIG__CALIB_RANGE = 220,
AXIS1__SENSORLESS_ESTIMATOR__ERROR = 221,
AXIS1__SENSORLESS_ESTIMATOR__PHASE = 222,
AXIS1__SENSORLESS_ESTIMATOR__PLL_POS = 223,
AXIS1__SENSORLESS_ESTIMATOR__PLL_VEL = 224,
AXIS1__SENSORLESS_ESTIMATOR__PLL_KP = 225,
AXIS1__SENSORLESS_ESTIMATOR__PLL_KI = 226,
TEST_PROPERTY = 227,
};
template<int I>
struct endpoint_type;
template<> struct endpoint_type<VBUS_VOLTAGE> { typedef float type; };
template<> struct endpoint_type<SERIAL_NUMBER> { typedef uint64_t type; };
template<> struct endpoint_type<HW_VERSION_MAJOR> { typedef uint8_t type; };
template<> struct endpoint_type<HW_VERSION_MINOR> { typedef uint8_t type; };
template<> struct endpoint_type<HW_VERSION_VARIANT> { typedef uint8_t type; };
template<> struct endpoint_type<FW_VERSION_MAJOR> { typedef uint8_t type; };
template<> struct endpoint_type<FW_VERSION_MINOR> { typedef uint8_t type; };
template<> struct endpoint_type<FW_VERSION_REVISION> { typedef uint8_t type; };
template<> struct endpoint_type<FW_VERSION_UNRELEASED> { typedef uint8_t type; };
template<> struct endpoint_type<USER_CONFIG_LOADED> { typedef bool type; };
template<> struct endpoint_type<BRAKE_RESISTOR_ARMED> { typedef bool type; };
template<> struct endpoint_type<SYSTEM_STATS__UPTIME> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_HEAP_SPACE> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_STACK_SPACE_AXIS0> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_STACK_SPACE_AXIS1> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_STACK_SPACE_COMMS> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_STACK_SPACE_USB> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_STACK_SPACE_UART> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_STACK_SPACE_USB_IRQ> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__MIN_STACK_SPACE_STARTUP> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__USB__RX_CNT> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__USB__TX_CNT> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__USB__TX_OVERRUN_CNT> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__I2C__ADDR> { typedef uint8_t type; };
template<> struct endpoint_type<SYSTEM_STATS__I2C__ADDR_MATCH_CNT> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__I2C__RX_CNT> { typedef uint32_t type; };
template<> struct endpoint_type<SYSTEM_STATS__I2C__ERROR_CNT> { typedef uint32_t type; };
template<> struct endpoint_type<CONFIG__BRAKE_RESISTANCE> { typedef float type; };
template<> struct endpoint_type<CONFIG__ENABLE_UART> { typedef bool type; };
template<> struct endpoint_type<CONFIG__ENABLE_I2C_INSTEAD_OF_CAN> { typedef bool type; };
template<> struct endpoint_type<CONFIG__DC_BUS_UNDERVOLTAGE_TRIP_LEVEL> { typedef float type; };
template<> struct endpoint_type<CONFIG__DC_BUS_OVERVOLTAGE_TRIP_LEVEL> { typedef float type; };
template<> struct endpoint_type<AXIS0__ERROR> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__ENABLE_STEP_DIR> { typedef bool type; };
template<> struct endpoint_type<AXIS0__CURRENT_STATE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__REQUESTED_STATE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__LOOP_COUNTER> { typedef uint32_t type; };
template<> struct endpoint_type<AXIS0__CONFIG__STARTUP_MOTOR_CALIBRATION> { typedef bool type; };
template<> struct endpoint_type<AXIS0__CONFIG__STARTUP_ENCODER_INDEX_SEARCH> { typedef bool type; };
template<> struct endpoint_type<AXIS0__CONFIG__STARTUP_ENCODER_OFFSET_CALIBRATION> { typedef bool type; };
template<> struct endpoint_type<AXIS0__CONFIG__STARTUP_CLOSED_LOOP_CONTROL> { typedef bool type; };
template<> struct endpoint_type<AXIS0__CONFIG__STARTUP_SENSORLESS_CONTROL> { typedef bool type; };
template<> struct endpoint_type<AXIS0__CONFIG__ENABLE_STEP_DIR> { typedef bool type; };
template<> struct endpoint_type<AXIS0__CONFIG__COUNTS_PER_STEP> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONFIG__RAMP_UP_TIME> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONFIG__RAMP_UP_DISTANCE> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONFIG__SPIN_UP_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONFIG__SPIN_UP_ACCELERATION> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONFIG__SPIN_UP_TARGET_VEL> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__ERROR> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__ARMED_STATE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__IS_CALIBRATED> { typedef bool type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_MEAS_PHB> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_MEAS_PHC> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__DC_CALIB_PHB> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__DC_CALIB_PHC> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__PHASE_CURRENT_REV_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__P_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__I_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_D> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_Q> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__IBUS> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__FINAL_V_ALPHA> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__FINAL_V_BETA> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__IQ_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__IQ_MEASURED> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CURRENT_CONTROL__MAX_ALLOWED_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__GATE_DRIVER__DRV_FAULT> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_GENERAL> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_I> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_DC> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_R> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_L> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_ENC_CALIB> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_IDX_SEARCH> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_FOC_VOLTAGE> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__TIMING_LOG__TIMING_LOG_FOC_CURRENT> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__PRE_CALIBRATED> { typedef bool type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__POLE_PAIRS> { typedef int32_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__CALIBRATION_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__RESISTANCE_CALIB_MAX_VOLTAGE> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__PHASE_INDUCTANCE> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__PHASE_RESISTANCE> { typedef float type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__DIRECTION> { typedef int32_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__MOTOR_TYPE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__MOTOR__CONFIG__CURRENT_LIM> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__POS_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__VEL_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__VEL_INTEGRATOR_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__CURRENT_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__CONFIG__CONTROL_MODE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__CONFIG__POS_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__CONFIG__VEL_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__CONFIG__VEL_INTEGRATOR_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS0__CONTROLLER__CONFIG__VEL_LIMIT> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__ERROR> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__ENCODER__IS_READY> { typedef bool type; };
template<> struct endpoint_type<AXIS0__ENCODER__INDEX_FOUND> { typedef bool type; };
template<> struct endpoint_type<AXIS0__ENCODER__SHADOW_COUNT> { typedef int32_t type; };
template<> struct endpoint_type<AXIS0__ENCODER__COUNT_IN_CPR> { typedef int32_t type; };
template<> struct endpoint_type<AXIS0__ENCODER__OFFSET> { typedef int32_t type; };
template<> struct endpoint_type<AXIS0__ENCODER__PHASE> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__POS_ESTIMATE> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__POS_CPR> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__PLL_VEL> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__PLL_KP> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__PLL_KI> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__CONFIG__USE_INDEX> { typedef bool type; };
template<> struct endpoint_type<AXIS0__ENCODER__CONFIG__PRE_CALIBRATED> { typedef bool type; };
template<> struct endpoint_type<AXIS0__ENCODER__CONFIG__IDX_SEARCH_SPEED> { typedef float type; };
template<> struct endpoint_type<AXIS0__ENCODER__CONFIG__CPR> { typedef int32_t type; };
template<> struct endpoint_type<AXIS0__ENCODER__CONFIG__OFFSET> { typedef int32_t type; };
template<> struct endpoint_type<AXIS0__ENCODER__CONFIG__CALIB_RANGE> { typedef float type; };
template<> struct endpoint_type<AXIS0__SENSORLESS_ESTIMATOR__ERROR> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS0__SENSORLESS_ESTIMATOR__PHASE> { typedef float type; };
template<> struct endpoint_type<AXIS0__SENSORLESS_ESTIMATOR__PLL_POS> { typedef float type; };
template<> struct endpoint_type<AXIS0__SENSORLESS_ESTIMATOR__PLL_VEL> { typedef float type; };
template<> struct endpoint_type<AXIS0__SENSORLESS_ESTIMATOR__PLL_KP> { typedef float type; };
template<> struct endpoint_type<AXIS0__SENSORLESS_ESTIMATOR__PLL_KI> { typedef float type; };
template<> struct endpoint_type<AXIS1__ERROR> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__ENABLE_STEP_DIR> { typedef bool type; };
template<> struct endpoint_type<AXIS1__CURRENT_STATE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__REQUESTED_STATE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__LOOP_COUNTER> { typedef uint32_t type; };
template<> struct endpoint_type<AXIS1__CONFIG__STARTUP_MOTOR_CALIBRATION> { typedef bool type; };
template<> struct endpoint_type<AXIS1__CONFIG__STARTUP_ENCODER_INDEX_SEARCH> { typedef bool type; };
template<> struct endpoint_type<AXIS1__CONFIG__STARTUP_ENCODER_OFFSET_CALIBRATION> { typedef bool type; };
template<> struct endpoint_type<AXIS1__CONFIG__STARTUP_CLOSED_LOOP_CONTROL> { typedef bool type; };
template<> struct endpoint_type<AXIS1__CONFIG__STARTUP_SENSORLESS_CONTROL> { typedef bool type; };
template<> struct endpoint_type<AXIS1__CONFIG__ENABLE_STEP_DIR> { typedef bool type; };
template<> struct endpoint_type<AXIS1__CONFIG__COUNTS_PER_STEP> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONFIG__RAMP_UP_TIME> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONFIG__RAMP_UP_DISTANCE> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONFIG__SPIN_UP_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONFIG__SPIN_UP_ACCELERATION> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONFIG__SPIN_UP_TARGET_VEL> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__ERROR> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__ARMED_STATE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__IS_CALIBRATED> { typedef bool type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_MEAS_PHB> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_MEAS_PHC> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__DC_CALIB_PHB> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__DC_CALIB_PHC> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__PHASE_CURRENT_REV_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__P_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__I_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_D> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__V_CURRENT_CONTROL_INTEGRAL_Q> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__IBUS> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__FINAL_V_ALPHA> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__FINAL_V_BETA> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__IQ_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__IQ_MEASURED> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CURRENT_CONTROL__MAX_ALLOWED_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__GATE_DRIVER__DRV_FAULT> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_GENERAL> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_I> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_ADC_CB_DC> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_R> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_MEAS_L> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_ENC_CALIB> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_IDX_SEARCH> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_FOC_VOLTAGE> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__TIMING_LOG__TIMING_LOG_FOC_CURRENT> { typedef uint16_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__PRE_CALIBRATED> { typedef bool type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__POLE_PAIRS> { typedef int32_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__CALIBRATION_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__RESISTANCE_CALIB_MAX_VOLTAGE> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__PHASE_INDUCTANCE> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__PHASE_RESISTANCE> { typedef float type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__DIRECTION> { typedef int32_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__MOTOR_TYPE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__MOTOR__CONFIG__CURRENT_LIM> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__POS_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__VEL_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__VEL_INTEGRATOR_CURRENT> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__CURRENT_SETPOINT> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__CONFIG__CONTROL_MODE> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__CONFIG__POS_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__CONFIG__VEL_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__CONFIG__VEL_INTEGRATOR_GAIN> { typedef float type; };
template<> struct endpoint_type<AXIS1__CONTROLLER__CONFIG__VEL_LIMIT> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__ERROR> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__ENCODER__IS_READY> { typedef bool type; };
template<> struct endpoint_type<AXIS1__ENCODER__INDEX_FOUND> { typedef bool type; };
template<> struct endpoint_type<AXIS1__ENCODER__SHADOW_COUNT> { typedef int32_t type; };
template<> struct endpoint_type<AXIS1__ENCODER__COUNT_IN_CPR> { typedef int32_t type; };
template<> struct endpoint_type<AXIS1__ENCODER__OFFSET> { typedef int32_t type; };
template<> struct endpoint_type<AXIS1__ENCODER__PHASE> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__POS_ESTIMATE> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__POS_CPR> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__PLL_VEL> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__PLL_KP> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__PLL_KI> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__CONFIG__USE_INDEX> { typedef bool type; };
template<> struct endpoint_type<AXIS1__ENCODER__CONFIG__PRE_CALIBRATED> { typedef bool type; };
template<> struct endpoint_type<AXIS1__ENCODER__CONFIG__IDX_SEARCH_SPEED> { typedef float type; };
template<> struct endpoint_type<AXIS1__ENCODER__CONFIG__CPR> { typedef int32_t type; };
template<> struct endpoint_type<AXIS1__ENCODER__CONFIG__OFFSET> { typedef int32_t type; };
template<> struct endpoint_type<AXIS1__ENCODER__CONFIG__CALIB_RANGE> { typedef float type; };
template<> struct endpoint_type<AXIS1__SENSORLESS_ESTIMATOR__ERROR> { typedef uint8_t type; };
template<> struct endpoint_type<AXIS1__SENSORLESS_ESTIMATOR__PHASE> { typedef float type; };
template<> struct endpoint_type<AXIS1__SENSORLESS_ESTIMATOR__PLL_POS> { typedef float type; };
template<> struct endpoint_type<AXIS1__SENSORLESS_ESTIMATOR__PLL_VEL> { typedef float type; };
template<> struct endpoint_type<AXIS1__SENSORLESS_ESTIMATOR__PLL_KP> { typedef float type; };
template<> struct endpoint_type<AXIS1__SENSORLESS_ESTIMATOR__PLL_KI> { typedef float type; };
template<> struct endpoint_type<TEST_PROPERTY> { typedef uint32_t type; };
template<int I>
using endpoint_type_t = typename endpoint_type<I>::type;
}
#endif __ODRIVE_ENDPOINTS_HPP
+267
View File
@@ -0,0 +1,267 @@
/*
* This file is a very small part of the GCC STL because AVR-GCC ships
* without the STL.
*/
namespace std
{
/**
* @defgroup metaprogramming Metaprogramming
* @ingroup utilities
*
* Template utilities for compile-time introspection and modification,
* including type classification traits, type property inspection traits
* and type transformation traits.
*
* @{
*/
/// integral_constant
template<typename _Tp, _Tp __v>
struct integral_constant
{
static constexpr _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant<_Tp, __v> type;
constexpr operator value_type() const noexcept { return value; }
#if __cplusplus > 201103L
#define __cpp_lib_integral_constant_callable 201304
constexpr value_type operator()() const noexcept { return value; }
#endif
};
template<typename _Tp, _Tp __v>
constexpr _Tp integral_constant<_Tp, __v>::value;
/// The type used as a compile-time boolean with true value.
typedef integral_constant<bool, true> true_type;
/// The type used as a compile-time boolean with false value.
typedef integral_constant<bool, false> false_type;
template<bool __v>
using __bool_constant = integral_constant<bool, __v>;
#if __cplusplus > 201402L
# define __cpp_lib_bool_constant 201505
template<bool __v>
using bool_constant = integral_constant<bool, __v>;
#endif
// Primary type categories.
template<typename>
struct remove_cv;
template<typename>
struct __is_void_helper
: public false_type { };
template<>
struct __is_void_helper<void>
: public true_type { };
/// is_void
template<typename _Tp>
struct is_void
: public __is_void_helper<typename remove_cv<_Tp>::type>::type
{ };
template<typename>
struct __is_integral_helper
: public false_type { };
template<>
struct __is_integral_helper<bool>
: public true_type { };
template<>
struct __is_integral_helper<char>
: public true_type { };
template<>
struct __is_integral_helper<signed char>
: public true_type { };
template<>
struct __is_integral_helper<unsigned char>
: public true_type { };
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
struct __is_integral_helper<wchar_t>
: public true_type { };
#endif
template<>
struct __is_integral_helper<char16_t>
: public true_type { };
template<>
struct __is_integral_helper<char32_t>
: public true_type { };
template<>
struct __is_integral_helper<short>
: public true_type { };
template<>
struct __is_integral_helper<unsigned short>
: public true_type { };
template<>
struct __is_integral_helper<int>
: public true_type { };
template<>
struct __is_integral_helper<unsigned int>
: public true_type { };
template<>
struct __is_integral_helper<long>
: public true_type { };
template<>
struct __is_integral_helper<unsigned long>
: public true_type { };
template<>
struct __is_integral_helper<long long>
: public true_type { };
template<>
struct __is_integral_helper<unsigned long long>
: public true_type { };
// Conditionalizing on __STRICT_ANSI__ here will break any port that
// uses one of these types for size_t.
#if defined(__GLIBCXX_TYPE_INT_N_0)
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
: public true_type { };
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
: public true_type { };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_1)
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
: public true_type { };
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
: public true_type { };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_2)
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
: public true_type { };
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
: public true_type { };
#endif
#if defined(__GLIBCXX_TYPE_INT_N_3)
template<>
struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
: public true_type { };
template<>
struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
: public true_type { };
#endif
/// is_integral
template<typename _Tp>
struct is_integral
: public __is_integral_helper<typename remove_cv<_Tp>::type>::type
{ };
template<typename>
struct __is_floating_point_helper
: public false_type { };
template<>
struct __is_floating_point_helper<float>
: public true_type { };
template<>
struct __is_floating_point_helper<double>
: public true_type { };
template<>
struct __is_floating_point_helper<long double>
: public true_type { };
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
template<>
struct __is_floating_point_helper<__float128>
: public true_type { };
#endif
/// is_floating_point
template<typename _Tp>
struct is_floating_point
: public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type
{ };
// Const-volatile modifications.
/// remove_const
template<typename _Tp>
struct remove_const
{ typedef _Tp type; };
template<typename _Tp>
struct remove_const<_Tp const>
{ typedef _Tp type; };
/// remove_volatile
template<typename _Tp>
struct remove_volatile
{ typedef _Tp type; };
template<typename _Tp>
struct remove_volatile<_Tp volatile>
{ typedef _Tp type; };
/// remove_cv
template<typename _Tp>
struct remove_cv
{
typedef typename
remove_const<typename remove_volatile<_Tp>::type>::type type;
};
// Primary template.
/// Define a member typedef @c type only if a boolean constant is true.
template<bool, typename _Tp = void>
struct enable_if
{ };
// Partial specialization for true.
template<typename _Tp>
struct enable_if<true, _Tp>
{ typedef _Tp type; };
// Type relations.
/// is_same
template<typename, typename>
struct is_same
: public false_type { };
template<typename _Tp>
struct is_same<_Tp, _Tp>
: public true_type { };
}