Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for ErgoDox with STM32 Microcontroller #5398

Merged
merged 25 commits into from
Sep 25, 2019
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a392fb4
Began Work On STM32 Ergodox
Codetector1374 Jan 16, 2019
079fbc4
test
Codetector1374 Jan 17, 2019
304cd5b
Now it compile. Not linking thou
Codetector1374 Jan 17, 2019
c2b9529
Screw this Linker. It links now!
Codetector1374 Jan 17, 2019
06f9f2a
Blinkly Keyboard
Codetector1374 Jan 17, 2019
4927abe
bootloader test code
Codetector1374 Jan 18, 2019
23b445a
Working on matrix / i2c stuff
Codetector1374 Jan 23, 2019
3c5251f
Progress (LED Blink)
Codetector1374 Jan 24, 2019
0365c92
Progress on MCP_23017 Status Flag
Codetector1374 Jan 24, 2019
cf99732
[WIP]
Codetector1374 Jan 24, 2019
fd84782
update
Codetector1374 Jan 25, 2019
1f1f23c
Works! Remeber to change back the bootloader address when the new boo…
Codetector1374 Jan 26, 2019
ee657d7
Time to go debug the i2c
Codetector1374 Jan 26, 2019
ec07114
Finally, it now works with PCB Rev 1.0.2
Codetector1374 Jan 29, 2019
222e791
updated for rev.2 pcb
Codetector1374 Feb 23, 2019
082de2c
minor compilation fix
Codetector1374 Mar 13, 2019
4378d6c
Merge remote-tracking branch 'upstream/master' into ergodox_stm32
Codetector1374 Mar 13, 2019
224637b
Why when debugger is enabled then everything works.
Codetector1374 Mar 13, 2019
3438cad
Remeber to call init functions.
Codetector1374 Mar 13, 2019
35591b3
Update arm i2c driver to support STM32F103 series device.
Codetector1374 Mar 14, 2019
f7b501d
fix include once header. Replaced with #pragma once.
Codetector1374 Mar 14, 2019
86db0c2
Merge remote-tracking branch 'source/master' into ergodox_stm32
Codetector1374 Jul 9, 2019
c4ec830
complication test
Codetector1374 Jul 9, 2019
20ae9ce
Merge branch 'master' into ergodox_stm32
Codetector1374 Sep 21, 2019
6ef3d88
fix conflict and support for latest gcc
Codetector1374 Sep 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remeber to call init functions.
  • Loading branch information
Codetector1374 committed Mar 13, 2019
commit 3438cad24106da032b7b51299e8cbc9fbabc831f
84 changes: 14 additions & 70 deletions keyboards/ergodox_stm32/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ static void select_row(uint8_t row);

static void init_rows(void);

//static uint32_t scanningRate

// static uint8_t reverse(uint8_t n);

__attribute__((weak)) void matrix_init_user(void) {}

__attribute__((weak)) void matrix_scan_user(void) {}
Expand All @@ -55,28 +51,23 @@ __attribute__((weak)) void matrix_scan_kb(void) {
void matrix_init(void) {
mcp23017_status = init_mcp23017();
(void) mcp23017_reset_loop;

init_rows();
unselect_rows();
init_cols();


for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
raw_matrix[i] = 0;
for (uint8_t j = 0; j < MATRIX_COLS; ++j) {
debounce_matrix[i * MATRIX_COLS + j] = 0;
}
}

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

matrix_init_quantum();
}

void matrix_power_up(void) {
// mcp23017_status = init_mcp23017();
mcp23017_status = init_mcp23017();

init_rows();
unselect_rows();
Expand Down Expand Up @@ -114,47 +105,23 @@ matrix_row_t debounce_read_cols(uint8_t row) {
}

uint8_t matrix_scan(void) {
//#ifdef DEBUG_MATRIX_SCAN_RATE
// matrix_scan_count++;
//
// uint32_t timer_now = timer_read32();
// if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) {
// print("matrix scan frequency: ");
// pdec(matrix_scan_count);
// print("\n");
// matrix_print();
//
// matrix_timer = timer_now;
// matrix_scan_count = 0;
// }
//#endif

// if (mcp23017_status) {
// if (++mcp23017_reset_loop == 0) {
// mcp23017_status = init_mcp23017();
// print("trying to reset mcp23018\n");
// if (mcp23017_status) {
// print("left side not responding\n");
// } else {
// print("left side attached\n");
// ergodox_blink_all_leds();
// }
// }
// }
if (mcp23017_status) {
if (++mcp23017_reset_loop == 0) {
mcp23017_status = init_mcp23017();
if (!mcp23017_status) {
ergodox_blink_all_leds();
}
}
}
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
// select_row(i);
select_row(i);
select_row(i + MATRIX_ROWS_PER_SIDE);

// matrix[i] = debounce_read_cols(i);
matrix[i] = debounce_read_cols(i);
matrix[i + MATRIX_ROWS_PER_SIDE] = debounce_read_cols(i + MATRIX_ROWS_PER_SIDE);

unselect_rows();
}
if (matrix[10]) {
ergodox_board_led_1_on();
} else {
ergodox_board_led_1_off();
}
matrix_scan_quantum();
return 0;
}
Expand All @@ -174,31 +141,8 @@ matrix_row_t matrix_get_row(uint8_t row) {
}

void matrix_print(void) {
print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row);
print(": ");
pbin_reverse16(matrix_get_row(row));
print("\n");
}
}

// static unsigned char lookup[16] = {
// 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
// 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, };

// static uint8_t reverse(uint8_t n) {
// // Reverse the top and bottom nibble then swap them.
// return (lookup[n&0b1111] << 4) | lookup[n>>4];
// }

//static uint8_t swapBits3(uint8_t num, uint8_t nPosition, uint8_t mPosition)
//{
// uint8_t k = ((num >> nPosition) & 1) - ((num >> mPosition) & 1);
//
// return num + k*(1<<mPosition) - k*(1<<nPosition);
//}

static matrix_row_t read_cols(uint8_t row) {
if (row < MATRIX_ROWS_PER_SIDE) {
uint8_t data = 0xFF;
Expand Down Expand Up @@ -237,7 +181,7 @@ static void init_rows(void) {
}

static void unselect_rows(void) {
GPIOB->BSRR = 0b0111111100000000;
GPIOB->BSRR = 0b1111111 << 8;
}

static void select_row(uint8_t row) {
Expand Down