Mangue Baja team's code to rear ECU

Committer:
einsteingustavo
Date:
Wed Jul 24 20:04:55 2019 +0000
Revision:
0:80950b84a6c4
Mangue Baja team's code to rear ECU

Who changed what in which revision?

UserRevisionLine numberNew contents of line
einsteingustavo 0:80950b84a6c4 1 #ifndef DEFINITIONS_H
einsteingustavo 0:80950b84a6c4 2 #define DEFINITIONS_H
einsteingustavo 0:80950b84a6c4 3
einsteingustavo 0:80950b84a6c4 4 #ifndef MBED_H
einsteingustavo 0:80950b84a6c4 5 #include "mbed.h"
einsteingustavo 0:80950b84a6c4 6 #define MBED_H
einsteingustavo 0:80950b84a6c4 7 #endif
einsteingustavo 0:80950b84a6c4 8
einsteingustavo 0:80950b84a6c4 9 #define CAN_IER (*((volatile unsigned long *)0x40006414))
einsteingustavo 0:80950b84a6c4 10
einsteingustavo 0:80950b84a6c4 11 #define BUFFER_SIZE 50
einsteingustavo 0:80950b84a6c4 12 #define THROTTLE_MID 0x00
einsteingustavo 0:80950b84a6c4 13 #define THROTTLE_RUN 0x01
einsteingustavo 0:80950b84a6c4 14 #define THROTTLE_CHOKE 0x02
einsteingustavo 0:80950b84a6c4 15
einsteingustavo 0:80950b84a6c4 16 #define SYNC_ID 0x001 // message for bus sync
einsteingustavo 0:80950b84a6c4 17 #define THROTTLE_ID 0x100 // 1by = throttle state (0x00, 0x01 or 0x02)
einsteingustavo 0:80950b84a6c4 18 #define FLAGS_ID 0x101 // 1by
einsteingustavo 0:80950b84a6c4 19 #define IMU_ACC_ID 0x200 // 8by = accelerometer data (3D) + timestamp
einsteingustavo 0:80950b84a6c4 20 #define IMU_DPS_ID 0x201 // 8by = gyroscope data (3D) + timestamp
einsteingustavo 0:80950b84a6c4 21 #define SPEED_ID 0x300 // 4by = speed + timestamp
einsteingustavo 0:80950b84a6c4 22 #define RPM_ID 0x304 // 4by = rpm + timestamp
einsteingustavo 0:80950b84a6c4 23 #define TEMPERATURE_ID 0x400 // 4by = engine temp. + cvt temp. + timestamp
einsteingustavo 0:80950b84a6c4 24 #define FUEL_ID 0x500 // 3by = fuel level + timestamp
einsteingustavo 0:80950b84a6c4 25
einsteingustavo 0:80950b84a6c4 26
einsteingustavo 0:80950b84a6c4 27 typedef struct
einsteingustavo 0:80950b84a6c4 28 {
einsteingustavo 0:80950b84a6c4 29 int16_t acc_x;
einsteingustavo 0:80950b84a6c4 30 int16_t acc_y;
einsteingustavo 0:80950b84a6c4 31 int16_t acc_z;
einsteingustavo 0:80950b84a6c4 32 int16_t dps_x;
einsteingustavo 0:80950b84a6c4 33 int16_t dps_y;
einsteingustavo 0:80950b84a6c4 34 int16_t dps_z;
einsteingustavo 0:80950b84a6c4 35 } imu_t;
einsteingustavo 0:80950b84a6c4 36
einsteingustavo 0:80950b84a6c4 37 typedef struct
einsteingustavo 0:80950b84a6c4 38 {
einsteingustavo 0:80950b84a6c4 39 imu_t imu[4];
einsteingustavo 0:80950b84a6c4 40 uint16_t rpm;
einsteingustavo 0:80950b84a6c4 41 uint16_t speed;
einsteingustavo 0:80950b84a6c4 42 uint8_t temperature;
einsteingustavo 0:80950b84a6c4 43 uint8_t flags; // MSB - BOX | BUFFER FULL | NC | NC | FUEL_LEVEL | SERVO_ERROR | CHK | RUN - LSB
einsteingustavo 0:80950b84a6c4 44 uint32_t timestamp;
einsteingustavo 0:80950b84a6c4 45 } packet_t;
einsteingustavo 0:80950b84a6c4 46
einsteingustavo 0:80950b84a6c4 47 #endif
einsteingustavo 0:80950b84a6c4 48