Keyboard firmwares for Atmel AVR and Cortex-M
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Copyright 2012 Jun Wako <[email protected]> */
  2. /* Very basic print functions, intended to be used with usb_debug_only.c
  3. * http://www.pjrc.com/teensy/
  4. * Copyright (c) 2008 PJRC.COM, LLC
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #ifndef PRINT_H__
  25. #define PRINT_H__ 1
  26. #include <stdint.h>
  27. #include <stdbool.h>
  28. #include <avr/pgmspace.h>
  29. // avoid collision with arduino/Print.h
  30. #ifndef __cplusplus
  31. // this macro allows you to write print("some text") and
  32. // the string is automatically placed into flash memory :)
  33. #define print(s) print_P(PSTR(s))
  34. #endif
  35. #define println(s) print_P(PSTR(s "\n"))
  36. #define phex(data) print_hex8(data)
  37. #define phex16(data) print_hex16(data)
  38. #define pdec(data) print_dec8(data)
  39. #define pdec16(data) print_dec16(data)
  40. #define pbin(data) print_bin8(data)
  41. #define pbin16(data) print_bin16(data)
  42. #define pbin_reverse(data) print_bin_reverse8(data)
  43. #define pbin_reverse16(data) print_bin_reverse16(data)
  44. /* print value utility */
  45. #define pv_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0)
  46. #define pv_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0)
  47. #define pv_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0)
  48. #define pv_dec8(v) do { print_P(PSTR(#v ": ")); print_dec8(v); print_P(PSTR("\n")); } while (0)
  49. #define pv_dec16(v) do { print_P(PSTR(#v ": ")); print_dec16(v); print_P(PSTR("\n")); } while (0)
  50. #define pv_dec32(v) do { print_P(PSTR(#v ": ")); print_dec32(v); print_P(PSTR("\n")); } while (0)
  51. #define pv_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0)
  52. #define pv_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0)
  53. #define pv_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0)
  54. #define pv_bin_reverse8(v) do { print_P(PSTR(#v ": ")); print_bin_reverse8(v); print_P(PSTR("\n")); } while (0)
  55. #define pv_bin_reverse16(v) do { print_P(PSTR(#v ": ")); print_bin_reverse16(v); print_P(PSTR("\n")); } while (0)
  56. #define pv_bin_reverse32(v) do { print_P(PSTR(#v ": ")); print_bin_reverse32(v); print_P(PSTR("\n")); } while (0)
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60. /* function pointer of sendchar to be used by print utility */
  61. extern int8_t (*print_sendchar_func)(uint8_t);
  62. extern bool print_enable;
  63. /* print string stored in data memory(SRAM) */
  64. void print_S(const char *s);
  65. /* print string stored in program memory(FLASH) */
  66. void print_P(const char *s);
  67. void print_hex8(uint8_t data);
  68. void print_hex16(uint16_t data);
  69. void print_hex32(uint32_t data);
  70. void print_dec8(uint8_t data);
  71. void print_dec16(uint16_t data);
  72. void print_bin8(uint8_t data);
  73. void print_bin16(uint16_t data);
  74. void print_bin_reverse8(uint8_t data);
  75. void print_bin_reverse16(uint16_t data);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif