Skip to content

Commit

Permalink
Compact avr_bitbang_write_bit
Browse files Browse the repository at this point in the history
  • Loading branch information
hovercraft-github committed May 14, 2018
1 parent 2ec8a9a commit 40f8003
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions simavr/sim/avr_bitbang.c
Expand Up @@ -102,11 +102,7 @@ static void avr_bitbang_write_bit(avr_bitbang_t *p)
if ( p->p_out.port ) {
avr_raise_irq(p->p_out.irq, bit);
uint16_t addr = p->p_out.ioport->r_port;
uint8_t value = p->avr->data[addr];
if (bit)
value |= 1 << p->p_out.pin;
else
value &= ~(1 << p->p_out.pin);
uint8_t value = (p->avr->data[addr] & ~(1 << p->p_out.pin)) | (!!bit << p->p_out.pin);
// at least avr->data[addr] update is required, otherwise port state is broken
// also triggering vcd signal would be nice here
avr_core_watch_write(p->avr, addr, value);
Expand Down Expand Up @@ -142,11 +138,7 @@ static void avr_bitbang_clk_edge(avr_bitbang_t *p)
if ( p->clk_generate && p->p_clk.port ) {
avr_raise_irq(p->p_clk.irq, clk);
uint16_t addr = p->p_clk.ioport->r_port;
uint8_t value = p->avr->data[addr];
if (clk)
value |= 1 << p->p_clk.pin;
else
value &= ~(1 << p->p_clk.pin);
uint8_t value = (p->avr->data[addr] & ~(1 << p->p_clk.pin)) | (!!clk << p->p_clk.pin);
// at least avr->data[addr] update is required, otherwise port state is broken
// also triggering vcd signal would be nice here
avr_core_watch_write(p->avr, addr, value);
Expand Down

0 comments on commit 40f8003

Please sign in to comment.