irom void io_mcp_periodic(int io, const struct io_info_entry_T *info, io_data_entry_t *data, io_flags_t *flags) { int pin; int intf[2], intcap[2]; int bank, bankpin; mcp_data_pin_t *mcp_pin_data; io_config_pin_entry_t *pin_config; read_register((string_t *)0, info->address, INTF(0), &intf[0]); read_register((string_t *)0, info->address, INTF(1), &intf[1]); read_register((string_t *)0, info->address, INTCAP(0), &intcap[0]); read_register((string_t *)0, info->address, INTCAP(1), &intcap[1]); for(pin = 0; pin < 16; pin++) { bank = (pin & 0x08) >> 3; bankpin = pin & 0x07; mcp_pin_data = &mcp_data_pin_table[info->instance][pin]; pin_config = &config.io_config[io][pin]; if(pin_config->llmode == io_pin_ll_counter) { if(mcp_pin_data->debounce != 0) { if(mcp_pin_data->debounce >= 10) mcp_pin_data->debounce -= 10; // 10 ms per tick else mcp_pin_data->debounce = 0; } else { if((intf[bank] & (1 << bankpin)) && !(intcap[bank] & (1 << bankpin))) // only count downward edge, counter is mostly pull-up { mcp_pin_data->counter++; mcp_pin_data->debounce = pin_config->speed; flags->counter_triggered = 1; } } } } }
static void linux_check_address_consistency(mblty_intf_addr_t *addr) { mblty_intf_addr_state_t oldstate = addr->state; addr->state = addr->newstate; if (addr->pending != addr->state) { mblty_intf_addr_change_to(addr, addr->pending); } else { if (oldstate == MBLTY_INTF_ADDR_STATE_NOINFO) list_add_tail(&addr->entry, &INTF(addr->intf)->addresses); else if (addr->state == MBLTY_INTF_ADDR_STATE_NOINFO) list_del(&addr->entry); if (addr->ops) addr->ops->changed_state(addr, oldstate); } }