2018.07.26
Dependencies: QEI mbed-rtos mbed
common.h@2:c62dc496b79a, 2016-04-14 (annotated)
- Committer:
- sayzyas
- Date:
- Thu Apr 14 10:27:21 2016 +0000
- Revision:
- 2:c62dc496b79a
- Parent:
- 1:86705c6e0ab7
- Child:
- 3:85eb7e954bfa
2016.04.14
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sayzyas | 0:b1136bf48c38 | 1 | /* |
sayzyas | 0:b1136bf48c38 | 2 | * mbed LPC824-Max header |
sayzyas | 0:b1136bf48c38 | 3 | * |
sayzyas | 0:b1136bf48c38 | 4 | */ |
sayzyas | 0:b1136bf48c38 | 5 | |
sayzyas | 0:b1136bf48c38 | 6 | #define __DEBUG__ |
sayzyas | 0:b1136bf48c38 | 7 | #ifdef __DEBUG__ |
sayzyas | 0:b1136bf48c38 | 8 | #define DEBUG_PRINT(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:b1136bf48c38 | 9 | #else |
sayzyas | 0:b1136bf48c38 | 10 | #define DEBUG_PRINT(...) ; |
sayzyas | 0:b1136bf48c38 | 11 | //#define DEBUG_PRINT(...) 1 ? (void)0 : pc.printf(__VA_ARGS__) |
sayzyas | 0:b1136bf48c38 | 12 | #endif |
sayzyas | 0:b1136bf48c38 | 13 | /* Information */ |
sayzyas | 0:b1136bf48c38 | 14 | #define LatestUpDate "2015.12.21" |
sayzyas | 0:b1136bf48c38 | 15 | #define ProgramRevision "RC2015.12.21" |
sayzyas | 0:b1136bf48c38 | 16 | #define Author "Sayzyas" |
sayzyas | 0:b1136bf48c38 | 17 | #define Company "Revast Co.,Ltd" |
sayzyas | 0:b1136bf48c38 | 18 | |
sayzyas | 0:b1136bf48c38 | 19 | |
sayzyas | 0:b1136bf48c38 | 20 | /* Debug macro */ |
sayzyas | 0:b1136bf48c38 | 21 | #define __DEBUG_L0__ |
sayzyas | 0:b1136bf48c38 | 22 | #define __DEBUG_L1__ |
sayzyas | 0:b1136bf48c38 | 23 | #define __DEBUG_L2__ |
sayzyas | 0:b1136bf48c38 | 24 | #define __DEBUG_L3__ |
sayzyas | 0:b1136bf48c38 | 25 | #define __DEBUG_L4__ |
sayzyas | 0:b1136bf48c38 | 26 | |
sayzyas | 0:b1136bf48c38 | 27 | #ifdef __DEBUG_L0__ |
sayzyas | 0:b1136bf48c38 | 28 | #define DEBUG_PRINT_L0(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:b1136bf48c38 | 29 | #else |
sayzyas | 0:b1136bf48c38 | 30 | #define DEBUG_PRINT_L0(...) |
sayzyas | 0:b1136bf48c38 | 31 | #endif |
sayzyas | 0:b1136bf48c38 | 32 | #ifdef __DEBUG_L1__ |
sayzyas | 0:b1136bf48c38 | 33 | #define DEBUG_PRINT_L1(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:b1136bf48c38 | 34 | #else |
sayzyas | 0:b1136bf48c38 | 35 | #define DEBUG_PRINT_L1(...) |
sayzyas | 0:b1136bf48c38 | 36 | #endif |
sayzyas | 0:b1136bf48c38 | 37 | #ifdef __DEBUG_L2__ |
sayzyas | 0:b1136bf48c38 | 38 | #define DEBUG_PRINT_L2(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:b1136bf48c38 | 39 | #else |
sayzyas | 0:b1136bf48c38 | 40 | #define DEBUG_PRINT_L2(...) |
sayzyas | 0:b1136bf48c38 | 41 | #endif |
sayzyas | 0:b1136bf48c38 | 42 | #ifdef __DEBUG_L3__ |
sayzyas | 0:b1136bf48c38 | 43 | #define DEBUG_PRINT_L3(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:b1136bf48c38 | 44 | #else |
sayzyas | 0:b1136bf48c38 | 45 | #define DEBUG_PRINT_L3(...) |
sayzyas | 0:b1136bf48c38 | 46 | #endif |
sayzyas | 0:b1136bf48c38 | 47 | #ifdef __DEBUG_L4__ |
sayzyas | 0:b1136bf48c38 | 48 | #define DEBUG_PRINT_L4(...) pc.printf(__VA_ARGS__) |
sayzyas | 0:b1136bf48c38 | 49 | #else |
sayzyas | 0:b1136bf48c38 | 50 | #define DEBUG_PRINT_L4(...) |
sayzyas | 0:b1136bf48c38 | 51 | #endif |
sayzyas | 0:b1136bf48c38 | 52 | |
sayzyas | 2:c62dc496b79a | 53 | #define NumberOfI2CCommand 14 |
sayzyas | 2:c62dc496b79a | 54 | |
sayzyas | 2:c62dc496b79a | 55 | /* For resolver reader controller */ |
sayzyas | 2:c62dc496b79a | 56 | enum{ |
sayzyas | 2:c62dc496b79a | 57 | I2C_CP_PREAMBLE_R, // Preamble of command packet |
sayzyas | 2:c62dc496b79a | 58 | I2C_CP_COMMAND_R, // instruction command |
sayzyas | 2:c62dc496b79a | 59 | I2C_CP_WDRAM_DIA_UPPER, // motor1 rotation direction |
sayzyas | 2:c62dc496b79a | 60 | I2C_CP_WDRAM_DIA_LOWER, // motor1 rotation speed |
sayzyas | 2:c62dc496b79a | 61 | I2C_CP_CCABLE_DIA_UPPER, // motor1 current limit detection threshold upper byte |
sayzyas | 2:c62dc496b79a | 62 | I2C_CP_CCABLE_DIA_LOWER, // motor1 current limit detection threshold lower byte |
sayzyas | 2:c62dc496b79a | 63 | I2C_CP_RESOLVER_RESO, // motor1 current limit detection threshold upper byte |
sayzyas | 2:c62dc496b79a | 64 | I2C_CP_RES1, // reserved |
sayzyas | 2:c62dc496b79a | 65 | I2C_CP_RES2, // reserved |
sayzyas | 2:c62dc496b79a | 66 | I2C_CP_RES3, // reserved |
sayzyas | 2:c62dc496b79a | 67 | I2C_CP_RES4, // reserved |
sayzyas | 2:c62dc496b79a | 68 | I2C_CP_RES5, // reserved |
sayzyas | 2:c62dc496b79a | 69 | I2C_CP_RES6, // reserved |
sayzyas | 2:c62dc496b79a | 70 | I2C_CP_RES7, // reserved |
sayzyas | 2:c62dc496b79a | 71 | }; |
sayzyas | 0:b1136bf48c38 | 72 | |
sayzyas | 0:b1136bf48c38 | 73 | #define ROTATE_PER_RESOLUTION 24 |
sayzyas | 0:b1136bf48c38 | 74 | #define REAL_THREAD_DIAMETER 63 // 60+3 |
sayzyas | 0:b1136bf48c38 | 75 | //#define ROTATION_DISTANCE 197.82f // (60+3)*3.14 |
sayzyas | 0:b1136bf48c38 | 76 | #define ROTATION_PULSE_PER_1ROUND 16384 // 2^12(bit) * 4 |
sayzyas | 0:b1136bf48c38 | 77 | #define PAI 3.1415 |
sayzyas | 0:b1136bf48c38 | 78 | |
sayzyas | 0:b1136bf48c38 | 79 | /* ***************** */ |
sayzyas | 0:b1136bf48c38 | 80 | /* Target definition */ |
sayzyas | 0:b1136bf48c38 | 81 | /* ***************** */ |
sayzyas | 1:86705c6e0ab7 | 82 | #define I2C_ADDRESS_RESOLVER 0x02 |
sayzyas | 1:86705c6e0ab7 | 83 | #define Target_IIC_ADDR 0x02 // For Resolver count controller |
sayzyas | 0:b1136bf48c38 | 84 | |
sayzyas | 0:b1136bf48c38 | 85 | |
sayzyas | 0:b1136bf48c38 | 86 | /* Command Packet */ |
sayzyas | 0:b1136bf48c38 | 87 | #define CLEAR_RESOLVER_POSITION 'X' |
sayzyas | 0:b1136bf48c38 | 88 | #define HELLO_PACKET 'A' |
sayzyas | 0:b1136bf48c38 | 89 | |
sayzyas | 0:b1136bf48c38 | 90 | #define LED_ON 0 |
sayzyas | 0:b1136bf48c38 | 91 | #define LED_OFF 1 |