static inline void shmem_init_private (int npes) { if (!check_pe_status ()) { return; } shmemi_comms_init (); /* just note start_pes() not passed 0, it's not a big deal */ if (npes != 0) { shmemi_trace (SHMEM_LOG_INFO, "start_pes() was passed %d, should be 0", npes); } report_up (); /* * and we're up and running */ }
int main(void) { /* pin map: * * PB0 hardware shift (r/l, TODO: split r/l) * PB1 row data out (to 74HC595) * PB2 row shift (same) * PB3 row X8 direct output * PB4 col in Y9 * PB5 col in Y8 * PB6 XTAL * PB7 XTAL * * PC0 col in Y5 * PC1 col in Y0 * PC2 col in Y1 * PC3 col in Y2 * PC4 col in Y3 * PC5 col in Y4 * PC6 !RESET * * PD0 RXD * PD1 TXD * PD2 col in Y6 * PD3 col in Y7 * PD4 NC * PD5 NC * PD6 NC * PD7 NC * * We're not un-scrambling the rows here, we are just using them directly to index the lookup table. * * The device outputs 9N1 (!) data on its uart. The 9th bit indicates key press (1) or release (0), the remaining 8 * bits the USB HID keycode. */ DDRB = 0x0f; /* row outputs, shift */ /* uart setup */ DDRD |= 0x02; UBRR0 = F_CPU/16/(BAUDRATE-1); UCSR0B = (1<<TXEN0) | (1<<UCSZ02); UCSR0C = (1<<UCSZ01) | (1<<UCSZ00); int ridx = 0; reset_row(); while (23) { uint16_t cols = read_cols(); uint8_t cidx = ridx; if (ridx == 30) cols |= (PINB&1)<<1; /* map hard shift to keycode 0x1f (31) */ while (cidx < ridx+10) { if (keystate[cidx] > 1) { keystate[cidx]--; } else if (keystate[cidx] < 0) { keystate[cidx]++; } else { uint8_t c = keymap[cidx]; if (cols & 1) { if (!keystate[cidx]) { keystate[cidx] = DEBOUNCE_TIME; report_down(c); } } else { if (keystate[cidx]) { keystate[cidx] = -DEBOUNCE_TIME; report_up(c); } } } cidx ++; cols >>= 1; } if (ridx == 80) { ridx = 0; reset_row(); } else { ridx += 10; next_row(); } _delay_us(100); } }