Changes in / [05e6dbe:7b50125] in buchla-emu
Legend:
- Unmodified
- Added
- Removed
-
emu/cpu.c
r05e6dbe r7b50125 75 75 { 0x180000, 0x200000, 0, fpu_init, fpu_quit, fpu_exec, fpu_read, fpu_write }, 76 76 { 0x200000, 0x280002, 0, vid_init, vid_quit, vid_exec, vid_read, vid_write }, 77 { 0x3a0001, 0x3a4001, 0, tim_init, tim_quit, tim_exec, tim_read, tim_write },77 { 0x3a0001, 0x3a4001, 4, tim_init, tim_quit, tim_exec, tim_read, tim_write }, 78 78 { 0x3a4001, 0x3a8001, 0, lcd_init, lcd_quit, lcd_exec, lcd_read, lcd_write }, 79 79 { 0x3a8001, 0x3ac001, 5, ser_init, ser_quit, ser_exec, ser_read, ser_write }, -
emu/tim.c
r05e6dbe r7b50125 24 24 int32_t tim_verbose = 0; 25 25 26 #define REG_CRX 0 27 #define REG_CR2_SR 1 28 #define REG_T1H 2 29 #define REG_T1L 3 30 #define REG_T2H 4 31 #define REG_T2L 5 32 #define REG_T3H 6 33 #define REG_T3L 7 34 35 #define COUNT_1 32 36 #define COUNT_2 3200 37 #define COUNT_3 801 38 39 typedef struct { 40 bool irq_e; 41 bool irq; 42 int32_t latch; 43 int32_t count; 44 } state_timer; 45 46 static state_timer timers[] = { 47 { .irq_e = false, .irq = false, .latch = COUNT_1, .count = COUNT_1 }, 48 { .irq_e = false, .irq = false, .latch = COUNT_2, .count = COUNT_2 }, 49 { .irq_e = false, .irq = false, .latch = COUNT_3, .count = COUNT_3 } 50 }; 51 52 static bool wr_cr1 = false; 53 static bool oper = false; 54 26 55 void tim_init(void) 27 56 { … … 36 65 bool tim_exec(void) 37 66 { 38 ver3("tim exec"); 39 return false; 67 if (oper) { 68 for (int32_t i = 0; i < ARRAY_COUNT(timers); ++i) { 69 --timers[i].count; 70 71 if (timers[i].count == 0) { 72 ver2("tim %d zero", i + 1); 73 timers[i].count = timers[i].latch; 74 75 if (timers[i].irq_e) { 76 ver2("tim %d irq", i + 1); 77 timers[i].irq = true; 78 } 79 } 80 } 81 } 82 83 return timers[0].irq || timers[1].irq || timers[2].irq; 40 84 } 41 85 … … 43 87 { 44 88 ver2("tim rd %u:%d", off, sz * 8); 45 return 0; 89 90 if (sz != 1 || off > 7) { 91 fail("invalid tim rd %u:%d", off, sz * 8); 92 } 93 94 uint32_t rv = 0x00; 95 96 switch (off) { 97 case REG_CR2_SR: 98 rv |= (uint32_t)timers[0].irq << 0; 99 rv |= (uint32_t)timers[1].irq << 1; 100 rv |= (uint32_t)timers[2].irq << 2; 101 102 ver2("tim irqs %u %u %u", 103 (uint32_t)timers[0].irq, (uint32_t)timers[1].irq, (uint32_t)timers[2].irq); 104 break; 105 106 case REG_T1L: 107 if (timers[0].irq) { 108 ver2("tim 1 !irq"); 109 timers[0].irq = false; 110 } 111 112 break; 113 114 case REG_T2L: 115 if (timers[1].irq) { 116 ver2("tim 2 !irq"); 117 timers[1].irq = false; 118 } 119 120 break; 121 122 case REG_T3L: 123 if (timers[2].irq) { 124 ver2("tim 3 !irq"); 125 timers[2].irq = false; 126 } 127 128 break; 129 130 default: 131 break; 132 } 133 134 return rv; 46 135 } 47 136 … … 49 138 { 50 139 ver2("tim wr %u:%d 0x%0*x", off, sz * 8, sz * 2, val); 140 141 if (sz != 1 || off > 7) { 142 fail("invalid tim wr %u:%d", off, sz * 8); 143 } 144 145 switch (off) { 146 case REG_CRX: 147 if (wr_cr1) { 148 if ((val & 0x01) == 0) { 149 ver2("tim start"); 150 oper = true; 151 } 152 153 timers[0].irq_e = (val & 0x40) != 0; 154 } 155 else { 156 timers[2].irq_e = (val & 0x40) != 0; 157 } 158 159 break; 160 161 case REG_CR2_SR: 162 wr_cr1 = (val & 0x01) != 0; 163 timers[1].irq_e = (val & 0x40) != 0; 164 break; 165 166 default: 167 break; 168 } 51 169 }
Note:
See TracChangeset
for help on using the changeset viewer.