Esempio n. 1
0
File: app.c Progetto: rmull/mittens
void
app_demo_timer_cb(void *ctx)
{
    uint16_t *timer = (uint16_t *)ctx;

    if (timer != NULL) {

        if (++(*timer) == 100) {
            *timer = 0;
        }

        if (timer == &(app.timer_b)) {
            if (*timer == 0) {
                gpio_toggle(GPIO_LED_B);
            }
            sched_set(&(app.sched), TASK_ID_LED_B, 50000, app_demo_timer_cb, (void *)&(app.timer_b));

        } else if (timer == &(app.timer_g)) {
            if (*timer == 0) {
                gpio_toggle(GPIO_LED_G);
            }
            sched_set(&(app.sched), TASK_ID_LED_G, 25000, app_demo_timer_cb, (void *)&(app.timer_g));
        }
    }
}
Esempio n. 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;
    }
}
Esempio n. 3
0
File: app.c Progetto: rmull/mittens
/* Call once, don't poll */
void
app_demo_timer(void)
{
    sched_set(&(app.sched), TASK_ID_LED_B, 50000, app_demo_timer_cb, (void *)&(app.timer_b));
    sched_set(&(app.sched), TASK_ID_LED_G, 25000, app_demo_timer_cb, (void *)&(app.timer_g));
}