Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

m0110.h 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. Copyright 2011,2012 Jun WAKO <[email protected]>
  3. This software is licensed with a Modified BSD License.
  4. All of this is supposed to be Free Software, Open Source, DFSG-free,
  5. GPL-compatible, and OK to use in both free and proprietary applications.
  6. Additions and corrections to this file are welcome.
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are met:
  9. * Redistributions of source code must retain the above copyright
  10. notice, this list of conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above copyright
  12. notice, this list of conditions and the following disclaimer in
  13. the documentation and/or other materials provided with the
  14. distribution.
  15. * Neither the name of the copyright holders nor the names of
  16. contributors may be used to endorse or promote products derived
  17. from this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  22. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef M0110_H
  31. #define M0110_H
  32. /* port settings for clock and data line */
  33. #if !(defined(M0110_CLOCK_PORT) && \
  34. defined(M0110_CLOCK_PIN) && \
  35. defined(M0110_CLOCK_DDR) && \
  36. defined(M0110_CLOCK_BIT))
  37. # error "M0110 clock port setting is required in config.h"
  38. #endif
  39. #if !(defined(M0110_DATA_PORT) && \
  40. defined(M0110_DATA_PIN) && \
  41. defined(M0110_DATA_DDR) && \
  42. defined(M0110_DATA_BIT))
  43. # error "M0110 data port setting is required in config.h"
  44. #endif
  45. /* Commands */
  46. #define M0110_INQUIRY 0x10
  47. #define M0110_INSTANT 0x14
  48. #define M0110_MODEL 0x16
  49. #define M0110_TEST 0x36
  50. /* Response(raw byte from M0110) */
  51. #define M0110_NULL 0x7B
  52. #define M0110_KEYPAD 0x79
  53. #define M0110_TEST_ACK 0x7D
  54. #define M0110_TEST_NAK 0x77
  55. #define M0110_SHIFT 0x71
  56. #define M0110_ARROW_UP 0x1B
  57. #define M0110_ARROW_DOWN 0x11
  58. #define M0110_ARROW_LEFT 0x0D
  59. #define M0110_ARROW_RIGHT 0x05
  60. /* This inidcates no response. */
  61. #define M0110_ERROR 0xFF
  62. /* scan code offset for keypad and arrow keys */
  63. #define M0110_KEYPAD_OFFSET 0x40
  64. #define M0110_CALC_OFFSET 0x60
  65. extern uint8_t m0110_error;
  66. /* host role */
  67. void m0110_init(void);
  68. uint8_t m0110_send(uint8_t data);
  69. uint8_t m0110_recv(void);
  70. uint8_t m0110_recv_key(void);
  71. uint8_t m0110_inquiry(void);
  72. uint8_t m0110_instant(void);
  73. #endif