Beispiel #1
0
static void rtc_write(const uint16_t pio, const uint8_t byte) {
    uint16_t index = pio & 0xFF;
    uint8_t bit_offset = (index & 3) << 3;

    switch (index) {
        case 0x10:
            rtc.alarmSec = byte;
            break;
        case 0x14:
            rtc.alarmMin = byte;
            break;
        case 0x18:
            rtc.alarmHour = byte;
            break;
        case 0x20:
            rtc.control = byte;
            if (rtc.control & 1) {
                event_set(SCHED_RTC, 0);
            } else {
                event_clear(SCHED_RTC);
            }
            if (rtc.control & 64) { /* (Bit 6) -- Load time */
                rtc.readSec = rtc.writeSec;
                rtc.readMin = rtc.writeMin;
                rtc.readHour = rtc.writeHour;
                rtc.readDay = rtc.writeDay;
                rtc.control &= ~64;
                rtc.interrupt |= 32;  /* Load operation complete */
                intrpt_set(INT_RTC, (rtc.interrupt & rtc.control & 15) ? true : false);
            }
            if (!(rtc.control & 128)) {
                hold_read();
            }
            break;
        case 0x24:
            rtc.writeSec = byte;
            break;
        case 0x28:
            rtc.writeMin = byte;
            break;
        case 0x2C:
            rtc.writeHour = byte;
            break;
        case 0x30: case 0x31:
            write8(rtc.writeDay, bit_offset, byte);
            break;
        case 0x34:
            rtc.interrupt &= ~byte;
            intrpt_set(INT_RTC, (rtc.interrupt & rtc.control & 15) ? true : false);
            break;
        default:
            break;
    }
}
Beispiel #2
0
static void rtc_write(const uint16_t pio, const uint8_t byte, bool poke) {
    uint16_t index = pio & 0xFF;
    uint8_t bit_offset = (index & 3) << 3;
    (void)poke;

    switch (index) {
        case 0x10:
            rtc.alarmSec = byte;
            break;
        case 0x14:
            rtc.alarmMin = byte;
            break;
        case 0x18:
            rtc.alarmHour = byte;
            break;
        case 0x20:
            rtc.control = byte;
            if (rtc.control & 1) {
                sched_set(SCHED_RTC, 0);
            } else {
                sched_clear(SCHED_RTC);
            }
            if (!(rtc.control & 128)) {
                hold_read();
            }
            break;
        case 0x24:
            rtc.writeSec = byte;
            break;
        case 0x28:
            rtc.writeMin = byte;
            break;
        case 0x2C:
            rtc.writeHour = byte;
            break;
        case 0x30: case 0x31:
            write8(rtc.writeDay, bit_offset, byte);
            break;
        case 0x34:
            rtc.interrupt &= ~byte;
            intrpt_set(INT_RTC, rtc.interrupt & rtc.control & 15);
            break;
        default:
            break;
    }
}