Exemplo n.º 1
0
void matrix_init(void)
{
    PC98_RST_DDR |= (1<<PC98_RST_BIT);
    PC98_RDY_DDR |= (1<<PC98_RDY_BIT);
    PC98_RTY_DDR |= (1<<PC98_RTY_BIT);
    PC98_RST_PORT |= (1<<PC98_RST_BIT);
    PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
    PC98_RTY_PORT |= (1<<PC98_RTY_BIT);


    serial_init();

    // PC98 reset
/*
    PC98_RST_PORT &= ~(1<<PC98_RST_BIT);
    _delay_us(15);
    PC98_RST_PORT |= (1<<PC98_RST_BIT);
    _delay_us(13);
    PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
*/

    _delay_ms(500);
    pc98_inhibit_repeat();


    // PC98 ready
    PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;

    debug("init\n");
    return;
}
Exemplo n.º 2
0
void matrix_init(void)
{
    debug_keyboard = true;
    PC98_RST_DDR |= (1<<PC98_RST_BIT);
    PC98_RDY_DDR |= (1<<PC98_RDY_BIT);
    PC98_RTY_DDR |= (1<<PC98_RTY_BIT);
    PC98_RST_PORT |= (1<<PC98_RST_BIT);
    PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
    PC98_RTY_PORT |= (1<<PC98_RTY_BIT);


    serial_init();

    // PC98 reset
    // https://archive.org/stream/PC9800TechnicalDataBookHARDWARE1993/PC-9800TechnicalDataBook_HARDWARE1993#page/n359
    PC98_RDY_PORT |=  (1<<PC98_RDY_BIT);    // RDY: high
    PC98_RST_PORT &= ~(1<<PC98_RST_BIT);    // RST: low
    _delay_us(15);                          // > 13us
    PC98_RST_PORT |= (1<<PC98_RST_BIT);     // RST: high

    _delay_ms(50);
    pc98_inhibit_repeat();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;

    // ready to receive from keyboard
    PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);    // RDY: low

    print("matrix_init done.\n");
    return;
}
Exemplo n.º 3
0
uint8_t matrix_scan(void)
{
    uint16_t code;
    PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
    _delay_us(30);
    code = serial_recv2();
    PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
    if (code == -1) return 0;

if (code == 0x60) {
    pc98_inhibit_repeat();

/*
    PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
    _delay_ms(100);
    serial_send(0x96);
    PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
*/

    return 0;
}

    print_hex8(code); print(" ");

    if (code&0x80) {
        // break code
        if (matrix_is_on(ROW(code), COL(code))) {
            matrix[ROW(code)] &= ~(1<<COL(code));
        }
    } else {
        // make code
        if (!matrix_is_on(ROW(code), COL(code))) {
            matrix[ROW(code)] |=  (1<<COL(code));
        }
    }
    return code;
}