Fixed sizeof command

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

@ -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++) {

@ -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;
@ -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);
}
@ -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);
@ -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)) {
@ -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

@ -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);

@ -11,7 +11,6 @@
#include <util/delay.h>
#include <stdbool.h>
#include "serial.h"
#include "matrix.h"
#ifdef USE_SERIAL
@ -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);
@ -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)) {

Loading…
Cancel
Save