Skip to content

Commit

Permalink
Fixed sizeof command
Browse files Browse the repository at this point in the history
  • Loading branch information
reddragond committed Jun 10, 2017
1 parent 24d1253 commit f62a5b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion keyboards/lets_split/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
18 changes: 9 additions & 9 deletions keyboards/lets_split/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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;
Expand All @@ -42,7 +42,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);
}

Expand Down Expand Up @@ -93,10 +93,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)*8; ++i) {
byte = (byte << 1) | serial_read_pin();
serial_delay();
_delay_us(1);
Expand All @@ -107,8 +107,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)*8;
serial_output();
while( b-- ) {
if(data & (1 << b)) {
Expand Down Expand Up @@ -145,7 +145,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
Expand Down
5 changes: 3 additions & 2 deletions keyboards/lets_split/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "config.h"
#include <stdbool.h>
#include "matrix.h"

/* TODO: some defines for interrupt setup */
#define SERIAL_PIN_DDR DDRD
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions keyboards/orthodox/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <util/delay.h>
#include <stdbool.h>
#include "serial.h"
#include "matrix.h"

#ifdef USE_SERIAL

Expand Down Expand Up @@ -97,7 +96,7 @@ static
matrix_row_t serial_read_byte(void) {
matrix_row_t byte = 0;
serial_input();
for ( uint8_t i = 0; i < sizeof(matrix_row_t); ++i) {
for ( uint8_t i = 0; i < sizeof(matrix_row_t)*8; ++i) {
byte = (byte << 1) | serial_read_pin();
serial_delay();
_delay_us(1);
Expand All @@ -109,7 +108,7 @@ matrix_row_t serial_read_byte(void) {
// Sends a byte with MSB ordering
static
void serial_write_byte(matrix_row_t data) {
matrix_row_t b = sizeof(matrix_row_t);
matrix_row_t b = sizeof(matrix_row_t)*8;
serial_output();
while( b-- ) {
if(data & (1 << b)) {
Expand Down

0 comments on commit f62a5b9

Please sign in to comment.