qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: G S Niteesh Babu <niteesh.gs@gmail.com>
To: qemu-devel@nongnu.org
Cc: G S Niteesh Babu <niteesh.gs@gmail.com>,
	f4bug@amsat.org, heecheol.yang@outlook.com
Subject: [PATCH 2/3] avr/arduino: Add D13 LED
Date: Tue,  2 Mar 2021 22:59:18 +0530	[thread overview]
Message-ID: <20210302172919.7923-2-niteesh.gs@gmail.com> (raw)
In-Reply-To: <20210302172919.7923-1-niteesh.gs@gmail.com>

Signed-off-by: G S Niteesh Babu <niteesh.gs@gmail.com>
---
 hw/avr/Kconfig   |  1 +
 hw/avr/arduino.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/hw/avr/Kconfig b/hw/avr/Kconfig
index 16a57ced11..e0d4fc5537 100644
--- a/hw/avr/Kconfig
+++ b/hw/avr/Kconfig
@@ -8,3 +8,4 @@ config AVR_ATMEGA_MCU
 config ARDUINO
     select AVR_ATMEGA_MCU
     select UNIMP
+    select LED
diff --git a/hw/avr/arduino.c b/hw/avr/arduino.c
index 3c8388490d..5cdba3201c 100644
--- a/hw/avr/arduino.c
+++ b/hw/avr/arduino.c
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/boards.h"
+#include "hw/misc/led.h"
 #include "atmega.h"
 #include "boot.h"
 #include "qom/object.h"
@@ -22,6 +23,8 @@ struct ArduinoMachineState {
     MachineState parent_obj;
     /*< public >*/
     AtmegaMcuState mcu;
+
+    LEDState *onboard_led;
 };
 typedef struct ArduinoMachineState ArduinoMachineState;
 
@@ -49,6 +52,18 @@ static void arduino_machine_init(MachineState *machine)
                              amc->xtal_hz, &error_abort);
     sysbus_realize(SYS_BUS_DEVICE(&ams->mcu), &error_abort);
 
+    ams->onboard_led = led_create_simple(OBJECT(ams),
+                                         GPIO_POLARITY_ACTIVE_HIGH,
+                                         LED_COLOR_BLUE,
+                                         "D13 LED");
+
+    /* TODO: Add macro or function to map pins to ports */
+    /* The onboard led is connected to PIN 13 in all boards currently supported
+     * in QEMU. And PIN 13 is mapped to PORT B BIT 5.
+     */
+    qdev_connect_gpio_out(DEVICE(&ams->mcu.gpio[1]), 5,
+                          qdev_get_gpio_in(DEVICE(ams->onboard_led), 0));
+
     if (machine->firmware) {
         if (!avr_load_firmware(&ams->mcu.cpu, machine,
                                &ams->mcu.flash, machine->firmware)) {
-- 
2.17.1



  reply	other threads:[~2021-03-02 17:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 17:29 [PATCH 1/3] hw/avr: Add limited support for avr gpio registers G S Niteesh Babu
2021-03-02 17:29 ` G S Niteesh Babu [this message]
2021-03-02 17:29 ` [PATCH 3/3] hw/gpio/avr_gpio.c: add tracing for read and writes G S Niteesh Babu
2021-03-09 13:15 ` [PATCH 1/3] hw/avr: Add limited support for avr gpio registers Niteesh G. S.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210302172919.7923-2-niteesh.gs@gmail.com \
    --to=niteesh.gs@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=heecheol.yang@outlook.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).