Skip to content

Commit

Permalink
Initial commit for UARTConnect module
Browse files Browse the repository at this point in the history
* Keyboard interconnect using two uarts
* Supports daisy chain addressing using a master/slave direction communication scheme

- Still needs more testing
- Functions have been tested alone to be generally working
  • Loading branch information
haata committed Mar 15, 2015
1 parent aeaaaaa commit ed71f7f
Show file tree
Hide file tree
Showing 9 changed files with 1,108 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Debug/cli/cli.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2014 by Jacob Alexander
/* Copyright (C) 2014-2015 by Jacob Alexander
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -34,7 +34,7 @@
// ----- Defines -----

#define CLILineBufferMaxSize 100
#define CLIMaxDictionaries 5
#define CLIMaxDictionaries 10
#define CLIEntryTabAlign 13


Expand Down
2 changes: 2 additions & 0 deletions Lib/mk20dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,9 @@ typedef struct {
#define UART0_IR *(volatile uint8_t *)0x4006A00E // UART Infrared Register
#define UART0_PFIFO *(volatile uint8_t *)0x4006A010 // UART FIFO Parameters
#define UART_PFIFO_TXFE (uint8_t)0x80
#define UART_PFIFO_TXFIFOSIZE (uint8_t)0x70
#define UART_PFIFO_RXFE (uint8_t)0x08
#define UART_PFIFO_RXFIFOSIZE (uint8_t)0x07
#define UART0_CFIFO *(volatile uint8_t *)0x4006A011 // UART FIFO Control Register
#define UART_CFIFO_TXFLUSH (uint8_t)0x80 //
#define UART_CFIFO_RXFLUSH (uint8_t)0x40 //
Expand Down
2 changes: 1 addition & 1 deletion LoadFile/load.teensy
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ EXIT_STATUS=$?
# Load Screen Session if specified
if (( "$EXIT_STATUS" == "0" )) && [[ "$AUTO_SCREEN_SESSION" != "" ]]; then
if type screen &>/dev/null; then
sleep 0.1
sleep 2
screen $AUTO_SCREEN_SESSION
else
echo "screen is not installed"
Expand Down
10 changes: 10 additions & 0 deletions Macro/PartialMap/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ nat_ptr_t *Macro_layerLookup( TriggerGuide *guide, uint8_t latch_expire )
}


// Update the scancode using a list of TriggerGuides
// TODO Handle led state and analog
inline void Macro_triggerState( void *triggers, uint8_t num )
{
// Copy each of the TriggerGuides to the TriggerListBuffer
for ( uint8_t c = 0; c < num; c++ )
macroTriggerListBuffer[ macroTriggerListBufferSize++ ] = ((TriggerGuide*)triggers)[ c ];
}


// Update the scancode key state
// States:
// * 0x00 - Off
Expand Down
3 changes: 2 additions & 1 deletion Macro/PartialMap/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ void Macro_layerShift_capability( uint8_t state, uint8_t stateType, uint8_t *arg

// ----- Functions -----

void Macro_keyState( uint8_t scanCode, uint8_t state );
void Macro_analogState( uint8_t scanCode, uint8_t state );
void Macro_keyState( uint8_t scanCode, uint8_t state );
void Macro_ledState( uint8_t ledCode, uint8_t state );
void Macro_triggerState( void *triggers, uint8_t num ); // triggers is of type TriggerGuide, void* for circular dependencies
void Macro_process();
void Macro_setup();

Expand Down
31 changes: 31 additions & 0 deletions Scan/UARTConnect/capabilities.kll
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Name = UARTConnectCapabilities;
Version = 0.1;
Author = "HaaTa (Jacob Alexander) 2015";
KLL = 0.3a;

# Modified Date
Date = 2015-03-15;

# UART Buffer Size
# Number of bytes to reserve for each side of UARTConnect
# For true NKRO support must be at least: <# of Keys> x 3 + 5
UARTConnectBufSize => UARTConnectBufSize_define;
UARTConnectBufSize = 128; # MDErgo1 requires at least a 119 byte buffer

# UART Speed
# *NOTE* This must be changed on every device in the chain or else UARTConnect will not work
# The faster the speed, the lower the latency, but higher chance for an error
UARTConnectBaud => UARTConnectBaud_define;
UARTConnectBaudFine => UARTConnectBaudFine_define;
# Generally, leave BaudFine at zero unless trying to tune the link to an external UART
# You'll want to look at the specific chip datasheet for the exact equation
#
# Example of 115200 Baud using a 48 MHz clock (mk20dx128vlf5)
# 48 MHz / ( 16 * Baud ) = BDH/L
# Baud: 115200 -> 48 MHz / ( 16 * 115200 ) = 26.0416667
# Thus baud setting = 26
# NOTE: If finer baud adjustment is needed see UARTx_C4 -> BRFA in the datasheet
# Baud fine setting = 0x02
UARTConnectBaud = 26;
UARTConnectBaudFine = 0x02;

Loading

0 comments on commit ed71f7f

Please sign in to comment.