]> git.gir.st - tmk_keyboard.git/blame - keyboard/teensy_lc_onekey/instructions.md
remove experimental return, cleanup slash_question key
[tmk_keyboard.git] / keyboard / teensy_lc_onekey / instructions.md
CommitLineData
c61210cf 1# Teensy LC, 3.0, 3.1, 3.2 support
2
82e8e6fb 3These ARM Teensies are now supported through [ChibiOS](http://chibios.org).
c61210cf 4
e54d7986 5Follow the setup instructions in `tmk_core/protocol/chibios/README.md` to install ChibiOS and required toolchain.
be9c2935 6
7Running `make` in `keyboard/teensy_lc_onekey` should create a working firmware in `build/`, called `ch.hex`.
c61210cf 8
9For more notes about the ChibiOS backend in TMK, see `tmk_core/protocol/chibios/README.md`.
10
11## About this onekey example
12
0998a993 13It's set up for Teensy LC. To use 3.x, you'll need to edit the `Makefile` (and comment out one line in `mcuconf.h`). A sample makefile for Teensy 3.0 is provided as `Makefile.3.0`, can be used without renaming with `make -f Makefile.3.0`. Similarly for Teensy 3.2, there's `Makefile.3.2`.
c61210cf 14
15## Credits
16
c1c8e079 17TMK itself is written by hasu, original sources [here](https://github.com/tmk/tmk_keyboard).
18
c61210cf 19The USB support for Kinetis MCUs is due to RedoX. His ChibiOS fork is also [on github](https://github.com/RedoXyde/ChibiOS); but it doesn't include Teensy LC definitions.
20
21## Features that are not implemented yet
22
0998a993 23Currently only the more fancy suspend features are not there (power saving during suspend). The rest should work fine (reports either way are welcome).
c61210cf 24
25# Matrix programming notes
26
27The notes below explain what commands can be used to examine and set the status of Teensy pins.
28
29## ChibiOS pin manipulation basics
30
31### Pins
32
33Each pin sits on a "port", each of which comprises at most 32 individual pins.
34So for instance "PTC5" from Kinetis manual/datasheet refers to port C (or GPIOA), pin 5. Most functions dealing with pins take 2 parameters which specify the pin -- the first being the port, the second being the pin number.
35
36Within ChibiOS, there are definitions which simplify this a bit for the Teensies. `TEENSY_PINn_IOPORT` represents the port of the MCU's pin connected Teensy's PIN `n`, and `TEENSY_PINn` represents its MCU's pin number.
37
38### Mode
39
40A MCU pin can be in several modes. The basic command to set a pin mode is
41
42 palSetPadMode(TEENSY_PINn_IOPORT, TEENSY_PINn, PAL_MODE_INPUT_PULLUP);
43
44The last parameter is the mode. For keyboards, the usual ones that are used are `PAL_MODE_INPUT_PULLUP` (input with a pullup), `PAL_MODE_INPUT_PULLDOWN` (input with a pulldown), `PAL_MODE_INPUT` (input floating, a.k.a. Hi-Z), `PAL_MODE_OUTPUT_PUSHPULL` (output in the Arduino sense -- can be then set HIGH or LOW).
45
46### Setting
47
48Pins are set HIGH (after they've been put into `OUTPUT_PUSHPULL` mode) by
49
50 palSetPad(TEENSY_PINn_IOPORT, TEENSY_PINn);
51
52or set LOW by
53
54 palClearPad(TEENSY_PINn_IOPORT, TEENSY_PINn);
55
aa2c5682 56Toggling can be done with
57
58 palTogglePad(TEENSY_PINn_IOPORT, TEENSY_PINn);
59
60Alternatively, you can use
61
62 palWritePad(TEENSY_PINn_IOPORT, TEENSY_PINn, bit);
63
64where `bit` is either `PAL_LOW` or `PAL_HIGH` (i.e. `0` or `1`).
65
c61210cf 66### Reading
67
68Reading pin status is done with
69
70 palReadPad(TEENSY_PINn_IOPORT, TEENSY_PINn);
71
72The function returns either `PAL_HIGH` (actually `1`) or `PAL_LOW` (actually `0`).
aa2c5682 73
74### Further docs
75
76All the commands that are available for pin manipulation through ChibiOS HAL are documented in [ChibiOS PAL driver docs](http://chibios.sourceforge.net/docs3/hal/group___p_a_l.html).
Imprint / Impressum