X-CUBE-SPN1-20150128 example source code for one motor compiled under mbed. Tested OK on Nucleo F401. l6474.cpp is modified from original with defines in l6474_target_config.h to select the original behaviour (motor de-energised when halted), or new mode to continue powering with a (reduced) current in the coils (braking/position hold capability). On F401 avoid using mbed's InterruptIn on pins 10-15 (any port). Beware of other conflicts! L0 & F0 are included but untested.

Dependencies:   mbed

Committer:
gregeric
Date:
Tue Oct 13 10:46:01 2015 +0000
Revision:
6:19c1b4a04c24
Parent:
0:b9444a40a999
Ensure bridge is disabled before resetting the L6474.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gregeric 0:b9444a40a999 1 /* Copyright (C) ARM Ltd., 1999,2014 */
gregeric 0:b9444a40a999 2 /* All rights reserved */
gregeric 0:b9444a40a999 3
gregeric 0:b9444a40a999 4 /*
gregeric 0:b9444a40a999 5 * RCS $Revision: 185525 $
gregeric 0:b9444a40a999 6 * Checkin $Date: 2014-05-29 12:44:48 +0100 (Thu, 29 May 2014) $
gregeric 0:b9444a40a999 7 * Revising $Author: agrant $
gregeric 0:b9444a40a999 8 */
gregeric 0:b9444a40a999 9
gregeric 0:b9444a40a999 10 #ifndef __stdint_h
gregeric 0:b9444a40a999 11 #define __stdint_h
gregeric 0:b9444a40a999 12 #define __ARMCLIB_VERSION 5060001
gregeric 0:b9444a40a999 13
gregeric 0:b9444a40a999 14 #ifdef __INT64_TYPE__
gregeric 0:b9444a40a999 15 /* armclang predefines '__INT64_TYPE__' and '__INT64_C_SUFFIX__' */
gregeric 0:b9444a40a999 16 #define __INT64 __INT64_TYPE__
gregeric 0:b9444a40a999 17 #else
gregeric 0:b9444a40a999 18 /* armcc has builtin '__int64' which can be used in --strict mode */
gregeric 0:b9444a40a999 19 #define __INT64 __int64
gregeric 0:b9444a40a999 20 #define __INT64_C_SUFFIX__ ll
gregeric 0:b9444a40a999 21 #endif
gregeric 0:b9444a40a999 22 #define __PASTE2(x, y) x ## y
gregeric 0:b9444a40a999 23 #define __PASTE(x, y) __PASTE2(x, y)
gregeric 0:b9444a40a999 24 #define __INT64_C(x) __ESCAPE__(__PASTE(x, __INT64_C_SUFFIX__))
gregeric 0:b9444a40a999 25 #define __UINT64_C(x) __ESCAPE__(__PASTE(x ## u, __INT64_C_SUFFIX__))
gregeric 0:b9444a40a999 26 #if defined(__clang__) || (defined(__ARMCC_VERSION) && !defined(__STRICT_ANSI__))
gregeric 0:b9444a40a999 27 /* armclang and non-strict armcc allow 'long long' in system headers */
gregeric 0:b9444a40a999 28 #define __LONGLONG long long
gregeric 0:b9444a40a999 29 #else
gregeric 0:b9444a40a999 30 /* strict armcc has '__int64' */
gregeric 0:b9444a40a999 31 #define __LONGLONG __int64
gregeric 0:b9444a40a999 32 #endif
gregeric 0:b9444a40a999 33
gregeric 0:b9444a40a999 34 #ifndef __STDINT_DECLS
gregeric 0:b9444a40a999 35 #define __STDINT_DECLS
gregeric 0:b9444a40a999 36
gregeric 0:b9444a40a999 37 #undef __CLIBNS
gregeric 0:b9444a40a999 38
gregeric 0:b9444a40a999 39 #ifdef __cplusplus
gregeric 0:b9444a40a999 40 namespace std {
gregeric 0:b9444a40a999 41 #define __CLIBNS std::
gregeric 0:b9444a40a999 42 extern "C" {
gregeric 0:b9444a40a999 43 #else
gregeric 0:b9444a40a999 44 #define __CLIBNS
gregeric 0:b9444a40a999 45 #endif /* __cplusplus */
gregeric 0:b9444a40a999 46
gregeric 0:b9444a40a999 47
gregeric 0:b9444a40a999 48 /*
gregeric 0:b9444a40a999 49 * 'signed' is redundant below, except for 'signed char' and if
gregeric 0:b9444a40a999 50 * the typedef is used to declare a bitfield.
gregeric 0:b9444a40a999 51 */
gregeric 0:b9444a40a999 52
gregeric 0:b9444a40a999 53 /* 7.18.1.1 */
gregeric 0:b9444a40a999 54
gregeric 0:b9444a40a999 55 /* exact-width signed integer types */
gregeric 0:b9444a40a999 56 typedef signed char int8_t;
gregeric 0:b9444a40a999 57 typedef signed short int int16_t;
gregeric 0:b9444a40a999 58 typedef signed int int32_t;
gregeric 0:b9444a40a999 59 typedef signed __INT64 int64_t;
gregeric 0:b9444a40a999 60
gregeric 0:b9444a40a999 61 /* exact-width unsigned integer types */
gregeric 0:b9444a40a999 62 typedef unsigned char uint8_t;
gregeric 0:b9444a40a999 63 typedef unsigned short int uint16_t;
gregeric 0:b9444a40a999 64 typedef unsigned int uint32_t;
gregeric 0:b9444a40a999 65 typedef unsigned __INT64 uint64_t;
gregeric 0:b9444a40a999 66
gregeric 0:b9444a40a999 67 /* 7.18.1.2 */
gregeric 0:b9444a40a999 68
gregeric 0:b9444a40a999 69 /* smallest type of at least n bits */
gregeric 0:b9444a40a999 70 /* minimum-width signed integer types */
gregeric 0:b9444a40a999 71 typedef signed char int_least8_t;
gregeric 0:b9444a40a999 72 typedef signed short int int_least16_t;
gregeric 0:b9444a40a999 73 typedef signed int int_least32_t;
gregeric 0:b9444a40a999 74 typedef signed __INT64 int_least64_t;
gregeric 0:b9444a40a999 75
gregeric 0:b9444a40a999 76 /* minimum-width unsigned integer types */
gregeric 0:b9444a40a999 77 typedef unsigned char uint_least8_t;
gregeric 0:b9444a40a999 78 typedef unsigned short int uint_least16_t;
gregeric 0:b9444a40a999 79 typedef unsigned int uint_least32_t;
gregeric 0:b9444a40a999 80 typedef unsigned __INT64 uint_least64_t;
gregeric 0:b9444a40a999 81
gregeric 0:b9444a40a999 82 /* 7.18.1.3 */
gregeric 0:b9444a40a999 83
gregeric 0:b9444a40a999 84 /* fastest minimum-width signed integer types */
gregeric 0:b9444a40a999 85 typedef signed int int_fast8_t;
gregeric 0:b9444a40a999 86 typedef signed int int_fast16_t;
gregeric 0:b9444a40a999 87 typedef signed int int_fast32_t;
gregeric 0:b9444a40a999 88 typedef signed __INT64 int_fast64_t;
gregeric 0:b9444a40a999 89
gregeric 0:b9444a40a999 90 /* fastest minimum-width unsigned integer types */
gregeric 0:b9444a40a999 91 typedef unsigned int uint_fast8_t;
gregeric 0:b9444a40a999 92 typedef unsigned int uint_fast16_t;
gregeric 0:b9444a40a999 93 typedef unsigned int uint_fast32_t;
gregeric 0:b9444a40a999 94 typedef unsigned __INT64 uint_fast64_t;
gregeric 0:b9444a40a999 95
gregeric 0:b9444a40a999 96 /* 7.18.1.4 integer types capable of holding object pointers */
gregeric 0:b9444a40a999 97 #if __sizeof_ptr == 8
gregeric 0:b9444a40a999 98 typedef signed __INT64 intptr_t;
gregeric 0:b9444a40a999 99 typedef unsigned __INT64 uintptr_t;
gregeric 0:b9444a40a999 100 #else
gregeric 0:b9444a40a999 101 typedef signed int intptr_t;
gregeric 0:b9444a40a999 102 typedef unsigned int uintptr_t;
gregeric 0:b9444a40a999 103 #endif
gregeric 0:b9444a40a999 104
gregeric 0:b9444a40a999 105 /* 7.18.1.5 greatest-width integer types */
gregeric 0:b9444a40a999 106 typedef signed __LONGLONG intmax_t;
gregeric 0:b9444a40a999 107 typedef unsigned __LONGLONG uintmax_t;
gregeric 0:b9444a40a999 108
gregeric 0:b9444a40a999 109
gregeric 0:b9444a40a999 110 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
gregeric 0:b9444a40a999 111
gregeric 0:b9444a40a999 112 /* 7.18.2.1 */
gregeric 0:b9444a40a999 113
gregeric 0:b9444a40a999 114 /* minimum values of exact-width signed integer types */
gregeric 0:b9444a40a999 115 #define INT8_MIN -128
gregeric 0:b9444a40a999 116 #define INT16_MIN -32768
gregeric 0:b9444a40a999 117 #define INT32_MIN (~0x7fffffff) /* -2147483648 is unsigned */
gregeric 0:b9444a40a999 118 #define INT64_MIN __INT64_C(~0x7fffffffffffffff) /* -9223372036854775808 is unsigned */
gregeric 0:b9444a40a999 119
gregeric 0:b9444a40a999 120 /* maximum values of exact-width signed integer types */
gregeric 0:b9444a40a999 121 #define INT8_MAX 127
gregeric 0:b9444a40a999 122 #define INT16_MAX 32767
gregeric 0:b9444a40a999 123 #define INT32_MAX 2147483647
gregeric 0:b9444a40a999 124 #define INT64_MAX __INT64_C(9223372036854775807)
gregeric 0:b9444a40a999 125
gregeric 0:b9444a40a999 126 /* maximum values of exact-width unsigned integer types */
gregeric 0:b9444a40a999 127 #define UINT8_MAX 255
gregeric 0:b9444a40a999 128 #define UINT16_MAX 65535
gregeric 0:b9444a40a999 129 #define UINT32_MAX 4294967295u
gregeric 0:b9444a40a999 130 #define UINT64_MAX __UINT64_C(18446744073709551615)
gregeric 0:b9444a40a999 131
gregeric 0:b9444a40a999 132 /* 7.18.2.2 */
gregeric 0:b9444a40a999 133
gregeric 0:b9444a40a999 134 /* minimum values of minimum-width signed integer types */
gregeric 0:b9444a40a999 135 #define INT_LEAST8_MIN -128
gregeric 0:b9444a40a999 136 #define INT_LEAST16_MIN -32768
gregeric 0:b9444a40a999 137 #define INT_LEAST32_MIN (~0x7fffffff)
gregeric 0:b9444a40a999 138 #define INT_LEAST64_MIN __INT64_C(~0x7fffffffffffffff)
gregeric 0:b9444a40a999 139
gregeric 0:b9444a40a999 140 /* maximum values of minimum-width signed integer types */
gregeric 0:b9444a40a999 141 #define INT_LEAST8_MAX 127
gregeric 0:b9444a40a999 142 #define INT_LEAST16_MAX 32767
gregeric 0:b9444a40a999 143 #define INT_LEAST32_MAX 2147483647
gregeric 0:b9444a40a999 144 #define INT_LEAST64_MAX __INT64_C(9223372036854775807)
gregeric 0:b9444a40a999 145
gregeric 0:b9444a40a999 146 /* maximum values of minimum-width unsigned integer types */
gregeric 0:b9444a40a999 147 #define UINT_LEAST8_MAX 255
gregeric 0:b9444a40a999 148 #define UINT_LEAST16_MAX 65535
gregeric 0:b9444a40a999 149 #define UINT_LEAST32_MAX 4294967295u
gregeric 0:b9444a40a999 150 #define UINT_LEAST64_MAX __UINT64_C(18446744073709551615)
gregeric 0:b9444a40a999 151
gregeric 0:b9444a40a999 152 /* 7.18.2.3 */
gregeric 0:b9444a40a999 153
gregeric 0:b9444a40a999 154 /* minimum values of fastest minimum-width signed integer types */
gregeric 0:b9444a40a999 155 #define INT_FAST8_MIN (~0x7fffffff)
gregeric 0:b9444a40a999 156 #define INT_FAST16_MIN (~0x7fffffff)
gregeric 0:b9444a40a999 157 #define INT_FAST32_MIN (~0x7fffffff)
gregeric 0:b9444a40a999 158 #define INT_FAST64_MIN __INT64_C(~0x7fffffffffffffff)
gregeric 0:b9444a40a999 159
gregeric 0:b9444a40a999 160 /* maximum values of fastest minimum-width signed integer types */
gregeric 0:b9444a40a999 161 #define INT_FAST8_MAX 2147483647
gregeric 0:b9444a40a999 162 #define INT_FAST16_MAX 2147483647
gregeric 0:b9444a40a999 163 #define INT_FAST32_MAX 2147483647
gregeric 0:b9444a40a999 164 #define INT_FAST64_MAX __INT64_C(9223372036854775807)
gregeric 0:b9444a40a999 165
gregeric 0:b9444a40a999 166 /* maximum values of fastest minimum-width unsigned integer types */
gregeric 0:b9444a40a999 167 #define UINT_FAST8_MAX 4294967295u
gregeric 0:b9444a40a999 168 #define UINT_FAST16_MAX 4294967295u
gregeric 0:b9444a40a999 169 #define UINT_FAST32_MAX 4294967295u
gregeric 0:b9444a40a999 170 #define UINT_FAST64_MAX __UINT64_C(18446744073709551615)
gregeric 0:b9444a40a999 171
gregeric 0:b9444a40a999 172 /* 7.18.2.4 */
gregeric 0:b9444a40a999 173
gregeric 0:b9444a40a999 174 /* minimum value of pointer-holding signed integer type */
gregeric 0:b9444a40a999 175 #if __sizeof_ptr == 8
gregeric 0:b9444a40a999 176 #define INTPTR_MIN INT64_MIN
gregeric 0:b9444a40a999 177 #else
gregeric 0:b9444a40a999 178 #define INTPTR_MIN INT32_MIN
gregeric 0:b9444a40a999 179 #endif
gregeric 0:b9444a40a999 180
gregeric 0:b9444a40a999 181 /* maximum value of pointer-holding signed integer type */
gregeric 0:b9444a40a999 182 #if __sizeof_ptr == 8
gregeric 0:b9444a40a999 183 #define INTPTR_MAX INT64_MAX
gregeric 0:b9444a40a999 184 #else
gregeric 0:b9444a40a999 185 #define INTPTR_MAX INT32_MAX
gregeric 0:b9444a40a999 186 #endif
gregeric 0:b9444a40a999 187
gregeric 0:b9444a40a999 188 /* maximum value of pointer-holding unsigned integer type */
gregeric 0:b9444a40a999 189 #if __sizeof_ptr == 8
gregeric 0:b9444a40a999 190 #define UINTPTR_MAX INT64_MAX
gregeric 0:b9444a40a999 191 #else
gregeric 0:b9444a40a999 192 #define UINTPTR_MAX INT32_MAX
gregeric 0:b9444a40a999 193 #endif
gregeric 0:b9444a40a999 194
gregeric 0:b9444a40a999 195 /* 7.18.2.5 */
gregeric 0:b9444a40a999 196
gregeric 0:b9444a40a999 197 /* minimum value of greatest-width signed integer type */
gregeric 0:b9444a40a999 198 #define INTMAX_MIN __ESCAPE__(~0x7fffffffffffffffll)
gregeric 0:b9444a40a999 199
gregeric 0:b9444a40a999 200 /* maximum value of greatest-width signed integer type */
gregeric 0:b9444a40a999 201 #define INTMAX_MAX __ESCAPE__(9223372036854775807ll)
gregeric 0:b9444a40a999 202
gregeric 0:b9444a40a999 203 /* maximum value of greatest-width unsigned integer type */
gregeric 0:b9444a40a999 204 #define UINTMAX_MAX __ESCAPE__(18446744073709551615ull)
gregeric 0:b9444a40a999 205
gregeric 0:b9444a40a999 206 /* 7.18.3 */
gregeric 0:b9444a40a999 207
gregeric 0:b9444a40a999 208 /* limits of ptrdiff_t */
gregeric 0:b9444a40a999 209 #if __sizeof_ptr == 8
gregeric 0:b9444a40a999 210 #define PTRDIFF_MIN INT64_MIN
gregeric 0:b9444a40a999 211 #define PTRDIFF_MAX INT64_MAX
gregeric 0:b9444a40a999 212 #else
gregeric 0:b9444a40a999 213 #define PTRDIFF_MIN INT32_MIN
gregeric 0:b9444a40a999 214 #define PTRDIFF_MAX INT32_MAX
gregeric 0:b9444a40a999 215 #endif
gregeric 0:b9444a40a999 216
gregeric 0:b9444a40a999 217 /* limits of sig_atomic_t */
gregeric 0:b9444a40a999 218 #define SIG_ATOMIC_MIN (~0x7fffffff)
gregeric 0:b9444a40a999 219 #define SIG_ATOMIC_MAX 2147483647
gregeric 0:b9444a40a999 220
gregeric 0:b9444a40a999 221 /* limit of size_t */
gregeric 0:b9444a40a999 222 #if __sizeof_ptr == 8
gregeric 0:b9444a40a999 223 #define SIZE_MAX UINT64_MAX
gregeric 0:b9444a40a999 224 #else
gregeric 0:b9444a40a999 225 #define SIZE_MAX UINT32_MAX
gregeric 0:b9444a40a999 226 #endif
gregeric 0:b9444a40a999 227
gregeric 0:b9444a40a999 228 /* limits of wchar_t */
gregeric 0:b9444a40a999 229 /* NB we have to undef and redef because they're defined in both
gregeric 0:b9444a40a999 230 * stdint.h and wchar.h */
gregeric 0:b9444a40a999 231 #undef WCHAR_MIN
gregeric 0:b9444a40a999 232 #undef WCHAR_MAX
gregeric 0:b9444a40a999 233
gregeric 0:b9444a40a999 234 #if defined(__WCHAR32) || (defined(__ARM_SIZEOF_WCHAR_T) && __ARM_SIZEOF_WCHAR_T == 4)
gregeric 0:b9444a40a999 235 #define WCHAR_MIN 0
gregeric 0:b9444a40a999 236 #define WCHAR_MAX 0xffffffffU
gregeric 0:b9444a40a999 237 #else
gregeric 0:b9444a40a999 238 #define WCHAR_MIN 0
gregeric 0:b9444a40a999 239 #define WCHAR_MAX 65535
gregeric 0:b9444a40a999 240 #endif
gregeric 0:b9444a40a999 241
gregeric 0:b9444a40a999 242 /* limits of wint_t */
gregeric 0:b9444a40a999 243 #define WINT_MIN (~0x7fffffff)
gregeric 0:b9444a40a999 244 #define WINT_MAX 2147483647
gregeric 0:b9444a40a999 245
gregeric 0:b9444a40a999 246 #endif /* __STDC_LIMIT_MACROS */
gregeric 0:b9444a40a999 247
gregeric 0:b9444a40a999 248 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
gregeric 0:b9444a40a999 249
gregeric 0:b9444a40a999 250 /* 7.18.4.1 macros for minimum-width integer constants */
gregeric 0:b9444a40a999 251 #define INT8_C(x) (x)
gregeric 0:b9444a40a999 252 #define INT16_C(x) (x)
gregeric 0:b9444a40a999 253 #define INT32_C(x) (x)
gregeric 0:b9444a40a999 254 #define INT64_C(x) __INT64_C(x)
gregeric 0:b9444a40a999 255
gregeric 0:b9444a40a999 256 #define UINT8_C(x) (x ## u)
gregeric 0:b9444a40a999 257 #define UINT16_C(x) (x ## u)
gregeric 0:b9444a40a999 258 #define UINT32_C(x) (x ## u)
gregeric 0:b9444a40a999 259 #define UINT64_C(x) __UINT64_C(x)
gregeric 0:b9444a40a999 260
gregeric 0:b9444a40a999 261 /* 7.18.4.2 macros for greatest-width integer constants */
gregeric 0:b9444a40a999 262 #define INTMAX_C(x) __ESCAPE__(x ## ll)
gregeric 0:b9444a40a999 263 #define UINTMAX_C(x) __ESCAPE__(x ## ull)
gregeric 0:b9444a40a999 264
gregeric 0:b9444a40a999 265 #endif /* __STDC_CONSTANT_MACROS */
gregeric 0:b9444a40a999 266
gregeric 0:b9444a40a999 267 #ifdef __cplusplus
gregeric 0:b9444a40a999 268 } /* extern "C" */
gregeric 0:b9444a40a999 269 } /* namespace std */
gregeric 0:b9444a40a999 270 #endif /* __cplusplus */
gregeric 0:b9444a40a999 271 #endif /* __STDINT_DECLS */
gregeric 0:b9444a40a999 272
gregeric 0:b9444a40a999 273 #ifdef __cplusplus
gregeric 0:b9444a40a999 274 #ifndef __STDINT_NO_EXPORTS
gregeric 0:b9444a40a999 275 using ::std::int8_t;
gregeric 0:b9444a40a999 276 using ::std::int16_t;
gregeric 0:b9444a40a999 277 using ::std::int32_t;
gregeric 0:b9444a40a999 278 using ::std::int64_t;
gregeric 0:b9444a40a999 279 using ::std::uint8_t;
gregeric 0:b9444a40a999 280 using ::std::uint16_t;
gregeric 0:b9444a40a999 281 using ::std::uint32_t;
gregeric 0:b9444a40a999 282 using ::std::uint64_t;
gregeric 0:b9444a40a999 283 using ::std::int_least8_t;
gregeric 0:b9444a40a999 284 using ::std::int_least16_t;
gregeric 0:b9444a40a999 285 using ::std::int_least32_t;
gregeric 0:b9444a40a999 286 using ::std::int_least64_t;
gregeric 0:b9444a40a999 287 using ::std::uint_least8_t;
gregeric 0:b9444a40a999 288 using ::std::uint_least16_t;
gregeric 0:b9444a40a999 289 using ::std::uint_least32_t;
gregeric 0:b9444a40a999 290 using ::std::uint_least64_t;
gregeric 0:b9444a40a999 291 using ::std::int_fast8_t;
gregeric 0:b9444a40a999 292 using ::std::int_fast16_t;
gregeric 0:b9444a40a999 293 using ::std::int_fast32_t;
gregeric 0:b9444a40a999 294 using ::std::int_fast64_t;
gregeric 0:b9444a40a999 295 using ::std::uint_fast8_t;
gregeric 0:b9444a40a999 296 using ::std::uint_fast16_t;
gregeric 0:b9444a40a999 297 using ::std::uint_fast32_t;
gregeric 0:b9444a40a999 298 using ::std::uint_fast64_t;
gregeric 0:b9444a40a999 299 using ::std::intptr_t;
gregeric 0:b9444a40a999 300 using ::std::uintptr_t;
gregeric 0:b9444a40a999 301 using ::std::intmax_t;
gregeric 0:b9444a40a999 302 using ::std::uintmax_t;
gregeric 0:b9444a40a999 303 #endif
gregeric 0:b9444a40a999 304 #endif /* __cplusplus */
gregeric 0:b9444a40a999 305
gregeric 0:b9444a40a999 306 #undef __INT64
gregeric 0:b9444a40a999 307 #undef __LONGLONG
gregeric 0:b9444a40a999 308
gregeric 0:b9444a40a999 309 #endif /* __stdint_h */
gregeric 0:b9444a40a999 310
gregeric 0:b9444a40a999 311 /* end of stdint.h */