Feng Hong / Mbed OS Nucleo_yoda2_v2
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers yoda2.h Source File

yoda2.h

00001 //#define RASPBERRY_PI_CAN_ADDRESS  0x01
00002 #define YODA2
00003 #define RASPBERRY_PI_CAN_TYPE   0x07
00004 #define RASPBERRY_PI_CAN_ID     0x01
00005 #define RASPBERRY_PI_CAN_ADDRESS    ((RASPBERRY_PI_CAN_TYPE<<8) | RASPBERRY_PI_CAN_ID)
00006 
00007 #ifdef OWN_SOLDER_BOARD
00008 #define BUTTON1 PB_4        // right // up
00009 #define BUTTON2 PC_1        // left  // down
00010 #define BUTTON3 PC_7        // enter    // next
00011 #define BUTTON4 PA_9        // menu     // back
00012 #endif
00013 
00014 #ifdef YODA2
00015 #define BUTTON1 PA_8        // right // up
00016 #define BUTTON2 PB_10        // left  // down
00017 #define BUTTON3 PB_4        // enter    // next
00018 #define BUTTON4 PB_5        // menu     // back
00019 #define RELAY_4 PD_2 
00020 #define RELAY_3 PC_11
00021 #define RELAY_2 PC_10
00022 #define RELAY_1 PC_12
00023 #endif
00024 
00025 #define BUTTON1_HOLD_EVENT         0x0001
00026 #define BUTTON1_PRESSED_EVENT       0x0002
00027 #define BUTTON2_HOLD_EVENT         0x0004
00028 #define BUTTON2_PRESSED_EVENT       0x0008
00029 #define BUTTON3_HOLD_EVENT         0x0010
00030 #define BUTTON3_PRESSED_EVENT       0x0020
00031 #define BUTTON4_HOLD_EVENT         0x0040
00032 #define BUTTON4_PRESSED_EVENT       0x0080
00033 #define NEXT_HOLD_EVENT          BUTTON4_HOLD_EVENT
00034 #define NEXT_PRESSED_EVENT       BUTTON4_PRESSED_EVENT
00035 #define BACK_HOLD_EVENT         BUTTON3_HOLD_EVENT
00036 #define BACK_PRESSED_EVENT      BUTTON3_PRESSED_EVENT
00037 #define DOWN_HOLD_EVENT          BUTTON2_HOLD_EVENT
00038 #define DOWN_PRESSED_EVENT       BUTTON2_PRESSED_EVENT
00039 #define UP_HOLD_EVENT         BUTTON1_HOLD_EVENT
00040 #define UP_PRESSED_EVENT      BUTTON1_PRESSED_EVENT
00041 #define LCD_DISPLAY_HOLD_EVENT      0x0001
00042 #define LCD_DISPLAY_RELEASE_EVENT   0x0002
00043 
00044 #define COMMAND_INIT  0 // all the devices return to the point 0 and return the current possition or current weight
00045 #define COMMAND_PLUS  1 // for the devices to plus weight return the weight
00046 #define COMMAND_MINUS 2 // for the devices to minus weight return the weight
00047 #define COMMAND_MOVE_ABSOLUTE 3 // for the devices to move to the absolute position return the current absolute position
00048 #define COMMAND_MOVE_RELATIVE 4 // for the devices to move relative distance return the current absolute position
00049 #define COMMAND_REPORT_WEIGHT 5 // for the devices to report the current weight 
00050 #define COMMAND_REPORT_POSITION 6 // for the devices to report the current absolute position
00051 #define COMMAND_CLEAN 7 // for the devices to clean the cups return done or failed
00052 #define COMMAND_TARE 8  // for the devices to tare the scale return done or failed
00053 #define COMMAND_SHAKE_CUP 9 // for the device to shake the cups return done or failed
00054 #define COMMAND_POUR_TEA 10 // for the device to pour the tea return done or failed
00055 #define COMMAND_FINISH 11   // for everything finished return done or failed
00056 #define COMMAND_RESET 12    // for the devices return to the point 0 and clean themselvies
00057 #define COMMAND_REGISTER 13 // for device to register itself to raspberry pi
00058 
00059 
00060 #define WEIGHT_DIFFERENCE   200   // 10g ADC value minimum difference
00061 #define CALIBRATION_WEIGHT  2000    // calibration weight
00062 #define MAXIMUM_CALIBRATION_WEIGHT  5000 
00063 #define MINIMUM_CALIBRATION_WEIGHT  100 
00064 
00065 #ifdef OWN_SOLDER_BOARD
00066 #define EEPROM_ADDR 0x0   // I2c EEPROM address is 0x00
00067 #endif
00068 #ifdef YODA2
00069 #define EEPROM_ADDR 0x57   
00070 #endif
00071 #ifdef STM32F207xx
00072 #define SDA PB_9            // I2C SDA pin
00073 #define SCL PB_8           // I2C SCL pin
00074 #endif
00075 
00076 #ifdef STM32F303xE
00077 #ifdef OWN_SOLDER_BOARD
00078 #define SDA PC_9//D2//D2//PB_9 //PF_0            // I2C SDA pin
00079 #define SCL D7//D8//D8//PB_8 //PF_1           // I2C SCL pin
00080 #endif
00081 #ifdef YODA2
00082 #define SDA PA_10//D2//D2//PB_9 //PF_0            // I2C SDA pin
00083 #define SCL PA_9//D8//D8//PB_8 //PF_1           // I2C SCL pin
00084 #define LCD_SDA PB_9            // I2C SDA pin
00085 #define LCD_SCL PB_8           // I2C SCL pin
00086 #define SCALE_SDA PA_1
00087 #define SCALE_SCL PA_0
00088 #define SCALE2_SDA PF_1
00089 #define SCALE2_SCL PA_0
00090 #define CAN_RD PA_11
00091 #define CAN_TD PA_12
00092 #define DIN1    PC_0
00093 #define DIN2    PC_1
00094 #define DIN3    PB_0
00095 #define DIN4    PA_4
00096 #define DIN5    PC_3
00097 #define DIN6    PC_2
00098 #define DIN7    PB_7
00099 #define DIN8    PA_15
00100 #endif
00101 #endif
00102  
00103 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
00104 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
00105 
00106 #define EEPROM_DEVICE_ADDRESS_ADDRESS  0x40
00107 #define DEVICE_DEFAULT_ADDRESS   12
00108 
00109 
00110 enum Device_Type_d
00111 {
00112     CupTrack=0,
00113     JamTrack=1,
00114     TeaTrack=2,
00115     Tea=3,
00116     Jam=4,
00117     Shaker=5, 
00118     IceMaker=6
00119 };
00120 
00121 
00122 struct ScaleCalibrationData {
00123   unsigned int calibrationWeight;  // the weight (g) used for calibration for example 1000g or 10g. The maximum value is 3000. 
00124   long offsetValue;       // the value for scale offset
00125   float scaleValue;       // the ADC increment for 1g  
00126   uint8_t checksum;  
00127 };
00128 
00129 // because memcpy is 16 byte alignment no byte in struct
00130 struct data_field_d {
00131     uint16_t cmd;
00132     uint16_t value1;
00133     uint16_t value2;
00134     uint16_t value3;
00135 };