trunk/src/emu/machine/msm6242.c
| r19740 | r19741 | |
| 41 | 41 | |
| 42 | 42 | #define TIMER_RTC_CALLBACK 1 |
| 43 | 43 | |
| 44 | | #define LOG_UNMAPPED 1 |
| 45 | | #define LOG_IRQ 1 |
| 44 | #define LOG_UNMAPPED 0 |
| 45 | #define LOG_IRQ 0 |
| 46 | #define LOG_IRQ_ENABLE 0 |
| 46 | 47 | |
| 47 | 48 | |
| 48 | 49 | |
| r19740 | r19741 | |
| 316 | 317 | // if set, convert ticks to an attotime |
| 317 | 318 | if (callback_ticks > 0) |
| 318 | 319 | { |
| 319 | | callback_time = attotime::from_ticks(callback_ticks, clock()) - machine().time(); |
| 320 | // get the current time |
| 321 | UINT64 curtime = current_time(); |
| 322 | |
| 323 | // we need the absolute callback time, in ticks |
| 324 | UINT64 absolute_callback_ticks = curtime + callback_ticks; |
| 325 | |
| 326 | // convert that to an attotime |
| 327 | attotime absolute_callback_time = attotime::from_ticks(absolute_callback_ticks, clock()); |
| 328 | |
| 329 | // and finally get the delta as an attotime |
| 330 | callback_time = absolute_callback_time - machine().time(); |
| 320 | 331 | } |
| 321 | 332 | |
| 322 | 333 | m_timer->adjust(callback_time); |
| r19740 | r19741 | |
| 342 | 353 | void msm6242_device::rtc_timer_callback() |
| 343 | 354 | { |
| 344 | 355 | update_rtc_registers(); |
| 356 | update_timer(); |
| 345 | 357 | } |
| 346 | 358 | |
| 347 | 359 | |
| r19740 | r19741 | |
| 359 | 371 | |
| 360 | 372 | |
| 361 | 373 | |
| 374 | //------------------------------------------------- |
| 375 | // get_clock_nibble |
| 376 | //------------------------------------------------- |
| 377 | |
| 378 | const char *msm6242_device::irq_type_string(UINT8 irq_type) |
| 379 | { |
| 380 | switch(irq_type) |
| 381 | { |
| 382 | case IRQ_64THSECOND: return "1/64th second"; |
| 383 | case IRQ_SECOND: return "second"; |
| 384 | case IRQ_MINUTE: return "minute"; |
| 385 | case IRQ_HOUR: return "hour"; |
| 386 | default: return "???"; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | |
| 391 | |
| 362 | 392 | //************************************************************************** |
| 363 | 393 | // READ/WRITE HANDLERS |
| 364 | 394 | //************************************************************************** |
| r19740 | r19741 | |
| 487 | 517 | { |
| 488 | 518 | m_irq_flag = 1; |
| 489 | 519 | m_irq_type = (data & 0xc) >> 2; |
| 520 | |
| 521 | if (LOG_IRQ_ENABLE) |
| 522 | logerror("%s: MSM6242 enabling irq '%s'\n", machine().describe_context(), irq_type_string(m_irq_type)); |
| 490 | 523 | } |
| 491 | 524 | else |
| 492 | 525 | { |
| 493 | 526 | m_irq_flag = 0; |
| 494 | 527 | if ( !m_res_out_int_func.isnull() ) |
| 495 | 528 | m_res_out_int_func( CLEAR_LINE ); |
| 529 | |
| 530 | if (LOG_IRQ_ENABLE) |
| 531 | logerror("%s: MSM6242 disabling irq\n", machine().describe_context()); |
| 496 | 532 | } |
| 497 | 533 | break; |
| 498 | 534 | |