test upload STMicroelectronics L6470
Diff: L6470.h
- Revision:
- 2:97c203ed65da
- Parent:
- 1:bb4bb05904cb
diff -r bb4bb05904cb -r 97c203ed65da L6470.h --- a/L6470.h Tue Dec 25 02:46:32 2012 +0000 +++ b/L6470.h Wed Mar 05 06:17:55 2014 +0000 @@ -8,63 +8,119 @@ #define FORWARD 1 #define REVERSE 0 -// name (length<<8)+address -#define ABS_POS ((22<<8)+0x01) //Current position -#define EL_POS ((9<<8)+0x02) //Electrical position -#define MARK ((22<<8)+0x03) //Mark position -#define SPEED ((20<<8)+0x04) //Current speed -#define ACC ((12<<8)+0x05) //Acceleration -#define DEC ((12<<8)+0x06) //Deceleration -#define MAX_SPEED ((10<<8)+0x07) //Maximum speed -#define MIN_SPEED ((13<<8)+0x08) //Minimum speed -#define KVAL_HOLD ((8<<8)+0x09) //Full step speed -#define KVAL_RUN ((8<<8)+0x0A) // -#define KVAL_ACC ((8<<8)+0x0B) // -#define KVAL_DEC ((8<<8)+0x0C) // -#define INT_SPD ((14<<8)+0x0D) // -#define ST_SLP ((8<<8)+0x0E) // -#define FN_SLP_ACC ((8<<8)+0x0F) // -#define FN_SLP_DEC ((8<<8)+0x10) // -#define K_THERA ((4<<8)+0x11) // -#define ADC_OUT ((5<<8)+0x12) // -#define OCR_TH ((4<<8)+0x13) // -#define STALL_TH ((7<<8)+0x14) // -#define FS_SPD ((10<<8)+0x15) // -#define STEP_MODE ((8<<8)+0x16) // -#define ARARM_FN ((8<<8)+0x17) // -#define CONFIG ((16<<8)+0x18) // -#define STATUS ((16<<8)+0x19) // +// +//INI = ResetHex +//My specification for Initial value +#define INI_ABS_POS 0 //Current position +#define INI_EL_POS 0 //Electrical position +#define INI_MARK 0 //Mark position +#define INI_SPEED 0 //Current speed +#define INI_ACC 0x8A //Acceleration +#define INI_DEC 0x8A //Deceleration +#define INI_MAX_SPEED 0x20 //Maximum speed +#define INI_MIN_SPEED 0 //Minimum speed +#define INI_KVAL_HOLD 0xFF //Full step speed +#define INI_KVAL_RUN 0xFF // +#define INI_KVAL_ACC 0xFF // +#define INI_KVAL_DEC 0xFF // +#define INI_INT_SPD 0x408 // +#define INI_ST_SLP 0x19 // +#define INI_FN_SLP_ACC 0x29 // +#define INI_FN_SLP_DEC 0x29 // +#define INI_K_THERA 0x0 // +// ADC_OUT ReadOnly +#define INI_OCR_TH 0xF +#define INI_STALL_TH 0x7F +#define INI_FS_SPD 0x27 +#define INI_STEP_MODE 0x7 +#define INI_ARARM_FN 0xFF +#define INI_CONFIG 0x2E88 +// INI_STATUS ReadOnly + + +#define LEN_ABS_POS 22 +#define LEN_EL_POS 9 +#define LEN_MARK 22 +#define LEN_SPEED 20 +#define LEN_ACC 12 +#define LEN_DEC 12 +#define LEN_MAX_SPEED 10 +#define LEN_MIN_SPEED 13 +#define LEN_KVAL_HOLD 8 +#define LEN_KVAL_RUN 8 +#define LEN_KVAL_ACC 8 +#define LEN_KVAL_DEC 8 +#define LEN_INT_SPD 14 +#define LEN_ST_SLP 8 +#define LEN_FN_SLP_ACC 8 +#define LEN_FN_SLP_DEC 8 +#define LEN_K_THERA 4 +#define LEN_ADC_OUT 5 +#define LEN_OCR_TH 4 +#define LEN_STALL_TH 7 +#define LEN_FS_SPD 10 +#define LEN_STEP_MODE 8 +#define LEN_ARARM_FN 8 +#define LEN_CONFIG 16 +#define LEN_STATUS 16 + + +#define ADD_ABS_POS 0x01 +#define ADD_EL_POS 0x02 +#define ADD_MARK 0x03 +#define ADD_SPEED 0x04 +#define ADD_ACC 0x05 +#define ADD_DEC 0x06 +#define ADD_MAX_SPEED 0x07 +#define ADD_MIN_SPEED 0x08 +#define ADD_KVAL_HOLD 0x09 +#define ADD_KVAL_RUN 0x0A +#define ADD_KVAL_ACC 0x0B +#define ADD_KVAL_DEC 0x0C +#define ADD_INT_SPD 0x0D +#define ADD_ST_SLP 0x0E +#define ADD_FN_SLP_ACC 0x0F +#define ADD_FN_SLP_DEC 0x10 +#define ADD_K_THERA 0x11 +#define ADD_ADC_OUT 0x12 +#define ADD_OCR_TH 0x13 +#define ADD_STALL_TH 0x14 +#define ADD_FS_SPD 0x15 +#define ADD_STEP_MODE 0x16 +#define ADD_ARARM_FN 0x17 +#define ADD_CONFIG 0x18 +#define ADD_STATUS 0x19 -//RH = ResetHex -#define RH_ABS_POS 0 //Current position -#define RH_EL_POS 0 //Electrical position -#define RH_MARK 0 //Mark position -#define RH_SPEED 0 //Current speed -#define RH_ACC 0x8A //Acceleration -#define RH_DEC 0x8A //Deceleration -#define RH_MAX_SPEED 0x20 //Maximum speed -#define RH_MIN_SPEED 0 //Minimum speed -#define RH_KVAL_HOLD 0xFF //Full step speed -#define RH_KVAL_RUN 0xFF // -#define RH_KVAL_ACC 0xFF // -#define RH_KVAL_DEC 0xFF // -#define RH_INT_SPD 0x408 // -#define RH_ST_SLP 0x19 // -#define RH_FN_SLP_ACC 0x29 // -#define RH_FN_SLP_DEC 0x29 // -#define RH_K_THERA 0x0 // -// ADC_OUT ReadOnly -#define RH_OCR_TH 0xF -#define RH_STALL_TH 0x7F -#define RH_FS_SPD 0x27 -#define RH_STEP_MODE 0x7 -#define RH_ARARM_FN 0xFF -#define RH_CONFIG 0x2E88 -// RH_STATUS ReadOnly - +enum L6470_Register{ + ABS_POS = 0x01, + EL_POS, + MARK, + SPEED, + ACC, + DEC, + MAX_SPEED, + MIN_SPEED, + KVAL_HOLD, + KVAL_RUN, + KVAL_ACC, + KVAL_DEC, + INT_SPD, + ST_SLP, + FN_SLP_ACC, + FN_SLP_DEC, + K_THERA, + ADC_OUT, + OCR_TH, + STALL_TH, + FS_SPD, + STEP_MODE, + ARARM_FN, + CONFIG, + STATUS +}; class L6470{ public: @@ -73,8 +129,8 @@ unsigned char send(unsigned char temp); void send_bytes(unsigned char temp[],int i); void NOP(); - void SetParam(int param,int value); - int GetParam(int param); + void SetParam(L6470_Register param,int value); + int GetParam(L6470_Register param); void Run(unsigned char dir,int spd); void StepClock(unsigned char dir); void Move(unsigned char dir,int n_step);