2018.07.26

Dependencies:   QEI mbed-rtos mbed

common.h

Committer:
sayzyas
Date:
2016-04-14
Revision:
2:c62dc496b79a
Parent:
1:86705c6e0ab7
Child:
3:85eb7e954bfa

File content as of revision 2:c62dc496b79a:

/*
 * mbed LPC824-Max header
 *
 */

#define __DEBUG__
#ifdef __DEBUG__
#define DEBUG_PRINT(...)  pc.printf(__VA_ARGS__)
#else
#define DEBUG_PRINT(...)  ;
//#define DEBUG_PRINT(...)  1 ? (void)0 : pc.printf(__VA_ARGS__)
#endif
/* Information */
#define LatestUpDate "2015.12.21"
#define ProgramRevision "RC2015.12.21" 
#define Author "Sayzyas"
#define Company "Revast Co.,Ltd"


/* Debug macro */
#define __DEBUG_L0__
#define __DEBUG_L1__
#define __DEBUG_L2__
#define __DEBUG_L3__
#define __DEBUG_L4__

#ifdef __DEBUG_L0__
    #define DEBUG_PRINT_L0(...)  pc.printf(__VA_ARGS__)
#else
    #define DEBUG_PRINT_L0(...) 
#endif
#ifdef __DEBUG_L1__
    #define DEBUG_PRINT_L1(...)  pc.printf(__VA_ARGS__)
#else
    #define DEBUG_PRINT_L1(...) 
#endif
#ifdef __DEBUG_L2__
    #define DEBUG_PRINT_L2(...)  pc.printf(__VA_ARGS__)
#else
    #define DEBUG_PRINT_L2(...) 
#endif
#ifdef __DEBUG_L3__
    #define DEBUG_PRINT_L3(...)  pc.printf(__VA_ARGS__)
#else
    #define DEBUG_PRINT_L3(...) 
#endif
#ifdef __DEBUG_L4__
    #define DEBUG_PRINT_L4(...)  pc.printf(__VA_ARGS__)
#else
    #define DEBUG_PRINT_L4(...) 
#endif

#define NumberOfI2CCommand 14

/* For resolver reader controller */
enum{
    I2C_CP_PREAMBLE_R,          // Preamble of command packet
    I2C_CP_COMMAND_R,           // instruction command
    I2C_CP_WDRAM_DIA_UPPER,     // motor1 rotation direction   
    I2C_CP_WDRAM_DIA_LOWER,     // motor1 rotation speed    
    I2C_CP_CCABLE_DIA_UPPER,    // motor1 current limit detection threshold upper byte 
    I2C_CP_CCABLE_DIA_LOWER,    // motor1 current limit detection threshold lower byte 
    I2C_CP_RESOLVER_RESO,       // motor1 current limit detection threshold upper byte
    I2C_CP_RES1,                // reserved   
    I2C_CP_RES2,                // reserved   
    I2C_CP_RES3,                // reserved   
    I2C_CP_RES4,                // reserved   
    I2C_CP_RES5,                // reserved  
    I2C_CP_RES6,                // reserved
    I2C_CP_RES7,                // reserved    
};

#define ROTATE_PER_RESOLUTION       24
#define REAL_THREAD_DIAMETER        63          // 60+3
//#define ROTATION_DISTANCE           197.82f     // (60+3)*3.14
#define ROTATION_PULSE_PER_1ROUND   16384       // 2^12(bit) * 4
#define PAI                         3.1415

/* ***************** */
/* Target definition */
/* ***************** */
#define I2C_ADDRESS_RESOLVER    0x02
#define Target_IIC_ADDR 0x02 // For Resolver count controller 


/* Command Packet */
#define CLEAR_RESOLVER_POSITION       'X'
#define HELLO_PACKET        'A'

#define LED_ON  0
#define LED_OFF 1