diff --git a/src/keyboard/controller.c b/src/keyboard/controller.c index 3c184cc..b97b112 100644 --- a/src/keyboard/controller.c +++ b/src/keyboard/controller.c @@ -438,3 +438,61 @@ uint8_t teensy_update_matrix(bool matrix[KB_ROWS][KB_COLUMNS]) { return 0; // success } + +// ---------------------------------------------------------------------------- + +void twi_init(void) { + // set the prescaler value to 0 + TWSR &= ~( (1< #include #include -#include "../lib/teensy-2-0.h" #include "./options.h" #include "./matrix.h" #include @@ -78,3 +74,13 @@ uint8_t teensy_update_matrix( bool matrix[KB_ROWS][KB_COLUMNS] ); _kb_led_2_set_percent(n); \ _kb_led_3_set_percent(n); \ } while(0) + +// -------------------------------------------------------------------- + +#define TWI_FREQ 400000 + +void twi_init (void); +uint8_t twi_start (void); +void twi_stop (void); +uint8_t twi_send (uint8_t data); +uint8_t twi_read (uint8_t * data); diff --git a/src/lib/teensy-2-0.c b/src/lib/teensy-2-0.c deleted file mode 100644 index 45cf275..0000000 --- a/src/lib/teensy-2-0.c +++ /dev/null @@ -1,81 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Very simple Teensy 2.0 TWI library : code - * - * - This is mostly straight from the datasheet, section 20.6.6, figure 20-11 - * (the code example in C), and section 20.8.1, figure 20-12 - * - Also see the documentation for `` at - * - * - * Some other (more complete) TWI libraries for the Teensy 2.0 (and other Atmel - * processors): - * - [i2cmaster] (http://homepage.hispeed.ch/peterfleury/i2cmaster.zip) - * - written by [peter-fleury] (http://homepage.hispeed.ch/peterfleury/) - * - [the arduino twi library] - * (https://github.com/arduino/Arduino/tree/master/libraries/Wire/utility) - * - look for an older version if you need one that doesn't depend on all the - * other Arduino stuff - * ---------------------------------------------------------------------------- - * Copyright (c) 2012 Ben Blazak - * Released under The MIT License (MIT) (see "license.md") - * Project located at - * ------------------------------------------------------------------------- */ - -#include "./teensy-2-0.h" - -// ---------------------------------------------------------------------------- - -void twi_init(void) { - // set the prescaler value to 0 - TWSR &= ~( (1< - * Released under The MIT License (MIT) (see "license.md") - * Project located at - * ------------------------------------------------------------------------- */ - -#pragma once -#include - -// -------------------------------------------------------------------- - -#ifndef TWI_FREQ -#define TWI_FREQ 100000 // in Hz -#endif - -// -------------------------------------------------------------------- - -void twi_init (void); -uint8_t twi_start (void); -void twi_stop (void); -uint8_t twi_send (uint8_t data); -uint8_t twi_read (uint8_t * data); diff --git a/src/lib/readme.md b/src/lib/teensy-readme.md similarity index 100% rename from src/lib/readme.md rename to src/lib/teensy-readme.md