2018-04-02 12:41:52 -06:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t TIR; /*!< CAN TX mailbox identifier register */
|
|
|
|
uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */
|
|
|
|
uint32_t TDLR; /*!< CAN mailbox data low register */
|
|
|
|
uint32_t TDHR; /*!< CAN mailbox data high register */
|
|
|
|
} CAN_TxMailBox_TypeDef;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */
|
|
|
|
uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */
|
|
|
|
uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */
|
|
|
|
uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */
|
|
|
|
} CAN_FIFOMailBox_TypeDef;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t CNT;
|
|
|
|
} TIM_TypeDef;
|
|
|
|
|
2018-07-17 20:43:06 -06:00
|
|
|
struct sample_t toyota_torque_meas;
|
2018-06-01 20:45:29 -06:00
|
|
|
struct sample_t cadillac_torque_driver;
|
2018-06-14 00:13:59 -06:00
|
|
|
struct sample_t gm_torque_driver;
|
2018-08-30 01:04:05 -06:00
|
|
|
struct sample_t hyundai_torque_driver;
|
2019-03-11 03:12:22 -06:00
|
|
|
struct sample_t chrysler_torque_meas;
|
|
|
|
struct sample_t subaru_torque_driver;
|
2018-04-11 15:34:17 -06:00
|
|
|
|
2018-04-02 12:41:52 -06:00
|
|
|
TIM_TypeDef timer;
|
|
|
|
TIM_TypeDef *TIM2 = &timer;
|
|
|
|
|
|
|
|
#define min(a,b) \
|
|
|
|
({ __typeof__ (a) _a = (a); \
|
|
|
|
__typeof__ (b) _b = (b); \
|
|
|
|
_a < _b ? _a : _b; })
|
|
|
|
|
|
|
|
#define max(a,b) \
|
|
|
|
({ __typeof__ (a) _a = (a); \
|
|
|
|
__typeof__ (b) _b = (b); \
|
|
|
|
_a > _b ? _a : _b; })
|
|
|
|
|
|
|
|
|
2018-04-12 05:45:27 -06:00
|
|
|
#define PANDA
|
2018-04-02 12:41:52 -06:00
|
|
|
#define static
|
|
|
|
#include "safety.h"
|
|
|
|
|
|
|
|
void set_controls_allowed(int c){
|
|
|
|
controls_allowed = c;
|
|
|
|
}
|
|
|
|
|
2018-04-11 15:34:17 -06:00
|
|
|
void reset_angle_control(void){
|
|
|
|
angle_control = 0;
|
|
|
|
}
|
|
|
|
|
2018-04-02 12:41:52 -06:00
|
|
|
int get_controls_allowed(void){
|
|
|
|
return controls_allowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_timer(int t){
|
|
|
|
timer.CNT = t;
|
|
|
|
}
|
|
|
|
|
2018-07-17 20:43:06 -06:00
|
|
|
void set_toyota_torque_meas(int min, int max){
|
|
|
|
toyota_torque_meas.min = min;
|
|
|
|
toyota_torque_meas.max = max;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2018-06-01 20:45:29 -06:00
|
|
|
void set_cadillac_torque_driver(int min, int max){
|
|
|
|
cadillac_torque_driver.min = min;
|
|
|
|
cadillac_torque_driver.max = max;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:13:59 -06:00
|
|
|
void set_gm_torque_driver(int min, int max){
|
|
|
|
gm_torque_driver.min = min;
|
|
|
|
gm_torque_driver.max = max;
|
|
|
|
}
|
|
|
|
|
2018-08-30 01:04:05 -06:00
|
|
|
void set_hyundai_torque_driver(int min, int max){
|
|
|
|
hyundai_torque_driver.min = min;
|
|
|
|
hyundai_torque_driver.max = max;
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:53:07 -07:00
|
|
|
void set_chrysler_torque_meas(int min, int max){
|
|
|
|
chrysler_torque_meas.min = min;
|
|
|
|
chrysler_torque_meas.max = max;
|
|
|
|
}
|
|
|
|
|
2019-03-11 03:12:22 -06:00
|
|
|
void set_subaru_torque_driver(int min, int max){
|
|
|
|
subaru_torque_driver.min = min;
|
|
|
|
subaru_torque_driver.max = max;
|
|
|
|
}
|
|
|
|
|
2019-01-02 22:53:07 -07:00
|
|
|
int get_chrysler_torque_meas_min(void){
|
|
|
|
return chrysler_torque_meas.min;
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_chrysler_torque_meas_max(void){
|
|
|
|
return chrysler_torque_meas.max;
|
2018-12-28 20:20:57 -07:00
|
|
|
}
|
|
|
|
|
2018-07-17 20:43:06 -06:00
|
|
|
int get_toyota_torque_meas_min(void){
|
|
|
|
return toyota_torque_meas.min;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2018-07-17 20:43:06 -06:00
|
|
|
int get_toyota_torque_meas_max(void){
|
|
|
|
return toyota_torque_meas.max;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2018-07-17 20:43:06 -06:00
|
|
|
void set_toyota_rt_torque_last(int t){
|
|
|
|
toyota_rt_torque_last = t;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2018-06-01 20:45:29 -06:00
|
|
|
void set_cadillac_rt_torque_last(int t){
|
|
|
|
cadillac_rt_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:13:59 -06:00
|
|
|
void set_gm_rt_torque_last(int t){
|
|
|
|
gm_rt_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2018-08-30 01:04:05 -06:00
|
|
|
void set_hyundai_rt_torque_last(int t){
|
|
|
|
hyundai_rt_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2018-12-28 20:20:57 -07:00
|
|
|
void set_chrysler_rt_torque_last(int t){
|
|
|
|
chrysler_rt_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2019-03-11 03:12:22 -06:00
|
|
|
void set_subaru_rt_torque_last(int t){
|
|
|
|
subaru_rt_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2018-07-17 20:43:06 -06:00
|
|
|
void set_toyota_desired_torque_last(int t){
|
|
|
|
toyota_desired_torque_last = t;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2018-06-01 20:45:29 -06:00
|
|
|
void set_cadillac_desired_torque_last(int t){
|
2018-06-03 02:52:37 -06:00
|
|
|
for (int i = 0; i < 4; i++) cadillac_desired_torque_last[i] = t;
|
2018-06-01 20:45:29 -06:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:13:59 -06:00
|
|
|
void set_gm_desired_torque_last(int t){
|
|
|
|
gm_desired_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2018-08-30 01:04:05 -06:00
|
|
|
void set_hyundai_desired_torque_last(int t){
|
|
|
|
hyundai_desired_torque_last = t;
|
|
|
|
}
|
2018-06-14 00:13:59 -06:00
|
|
|
|
2018-11-06 13:28:33 -07:00
|
|
|
void set_chrysler_desired_torque_last(int t){
|
|
|
|
chrysler_desired_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2019-03-11 03:12:22 -06:00
|
|
|
void set_subaru_desired_torque_last(int t){
|
|
|
|
subaru_desired_torque_last = t;
|
|
|
|
}
|
|
|
|
|
2019-06-04 13:43:50 -06:00
|
|
|
int get_honda_ego_speed(void){
|
|
|
|
return honda_ego_speed;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2019-06-04 13:43:50 -06:00
|
|
|
int get_honda_brake_prev(void){
|
|
|
|
return honda_brake_prev;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2019-06-04 13:21:52 -06:00
|
|
|
int get_honda_gas_prev(void){
|
|
|
|
return honda_gas_prev;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
|
|
|
|
2018-06-06 15:20:07 -06:00
|
|
|
void set_honda_alt_brake_msg(bool c){
|
|
|
|
honda_alt_brake_msg = c;
|
|
|
|
}
|
|
|
|
|
2019-06-04 13:43:50 -06:00
|
|
|
void set_honda_bosch_hardware(bool c){
|
|
|
|
honda_bosch_hardware = c;
|
2018-06-06 15:20:07 -06:00
|
|
|
}
|
|
|
|
|
2018-04-02 12:41:52 -06:00
|
|
|
void init_tests_toyota(void){
|
2018-07-17 20:43:06 -06:00
|
|
|
toyota_torque_meas.min = 0;
|
|
|
|
toyota_torque_meas.max = 0;
|
|
|
|
toyota_desired_torque_last = 0;
|
|
|
|
toyota_rt_torque_last = 0;
|
|
|
|
toyota_ts_last = 0;
|
2018-04-02 12:41:52 -06:00
|
|
|
set_timer(0);
|
|
|
|
}
|
|
|
|
|
2018-06-01 20:45:29 -06:00
|
|
|
void init_tests_cadillac(void){
|
|
|
|
cadillac_torque_driver.min = 0;
|
|
|
|
cadillac_torque_driver.max = 0;
|
2018-06-03 02:52:37 -06:00
|
|
|
for (int i = 0; i < 4; i++) cadillac_desired_torque_last[i] = 0;
|
2018-06-01 20:45:29 -06:00
|
|
|
cadillac_rt_torque_last = 0;
|
|
|
|
cadillac_ts_last = 0;
|
|
|
|
set_timer(0);
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:13:59 -06:00
|
|
|
void init_tests_gm(void){
|
|
|
|
gm_torque_driver.min = 0;
|
|
|
|
gm_torque_driver.max = 0;
|
|
|
|
gm_desired_torque_last = 0;
|
|
|
|
gm_rt_torque_last = 0;
|
|
|
|
gm_ts_last = 0;
|
|
|
|
set_timer(0);
|
|
|
|
}
|
|
|
|
|
2018-08-30 01:04:05 -06:00
|
|
|
void init_tests_hyundai(void){
|
|
|
|
hyundai_torque_driver.min = 0;
|
|
|
|
hyundai_torque_driver.max = 0;
|
|
|
|
hyundai_desired_torque_last = 0;
|
|
|
|
hyundai_rt_torque_last = 0;
|
|
|
|
hyundai_ts_last = 0;
|
|
|
|
set_timer(0);
|
|
|
|
}
|
|
|
|
|
2018-12-28 20:20:57 -07:00
|
|
|
void init_tests_chrysler(void){
|
2019-03-11 03:12:22 -06:00
|
|
|
chrysler_torque_meas.min = 0;
|
|
|
|
chrysler_torque_meas.max = 0;
|
2018-12-28 20:20:57 -07:00
|
|
|
chrysler_desired_torque_last = 0;
|
|
|
|
chrysler_rt_torque_last = 0;
|
|
|
|
chrysler_ts_last = 0;
|
|
|
|
set_timer(0);
|
|
|
|
}
|
|
|
|
|
2019-03-11 03:12:22 -06:00
|
|
|
void init_tests_subaru(void){
|
|
|
|
subaru_torque_driver.min = 0;
|
|
|
|
subaru_torque_driver.max = 0;
|
|
|
|
subaru_desired_torque_last = 0;
|
|
|
|
subaru_rt_torque_last = 0;
|
|
|
|
subaru_ts_last = 0;
|
|
|
|
set_timer(0);
|
|
|
|
}
|
|
|
|
|
2018-04-02 12:41:52 -06:00
|
|
|
void init_tests_honda(void){
|
2019-06-04 13:43:50 -06:00
|
|
|
honda_ego_speed = 0;
|
2019-06-04 14:36:46 -06:00
|
|
|
gas_interceptor_detected = 0;
|
2019-06-04 13:43:50 -06:00
|
|
|
honda_brake_prev = 0;
|
2019-06-04 13:21:52 -06:00
|
|
|
honda_gas_prev = 0;
|
2018-04-02 12:41:52 -06:00
|
|
|
}
|
2018-10-04 11:22:10 -06:00
|
|
|
|
|
|
|
void set_gmlan_digital_output(int to_set){
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset_gmlan_switch_timeout(void){
|
|
|
|
}
|
|
|
|
|
|
|
|
void gmlan_switch_init(int timeout_enable){
|
|
|
|
}
|
L-line relay (#166)
* Initial version of L-Line Relay
* lline relay fix build, add to health
* Add lline relay to safety
* Lline relay fix build
* Fix tests
* Add lline safety init. Dont fwd with relay closed
* Turn on relay with CAN
* relay hook
* More reliable lline relay
* Longer LLine timeout
* Only turn on wifi if not eon
* Dont disable ESP in early
* Allow CAN to be turned off
- CAN is turned off via USB.
- CAN is turned on when either try to transmit or can is received
- If only transmit is asleep, all messages should send okay
- If receive is alseep, will miss first message while waking up
- Sometimes will report error on second message while CAN perif wakes up
- Saves 130mW!
* Power Saver Mode
- Gray Panda power consumption 650mw -> 325mW
- Turns off CAN, GMLAN, LIN, GPS when no activity for 10s
- No acitvity is no CAN send, CAN Recv, Write to GPS
* Fix power_saving to better turn off can
- On some cars when the can is turned off, it triggers a wakeup.
Delaying the automatic wakeup seems to fix this
* Don't save power in pedal
* Fix relay clicking on startup
* Fix duplicate include
* consistent relay setting
* relay_status can be added when needed, as it's started_alt was consumed in other places
* need to skip forwarding only if relay control is claimed
* unneded change
* make lline_relay.h not depending on can.h
* less spaghetti I guess
* less lines
* reset pedal changes
* no unused input
* update version
2019-04-11 22:03:15 -06:00
|
|
|
|