diff --git a/chip/g/rdd.c b/chip/g/rdd.c index f6c11f69d2..a3c9758e54 100644 --- a/chip/g/rdd.c +++ b/chip/g/rdd.c @@ -8,9 +8,12 @@ #include "hooks.h" #include "rdd.h" #include "registers.h" +#include "system.h" #include "task.h" #include "usb_api.h" +#define CPRINTS(format, args...) cprints(CC_USB, format, ## args) + static uint16_t debug_detect; int debug_cable_is_attached(void) @@ -24,15 +27,17 @@ int debug_cable_is_attached(void) void rdd_interrupt(void) { if (debug_cable_is_attached()) { - ccprintf("Debug Accessory connected\n"); + CPRINTS("Debug Accessory connected"); + disable_sleep(SLEEP_MASK_RDD); /* Detect when debug cable is disconnected */ GWRITE(RDD, PROG_DEBUG_STATE_MAP, ~debug_detect); rdd_attached(); } else { - ccprintf("Debug Accessory disconnected\n"); + CPRINTS("Debug Accessory disconnected"); /* Detect when debug cable is connected */ GWRITE(RDD, PROG_DEBUG_STATE_MAP, debug_detect); rdd_detached(); + enable_sleep(SLEEP_MASK_RDD); } /* Clear interrupt */ diff --git a/include/system.h b/include/system.h index 0d2eebdf1e..4362097345 100644 --- a/include/system.h +++ b/include/system.h @@ -317,6 +317,7 @@ enum { SLEEP_MASK_I2C_SLAVE = (1 << 7), /* I2C slave communication ongoing */ SLEEP_MASK_FAN = (1 << 8), /* Fan control loop ongoing */ SLEEP_MASK_USB_DEVICE = (1 << 9), /* Generic USB device in use */ + SLEEP_MASK_RDD = (1 << 10),/* RDD ongoing */ SLEEP_MASK_FORCE_NO_DSLEEP = (1 << 15), /* Force disable. */