From patchwork Sun Sep 11 14:54:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 668473 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sXDZJ0vbHz9s9x for ; Mon, 12 Sep 2016 00:57:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=HtShNpXc; dkim-atps=neutral Received: from localhost ([::1]:37907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bj6C8-0006oP-O0 for incoming@patchwork.ozlabs.org; Sun, 11 Sep 2016 10:57:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bj6Ac-0005Pk-TD for qemu-devel@nongnu.org; Sun, 11 Sep 2016 10:55:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bj6AX-0004Mk-TZ for qemu-devel@nongnu.org; Sun, 11 Sep 2016 10:55:45 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:35003) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bj6AX-0004Md-Nk for qemu-devel@nongnu.org; Sun, 11 Sep 2016 10:55:41 -0400 Received: by mail-pa0-f68.google.com with SMTP id pp5so6491852pac.2 for ; Sun, 11 Sep 2016 07:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sNX+3qqO5DB+d/hnJMV+9UKQAGcCNf1Ca2MPT//9ukA=; b=HtShNpXcSEARDPsFUJU/iqhTw00nUhOxh2lLSTHx8b4uBZSOKNeKpeY5AJO7Vf/+r/ 5R9j6EuX/eUzkCRyKW1PFQskhB074P83HVBl4+NleyRjTJVoxUvwQEdWghJdOVr+kXjV 6HHxSODv0TW70Gug2aQI6h4IQtc3a9Ta3ao95WY0ZkdZgjfxmO8TJumPjfNRywbnDbpb 7ZgyDYhtCwdT/f6dHYJ2JR+3t44/i+i4FQtTNhoo8JIden7d59XEUHSdhtzkp5k/62hN FcIaOIgfMiHPURZHIO70TUMtGAybXbYJQtrnDE1YxTX4WNT5A1M0gU+N03kEj2zwt5nu GTjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sNX+3qqO5DB+d/hnJMV+9UKQAGcCNf1Ca2MPT//9ukA=; b=Yv9ogJUAnOz3SepazTyY8Ad/Ye/BiSTtjxy2gRPHwjwFBf6N11RHqXlHkMbhkgtZYX Cd2qEK4w2QTbT6biTY+Mh/SYrhk4qW83oWQ/tY9XDavDqHkYghsG4ECfQPdz2nn4grlo WykA4Soup4AnbAhyBI9cDb405ekPn1ku5Q95+JAoCI6oeMOt+yvQTNsQH4M9a2tN0a65 NRMp6ux7ybGgefpIHv+/rTTKiyI97bmhUKo0w4oZ8SqFyLYsfCU4yieY4kSWWit0FF9G oGPPwqnwr3v/SGh9mwtIEKrjUkQa7coefwxDO5G4OEy1VVARlUMGdL/12Xj44XTwoXtg A3EQ== X-Gm-Message-State: AE9vXwOVBeJHiMBOV4ft40v9OgTbXixwyQPiiO5bgnoz9ghYsdF18Uoe4MwOBr7GlvGqDA== X-Received: by 10.66.25.143 with SMTP id c15mr24856108pag.90.1473605680975; Sun, 11 Sep 2016 07:54:40 -0700 (PDT) Received: from localhost ([2601:646:8581:937e:2561:c199:6f8f:8bc8]) by smtp.gmail.com with ESMTPSA id d5sm18165619pfa.44.2016.09.11.07.54.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Sep 2016 07:54:40 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sun, 11 Sep 2016 07:54:39 -0700 Message-Id: <87cd1f5de411bbe46d6333e01e36731711197031.1473579576.git.alistair@alistair23.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.68 Subject: [Qemu-devel] [PATCH v7 2/8] STM32F2xx: Display PWM duty cycle from timer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, konstanty@ieee.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If correctly configured allow the STM32F2xx timer to print out the PWM duty cycle information. Signed-off-by: Alistair Francis Reviewed-by: Peter Crosthwaite --- V3: - Use OR instead of + for masking - Improve clarity of print statement V2: - Fix up if statement braces - Remove stm32f2xx_timer_set_alarm() call hw/timer/stm32f2xx_timer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c index bf0fb28..8c4c1f9 100644 --- a/hw/timer/stm32f2xx_timer.c +++ b/hw/timer/stm32f2xx_timer.c @@ -51,6 +51,15 @@ static void stm32f2xx_timer_interrupt(void *opaque) qemu_irq_pulse(s->irq); stm32f2xx_timer_set_alarm(s, s->hit_time); } + + if (s->tim_ccmr1 & (TIM_CCMR1_OC2M2 | TIM_CCMR1_OC2M1) && + !(s->tim_ccmr1 & TIM_CCMR1_OC2M0) && + s->tim_ccmr1 & TIM_CCMR1_OC2PE && + s->tim_ccer & TIM_CCER_CC2E) { + /* PWM 2 - Mode 1 */ + DB_PRINT("PWM2 Duty Cycle: %d%%\n", + s->tim_ccr2 / (100 * (s->tim_psc + 1))); + } } static inline int64_t stm32f2xx_ns_to_ticks(STM32F2XXTimerState *s, int64_t t)