]> git.gir.st - tmk_keyboard.git/blob - tmk_core/protocol/xt.h
Codes appear to be detected correctly, the break codes are broken.
[tmk_keyboard.git] / tmk_core / protocol / xt.h
1 /*
2 Copyright 2010,2011,2012,2013 Jun WAKO <wakojun@gmail.com>
3 Copyright 2016 Ethan Apodaca <papodaca@gmail.com>
4
5 This software is licensed with a Modified BSD License.
6 All of this is supposed to be Free Software, Open Source, DFSG-free,
7 GPL-compatible, and OK to use in both free and proprietary applications.
8 Additions and corrections to this file are welcome.
9
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
13
14 * Redistributions of source code must retain the above copyright
15 notice, this list of conditions and the following disclaimer.
16
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in
19 the documentation and/or other materials provided with the
20 distribution.
21
22 * Neither the name of the copyright holders nor the names of
23 contributors may be used to endorse or promote products derived
24 from this software without specific prior written permission.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef XT_H
40 #define XT_H
41
42 #include <stdbool.h>
43 #include "wait.h"
44 #include "xt_io.h"
45 #include "print.h"
46
47 void xt_host_init(void);
48 uint8_t xt_host_recv(void);
49
50
51 /*--------------------------------------------------------------------
52 * static functions
53 *------------------------------------------------------------------*/
54 static inline uint16_t wait_clock_lo(uint16_t us)
55 {
56 while (clock_in() && us) { asm(""); wait_us(1); us--; }
57 return us;
58 }
59 static inline uint16_t wait_clock_hi(uint16_t us)
60 {
61 while (!clock_in() && us) { asm(""); wait_us(1); us--; }
62 return us;
63 }
64 static inline uint16_t wait_data_lo(uint16_t us)
65 {
66 while (data_in() && us) { asm(""); wait_us(1); us--; }
67 return us;
68 }
69 static inline uint16_t wait_data_hi(uint16_t us)
70 {
71 while (!data_in() && us) { asm(""); wait_us(1); us--; }
72 return us;
73 }
74
75 #endif
Imprint / Impressum