trunk/src/emu/machine/mc68328.c
| r29289 | r29290 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | mc68328_device::mc68328_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 34 | | : device_t(mconfig, MC68328, "Motorola MC68328 (DragonBall) Integrated Processor", tag, owner, clock, "mc68328", __FILE__) |
| 34 | : device_t(mconfig, MC68328, "Motorola MC68328 (DragonBall) Integrated Processor", tag, owner, clock, "mc68328", __FILE__), |
| 35 | m_out_port_a_cb(*this), |
| 36 | m_out_port_b_cb(*this), |
| 37 | m_out_port_c_cb(*this), |
| 38 | m_out_port_d_cb(*this), |
| 39 | m_out_port_e_cb(*this), |
| 40 | m_out_port_f_cb(*this), |
| 41 | m_out_port_g_cb(*this), |
| 42 | m_out_port_j_cb(*this), |
| 43 | m_out_port_k_cb(*this), |
| 44 | m_out_port_m_cb(*this), |
| 45 | m_in_port_a_cb(*this), |
| 46 | m_in_port_b_cb(*this), |
| 47 | m_in_port_c_cb(*this), |
| 48 | m_in_port_d_cb(*this), |
| 49 | m_in_port_e_cb(*this), |
| 50 | m_in_port_f_cb(*this), |
| 51 | m_in_port_g_cb(*this), |
| 52 | m_in_port_j_cb(*this), |
| 53 | m_in_port_k_cb(*this), |
| 54 | m_in_port_m_cb(*this), |
| 55 | m_out_pwm_cb(*this), |
| 56 | m_out_spim_cb(*this), |
| 57 | m_in_spim_cb(*this), |
| 58 | m_spim_xch_trigger_cb(*this), |
| 59 | m_cpu(*this) |
| 35 | 60 | { |
| 36 | 61 | } |
| 37 | 62 | |
| 38 | 63 | //------------------------------------------------- |
| 39 | | // device_config_complete - perform any |
| 40 | | // operations now that the configuration is |
| 41 | | // complete |
| 42 | | //------------------------------------------------- |
| 43 | | |
| 44 | | void mc68328_device::device_config_complete() |
| 45 | | { |
| 46 | | // inherit a copy of the static data |
| 47 | | const mc68328_interface *intf = reinterpret_cast<const mc68328_interface *>(static_config()); |
| 48 | | if (intf != NULL) |
| 49 | | *static_cast<mc68328_interface *>(this) = *intf; |
| 50 | | |
| 51 | | // or initialize to defaults if none provided |
| 52 | | else |
| 53 | | { |
| 54 | | memset(&m_out_port_a_func, 0, sizeof(m_out_port_a_func)); |
| 55 | | memset(&m_out_port_b_func, 0, sizeof(m_out_port_b_func)); |
| 56 | | memset(&m_out_port_c_func, 0, sizeof(m_out_port_c_func)); |
| 57 | | memset(&m_out_port_d_func, 0, sizeof(m_out_port_d_func)); |
| 58 | | memset(&m_out_port_e_func, 0, sizeof(m_out_port_e_func)); |
| 59 | | memset(&m_out_port_f_func, 0, sizeof(m_out_port_f_func)); |
| 60 | | memset(&m_out_port_g_func, 0, sizeof(m_out_port_g_func)); |
| 61 | | memset(&m_out_port_j_func, 0, sizeof(m_out_port_j_func)); |
| 62 | | memset(&m_out_port_k_func, 0, sizeof(m_out_port_k_func)); |
| 63 | | memset(&m_out_port_m_func, 0, sizeof(m_out_port_m_func)); |
| 64 | | memset(&m_in_port_a_func, 0, sizeof(m_in_port_a_func)); |
| 65 | | memset(&m_in_port_b_func, 0, sizeof(m_in_port_b_func)); |
| 66 | | memset(&m_in_port_c_func, 0, sizeof(m_in_port_c_func)); |
| 67 | | memset(&m_in_port_d_func, 0, sizeof(m_in_port_d_func)); |
| 68 | | memset(&m_in_port_e_func, 0, sizeof(m_in_port_e_func)); |
| 69 | | memset(&m_in_port_f_func, 0, sizeof(m_in_port_f_func)); |
| 70 | | memset(&m_in_port_g_func, 0, sizeof(m_in_port_g_func)); |
| 71 | | memset(&m_in_port_j_func, 0, sizeof(m_in_port_j_func)); |
| 72 | | memset(&m_in_port_k_func, 0, sizeof(m_in_port_k_func)); |
| 73 | | memset(&m_in_port_m_func, 0, sizeof(m_in_port_m_func)); |
| 74 | | memset(&m_out_pwm_func, 0, sizeof(m_out_pwm_func)); |
| 75 | | memset(&m_out_spim_func, 0, sizeof(m_out_spim_func)); |
| 76 | | memset(&m_in_spim_func, 0, sizeof(m_in_spim_func)); |
| 77 | | memset(&m_spim_xch_trigger_func, 0, sizeof(m_spim_xch_trigger_func)); |
| 78 | | m68k_cpu_tag = ""; |
| 79 | | } |
| 80 | | } |
| 81 | | |
| 82 | | //------------------------------------------------- |
| 83 | 64 | // device_start - device-specific startup |
| 84 | 65 | //------------------------------------------------- |
| 85 | 66 | |
| 86 | 67 | void mc68328_device::device_start() |
| 87 | 68 | { |
| 88 | | m_out_port_a.resolve(m_out_port_a_func, *this); |
| 89 | | m_out_port_b.resolve(m_out_port_b_func, *this); |
| 90 | | m_out_port_c.resolve(m_out_port_c_func, *this); |
| 91 | | m_out_port_d.resolve(m_out_port_d_func, *this); |
| 92 | | m_out_port_e.resolve(m_out_port_e_func, *this); |
| 93 | | m_out_port_f.resolve(m_out_port_f_func, *this); |
| 94 | | m_out_port_g.resolve(m_out_port_g_func, *this); |
| 95 | | m_out_port_j.resolve(m_out_port_j_func, *this); |
| 96 | | m_out_port_k.resolve(m_out_port_k_func, *this); |
| 97 | | m_out_port_m.resolve(m_out_port_m_func, *this); |
| 69 | m_out_port_a_cb.resolve(); |
| 70 | m_out_port_b_cb.resolve(); |
| 71 | m_out_port_c_cb.resolve(); |
| 72 | m_out_port_d_cb.resolve(); |
| 73 | m_out_port_e_cb.resolve(); |
| 74 | m_out_port_f_cb.resolve(); |
| 75 | m_out_port_g_cb.resolve(); |
| 76 | m_out_port_j_cb.resolve(); |
| 77 | m_out_port_k_cb.resolve(); |
| 78 | m_out_port_m_cb.resolve(); |
| 98 | 79 | |
| 99 | | m_in_port_a.resolve(m_in_port_a_func, *this); |
| 100 | | m_in_port_b.resolve(m_in_port_b_func, *this); |
| 101 | | m_in_port_c.resolve(m_in_port_c_func, *this); |
| 102 | | m_in_port_d.resolve(m_in_port_d_func, *this); |
| 103 | | m_in_port_e.resolve(m_in_port_e_func, *this); |
| 104 | | m_in_port_f.resolve(m_in_port_f_func, *this); |
| 105 | | m_in_port_g.resolve(m_in_port_g_func, *this); |
| 106 | | m_in_port_j.resolve(m_in_port_j_func, *this); |
| 107 | | m_in_port_k.resolve(m_in_port_k_func, *this); |
| 108 | | m_in_port_m.resolve(m_in_port_m_func, *this); |
| 80 | m_in_port_a_cb.resolve(); |
| 81 | m_in_port_b_cb.resolve(); |
| 82 | m_in_port_c_cb.resolve(); |
| 83 | m_in_port_d_cb.resolve(); |
| 84 | m_in_port_e_cb.resolve(); |
| 85 | m_in_port_f_cb.resolve(); |
| 86 | m_in_port_g_cb.resolve(); |
| 87 | m_in_port_j_cb.resolve(); |
| 88 | m_in_port_k_cb.resolve(); |
| 89 | m_in_port_m_cb.resolve(); |
| 109 | 90 | |
| 110 | | m_out_pwm.resolve(m_out_pwm_func, *this); |
| 91 | m_out_pwm_cb.resolve(); |
| 111 | 92 | |
| 112 | | m_out_spim.resolve(m_out_spim_func, *this); |
| 113 | | m_in_spim.resolve(m_in_spim_func, *this); |
| 93 | m_out_spim_cb.resolve(); |
| 94 | m_in_spim_cb.resolve(); |
| 114 | 95 | |
| 115 | | m_spim_xch_trigger.resolve(m_spim_xch_trigger_func, *this); |
| 96 | m_spim_xch_trigger_cb.resolve(); |
| 116 | 97 | |
| 117 | | m_cpu = machine().device<cpu_device>(m68k_cpu_tag); |
| 118 | | |
| 119 | 98 | m_gptimer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68328_device::timer1_hit),this)); |
| 120 | 99 | m_gptimer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68328_device::timer2_hit),this)); |
| 121 | 100 | m_rtc = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc68328_device::rtc_tick),this)); |
| r29289 | r29290 | |
| 534 | 513 | |
| 535 | 514 | m_regs.pwmc ^= PWMC_PIN; |
| 536 | 515 | |
| 537 | | if (!m_out_pwm.isnull()) |
| 516 | if (!m_out_pwm_cb.isnull()) |
| 538 | 517 | { |
| 539 | | m_out_pwm(0, (m_regs.pwmc & PWMC_PIN) ? 1 : 0); |
| 518 | m_out_pwm_cb((offs_t)0, (m_regs.pwmc & PWMC_PIN) ? 1 : 0); |
| 540 | 519 | } |
| 541 | 520 | } |
| 542 | 521 | |
| r29289 | r29290 | |
| 990 | 969 | { |
| 991 | 970 | verboselog(machine(), 2, "mc68328_w: PADATA = %02x\n", data & 0x00ff); |
| 992 | 971 | m_regs.padata = data & 0x00ff; |
| 993 | | if (!m_out_port_a.isnull()) |
| 972 | if (!m_out_port_a_cb.isnull()) |
| 994 | 973 | { |
| 995 | | m_out_port_a(0, data & 0x00ff); |
| 974 | m_out_port_a_cb((offs_t)0, data & 0x00ff); |
| 996 | 975 | } |
| 997 | 976 | } |
| 998 | 977 | else |
| r29289 | r29290 | |
| 1019 | 998 | { |
| 1020 | 999 | verboselog(machine(), 2, "mc68328_w: PBDATA = %02x\n", data & 0x00ff); |
| 1021 | 1000 | m_regs.pbdata = data & 0x00ff; |
| 1022 | | if (!m_out_port_b.isnull()) |
| 1001 | if (!m_out_port_b_cb.isnull()) |
| 1023 | 1002 | { |
| 1024 | | m_out_port_b(0, data & 0x00ff); |
| 1003 | m_out_port_b_cb((offs_t)0, data & 0x00ff); |
| 1025 | 1004 | } |
| 1026 | 1005 | } |
| 1027 | 1006 | else |
| r29289 | r29290 | |
| 1048 | 1027 | { |
| 1049 | 1028 | verboselog(machine(), 2, "mc68328_w: PCDATA = %02x\n", data & 0x00ff); |
| 1050 | 1029 | m_regs.pcdata = data & 0x00ff; |
| 1051 | | if (!m_out_port_c.isnull()) |
| 1030 | if (!m_out_port_c_cb.isnull()) |
| 1052 | 1031 | { |
| 1053 | | m_out_port_c(0, data & 0x00ff); |
| 1032 | m_out_port_c_cb((offs_t)0, data & 0x00ff); |
| 1054 | 1033 | } |
| 1055 | 1034 | } |
| 1056 | 1035 | else |
| r29289 | r29290 | |
| 1131 | 1110 | { |
| 1132 | 1111 | verboselog(machine(), 2, "mc68328_w: PEDATA = %02x\n", data & 0x00ff); |
| 1133 | 1112 | m_regs.pedata = data & 0x00ff; |
| 1134 | | if (!m_out_port_e.isnull()) |
| 1113 | if (!m_out_port_e_cb.isnull()) |
| 1135 | 1114 | { |
| 1136 | | m_out_port_e(0, data & 0x00ff); |
| 1115 | m_out_port_e_cb((offs_t)0, data & 0x00ff); |
| 1137 | 1116 | } |
| 1138 | 1117 | } |
| 1139 | 1118 | else |
| r29289 | r29290 | |
| 1162 | 1141 | { |
| 1163 | 1142 | verboselog(machine(), 2, "mc68328_w: PFDATA = %02x\n", data & 0x00ff); |
| 1164 | 1143 | m_regs.pfdata = data & 0x00ff; |
| 1165 | | if (!m_out_port_f.isnull()) |
| 1144 | if (!m_out_port_f_cb.isnull()) |
| 1166 | 1145 | { |
| 1167 | | m_out_port_f(0, data & 0x00ff); |
| 1146 | m_out_port_f_cb((offs_t)0, data & 0x00ff); |
| 1168 | 1147 | } |
| 1169 | 1148 | } |
| 1170 | 1149 | else |
| r29289 | r29290 | |
| 1192 | 1171 | { |
| 1193 | 1172 | verboselog(machine(), 2, "mc68328_w: PGDATA = %02x\n", data & 0x00ff); |
| 1194 | 1173 | m_regs.pgdata = data & 0x00ff; |
| 1195 | | if (!m_out_port_g.isnull()) |
| 1174 | if (!m_out_port_g_cb.isnull()) |
| 1196 | 1175 | { |
| 1197 | | m_out_port_g(0, data & 0x00ff); |
| 1176 | m_out_port_g_cb((offs_t)0, data & 0x00ff); |
| 1198 | 1177 | } |
| 1199 | 1178 | } |
| 1200 | 1179 | else |
| r29289 | r29290 | |
| 1222 | 1201 | { |
| 1223 | 1202 | verboselog(machine(), 2, "mc68328_w: PJDATA = %02x\n", data & 0x00ff); |
| 1224 | 1203 | m_regs.pjdata = data & 0x00ff; |
| 1225 | | if (!m_out_port_j.isnull()) |
| 1204 | if (!m_out_port_j_cb.isnull()) |
| 1226 | 1205 | { |
| 1227 | | m_out_port_j(0, data & 0x00ff); |
| 1206 | m_out_port_j_cb((offs_t)0, data & 0x00ff); |
| 1228 | 1207 | } |
| 1229 | 1208 | } |
| 1230 | 1209 | else |
| r29289 | r29290 | |
| 1251 | 1230 | { |
| 1252 | 1231 | verboselog(machine(), 2, "mc68328_w: PKDATA = %02x\n", data & 0x00ff); |
| 1253 | 1232 | m_regs.pkdata = data & 0x00ff; |
| 1254 | | if (!m_out_port_k.isnull()) |
| 1233 | if (!m_out_port_k_cb.isnull()) |
| 1255 | 1234 | { |
| 1256 | | m_out_port_k(0, data & 0x00ff); |
| 1235 | m_out_port_k_cb((offs_t)0, data & 0x00ff); |
| 1257 | 1236 | } |
| 1258 | 1237 | } |
| 1259 | 1238 | else |
| r29289 | r29290 | |
| 1281 | 1260 | { |
| 1282 | 1261 | verboselog(machine(), 2, "mc68328_w: PMDATA = %02x\n", data & 0x00ff); |
| 1283 | 1262 | m_regs.pmdata = data & 0x00ff; |
| 1284 | | if (!m_out_port_m.isnull()) |
| 1263 | if (!m_out_port_m_cb.isnull()) |
| 1285 | 1264 | { |
| 1286 | | m_out_port_m(0, data & 0x00ff); |
| 1265 | m_out_port_m_cb((offs_t)0, data & 0x00ff); |
| 1287 | 1266 | } |
| 1288 | 1267 | } |
| 1289 | 1268 | else |
| r29289 | r29290 | |
| 1460 | 1439 | |
| 1461 | 1440 | case 0x800: |
| 1462 | 1441 | verboselog(machine(), 2, "mc68328_w: SPIMDATA = %04x\n", data); |
| 1463 | | if (!m_out_spim.isnull()) |
| 1442 | if (!m_out_spim_cb.isnull()) |
| 1464 | 1443 | { |
| 1465 | | m_out_spim(0, data, 0xffff); |
| 1444 | m_out_spim_cb(0, data, 0xffff); |
| 1466 | 1445 | } |
| 1467 | 1446 | else |
| 1468 | 1447 | { |
| r29289 | r29290 | |
| 1485 | 1464 | if (data & SPIM_XCH) |
| 1486 | 1465 | { |
| 1487 | 1466 | m_regs.spimcont &= ~SPIM_XCH; |
| 1488 | | if (!m_spim_xch_trigger.isnull()) |
| 1467 | if (!m_spim_xch_trigger_cb.isnull()) |
| 1489 | 1468 | { |
| 1490 | | m_spim_xch_trigger(0); |
| 1469 | m_spim_xch_trigger_cb(0); |
| 1491 | 1470 | } |
| 1492 | 1471 | if (data & SPIM_IRQEN) |
| 1493 | 1472 | { |
| r29289 | r29290 | |
| 2064 | 2043 | if (mem_mask & 0x00ff) |
| 2065 | 2044 | { |
| 2066 | 2045 | verboselog(machine(), 2, "mc68328_r (%04x): PADATA = %02x\n", mem_mask, m_regs.padata); |
| 2067 | | if (!m_in_port_a.isnull()) |
| 2046 | if (!m_in_port_a_cb.isnull()) |
| 2068 | 2047 | { |
| 2069 | | return m_in_port_a(0); |
| 2048 | return m_in_port_a_cb(0); |
| 2070 | 2049 | } |
| 2071 | 2050 | else |
| 2072 | 2051 | { |
| r29289 | r29290 | |
| 2096 | 2075 | if (mem_mask & 0x00ff) |
| 2097 | 2076 | { |
| 2098 | 2077 | verboselog(machine(), 2, "mc68328_r (%04x): PBDATA = %02x\n", mem_mask, m_regs.pbdata); |
| 2099 | | if (!m_in_port_b.isnull()) |
| 2078 | if (!m_in_port_b_cb.isnull()) |
| 2100 | 2079 | { |
| 2101 | | return m_in_port_b(0); |
| 2080 | return m_in_port_b_cb(0); |
| 2102 | 2081 | } |
| 2103 | 2082 | else |
| 2104 | 2083 | { |
| r29289 | r29290 | |
| 2128 | 2107 | if (mem_mask & 0x00ff) |
| 2129 | 2108 | { |
| 2130 | 2109 | verboselog(machine(), 2, "mc68328_r (%04x): PCDATA = %02x\n", mem_mask, m_regs.pcdata); |
| 2131 | | if (!m_in_port_c.isnull()) |
| 2110 | if (!m_in_port_c_cb.isnull()) |
| 2132 | 2111 | { |
| 2133 | | return m_in_port_c(0); |
| 2112 | return m_in_port_c_cb(0); |
| 2134 | 2113 | } |
| 2135 | 2114 | else |
| 2136 | 2115 | { |
| r29289 | r29290 | |
| 2160 | 2139 | if (mem_mask & 0x00ff) |
| 2161 | 2140 | { |
| 2162 | 2141 | verboselog(machine(), 2, "mc68328_r (%04x): PDDATA = %02x\n", mem_mask, m_regs.pddata); |
| 2163 | | if (!m_in_port_d.isnull()) |
| 2142 | if (!m_in_port_d_cb.isnull()) |
| 2164 | 2143 | { |
| 2165 | | return m_in_port_d(0); |
| 2144 | return m_in_port_d_cb(0); |
| 2166 | 2145 | } |
| 2167 | 2146 | else |
| 2168 | 2147 | { |
| r29289 | r29290 | |
| 2217 | 2196 | if (mem_mask & 0x00ff) |
| 2218 | 2197 | { |
| 2219 | 2198 | verboselog(machine(), 2, "mc68328_r (%04x): PEDATA = %02x\n", mem_mask, m_regs.pedata); |
| 2220 | | if (!m_in_port_e.isnull()) |
| 2199 | if (!m_in_port_e_cb.isnull()) |
| 2221 | 2200 | { |
| 2222 | | return m_in_port_e(0); |
| 2201 | return m_in_port_e_cb(0); |
| 2223 | 2202 | } |
| 2224 | 2203 | else |
| 2225 | 2204 | { |
| r29289 | r29290 | |
| 2250 | 2229 | if (mem_mask & 0x00ff) |
| 2251 | 2230 | { |
| 2252 | 2231 | verboselog(machine(), 2, "mc68328_r (%04x): PFDATA = %02x\n", mem_mask, m_regs.pfdata); |
| 2253 | | if (!m_in_port_f.isnull()) |
| 2232 | if (!m_in_port_f_cb.isnull()) |
| 2254 | 2233 | { |
| 2255 | | return m_in_port_f(0); |
| 2234 | return m_in_port_f_cb(0); |
| 2256 | 2235 | } |
| 2257 | 2236 | else |
| 2258 | 2237 | { |
| r29289 | r29290 | |
| 2283 | 2262 | if (mem_mask & 0x00ff) |
| 2284 | 2263 | { |
| 2285 | 2264 | verboselog(machine(), 2, "mc68328_r (%04x): PGDATA = %02x\n", mem_mask, m_regs.pgdata); |
| 2286 | | if (!m_in_port_g.isnull()) |
| 2265 | if (!m_in_port_g_cb.isnull()) |
| 2287 | 2266 | { |
| 2288 | | return m_in_port_g(0); |
| 2267 | return m_in_port_g_cb(0); |
| 2289 | 2268 | } |
| 2290 | 2269 | else |
| 2291 | 2270 | { |
| r29289 | r29290 | |
| 2316 | 2295 | if (mem_mask & 0x00ff) |
| 2317 | 2296 | { |
| 2318 | 2297 | verboselog(machine(), 2, "mc68328_r (%04x): PJDATA = %02x\n", mem_mask, m_regs.pjdata); |
| 2319 | | if (!m_in_port_j.isnull()) |
| 2298 | if (!m_in_port_j_cb.isnull()) |
| 2320 | 2299 | { |
| 2321 | | return m_in_port_j(0); |
| 2300 | return m_in_port_j_cb(0); |
| 2322 | 2301 | } |
| 2323 | 2302 | else |
| 2324 | 2303 | { |
| r29289 | r29290 | |
| 2348 | 2327 | if (mem_mask & 0x00ff) |
| 2349 | 2328 | { |
| 2350 | 2329 | verboselog(machine(), 2, "mc68328_r (%04x): PKDATA = %02x\n", mem_mask, m_regs.pkdata); |
| 2351 | | if (!m_in_port_k.isnull()) |
| 2330 | if (!m_in_port_k_cb.isnull()) |
| 2352 | 2331 | { |
| 2353 | | return m_in_port_k(0); |
| 2332 | return m_in_port_k_cb(0); |
| 2354 | 2333 | } |
| 2355 | 2334 | else |
| 2356 | 2335 | { |
| r29289 | r29290 | |
| 2381 | 2360 | if (mem_mask & 0x00ff) |
| 2382 | 2361 | { |
| 2383 | 2362 | verboselog(machine(), 2, "mc68328_r (%04x): PMDATA = %02x\n", mem_mask, m_regs.pmdata); |
| 2384 | | if (!m_in_port_m.isnull()) |
| 2363 | if (!m_in_port_m_cb.isnull()) |
| 2385 | 2364 | { |
| 2386 | | return m_in_port_m(0); |
| 2365 | return m_in_port_m_cb(0); |
| 2387 | 2366 | } |
| 2388 | 2367 | else |
| 2389 | 2368 | { |
| r29289 | r29290 | |
| 2500 | 2479 | |
| 2501 | 2480 | case 0x800: |
| 2502 | 2481 | verboselog(machine(), 2, "mc68328_r (%04x): SPIMDATA = %04x\n", mem_mask, m_regs.spimdata); |
| 2503 | | if (!m_in_spim.isnull()) |
| 2482 | if (!m_in_spim_cb.isnull()) |
| 2504 | 2483 | { |
| 2505 | | return m_in_spim(0, 0xffff); |
| 2484 | return m_in_spim_cb(0, 0xffff); |
| 2506 | 2485 | } |
| 2507 | 2486 | return m_regs.spimdata; |
| 2508 | 2487 | |
trunk/src/emu/machine/mc68328.h
| r29289 | r29290 | |
| 408 | 408 | #define PWMC_PWMEN 0x0010 |
| 409 | 409 | #define PWMC_CLKSEL 0x0007 |
| 410 | 410 | |
| 411 | | |
| 412 | | struct mc68328_interface |
| 413 | | { |
| 414 | | const char *m68k_cpu_tag; |
| 415 | | |
| 416 | | devcb_write8 m_out_port_a_func; /* 8-bit output */ |
| 417 | | devcb_write8 m_out_port_b_func; /* 8-bit output */ |
| 418 | | devcb_write8 m_out_port_c_func; /* 8-bit output */ |
| 419 | | devcb_write8 m_out_port_d_func; /* 8-bit output */ |
| 420 | | devcb_write8 m_out_port_e_func; /* 8-bit output */ |
| 421 | | devcb_write8 m_out_port_f_func; /* 8-bit output */ |
| 422 | | devcb_write8 m_out_port_g_func; /* 8-bit output */ |
| 423 | | devcb_write8 m_out_port_j_func; /* 8-bit output */ |
| 424 | | devcb_write8 m_out_port_k_func; /* 8-bit output */ |
| 425 | | devcb_write8 m_out_port_m_func; /* 8-bit output */ |
| 426 | | |
| 427 | | devcb_read8 m_in_port_a_func; /* 8-bit input */ |
| 428 | | devcb_read8 m_in_port_b_func; /* 8-bit input */ |
| 429 | | devcb_read8 m_in_port_c_func; /* 8-bit input */ |
| 430 | | devcb_read8 m_in_port_d_func; /* 8-bit input */ |
| 431 | | devcb_read8 m_in_port_e_func; /* 8-bit input */ |
| 432 | | devcb_read8 m_in_port_f_func; /* 8-bit input */ |
| 433 | | devcb_read8 m_in_port_g_func; /* 8-bit input */ |
| 434 | | devcb_read8 m_in_port_j_func; /* 8-bit input */ |
| 435 | | devcb_read8 m_in_port_k_func; /* 8-bit input */ |
| 436 | | devcb_read8 m_in_port_m_func; /* 8-bit input */ |
| 437 | | |
| 438 | | devcb_write8 m_out_pwm_func; /* 1-bit output */ |
| 439 | | |
| 440 | | devcb_write16 m_out_spim_func; /* 16-bit output */ |
| 441 | | devcb_read16 m_in_spim_func; /* 16-bit input */ |
| 442 | | |
| 443 | | devcb_write_line m_spim_xch_trigger_func; /* SPIM exchange trigger */ |
| 444 | | }; |
| 445 | | |
| 446 | | |
| 447 | 411 | struct mc68328_regs_t |
| 448 | 412 | { |
| 449 | 413 | // $(FF)FFF000 |
| r29289 | r29290 | |
| 638 | 602 | }; |
| 639 | 603 | |
| 640 | 604 | |
| 641 | | class mc68328_device : public device_t, |
| 642 | | public mc68328_interface |
| 605 | class mc68328_device : public device_t |
| 643 | 606 | { |
| 644 | 607 | public: |
| 645 | 608 | mc68328_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 646 | 609 | ~mc68328_device() {} |
| 647 | 610 | |
| 611 | static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<mc68328_device &>(device).m_cpu.set_tag(tag); } |
| 612 | template<class _Object> static devcb2_base &set_out_port_a_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_a_cb.set_callback(object); } |
| 613 | template<class _Object> static devcb2_base &set_out_port_b_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_b_cb.set_callback(object); } |
| 614 | template<class _Object> static devcb2_base &set_out_port_c_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_c_cb.set_callback(object); } |
| 615 | template<class _Object> static devcb2_base &set_out_port_d_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_d_cb.set_callback(object); } |
| 616 | template<class _Object> static devcb2_base &set_out_port_e_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_e_cb.set_callback(object); } |
| 617 | template<class _Object> static devcb2_base &set_out_port_f_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_f_cb.set_callback(object); } |
| 618 | template<class _Object> static devcb2_base &set_out_port_g_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_g_cb.set_callback(object); } |
| 619 | template<class _Object> static devcb2_base &set_out_port_j_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_j_cb.set_callback(object); } |
| 620 | template<class _Object> static devcb2_base &set_out_port_k_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_k_cb.set_callback(object); } |
| 621 | template<class _Object> static devcb2_base &set_out_port_m_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_port_m_cb.set_callback(object); } |
| 622 | template<class _Object> static devcb2_base &set_in_port_a_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_a_cb.set_callback(object); } |
| 623 | template<class _Object> static devcb2_base &set_in_port_b_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_b_cb.set_callback(object); } |
| 624 | template<class _Object> static devcb2_base &set_in_port_c_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_c_cb.set_callback(object); } |
| 625 | template<class _Object> static devcb2_base &set_in_port_d_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_d_cb.set_callback(object); } |
| 626 | template<class _Object> static devcb2_base &set_in_port_e_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_e_cb.set_callback(object); } |
| 627 | template<class _Object> static devcb2_base &set_in_port_f_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_f_cb.set_callback(object); } |
| 628 | template<class _Object> static devcb2_base &set_in_port_g_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_g_cb.set_callback(object); } |
| 629 | template<class _Object> static devcb2_base &set_in_port_j_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_j_cb.set_callback(object); } |
| 630 | template<class _Object> static devcb2_base &set_in_port_k_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_k_cb.set_callback(object); } |
| 631 | template<class _Object> static devcb2_base &set_in_port_m_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_port_m_cb.set_callback(object); } |
| 632 | template<class _Object> static devcb2_base &set_out_pwm_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_pwm_cb.set_callback(object); } |
| 633 | template<class _Object> static devcb2_base &set_out_spim_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_out_spim_cb.set_callback(object); } |
| 634 | template<class _Object> static devcb2_base &set_in_spim_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_in_spim_cb.set_callback(object); } |
| 635 | template<class _Object> static devcb2_base &set_spim_xch_trigger_callback(device_t &device, _Object object) { return downcast<mc68328_device &>(device).m_spim_xch_trigger_cb.set_callback(object); } |
| 636 | |
| 637 | |
| 648 | 638 | DECLARE_WRITE16_MEMBER(write); |
| 649 | 639 | DECLARE_READ16_MEMBER(read); |
| 650 | 640 | DECLARE_WRITE_LINE_MEMBER(set_penirq_line); |
| r29289 | r29290 | |
| 654 | 644 | |
| 655 | 645 | protected: |
| 656 | 646 | // device-level overrides |
| 657 | | virtual void device_config_complete(); |
| 658 | 647 | virtual void device_start(); |
| 659 | 648 | virtual void device_reset(); |
| 660 | 649 | |
| r29289 | r29290 | |
| 679 | 668 | emu_timer *m_rtc; |
| 680 | 669 | emu_timer *m_pwm; |
| 681 | 670 | |
| 682 | | devcb_resolved_write8 m_out_port_a; /* 8-bit output */ |
| 683 | | devcb_resolved_write8 m_out_port_b; /* 8-bit output */ |
| 684 | | devcb_resolved_write8 m_out_port_c; /* 8-bit output */ |
| 685 | | devcb_resolved_write8 m_out_port_d; /* 8-bit output */ |
| 686 | | devcb_resolved_write8 m_out_port_e; /* 8-bit output */ |
| 687 | | devcb_resolved_write8 m_out_port_f; /* 8-bit output */ |
| 688 | | devcb_resolved_write8 m_out_port_g; /* 8-bit output */ |
| 689 | | devcb_resolved_write8 m_out_port_j; /* 8-bit output */ |
| 690 | | devcb_resolved_write8 m_out_port_k; /* 8-bit output */ |
| 691 | | devcb_resolved_write8 m_out_port_m; /* 8-bit output */ |
| 671 | devcb2_write8 m_out_port_a_cb; /* 8-bit output */ |
| 672 | devcb2_write8 m_out_port_b_cb; /* 8-bit output */ |
| 673 | devcb2_write8 m_out_port_c_cb; /* 8-bit output */ |
| 674 | devcb2_write8 m_out_port_d_cb; /* 8-bit output */ |
| 675 | devcb2_write8 m_out_port_e_cb; /* 8-bit output */ |
| 676 | devcb2_write8 m_out_port_f_cb; /* 8-bit output */ |
| 677 | devcb2_write8 m_out_port_g_cb; /* 8-bit output */ |
| 678 | devcb2_write8 m_out_port_j_cb; /* 8-bit output */ |
| 679 | devcb2_write8 m_out_port_k_cb; /* 8-bit output */ |
| 680 | devcb2_write8 m_out_port_m_cb; /* 8-bit output */ |
| 692 | 681 | |
| 693 | | devcb_resolved_read8 m_in_port_a; /* 8-bit input */ |
| 694 | | devcb_resolved_read8 m_in_port_b; /* 8-bit input */ |
| 695 | | devcb_resolved_read8 m_in_port_c; /* 8-bit input */ |
| 696 | | devcb_resolved_read8 m_in_port_d; /* 8-bit input */ |
| 697 | | devcb_resolved_read8 m_in_port_e; /* 8-bit input */ |
| 698 | | devcb_resolved_read8 m_in_port_f; /* 8-bit input */ |
| 699 | | devcb_resolved_read8 m_in_port_g; /* 8-bit input */ |
| 700 | | devcb_resolved_read8 m_in_port_j; /* 8-bit input */ |
| 701 | | devcb_resolved_read8 m_in_port_k; /* 8-bit input */ |
| 702 | | devcb_resolved_read8 m_in_port_m; /* 8-bit input */ |
| 682 | devcb2_read8 m_in_port_a_cb; /* 8-bit input */ |
| 683 | devcb2_read8 m_in_port_b_cb; /* 8-bit input */ |
| 684 | devcb2_read8 m_in_port_c_cb; /* 8-bit input */ |
| 685 | devcb2_read8 m_in_port_d_cb; /* 8-bit input */ |
| 686 | devcb2_read8 m_in_port_e_cb; /* 8-bit input */ |
| 687 | devcb2_read8 m_in_port_f_cb; /* 8-bit input */ |
| 688 | devcb2_read8 m_in_port_g_cb; /* 8-bit input */ |
| 689 | devcb2_read8 m_in_port_j_cb; /* 8-bit input */ |
| 690 | devcb2_read8 m_in_port_k_cb; /* 8-bit input */ |
| 691 | devcb2_read8 m_in_port_m_cb; /* 8-bit input */ |
| 703 | 692 | |
| 704 | | devcb_resolved_write8 m_out_pwm; /* 1-bit output */ |
| 693 | devcb2_write8 m_out_pwm_cb; /* 1-bit output */ |
| 705 | 694 | |
| 706 | | devcb_resolved_write16 m_out_spim; /* 16-bit output */ |
| 707 | | devcb_resolved_read16 m_in_spim; /* 16-bit input */ |
| 695 | devcb2_write16 m_out_spim_cb; /* 16-bit output */ |
| 696 | devcb2_read16 m_in_spim_cb; /* 16-bit input */ |
| 708 | 697 | |
| 709 | | devcb_resolved_write_line m_spim_xch_trigger; // not really a write_line, fix when converting to devcb2! |
| 698 | devcb2_write_line m_spim_xch_trigger_cb; /* SPIM exchange trigger */ /*todo: not really a write line, fix*/ |
| 710 | 699 | |
| 711 | | cpu_device *m_cpu; |
| 700 | required_device<cpu_device> m_cpu; |
| 712 | 701 | }; |
| 702 | |
| 713 | 703 | |
| 704 | extern const device_type MC68328; |
| 714 | 705 | |
| 715 | | #define MC68328_INTERFACE(name) const mc68328_interface (name)= |
| 706 | #define MCFG_MC68328_CPU(_tag) \ |
| 707 | mc68328_device::static_set_cpu_tag(*device, "^"_tag); |
| 708 | |
| 709 | #define MCFG_MC68328_OUT_PORT_A_CB(_devcb) \ |
| 710 | devcb = &mc68328_device::set_out_port_a_callback(*device, DEVCB2_##_devcb); |
| 711 | |
| 712 | #define MCFG_MC68328_OUT_PORT_B_CB(_devcb) \ |
| 713 | devcb = &mc68328_device::set_out_port_b_callback(*device, DEVCB2_##_devcb); |
| 714 | |
| 715 | #define MCFG_MC68328_OUT_PORT_C_CB(_devcb) \ |
| 716 | devcb = &mc68328_device::set_out_port_c_callback(*device, DEVCB2_##_devcb); |
| 717 | |
| 718 | #define MCFG_MC68328_OUT_PORT_D_CB(_devcb) \ |
| 719 | devcb = &mc68328_device::set_out_port_d_callback(*device, DEVCB2_##_devcb); |
| 720 | |
| 721 | #define MCFG_MC68328_OUT_PORT_E_CB(_devcb) \ |
| 722 | devcb = &mc68328_device::set_out_port_e_callback(*device, DEVCB2_##_devcb); |
| 723 | |
| 724 | #define MCFG_MC68328_OUT_PORT_F_CB(_devcb) \ |
| 725 | devcb = &mc68328_device::set_out_port_f_callback(*device, DEVCB2_##_devcb); |
| 726 | |
| 727 | #define MCFG_MC68328_OUT_PORT_G_CB(_devcb) \ |
| 728 | devcb = &mc68328_device::set_out_port_g_callback(*device, DEVCB2_##_devcb); |
| 729 | |
| 730 | #define MCFG_MC68328_OUT_PORT_J_CB(_devcb) \ |
| 731 | devcb = &mc68328_device::set_out_port_j_callback(*device, DEVCB2_##_devcb); |
| 732 | |
| 733 | #define MCFG_MC68328_OUT_PORT_K_CB(_devcb) \ |
| 734 | devcb = &mc68328_device::set_out_port_k_callback(*device, DEVCB2_##_devcb); |
| 735 | |
| 736 | #define MCFG_MC68328_OUT_PORT_M_CB(_devcb) \ |
| 737 | devcb = &mc68328_device::set_out_port_m_callback(*device, DEVCB2_##_devcb); |
| 738 | |
| 739 | #define MCFG_MC68328_IN_PORT_A_CB(_devcb) \ |
| 740 | devcb = &mc68328_device::set_in_port_a_callback(*device, DEVCB2_##_devcb); |
| 741 | |
| 742 | #define MCFG_MC68328_IN_PORT_B_CB(_devcb) \ |
| 743 | devcb = &mc68328_device::set_in_port_b_callback(*device, DEVCB2_##_devcb); |
| 744 | |
| 745 | #define MCFG_MC68328_IN_PORT_C_CB(_devcb) \ |
| 746 | devcb = &mc68328_device::set_in_port_c_callback(*device, DEVCB2_##_devcb); |
| 747 | |
| 748 | #define MCFG_MC68328_IN_PORT_D_CB(_devcb) \ |
| 749 | devcb = &mc68328_device::set_in_port_d_callback(*device, DEVCB2_##_devcb); |
| 750 | |
| 751 | #define MCFG_MC68328_IN_PORT_E_CB(_devcb) \ |
| 752 | devcb = &mc68328_device::set_in_port_e_callback(*device, DEVCB2_##_devcb); |
| 753 | |
| 754 | #define MCFG_MC68328_IN_PORT_F_CB(_devcb) \ |
| 755 | devcb = &mc68328_device::set_in_port_f_callback(*device, DEVCB2_##_devcb); |
| 756 | |
| 757 | #define MCFG_MC68328_IN_PORT_G_CB(_devcb) \ |
| 758 | devcb = &mc68328_device::set_in_port_g_callback(*device, DEVCB2_##_devcb); |
| 759 | |
| 760 | #define MCFG_MC68328_IN_PORT_J_CB(_devcb) \ |
| 761 | devcb = &mc68328_device::set_in_port_j_callback(*device, DEVCB2_##_devcb); |
| 762 | |
| 763 | #define MCFG_MC68328_IN_PORT_K_CB(_devcb) \ |
| 764 | devcb = &mc68328_device::set_in_port_k_callback(*device, DEVCB2_##_devcb); |
| 765 | |
| 766 | #define MCFG_MC68328_IN_PORT_M_CB(_devcb) \ |
| 767 | devcb = &mc68328_device::set_in_port_m_callback(*device, DEVCB2_##_devcb); |
| 768 | |
| 769 | #define MCFG_MC68328_OUT_PWM_CB(_devcb) \ |
| 770 | devcb = &mc68328_device::set_out_pwm_callback(*device, DEVCB2_##_devcb); |
| 771 | |
| 772 | #define MCFG_MC68328_OUT_SPIM_CB(_devcb) \ |
| 773 | devcb = &mc68328_device::set_out_spim_callback(*device, DEVCB2_##_devcb); |
| 774 | |
| 775 | #define MCFG_MC68328_IN_SPIM_CB(_devcb) \ |
| 776 | devcb = &mc68328_device::set_in_spim_callback(*device, DEVCB2_##_devcb); |
| 777 | |
| 778 | #define MCFG_MC68328_SPIM_XCH_TRIGGER_CB(_devcb) \ |
| 779 | devcb = &mc68328_device::set_spim_xch_trigger_callback(*device, DEVCB2_##_devcb); |
| 716 | 780 | |
| 717 | 781 | |
| 718 | | #define MCFG_MC68328_ADD(_tag, _intrf) \ |
| 719 | | MCFG_DEVICE_ADD(_tag, MC68328, 0) \ |
| 720 | | MCFG_DEVICE_CONFIG(_intrf) |
| 721 | | |
| 722 | | extern const device_type MC68328; |
| 723 | | |
| 724 | | |
| 725 | 782 | #endif |
trunk/src/mess/drivers/palm.c
| r29289 | r29290 | |
| 185 | 185 | MACHINE DRIVERS |
| 186 | 186 | ***************************************************************************/ |
| 187 | 187 | |
| 188 | | |
| 189 | | static MC68328_INTERFACE(palm_dragonball_iface) |
| 190 | | { |
| 191 | | "maincpu", |
| 192 | | |
| 193 | | DEVCB_NULL, // Port A Output |
| 194 | | DEVCB_NULL, // Port B Output |
| 195 | | DEVCB_NULL, // Port C Output |
| 196 | | DEVCB_NULL, // Port D Output |
| 197 | | DEVCB_NULL, // Port E Output |
| 198 | | DEVCB_DRIVER_MEMBER(palm_state,palm_port_f_out),// Port F Output |
| 199 | | DEVCB_NULL, // Port G Output |
| 200 | | DEVCB_NULL, // Port J Output |
| 201 | | DEVCB_NULL, // Port K Output |
| 202 | | DEVCB_NULL, // Port M Output |
| 203 | | |
| 204 | | DEVCB_NULL, // Port A Input |
| 205 | | DEVCB_NULL, // Port B Input |
| 206 | | DEVCB_DRIVER_MEMBER(palm_state,palm_port_c_in),// Port C Input |
| 207 | | DEVCB_NULL, // Port D Input |
| 208 | | DEVCB_NULL, // Port E Input |
| 209 | | DEVCB_DRIVER_MEMBER(palm_state,palm_port_f_in),// Port F Input |
| 210 | | DEVCB_NULL, // Port G Input |
| 211 | | DEVCB_NULL, // Port J Input |
| 212 | | DEVCB_NULL, // Port K Input |
| 213 | | DEVCB_NULL, // Port M Input |
| 214 | | |
| 215 | | DEVCB_DRIVER_MEMBER(palm_state,palm_dac_transition), |
| 216 | | |
| 217 | | DEVCB_DRIVER_MEMBER16(palm_state,palm_spim_out), |
| 218 | | DEVCB_DRIVER_MEMBER16(palm_state,palm_spim_in), |
| 219 | | DEVCB_DRIVER_LINE_MEMBER(palm_state, palm_spim_exchange) |
| 220 | | }; |
| 221 | | |
| 222 | | |
| 223 | 188 | static MACHINE_CONFIG_START( palm, palm_state ) |
| 224 | 189 | /* basic machine hardware */ |
| 225 | 190 | MCFG_CPU_ADD( "maincpu", M68000, 32768*506 ) /* 16.580608 MHz */ |
| r29289 | r29290 | |
| 246 | 211 | MCFG_SOUND_ADD("dac", DAC, 0) |
| 247 | 212 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 248 | 213 | |
| 249 | | MCFG_MC68328_ADD( MC68328_TAG, palm_dragonball_iface ) // lsi device |
| 214 | MCFG_DEVICE_ADD( MC68328_TAG, MC68328, 0 ) // lsi device |
| 215 | MCFG_MC68328_CPU("maincpu") |
| 216 | MCFG_MC68328_OUT_PORT_F_CB(WRITE8(palm_state, palm_port_f_out)) // Port F Output |
| 217 | MCFG_MC68328_IN_PORT_C_CB(READ8(palm_state, palm_port_c_in)) // Port C Input |
| 218 | MCFG_MC68328_IN_PORT_F_CB(READ8(palm_state, palm_port_f_in)) // Port F Input |
| 219 | MCFG_MC68328_OUT_PWM_CB(WRITE8(palm_state, palm_dac_transition)) |
| 220 | MCFG_MC68328_OUT_SPIM_CB(WRITE16(palm_state, palm_spim_out)) |
| 221 | MCFG_MC68328_IN_SPIM_CB(READ16(palm_state, palm_spim_in)) |
| 222 | MCFG_MC68328_SPIM_XCH_TRIGGER_CB(WRITELINE(palm_state, palm_spim_exchange)) |
| 250 | 223 | MACHINE_CONFIG_END |
| 251 | 224 | |
| 252 | 225 | static INPUT_PORTS_START( palm ) |