qmk_firmware/keyboards/rkb1/matrix.pio.h

61 lines
1.9 KiB
C

// -------------------------------------------------- //
// This file is autogenerated by pioasm; do not edit! //
// -------------------------------------------------- //
#pragma once
#if !PICO_NO_HARDWARE
# include "hardware/pio.h"
#endif
// ------ //
// matrix //
// ------ //
#define matrix_wrap_target 0
#define matrix_wrap 6
static const uint16_t matrix_program_instructions[] = {
// .wrap_target
0xe027, // 0: set x, 7
0x9fe0, // 1: pull ifempty block [31]
0x7f08, // 2: out pins, 8 [31]
0x5f05, // 3: in pins, 5 [31]
0x1f41, // 4: jmp x--, 1 [31]
0x5f62, // 5: in null, 2 [31]
0x9f20, // 6: push block [31]
// .wrap
};
#if !PICO_NO_HARDWARE
static const struct pio_program matrix_program = {
.instructions = matrix_program_instructions,
.length = 7,
.origin = -1,
};
static inline pio_sm_config matrix_program_get_default_config(uint offset) {
pio_sm_config c = pio_get_default_sm_config();
sm_config_set_wrap(&c, offset + matrix_wrap_target, offset + matrix_wrap);
return c;
}
static inline void matrix_program_init(PIO pio, uint sm, uint offset, uint pin) {
pio_sm_config c = matrix_program_get_default_config(offset);
// The row inputs start at the pin base
sm_config_set_in_pins(&c, pin);
// The 6 output bits come after the 5 input bits
sm_config_set_out_pins(&c, pin + 5, 6);
// Set up the pins for PIO
for (int i = 0; i < 11; i++)
pio_gpio_init(pio, pin + i);
// Set the pin directions
pio_sm_set_consecutive_pindirs(pio, sm, pin, 5, false);
pio_sm_set_consecutive_pindirs(pio, sm, pin + 5, 6, true);
// Load our configuration, and jump to the start of the program
pio_sm_init(pio, sm, offset, &c);
// Set the state machine running
pio_sm_set_enabled(pio, sm, true);
}
#endif