Files
OpenCellular/common/case_closed_debug.c
Anton Staaf a0158dd136 CCD: Add ability to enable and disable SPI bridge
This required changing the USB-SPI implementation slightly
so that all work is done within the deferred callback.  In
particular, this allows the board specific enable and disable
functions to do things that can only be done from a task
context, like sleeping.

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

BRANCH=None
BUG=None
TEST=make buildall -j

Change-Id: I3f6a01ed9d6f31a3259ba0a0f6b4e123d6d2e718
Reviewed-on: https://chromium-review.googlesource.com/260964
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-03-23 19:23:35 +00:00

56 lines
1.3 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"
#include "usb_spi.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
#if defined(CONFIG_USB_SPI)
USB_SPI_CONFIG(ccd_usb_spi, USB_IFACE_SPI, USB_EP_SPI);
#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();
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 defined(CONFIG_USB_SPI)
usb_spi_enable(&ccd_usb_spi, new_mode == CCD_MODE_ENABLED);
#endif
if (new_mode != CCD_MODE_DISABLED)
usb_init();
}