From patchwork Wed Aug 3 03:10:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 655234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s3ym41Ml9z9t0q for ; Wed, 3 Aug 2016 13:12:04 +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=ixiOh+sz; dkim-atps=neutral Received: from localhost ([::1]:59917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUmbC-0006WB-7O for incoming@patchwork.ozlabs.org; Tue, 02 Aug 2016 23:12:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUma3-0005fH-2B for qemu-devel@nongnu.org; Tue, 02 Aug 2016 23:10:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUma2-0006t0-1d for qemu-devel@nongnu.org; Tue, 02 Aug 2016 23:10:50 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:33862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUma1-0006sv-RV for qemu-devel@nongnu.org; Tue, 02 Aug 2016 23:10:49 -0400 Received: by mail-pf0-x244.google.com with SMTP id g202so13727204pfb.1 for ; Tue, 02 Aug 2016 20:10:49 -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=ixiOh+szvQuRvJHiBe2GBh9SZctnZFXTVOiL8W0cRUR7ls200ZOfDPZks5uAo0Hta/ SgJLaTppU731nyCOrHXBaNCzJMwyKB283mKdQoP5Z1rGopUMCzkQCbG6pwfdkpVqDts8 DF89lAe5P6JPQA4HZTzw0aywBh30AveexoD1Li0v5+B1igxsyGkmf4pliuq7kEN44REC RrLbeWU45zMItSJlnyKO8gSeZTkA4jbg8pl9SNumVQrKVeRbHSDa0IzYF1eayN9S8DBN /RZ81dXlKGF/V2PJB83HgGA7WtViEeblmXdIfQTXKRA8hsFd07ItXPEZmbTyz98zckJl c/yw== 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=eTXVa+16WRCq1mfIfH++/tToIn8ZatLDd4FWh9pi/K1QW4NqAHVUXr6/dvE0MYy+Si R4UsZPcfgKDwqbB+COK6RbY3z6T3roihSW1go93hjQjqM47cZWjKDQDXAu4LgHk54H2Q uthueO6dglLyxoWV2q+RebHForD4wqJKNSjvkGATVQiT8Fw4QBS7RM2db9LGToeW/HZG b16SS1MUnP79EpZ2v0HExuqd+nL/K8B66oIRh3Y1nj23EvKPttSaIt3Bhx2pp8sTZQTI dKmXRQVZxpA6zxd4Mrr1EatyucQcqzNyeCmi7xC/HQfzfNDdkZLOiDrZ00137jM9YzOG 3bKA== X-Gm-Message-State: AEkoouttbsUaIefIvFPgMZHfV3avirbIacgnW8kaaAr6LHZ6E56GwyYSJ7LzMctJJALraw== X-Received: by 10.98.33.72 with SMTP id h69mr111127956pfh.28.1470193849061; Tue, 02 Aug 2016 20:10:49 -0700 (PDT) Received: from localhost ([2601:646:8581:937e:fc58:edc5:1254:cc96]) by smtp.gmail.com with ESMTPSA id o5sm7934196pfb.9.2016.08.02.20.10.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Aug 2016 20:10:48 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Tue, 2 Aug 2016 20:10:47 -0700 Message-Id: <773580dc3a1e519e60813137c2501afde3e52afd.1470156587.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] X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v6 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)