Modified serial communications to allow for over 8 columns

pull/1436/head
8 years ago
parent a1dcb5eada
commit 24d1253b59

@ -39,13 +39,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_LOWER] = KEYMAP( \
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LCTL, KC_NO, _______, _______, KC_NO, KC_RCTL, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, _______, _______, KC_F12, S(KC_NUHS),S(KC_NUBS),_______, _______, _______, _______ \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, _______, _______, RAISE, S(KC_NUHS),S(KC_NUBS),_______, _______, _______, _______ \
),
[_RAISE] = KEYMAP( \
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______,KC_NO,_______, _______,KC_NO, _______, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, _______, _______, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______ , _______ \
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, _______, _______, RAISE, KC_NUHS, KC_NUBS, _______, _______, _______ , _______ \
),
[_ADJUST] = KEYMAP( \

@ -122,7 +122,7 @@ void matrix_init(void)
uint8_t _matrix_scan(void)
{
// Right hand is stored after the left in the matirx so, we need to offset it
// Right hand is stored after the left in the matrix so, we need to offset it
int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {

@ -11,6 +11,7 @@
#include <util/delay.h>
#include <stdbool.h>
#include "serial.h"
#include "matrix.h"
#ifdef USE_SERIAL
@ -18,8 +19,8 @@
// value.
#define SERIAL_DELAY 24
uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
matrix_row_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
matrix_row_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
#define SLAVE_DATA_CORRUPT (1<<0)
volatile uint8_t status = 0;
@ -42,7 +43,7 @@ void serial_input(void) {
}
inline static
uint8_t serial_read_pin(void) {
matrix_row_t serial_read_pin(void) {
return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
}
@ -93,10 +94,10 @@ void sync_send(void) {
// Reads a byte from the serial line
static
uint8_t serial_read_byte(void) {
uint8_t byte = 0;
matrix_row_t serial_read_byte(void) {
matrix_row_t byte = 0;
serial_input();
for ( uint8_t i = 0; i < 8; ++i) {
for ( uint8_t i = 0; i < sizeof(matrix_row_t); ++i) {
byte = (byte << 1) | serial_read_pin();
serial_delay();
_delay_us(1);
@ -107,8 +108,8 @@ uint8_t serial_read_byte(void) {
// Sends a byte with MSB ordering
static
void serial_write_byte(uint8_t data) {
uint8_t b = 8;
void serial_write_byte(matrix_row_t data) {
matrix_row_t b = sizeof(matrix_row_t);
serial_output();
while( b-- ) {
if(data & (1 << b)) {
@ -145,7 +146,7 @@ ISR(SERIAL_PIN_INTERRUPT) {
sync_send();
checksum_computed += serial_master_buffer[i];
}
uint8_t checksum_received = serial_read_byte();
matrix_row_t checksum_received = serial_read_byte();
sync_send();
serial_input(); // end transaction

@ -3,6 +3,7 @@
#include "config.h"
#include <stdbool.h>
#include "matrix.h"
/* TODO: some defines for interrupt setup */
#define SERIAL_PIN_DDR DDRD
@ -15,8 +16,8 @@
#define SERIAL_MASTER_BUFFER_LENGTH 1
// Buffers for master - slave communication
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
extern volatile matrix_row_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
extern volatile matrix_row_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
void serial_master_init(void);
void serial_slave_init(void);

Loading…
Cancel
Save