-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
21 changed files
with
208 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v1.2.0 | ||
v1.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#ifdef PANDA | ||
|
||
int relay_control = 0; // True if relay is controlled through l-line | ||
|
||
/* Conrol a relay connected to l-line pin */ | ||
|
||
// 160us cycles, 1 high, 25 low | ||
|
||
volatile int turn_on_relay = 0; | ||
volatile int on_cycles = 25; | ||
|
||
//5s timeout | ||
#define LLINE_TIMEOUT_CYCLES 31250 | ||
volatile int timeout_cycles = LLINE_TIMEOUT_CYCLES; | ||
|
||
void TIM5_IRQHandler(void) { | ||
if (TIM5->SR & TIM_SR_UIF) { | ||
on_cycles--; | ||
timeout_cycles--; | ||
if (timeout_cycles == 0) { | ||
turn_on_relay = 0; | ||
} | ||
if (on_cycles > 0) { | ||
if (turn_on_relay) { | ||
set_gpio_output(GPIOC, 10, 0); | ||
} | ||
} | ||
else { | ||
set_gpio_output(GPIOC, 10, 1); | ||
on_cycles = 25; | ||
} | ||
} | ||
TIM5->ARR = 160-1; | ||
TIM5->SR = 0; | ||
} | ||
|
||
void lline_relay_init (void) { | ||
set_lline_output(0); | ||
relay_control = 1; | ||
set_gpio_output(GPIOC, 10, 1); | ||
|
||
// setup | ||
TIM5->PSC = 48-1; // tick on 1 us | ||
TIM5->CR1 = TIM_CR1_CEN; // enable | ||
TIM5->ARR = 50-1; // 50 us | ||
TIM5->DIER = TIM_DIER_UIE; // update interrupt | ||
TIM5->CNT = 0; | ||
|
||
NVIC_EnableIRQ(TIM5_IRQn); | ||
|
||
#ifdef DEBUG | ||
puts("INIT LLINE\n"); | ||
puts(" SR "); | ||
putui(TIM5->SR); | ||
puts(" PSC "); | ||
putui(TIM5->PSC); | ||
puts(" CR1 "); | ||
putui(TIM5->CR1); | ||
puts(" ARR "); | ||
putui(TIM5->ARR); | ||
puts(" DIER "); | ||
putui(TIM5->DIER); | ||
puts(" SR "); | ||
putui(TIM5->SR); | ||
puts(" CNT "); | ||
putui(TIM5->CNT); | ||
puts("\n"); | ||
#endif | ||
} | ||
|
||
void lline_relay_release (void) { | ||
set_lline_output(0); | ||
relay_control = 0; | ||
puts("RELEASE LLINE\n"); | ||
set_gpio_alternate(GPIOC, 10, GPIO_AF7_USART3); | ||
NVIC_DisableIRQ(TIM5_IRQn); | ||
} | ||
|
||
void set_lline_output(int to_set) { | ||
timeout_cycles = LLINE_TIMEOUT_CYCLES; | ||
turn_on_relay = to_set; | ||
} | ||
|
||
int get_lline_status() { | ||
return turn_on_relay; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.