コード例 #1
0
ファイル: pcf8583.c プロジェクト: EdCornejo/emu-ex-plus-alpha
rtc_pcf8583_t *pcf8583_init(char *device, int read_bit_shift)
{
    rtc_pcf8583_t *retval = lib_calloc(1, sizeof(rtc_pcf8583_t));
    int loaded = rtc_load_context(device, PCF8583_RAM_SIZE, PCF8583_REG_SIZE);

    if (loaded) {
        retval->ram = rtc_get_loaded_ram();
        retval->offset = rtc_get_loaded_offset();
        retval->clock_regs = rtc_get_loaded_clockregs();
    } else {
        retval->ram = lib_calloc(1, PCF8583_RAM_SIZE);
        retval->offset = 0;
        retval->clock_regs = lib_calloc(1, PCF8583_REG_SIZE);
    }
    memcpy(retval->old_ram, retval->ram, PCF8583_RAM_SIZE);
    retval->old_offset = retval->offset;
    memcpy(retval->old_clock_regs, retval->clock_regs, PCF8583_REG_SIZE);

    retval->device = lib_stralloc(device);
    retval->state = PCF8583_IDLE;
    retval->sclk_line = 1;
    retval->data_line = 1;
    retval->reg_ptr = 0;
    retval->read_bit_shift = read_bit_shift;

    return retval;
}
コード例 #2
0
rtc_72421_t *rtc72421_init(char *device)
{
    rtc_72421_t *retval = lib_calloc(1, sizeof(rtc_72421_t));
    int loaded = rtc_load_context(device, 0, 0);

    if (loaded) {
        retval->offset = rtc_get_loaded_offset();
    } else {
        retval->offset = 0;
    }
    retval->old_offset = retval->offset;

    retval->hour24 = 0;
    retval->device = lib_stralloc(device);

    return retval;
}
コード例 #3
0
ファイル: ds1216e.c プロジェクト: EdCornejo/emu-ex-plus-alpha
rtc_ds1216e_t *ds1216e_init(char *device)
{
    rtc_ds1216e_t *retval = lib_calloc(1, sizeof(rtc_ds1216e_t));
    int loaded = rtc_load_context(device, 0, DS1216E_REG_SIZE);

    if (loaded) {
        retval->offset = rtc_get_loaded_offset();
        retval->clock_regs = rtc_get_loaded_clockregs();
    } else {
        retval->offset = 0;
        retval->clock_regs = lib_calloc(1, DS1216E_REG_SIZE);
    }
    retval->old_offset = retval->offset;
    memcpy(retval->old_clock_regs, retval->clock_regs, DS1216E_REG_SIZE);

    retval->device = lib_stralloc(device);

    return retval;
}