debug endpoint for custom clock source period (#1538)

* debug endpoint for custom clock source period

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
Adeeb Shihadeh 2023-08-01 16:17:42 -07:00 committed by GitHub
parent 1b706040cd
commit 7f1944cf43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,10 @@
#define CLOCK_SOURCE_PERIOD_MS 50U
#define CLOCK_SOURCE_PULSE_LEN_MS 2U
void clock_source_set_period(uint8_t period) {
register_set(&(TIM1->ARR), ((period*10U) - 1U), 0xFFFFU);
}
void clock_source_init(void) {
// Setup timer
register_set(&(TIM1->PSC), ((APB2_TIMER_FREQ*100U)-1U), 0xFFFFU); // Tick on 0.1 ms

View File

@ -396,6 +396,10 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
can_loopback = (req->param1 > 0U);
can_init_all();
break;
// **** 0xe6: set custom clock source period
case 0xe6:
clock_source_set_period(req->param1);
break;
// **** 0xe7: set power save state
case 0xe7:
set_power_save_state(req->param1);

View File

@ -1019,6 +1019,9 @@ class Panda:
def set_green_led(self, enabled):
self._handle.controlWrite(Panda.REQUEST_OUT, 0xf7, int(enabled), 0, b'')
def set_clock_source_period(self, period):
self._handle.controlWrite(Panda.REQUEST_OUT, 0xe6, period, 0, b'')
# ****************** Logging *****************
def get_logs(self, last_id=None, get_all=False):
assert (last_id is None) or (0 <= last_id < 0xFFFF)