Skip to content

Commit

Permalink
Setup UI callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
blakewford committed Jun 3, 2015
1 parent 1b71542 commit e5d06a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions simavr/sim/avr_ioport.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
You should have received a copy of the GNU General Public License
along with simavr. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <stdio.h>
#include "avr_ioport.h"
#include "emscripten.h"

#define D(_w)

Expand Down Expand Up @@ -74,7 +75,14 @@ avr_ioport_write(
{
avr_ioport_t * p = (avr_ioport_t *)param;

if (avr->data[addr] != v) printf("** PORT%c(%02x) = %02x\r\n", p->name, addr, v);
const char* ports = "BCDEF";
if (avr->data[addr] != v)
{
//printf("** PORT%c(%02x) = %02x\r\n", p->name, addr, v);
char buffer[64];
sprintf(buffer, "writePort(%i, %i)", ports-strchr(ports, p->name), v);
emscripten_run_script(buffer);
}
avr_core_watch_write(avr, addr, v);
avr_raise_irq(p->io.irq + IOPORT_IRQ_REG_PORT, v);
avr_ioport_update_irqs(p);
Expand Down
5 changes: 4 additions & 1 deletion simavr/sim/avr_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <stdio.h>
#include "avr_spi.h"
#include "emscripten.h"

static avr_cycle_count_t avr_spi_raise(struct avr_t * avr, avr_cycle_count_t when, void * param)
{
Expand Down Expand Up @@ -53,7 +54,9 @@ static void avr_spi_write(struct avr_t * avr, avr_io_addr_t addr, uint8_t v, voi
if (addr == p->r_spdr) {
/* Clear the SPIF bit. See ATmega164/324/644 manual, Section 18.5.2. */
avr_regbit_clear(avr, p->spi.raised);
printf("SPI %i\n", v);
char buffer[64];
sprintf(buffer, "writeSPI(%i)", v);
emscripten_run_script(buffer);
avr_core_watch_write(avr, addr, v);
avr_cycle_timer_register_usec(avr, 100, avr_spi_raise, p); // should be speed dependent
}
Expand Down
1 change: 1 addition & 0 deletions simavr/sim/run_avr.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ int32_t fetchN(int32_t n)
break;
}
}
EM_ASM("refreshUI()");
return state;
}

Expand Down

0 comments on commit e5d06a2

Please sign in to comment.