From patchwork Sat Sep 24 19:20:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 9349245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B3BEA607F2 for ; Sat, 24 Sep 2016 19:21:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4B53290A2 for ; Sat, 24 Sep 2016 19:21:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 991E129114; Sat, 24 Sep 2016 19:21:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4582B290A2 for ; Sat, 24 Sep 2016 19:21:45 +0000 (UTC) Received: from localhost ([::1]:35282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnsW8-0005AK-EO for patchwork-qemu-devel@patchwork.kernel.org; Sat, 24 Sep 2016 15:21:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnsVa-000584-IN for qemu-devel@nongnu.org; Sat, 24 Sep 2016 15:21:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnsVU-0001rZ-Ug for qemu-devel@nongnu.org; Sat, 24 Sep 2016 15:21:09 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:32848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnsVU-0001rN-Ox for qemu-devel@nongnu.org; Sat, 24 Sep 2016 15:21:04 -0400 Received: by mail-pa0-f67.google.com with SMTP id oz2so6601201pac.0 for ; Sat, 24 Sep 2016 12:21:04 -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=ZYmws8M8X7IPEZHC1MOP3FFALFUY2wqwLrGYKU5Cvaw0MaOODmW19bI3jV7/SFZVyt NzeVUEJAh/XUIlzgOGNgr1fraAEbhN5VEEjBFUaDBSk1Dwn5mc9n5eqpTTV+XSrlFHZL x4ufNKyGhQmJejD4BdusgkO0hvyI12//6gjxrCG70//GF2k5NhqwQ90+1fgLe1xjp7/l OrhSQK12zn4Br6ev10XImhZWManU6gDEvyKV5tVyCYiOE8HTV9FzKtozb8Mub/gw2KWF QFp9avtResGMW/Pwb0c12XXN9jQvc9G0g3+qWRMTFfE1cQi4qyz9EEKpQXyF00sZIrIm omMQ== 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=gDXV2wJuV1/zHpecBa4AXT/YnxlrIoUKYqUGUHqL9RoaM9tUdqUZUbTsZnHFyhgtiN cEl/xPG7Z5xr1xS5MVWhllGITkmccqOjFXJD5YYNx3aIXOsp3W4tbvWzmSU1v7ASp1DG clb+9GzEctw+VS6hlXeHMFFI35N3HjM5dLxuIIhC63FZbuT1QcFxFiVY+JtoelKEFnLu Roj4Qmj20tTzPCnfgLuVG/s/ZoZXrVMkDByrs5bZevZcinZakjpHr6qbuGaF3LEE8kji JS0Ss0DVvmaFsNAGa/qtL7NeoDVQ0IgxoPUHWYNwgFm0lCPd3uSV/Y8AekazhmFyK7sV fOpg== X-Gm-Message-State: AE9vXwNF/iEVtKqzbal8TIhGbhdfXxUSmyTramjJRssiXwl4P9fsk9AwreP01TkrbWyTvw== X-Received: by 10.66.131.74 with SMTP id ok10mr23697096pab.126.1474744804222; Sat, 24 Sep 2016 12:20:04 -0700 (PDT) Received: from localhost ([2601:646:8581:937e:696f:1ffa:ab17:d7de]) by smtp.gmail.com with ESMTPSA id y11sm18335471pfa.4.2016.09.24.12.20.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Sep 2016 12:20:03 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sat, 24 Sep 2016 12:20:03 -0700 Message-Id: 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.67 Subject: [Qemu-devel] [PATCH v8 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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)