Files
OpenCellular/common/case_closed_debug.c
Anton Staaf 48b8c34aed ryu: Enable PD/EC console over USB
This enables forwarding of the local PD/EC console
over debug USB.  It gates the console functionality
based on the CCD mode that is set.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j
     Enable partial CCD mode on ryu and verify that it is
     enumerated by the host correctly, but doesn't respond
     to console input, and doesn't generate output.
     Enable full CCD mode on ryu and verify that it is
     enumerated and that the console works as expected.
     Verify that the console still works by default on the
     discovery-stm32f072 board.

Change-Id: I0325ce9689486c41387d6075330be1d7d42f1d42
Reviewed-on: https://chromium-review.googlesource.com/229342
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
2014-11-13 03:14:37 +00:00

51 lines
1.1 KiB
C

/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Case Closed Debug common implementation
*/
#include "case_closed_debug.h"
#include "common.h"
#include "usb_api.h"
#include "usb_console.h"
#if !defined(CONFIG_USB)
#error "CONFIG_USB must be defined to use Case Closed Debugging"
#endif
#if !defined(CONFIG_USB_CONSOLE)
#error "CONFIG_USB_CONSOLE must be defined to use Case Closed Debugging"
#endif
#if !defined(CONFIG_USB_INHIBIT_INIT)
#error "CONFIG_USB_INHIBIT_INIT must be defined to use Case Closed Debugging"
#endif
static enum ccd_mode current_mode = CCD_MODE_DISABLED;
void ccd_set_mode(enum ccd_mode new_mode)
{
if (new_mode == current_mode)
return;
if (current_mode != CCD_MODE_DISABLED) {
usb_release();
ccd_board_disconnect();
}
current_mode = new_mode;
/*
* Only enable forwarding the local console over USB if we are now in
* the fully enabled mode.
*/
usb_console_enable(new_mode == CCD_MODE_ENABLED);
if (new_mode != CCD_MODE_DISABLED) {
ccd_board_connect();
usb_init();
}
}