forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request qmk#16 from mtei/helix-serial-improvement2
Helix serial improvement
- Loading branch information
Showing
19 changed files
with
514 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
SRC += rev1/matrix.c \ | ||
rev1/split_util.c | ||
SRC += rev1/matrix.c | ||
SRC += rev1/split_util.c | ||
|
||
BACKLIGHT_ENABLE = no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
SRC += rev2/matrix.c \ | ||
rev2/split_util.c \ | ||
ws2812.c | ||
SRC += rev2/matrix.c | ||
SRC += rev2/split_util.c | ||
SRC += rev2/split_scomm.c | ||
SRC += ws2812.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef SERIAL_CONFIG_SIMPLEAPI_H | ||
#define SERIAL_CONFIG_SIMPLEAPI_H | ||
|
||
#undef SERIAL_USE_MULTI_TRANSACTION | ||
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | ||
#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 | ||
|
||
#endif // SERIAL_CONFIG_SIMPLEAPI_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#ifdef USE_SERIAL | ||
#ifdef SERIAL_USE_MULTI_TRANSACTION | ||
/* --- USE flexible API (using multi-type transaction function) --- */ | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <split_scomm.h> | ||
#include "serial.h" | ||
#ifdef SERIAL_DEBUG_MODE | ||
#include <avr/io.h> | ||
#endif | ||
|
||
uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; | ||
uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; | ||
uint8_t volatile status_com = 0; | ||
uint8_t volatile status1 = 0; | ||
uint8_t slave_buffer_change_count = 0; | ||
uint8_t s_change_old = 0xff; | ||
|
||
SSTD_t transactions[] = { | ||
#define GET_SLAVE_STATUS 0 | ||
/* master buffer not changed, only recive slave_buffer_change_count */ | ||
{ (uint8_t *)&status_com, | ||
0, NULL, | ||
sizeof(slave_buffer_change_count), &slave_buffer_change_count, | ||
}, | ||
#define PUT_MASTER_GET_SLAVE_STATUS 1 | ||
/* master buffer changed need send, and recive slave_buffer_change_count */ | ||
{ (uint8_t *)&status_com, | ||
sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer, | ||
sizeof(slave_buffer_change_count), &slave_buffer_change_count, | ||
}, | ||
#define GET_SLAVE_BUFFER 2 | ||
/* recive serial_slave_buffer */ | ||
{ (uint8_t *)&status1, | ||
0, NULL, | ||
sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer | ||
} | ||
}; | ||
|
||
void serial_master_init(void) | ||
{ | ||
soft_serial_initiator_init(transactions); | ||
} | ||
|
||
void serial_slave_init(void) | ||
{ | ||
soft_serial_target_init(transactions); | ||
} | ||
|
||
// 0 => no error | ||
// 1 => slave did not respond | ||
// 2 => checksum error | ||
int serial_update_buffers(int master_update) | ||
{ | ||
int status; | ||
static int need_retry = 0; | ||
if( s_change_old != slave_buffer_change_count ) { | ||
status = soft_serial_transaction(GET_SLAVE_BUFFER); | ||
if( status == TRANSACTION_END ) | ||
s_change_old = slave_buffer_change_count; | ||
} | ||
if( !master_update && !need_retry) | ||
status = soft_serial_transaction(GET_SLAVE_STATUS); | ||
else | ||
status = soft_serial_transaction(PUT_MASTER_GET_SLAVE_STATUS); | ||
need_retry = ( status == TRANSACTION_END ) ? 0 : 1; | ||
return status; | ||
} | ||
|
||
#endif // SERIAL_USE_MULTI_TRANSACTION | ||
#endif /* USE_SERIAL */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef SPLIT_COMM_H | ||
#define SPLIT_COMM_H | ||
|
||
#ifndef SERIAL_USE_MULTI_TRANSACTION | ||
/* --- USE Simple API (OLD API, compatible with let's split serial.c) --- */ | ||
#include "serial.h" | ||
|
||
#else | ||
/* --- USE flexible API (using multi-type transaction function) --- */ | ||
// Buffers for master - slave communication | ||
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | ||
#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 | ||
|
||
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; | ||
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; | ||
extern uint8_t slave_buffer_change_count; | ||
|
||
void serial_master_init(void); | ||
void serial_slave_init(void); | ||
int serial_update_buffers(int master_changed); | ||
|
||
#endif | ||
|
||
#endif /* SPLIT_COMM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.