Changeset 212bc4c in buchla-emu
- Timestamp:
- 08/02/2017 09:59:46 PM (7 years ago)
- Branches:
- master
- Children:
- 52c8401
- Parents:
- 8967dbc
- Location:
- emu
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
emu/cpu.c
r8967dbc r212bc4c 70 70 { 0x180000, 0x200000, 0, fpu_init, fpu_quit, fpu_exec, fpu_read, fpu_write }, 71 71 { 0x200000, 0x280000, 0, vid_init, vid_quit, vid_exec, vid_read, vid_write }, 72 { 0x3a0001, 0x3a4001, 0, tim_init, tim_quit, tim_exec, tim_read, tim_write },72 { 0x3a0001, 0x3a4001, 4, tim_init, tim_quit, tim_exec, tim_read, tim_write }, 73 73 { 0x3a4001, 0x3a8001, 0, lcd_init, lcd_quit, lcd_exec, lcd_read, lcd_write }, 74 74 { 0x3a8001, 0x3ac001, 5, ser_init, ser_quit, ser_exec, ser_read, ser_write }, -
emu/tim.c
r8967dbc r212bc4c 22 22 #define ver3(...) _ver(tim_verbose, 2, __VA_ARGS__) 23 23 24 typedef struct { 25 uint32_t irq; 26 bool run; 27 uint32_t latch; 28 uint32_t count; 29 } state_timer; 30 31 static state_timer timers[] = { 32 {.irq = 0, .run = false, .latch = 32, .count = 32}, 33 {.irq = 0, .run = false, .latch = 3200, .count = 3200}, 34 {.irq = 0, .run = false, .latch = 801, .count = 801} 35 }; 36 37 #define REG_CRX 0 38 #define REG_CR2 1 39 #define REG_T1H 2 40 #define REG_T1L 3 41 #define REG_T2H 4 42 #define REG_T2L 5 43 #define REG_T3H 6 44 #define REG_T3L 7 45 24 46 int32_t tim_verbose = 0; 25 47 … … 36 58 bool tim_exec(void) 37 59 { 38 ver3("tim exec"); 39 return false; 60 for (int32_t i = 0; i < ARRAY_COUNT(timers); ++i) { 61 if(timers[i].run == true) { 62 --timers[i].count; 63 if(timers[i].count == 0) { 64 timers[i].count = timers[i].latch; 65 timers[i].irq = 1; 66 } 67 //ver2("tim%d %u", i, timers[i].count); 68 } 69 } 70 return timers[0].irq || timers[1].irq || timers[2].irq; 40 71 } 41 72 … … 43 74 { 44 75 ver2("tim rd %u:%d", off, sz * 8); 45 return 0; 76 uint32_t rv; 77 rv = 0; 78 switch(off) { 79 case REG_CRX: 80 break; 81 case REG_CR2: 82 rv |= (timers[0].irq << 0); 83 rv |= (timers[1].irq << 1); 84 rv |= (timers[2].irq << 2); 85 ver2("tim plc %u fc %u rtc %u", timers[0].irq, timers[1].irq, timers[2].irq); 86 //ver2("tim rv %u", rv); 87 break; 88 case REG_T1H: 89 rv = 0; 90 break; 91 case REG_T1L: 92 rv = 31; 93 timers[0].irq = 0; 94 break; 95 case REG_T2H: 96 rv = 12; 97 break; 98 case REG_T2L: 99 rv = 127; 100 timers[1].irq = 0; 101 break; 102 case REG_T3H: 103 rv = 3; 104 break; 105 case REG_T3L: 106 rv = 32; 107 timers[2].irq = 0; 108 break; 109 default: 110 break; 111 } 112 return rv; 46 113 } 47 114 … … 49 116 { 50 117 ver2("tim wr %u:%d 0x%0*x", off, sz * 8, sz * 2, val); 118 if( off == 0 && (val & (1 << 7)) ) { 119 timers[0].run = true; 120 timers[1].run = true; 121 timers[2].run = true; 122 } 51 123 }
Note:
See TracChangeset
for help on using the changeset viewer.