Changeset 375f7fb in buchla-emu for emu


Ignore:
Timestamp:
07/29/2017 10:24:03 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
0726522
Parents:
3c30832
Message:

Better interrupt emulation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • emu/ser.c

    r3c30832 r375f7fb  
    3737
    3838typedef struct {
    39         bool irq;
     39        bool irq_r;
     40        bool irq_t;
     41        bool rdr_ok;
    4042        uint8_t rdr;
    4143} state_t;
     
    4446
    4547static state_t state[] = {
    46         { .irq = false, .rdr = 0x00 },
    47         { .irq = false, .rdr = 0x00 }
     48        { .irq_r = false, .irq_t = false, .rdr_ok = false, .rdr = 0x00 },
     49        { .irq_r = false, .irq_t = false, .rdr_ok = false, .rdr = 0x00 }
    4850};
    4951
     
    6062static void out(int32_t un, uint8_t c)
    6163{
    62         state[un].irq = true;
    6364        state[un].rdr = c;
     65        state[un].rdr_ok = true;
     66        state[un].irq_r = true;
    6467}
    6568
     
    271274{
    272275        ver3("ser exec");
    273         return state[0].irq || state[1].irq;
     276        return state[0].irq_r || state[0].irq_t || state[1].irq_r || state[1].irq_t;
    274277}
    275278
     
    289292        switch (rg) {
    290293        case REG_IER_ISR:
    291                 rv = (uint32_t)(0xc0 | (state[un].irq ? 0x01 : 0x00));
     294                rv = (uint32_t)(0xc0 | (state[un].rdr_ok ? 0x01 : 0x00));
     295                state[un].irq_r = false;
     296                state[un].irq_t = false;
    292297                ver2("ISR[%d] 0x%02x", un, rv);
    293298                break;
     
    295300        case REG_TDR_RDR:
    296301                rv = state[un].rdr;
    297                 state[un].irq = false;
     302                state[un].rdr_ok = false;
    298303                ver2("RDR[%d] 0x%02x", un, rv);
    299304                break;
     
    322327                ver2("TDR[%d] 0x%02x", un, val);
    323328                echo((uint8_t)val);
     329                state[un].irq_t = true;
    324330                break;
    325331
Note: See TracChangeset for help on using the changeset viewer.