Example #1
0
void matrix_init(void) {
    /* frees PORTF by setting the JTD bit twice within four cycles */
    #ifdef __AVR_ATmega32U4__
        MCUCR |= _BV(JTD);
        MCUCR |= _BV(JTD);
    #endif
    /* initializes the I/O pins */
#if DIODE_DIRECTION == COL2ROW
    for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
        /* DDRxn */
        _SFR_IO8((row_pins[r] >> 4) + 1) |= _BV(row_pins[r] & 0xF);
        toggle_row(r);
    }
    for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
        /* PORTxn */
        _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF);
    }
#else
    for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
        /* DDRxn */
        _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF);
        toggle_col(c);
    }
    for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
        /* PORTxn */
        _SFR_IO8((row_pins[r] >> 4) + 2) |= _BV(row_pins[r] & 0xF);
    }
#endif
    matrix_init_quantum();
}
Example #2
0
void matrix_init(void)
{
    memset(mlatest, 0, MATRIX_ROWS * sizeof(matrix_row_t));
    memset(mlast, 0, MATRIX_ROWS * sizeof(matrix_row_t));
    memset(mdebounced, 0, MATRIX_ROWS * sizeof(matrix_row_t));

    row_masks[PA] = 0;
    row_masks[PB] = 0;

    uint8_t row;
    for (row = 0; row < MATRIX_ROWS; row++)
    {
        PORT->Group[row_ports[row]].DIRCLR.reg = 1 << row_pins[row]; //Input
        PORT->Group[row_ports[row]].OUTCLR.reg = 1 << row_pins[row]; //Low
        PORT->Group[row_ports[row]].PINCFG[row_pins[row]].bit.INEN = 1; //Input Enable,
        PORT->Group[row_ports[row]].PINCFG[row_pins[row]].bit.PULLEN = 1; //Pull Enable
        row_masks[row_ports[row]] |= 1 << row_pins[row]; //Add pin to proper row mask
    }

    uint8_t col;
    for (col = 0; col < MATRIX_COLS; col++)
    {
        PORT->Group[col_ports[col]].DIRSET.reg = 1 << col_pins[col]; //Output
        PORT->Group[col_ports[col]].OUTCLR.reg = 1 << col_pins[col]; //Low
    }
    
    matrix_init_quantum();
}
Example #3
0
void matrix_init(void) {

    // disables JTAG so we can use them as columns
    MCUCSR = (1<<JTD);
    MCUCSR = (1<<JTD);

    // rows (output)
    DDRB |= ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7));
    PORTB |= ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7));

    // cols (input)
    DDRA &= ~((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7));
    DDRC &= ~((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2));
    DDRD &= ~((1 << 7));

    // pull-up cols
    PORTA |= ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7));
    PORTC |= ((1 << 7) | (1 << 6) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2));
    PORTD |= ((1 << 7));

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

    matrix_init_quantum();
}
Example #4
0
void matrix_init(void)
{
    // initialize row and col
    debug_enable = true;
    debug_matrix = true;
    debug_keyboard = true;
    debug_mouse = true;

    mcp23018_status = init_mcp23018();


    unselect_rows();
    init_cols();

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

#ifdef DEBUG_MATRIX_SCAN_RATE
    matrix_timer = timer_read32();
    matrix_scan_count = 0;
#endif

    matrix_init_quantum();

}
Example #5
0
void matrix_init(void) {
    printf("matrix init\n");
    //debug_matrix = true;

    /* Column(sense) */
    palSetPadMode(GPIOA, 2,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOA, 3,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOA, 6,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 14, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 15, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOA, 8,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOA, 9,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOA, 7,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 3,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 4,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOC, 15, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOC, 14, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOC, 13, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 5,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 6,  PAL_MODE_OUTPUT_PUSHPULL);

    /* Row(strobe) */
    palSetPadMode(GPIOB, 0,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOB, 1,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOB, 2,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOA, 15,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOA, 10,  PAL_MODE_INPUT_PULLDOWN);

    memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t));
    memset(matrix_debouncing, 0, MATRIX_COLS * sizeof(matrix_row_t));

    palClearPad(GPIOB, 7);  // Turn off capslock
    matrix_init_quantum();
}
Example #6
0
void matrix_init(void) {
  backlight_init_ports();
  unselect_cols();
  init_rows();

  for (uint8_t i=0; i < MATRIX_ROWS; i++)  {
    matrix[i] = 0;
    matrix_debouncing[i] = 0;
  }

  matrix_init_quantum();
}
Example #7
0
void matrix_init(void) {
  /* Ensure scanner power is on - else right hand will not work */
  DDRC |= _BV(7);
  PORTC |= _BV(7);

  i2c_init();
  i2c_set_keyscan_interval(LEFT, 2);
  i2c_set_keyscan_interval(RIGHT, 2);
  memset(rows, 0, sizeof(rows));

  matrix_init_quantum();
}
void matrix_init(void) {

  custom_matrix_init();

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

  debounce_init(MATRIX_ROWS);

  matrix_init_quantum();
}
Example #9
0
void matrix_init(void) {

    // initialize row and col
#if (DIODE_DIRECTION == COL2ROW)
    unselect_rows();
    init_cols();
#elif (DIODE_DIRECTION == ROW2COL)
    unselect_cols();
    init_rows();
#endif

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

    matrix_init_quantum();
}
Example #10
0
void matrix_init(void) {
  DDRD  |=  0b11010000;
  PORTD &= ~0b01010000;
  DDRB  |=  0b00011111;
  PORTB &= ~0b00001110;
  PORTB |=  0b00010001;
  DDRE  |=  0b01000000;
  PORTE &= ~0b01000000;

  unselect_cols();
  init_rows();

  for (uint8_t i=0; i < MATRIX_ROWS; i++)  {
    matrix[i] = 0;
    matrix_debouncing[i] = 0;
  }

  matrix_init_quantum();
}
Example #11
0
void matrix_init(void) {
    printf("matrix init\n");
    //debug_matrix = true;

    // dip switch setup
    palSetPadMode(GPIOB, 14, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(GPIOA, 15, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(GPIOB, 9,  PAL_MODE_INPUT_PULLUP);

    // encoder setup
    palSetPadMode(GPIOB, 12, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(GPIOB, 13, PAL_MODE_INPUT_PULLUP);

    encoder_state = (palReadPad(GPIOB, 12) << 0) | (palReadPad(GPIOB, 13) << 1);

    // actual matrix setup
    palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 2,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 1,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOA, 7,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(GPIOB, 0,  PAL_MODE_OUTPUT_PUSHPULL);

    palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOA, 9,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOA, 8,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOB, 15, PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOC, 13, PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOC, 14, PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOC, 15, PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOA, 2,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOA, 3,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(GPIOA, 6,  PAL_MODE_INPUT_PULLDOWN);


    memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t));
    memset(matrix_debouncing, 0, MATRIX_COLS * sizeof(matrix_col_t));


    matrix_init_quantum();
}
Example #12
0
void matrix_init(void) {
    // all outputs for rows high
    DDRB = 0xFF;
    PORTB = 0xFF;
    // all inputs for columns
    DDRA = 0x00;
    DDRC &= ~(0x111111<<2);
    DDRD &= ~(1<<PIND7);
    // all columns are pulled-up
    PORTA = 0xFF;
    PORTC |= (0b111111<<2);
    PORTD |= (1<<PIND7);

    // initialize matrix state: all keys off
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        matrix[row] = 0x00;
        matrix_debouncing[row] = 0x00;
    }
    
    matrix_init_quantum();
}
Example #13
0
void matrix_init(void) {
    // all outputs for rows high
    DDRB = 0xFF;
    PORTB = 0xFF;
    // all inputs for columns
    DDRA = 0x00;
    DDRC &= ~(0x111111<<2);
    //----> DDRD &= ~(1<<PIND7);
    // Port D not used on this keyboard
    // all columns are pulled-up
    PORTA = 0xFF;
    PORTC |= (0b111111<<2);
    //PORTD |= (1<<PIND7);
    // Port D not used on this keyboard

    // initialize matrix state: all keys off
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        matrix[row] = 0x00;
        matrix_debouncing[row] = 0x00;
    }
    matrix_init_quantum();  // missing from original port by Luiz
}
Example #14
0
void matrix_init(void) {
  debug_enable = true;
  debug_matrix = true;
  debug_mouse  = true;

  // Set pinout for right half if pinout for that half is defined
  if (!isLeftHand) {
#ifdef MATRIX_ROW_PINS_RIGHT
    const uint8_t row_pins_right[MATRIX_ROWS] = MATRIX_ROW_PINS_RIGHT;
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
      row_pins[i] = row_pins_right[i];
    }
#endif
#ifdef MATRIX_COL_PINS_RIGHT
    const uint8_t col_pins_right[MATRIX_COLS] = MATRIX_COL_PINS_RIGHT;
    for (uint8_t i = 0; i < MATRIX_COLS; i++) {
      col_pins[i] = col_pins_right[i];
    }
#endif
  }

  thisHand = isLeftHand ? 0 : (ROWS_PER_HAND);
  thatHand = ROWS_PER_HAND - thisHand;

  // initialize key pins
  init_pins();

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

  debounce_init(ROWS_PER_HAND);

  matrix_init_quantum();
}
Example #15
0
void matrix_init(void) {

    matrix_init_quantum();
}
Example #16
0
void matrix_init(void) {
    clear_all_keys();
    matrix_init_quantum();
}