2015-04-09 16:32:04 +00:00
|
|
|
/* Copyright 2012 Jun Wako <wakojun@gmail.com> */
|
|
|
|
/* Very basic print functions, intended to be used with usb_debug_only.c
|
|
|
|
* http://www.pjrc.com/teensy/
|
|
|
|
* Copyright (c) 2008 PJRC.COM, LLC
|
2016-04-17 17:54:32 +00:00
|
|
|
*
|
2015-04-09 16:32:04 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2016-04-17 17:54:32 +00:00
|
|
|
*
|
2015-04-09 16:32:04 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
2016-04-17 17:54:32 +00:00
|
|
|
*
|
2015-04-09 16:32:04 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2020-12-26 04:56:11 +00:00
|
|
|
#pragma once
|
2015-04-09 16:32:04 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "util.h"
|
|
|
|
|
Massdrop keyboard updates for SEND_STRING, syscalls, stdio, debug prints, Auto Shift (#3973)
* Update for SEND_STRING usage
Update for SEND_STRING usage.
Sending keyboard reports (kbd, nkro) now obey the minimum polling time.
While attempting to send a keyboard report and waiting for a USB poll, other functions of the keyboard, including LED effects and power management, will continue to operate at their intended intervals.
* Updates for send string, syscalls, stdio, debug prints, auto shift
Now properly waiting for previous keys sent over USB to complete before sending new.
Added heap to linker and now compiling with syscalls support.
Removed custom string functions and now using stdio.
dprintf now works as intended through virtser device.
* CTRL and ALT keymap updates
CTRL mac keymap updated
ALT default and mac keymap updated
ALT rules.mk added Auto Shift with default no
* Code cleanup as per discussion with vomindoraan
Code cleanup as per discussion with vomindoraan
2018-09-29 01:32:15 +00:00
|
|
|
#if defined(PROTOCOL_CHIBIOS) || defined(PROTOCOL_ARM_ATSAM)
|
2019-08-30 18:19:03 +00:00
|
|
|
# define PSTR(x) x
|
2016-07-08 21:41:15 +00:00
|
|
|
#endif
|
2015-04-09 16:32:04 +00:00
|
|
|
|
|
|
|
#ifndef NO_PRINT
|
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# if defined(__AVR__) /* __AVR__ */
|
2015-04-09 16:32:04 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# include "avr/xprintf.h"
|
2015-04-09 16:32:04 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# ifdef USER_PRINT /* USER_PRINT */
|
2015-04-09 16:32:04 +00:00
|
|
|
|
2016-09-08 04:50:58 +00:00
|
|
|
// Remove normal print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print(s)
|
|
|
|
# define println(s)
|
|
|
|
# undef xprintf
|
|
|
|
# define xprintf(fmt, ...)
|
2016-09-08 04:50:58 +00:00
|
|
|
|
|
|
|
// Create user print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define uprint(s) xputs(PSTR(s))
|
|
|
|
# define uprintln(s) xputs(PSTR(s "\r\n"))
|
|
|
|
# define uprintf(fmt, ...) __xprintf(PSTR(fmt), ##__VA_ARGS__)
|
2016-09-08 04:50:58 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# else /* NORMAL PRINT */
|
2016-09-08 04:50:58 +00:00
|
|
|
|
|
|
|
// Create user & normal print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print(s) xputs(PSTR(s))
|
|
|
|
# define println(s) xputs(PSTR(s "\r\n"))
|
|
|
|
# define uprint(s) print(s)
|
|
|
|
# define uprintln(s) println(s)
|
|
|
|
# define uprintf(fmt, ...) xprintf(fmt, ##__VA_ARGS__)
|
2016-09-08 04:50:58 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# endif /* USER_PRINT / NORMAL PRINT */
|
2016-09-08 04:50:58 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# ifdef __cplusplus
|
2015-04-09 16:32:04 +00:00
|
|
|
extern "C"
|
2019-08-30 18:19:03 +00:00
|
|
|
# endif
|
2016-09-08 04:50:58 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
/* function pointer of sendchar to be used by print utility */
|
|
|
|
void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
|
2015-04-09 16:32:04 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# elif defined(PROTOCOL_CHIBIOS) /* PROTOCOL_CHIBIOS */
|
2016-09-08 04:50:58 +00:00
|
|
|
|
2020-05-30 20:14:59 +00:00
|
|
|
# include "printf.h" // lib/printf/printf.h
|
2016-09-08 04:50:58 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# ifdef USER_PRINT /* USER_PRINT */
|
2016-09-08 04:50:58 +00:00
|
|
|
|
|
|
|
// Remove normal print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print(s)
|
|
|
|
# define println(s)
|
|
|
|
# define xprintf(fmt, ...)
|
2016-09-08 04:50:58 +00:00
|
|
|
|
|
|
|
// Create user print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define uprint(s) printf(s)
|
|
|
|
# define uprintln(s) printf(s "\r\n")
|
|
|
|
# define uprintf printf
|
2016-09-08 04:50:58 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# else /* NORMAL PRINT */
|
2016-09-08 04:50:58 +00:00
|
|
|
// Create user & normal print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print(s) printf(s)
|
|
|
|
# define println(s) printf(s "\r\n")
|
|
|
|
# define xprintf printf
|
|
|
|
# define uprint(s) printf(s)
|
|
|
|
# define uprintln(s) printf(s "\r\n")
|
|
|
|
# define uprintf printf
|
Add ChibiOS support for QMK (#465)
* Modularity and gcc warnings fixes.
* Add ChibiOS support (USB stack + support files).
* Make usb_main more USB_DRIVER #define independent.
* Move chibios to tool.
* Implement jump-to-bootloader.
* Small updates.
* Fix bootloader-jump compiling.
* Move AVR specific sleep_led.c into avr.
* Add basic sleep_led for chibios.
* Update chibios README.
* NKRO fixes.
* Rename some Makefile defines.
* Move STM32 bootloader address config to separate .h file.
* Add ARM Teensies bootloader code.
* Fix chibios/usb_main GET_REPORT handing.
* Add missing #include to keymap.c.
* Make bootmagic.c code portable (_delay_ms -> wait_ms).
* Move declaration of keymap_config.
Should really not declare variables in .h files - since it's included
in different .c files, a proper linker then complains that the same
variable is declared more than once (once for each .c file that the
offending .h is included in).
* Add eeprom support for chibios/kinetis.
* Rename chibios example keyboard.
* Move chibios/cortex selection to local Makefiles.
* Chibios: use WFI in idle. WIP suspend stuff.
* ChibiOS/kinetis: sending remote wakeup.
* ChibiOS/STM32: send remote wakeup.
* Fix report size of boot protocol.
* Fix drop key stroke
Keyboard report should be checked if its transfer finishs successfully.
Otherwise key stroke can be missing when other key event occurs
before the last report transfer is done.
Boot protocol 10ms interval probably causes this problem in case
it receives key events in a row within the period. NKRO protocol
suffers less or nothing due to its interval 1ms.
* Chibios/usb_main: rename a variable for clarity.
* Add correct chibios/bootloader_jump for infinity KB.
* ChibiOS: make reset request more CMSISy.
* Chibios: Add breathing sleep LED on Kinetis MCUs.
* ChibiOS: Update infinity bootloader code to match updated ChibiOS.
* ChibiOS: prettify/document sleep_led code.
* Chibios: Remove the wait in the main loop.
* Add maple mini code.
* Do timeout when writing to CONSOLE EP queue.
Fixes TMK bug #266.
* Chibios: add 'core/protocol' to the makefiles' search path.
* Chibios: Update to new USB API.
* Chibios: add more guards for transmitting (fix a deadlock bug).
* Add update for chibios in README
* Chibios: Fix a HardFault bug (wait after start).
* Chibios: cleanup usb_main code.
* Chibios: Revert common.mk change (fix AVR linking problem).
* core: Fix chibios user compile options
Compile options can be defined in project Makefile such as UDEFS, UADEFS, UINCDIR, ULIBDIR and ULIBS.
* Sysv format for ChibiOS arm-none-eabi-size
Some new patches to ChibiOS puts heap as it's own section. So the
berkeley format is now useless, as the heap will be included in the
BSS report. The sysv format displays the bss size correctly.
* Fix hard-coded path of CHIBIOS
* Add support for new version of ChibiOS and Contrib
The Kinetis support has moved to a separate Contrib repository in
the newest version of Chibios. There has also been some structure
changes. So this adds support for those, while maintaining back-
wards compability.
* Update ChibiOS instructions
* Chibios: implement sleep LED for STM32.
* Chibios: Update the main chibios README.
* Chibios: fix STM32_BOOTLOADER_ADDRESS name.
* Chibios: make the default bootloader_jump redefinable (weak).
* Chibios: disable LTO (link-time optimisation).
With LTO enabled, sometimes things fail for mysterious reasons
(e.g. bootloader jump on WF with LEDs enabled), just because the
linker optimisation is too aggressive.
* Chibios: add default location for chibios-contrib.
* ChibiOS: update mk to match chibios/master.
* ChibiOS: update instructions.md.
* Add chibi_onekey example.
* Add comments to chibi_onekey Makefile.
* Rename some Makefile defines.
* Move STM32 bootloader address config to separate .h file.
* Rename chibios example keyboard.
* Move chibios/cortex selection to local Makefiles.
* Add Teensy LC onekey example.
* Chibios: use WFI in idle. WIP suspend stuff.
* Update chibi/teensy instructions.
* Update chibios/Teensy instructions.
* Add infinity_chibios
* Add keymap_hasu.c
* Infinity_chibios: select correct bootloader_jump.
* Infinity_chibios: improve comments.
* Add generic STM32F103C8T6 example.
* Add maple mini code.
* STM32F103x fixes.
* Add maple mini pinout pic.
* Chibios: updates for 3.0.4 git.
* Chibios: rename example stm32_onekey -> stm32_f072_onekey.
* Chibios: add makefiles for Teensy 3.x examples.
* Chibios: update Teensy 3.x instructions.
* Chibios: Tsy LC is cortex-m0plus.
* Chibios: add more guards for transmitting (fix a deadlock bug).
* Change README for chibios
* Chibios: update examples to current chibios git.
Match the changes in mainline chibios:
- update chconf.h
- update supplied ld scripts structure
- update Teensy instructions (switch to official
chibios and introduce contrib)
* Add ChibiOS and ChibiOS-Contrib submodules
Also fix the makefile path for them.
* Moves chibios keyboards to keyboards folder
* First version of ChibiOS compilation
Only the stm32_f072_onkey keyboard is ported at the moment. It
compiles, but still doesn't link.
* More chibios fixes
It now compiles without warnings and links
* Move the teensy_lc_onekey to the keyboards folder
* Clean up the make file rule structure
* Remove keymap_fn_to_action
* Update more ChibiOS keyboards to QMK
Most of them does not compile at the moment though.
* Use older version of Chibios libraries
The newest ones have problems with compilation
* Remove USB_UNCONFIGURED event
It isn't present in the older version of ChibiOS
* Fix the infinity_chibios compilation
* Fix potentially uninitialized variable
* Add missing include
* Fix the ChibiOS makefile
* Fix some Chibios keyboard compilation
* Revert the rules.mk file back to master version
* Combine the chibios and AVR makefiles
With just the required overrides in the respective platform
specific one.
* Slight makefile restrucuring
Platform specific compiler options
* Move avr specific targets out of the main rules
* Fix ChibiOS objcopy
The ChibiOS objcopy needs different parameters, so the parameters
are moved to the corresponding platform rule file
* Fix the objcopy for real this time
The comands were moved around, so chibios used avr and the ohter
way around.
Also change the objsize output format
* Fix the thumb flags
* Fix the infinity hasu keymap
* Per platform cpp flags
* Add gcc-arm-none-eabi package to travis
* Add arm-none-eabi-newlib to travis
* Fix the name of the libnewlib-arm-none-eabi lib
* Fix the ChibiOS paths
So that they are properly relative, and builds don't generate
extra folders
* Fix the board path of stm32_f103_onekey
* Only consider folders with Makefiles as subproject
2016-07-01 14:04:53 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# endif /* USER_PRINT / NORMAL PRINT */
|
Add ChibiOS support for QMK (#465)
* Modularity and gcc warnings fixes.
* Add ChibiOS support (USB stack + support files).
* Make usb_main more USB_DRIVER #define independent.
* Move chibios to tool.
* Implement jump-to-bootloader.
* Small updates.
* Fix bootloader-jump compiling.
* Move AVR specific sleep_led.c into avr.
* Add basic sleep_led for chibios.
* Update chibios README.
* NKRO fixes.
* Rename some Makefile defines.
* Move STM32 bootloader address config to separate .h file.
* Add ARM Teensies bootloader code.
* Fix chibios/usb_main GET_REPORT handing.
* Add missing #include to keymap.c.
* Make bootmagic.c code portable (_delay_ms -> wait_ms).
* Move declaration of keymap_config.
Should really not declare variables in .h files - since it's included
in different .c files, a proper linker then complains that the same
variable is declared more than once (once for each .c file that the
offending .h is included in).
* Add eeprom support for chibios/kinetis.
* Rename chibios example keyboard.
* Move chibios/cortex selection to local Makefiles.
* Chibios: use WFI in idle. WIP suspend stuff.
* ChibiOS/kinetis: sending remote wakeup.
* ChibiOS/STM32: send remote wakeup.
* Fix report size of boot protocol.
* Fix drop key stroke
Keyboard report should be checked if its transfer finishs successfully.
Otherwise key stroke can be missing when other key event occurs
before the last report transfer is done.
Boot protocol 10ms interval probably causes this problem in case
it receives key events in a row within the period. NKRO protocol
suffers less or nothing due to its interval 1ms.
* Chibios/usb_main: rename a variable for clarity.
* Add correct chibios/bootloader_jump for infinity KB.
* ChibiOS: make reset request more CMSISy.
* Chibios: Add breathing sleep LED on Kinetis MCUs.
* ChibiOS: Update infinity bootloader code to match updated ChibiOS.
* ChibiOS: prettify/document sleep_led code.
* Chibios: Remove the wait in the main loop.
* Add maple mini code.
* Do timeout when writing to CONSOLE EP queue.
Fixes TMK bug #266.
* Chibios: add 'core/protocol' to the makefiles' search path.
* Chibios: Update to new USB API.
* Chibios: add more guards for transmitting (fix a deadlock bug).
* Add update for chibios in README
* Chibios: Fix a HardFault bug (wait after start).
* Chibios: cleanup usb_main code.
* Chibios: Revert common.mk change (fix AVR linking problem).
* core: Fix chibios user compile options
Compile options can be defined in project Makefile such as UDEFS, UADEFS, UINCDIR, ULIBDIR and ULIBS.
* Sysv format for ChibiOS arm-none-eabi-size
Some new patches to ChibiOS puts heap as it's own section. So the
berkeley format is now useless, as the heap will be included in the
BSS report. The sysv format displays the bss size correctly.
* Fix hard-coded path of CHIBIOS
* Add support for new version of ChibiOS and Contrib
The Kinetis support has moved to a separate Contrib repository in
the newest version of Chibios. There has also been some structure
changes. So this adds support for those, while maintaining back-
wards compability.
* Update ChibiOS instructions
* Chibios: implement sleep LED for STM32.
* Chibios: Update the main chibios README.
* Chibios: fix STM32_BOOTLOADER_ADDRESS name.
* Chibios: make the default bootloader_jump redefinable (weak).
* Chibios: disable LTO (link-time optimisation).
With LTO enabled, sometimes things fail for mysterious reasons
(e.g. bootloader jump on WF with LEDs enabled), just because the
linker optimisation is too aggressive.
* Chibios: add default location for chibios-contrib.
* ChibiOS: update mk to match chibios/master.
* ChibiOS: update instructions.md.
* Add chibi_onekey example.
* Add comments to chibi_onekey Makefile.
* Rename some Makefile defines.
* Move STM32 bootloader address config to separate .h file.
* Rename chibios example keyboard.
* Move chibios/cortex selection to local Makefiles.
* Add Teensy LC onekey example.
* Chibios: use WFI in idle. WIP suspend stuff.
* Update chibi/teensy instructions.
* Update chibios/Teensy instructions.
* Add infinity_chibios
* Add keymap_hasu.c
* Infinity_chibios: select correct bootloader_jump.
* Infinity_chibios: improve comments.
* Add generic STM32F103C8T6 example.
* Add maple mini code.
* STM32F103x fixes.
* Add maple mini pinout pic.
* Chibios: updates for 3.0.4 git.
* Chibios: rename example stm32_onekey -> stm32_f072_onekey.
* Chibios: add makefiles for Teensy 3.x examples.
* Chibios: update Teensy 3.x instructions.
* Chibios: Tsy LC is cortex-m0plus.
* Chibios: add more guards for transmitting (fix a deadlock bug).
* Change README for chibios
* Chibios: update examples to current chibios git.
Match the changes in mainline chibios:
- update chconf.h
- update supplied ld scripts structure
- update Teensy instructions (switch to official
chibios and introduce contrib)
* Add ChibiOS and ChibiOS-Contrib submodules
Also fix the makefile path for them.
* Moves chibios keyboards to keyboards folder
* First version of ChibiOS compilation
Only the stm32_f072_onkey keyboard is ported at the moment. It
compiles, but still doesn't link.
* More chibios fixes
It now compiles without warnings and links
* Move the teensy_lc_onekey to the keyboards folder
* Clean up the make file rule structure
* Remove keymap_fn_to_action
* Update more ChibiOS keyboards to QMK
Most of them does not compile at the moment though.
* Use older version of Chibios libraries
The newest ones have problems with compilation
* Remove USB_UNCONFIGURED event
It isn't present in the older version of ChibiOS
* Fix the infinity_chibios compilation
* Fix potentially uninitialized variable
* Add missing include
* Fix the ChibiOS makefile
* Fix some Chibios keyboard compilation
* Revert the rules.mk file back to master version
* Combine the chibios and AVR makefiles
With just the required overrides in the respective platform
specific one.
* Slight makefile restrucuring
Platform specific compiler options
* Move avr specific targets out of the main rules
* Fix ChibiOS objcopy
The ChibiOS objcopy needs different parameters, so the parameters
are moved to the corresponding platform rule file
* Fix the objcopy for real this time
The comands were moved around, so chibios used avr and the ohter
way around.
Also change the objsize output format
* Fix the thumb flags
* Fix the infinity hasu keymap
* Per platform cpp flags
* Add gcc-arm-none-eabi package to travis
* Add arm-none-eabi-newlib to travis
* Fix the name of the libnewlib-arm-none-eabi lib
* Fix the ChibiOS paths
So that they are properly relative, and builds don't generate
extra folders
* Fix the board path of stm32_f103_onekey
* Only consider folders with Makefiles as subproject
2016-07-01 14:04:53 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# elif defined(PROTOCOL_ARM_ATSAM) /* PROTOCOL_ARM_ATSAM */
|
2018-08-29 19:07:52 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# include "arm_atsam/printf.h"
|
2018-08-29 19:07:52 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# ifdef USER_PRINT /* USER_PRINT */
|
2018-08-29 19:07:52 +00:00
|
|
|
|
|
|
|
// Remove normal print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print(s)
|
|
|
|
# define println(s)
|
|
|
|
# define xprintf(fmt, ...)
|
2018-08-29 19:07:52 +00:00
|
|
|
|
|
|
|
// Create user print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define uprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
|
|
|
|
# define uprint(s) xprintf(s)
|
|
|
|
# define uprintln(s) xprintf(s "\r\n")
|
2018-08-29 19:07:52 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# else /* NORMAL PRINT */
|
2018-08-29 19:07:52 +00:00
|
|
|
|
|
|
|
// Create user & normal print defines
|
2019-08-30 18:19:03 +00:00
|
|
|
# define xprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
|
|
|
|
# define print(s) xprintf(s)
|
|
|
|
# define println(s) xprintf(s "\r\n")
|
|
|
|
# define uprint(s) print(s)
|
|
|
|
# define uprintln(s) println(s)
|
|
|
|
# define uprintf(fmt, ...) xprintf(fmt, ##__VA_ARGS__)
|
2018-08-29 19:07:52 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# endif /* USER_PRINT / NORMAL PRINT */
|
2018-08-29 19:07:52 +00:00
|
|
|
|
2019-12-11 19:36:00 +00:00
|
|
|
# endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM */
|
2016-09-08 04:50:58 +00:00
|
|
|
|
|
|
|
// User print disables the normal print messages in the body of QMK/TMK code and
|
|
|
|
// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do
|
|
|
|
// a spot of debugging but lack flash resources for allowing all of the codebase to
|
|
|
|
// print (and store their wasteful strings).
|
|
|
|
//
|
|
|
|
// !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!!
|
|
|
|
//
|
2019-08-30 18:19:03 +00:00
|
|
|
# ifdef USER_PRINT
|
2015-04-09 16:32:04 +00:00
|
|
|
|
2016-09-08 04:50:58 +00:00
|
|
|
// Disable normal print
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print_dec(data)
|
|
|
|
# define print_decs(data)
|
|
|
|
# define print_hex4(data)
|
|
|
|
# define print_hex8(data)
|
|
|
|
# define print_hex16(data)
|
|
|
|
# define print_hex32(data)
|
|
|
|
# define print_bin4(data)
|
|
|
|
# define print_bin8(data)
|
|
|
|
# define print_bin16(data)
|
|
|
|
# define print_bin32(data)
|
|
|
|
# define print_bin_reverse8(data)
|
|
|
|
# define print_bin_reverse16(data)
|
|
|
|
# define print_bin_reverse32(data)
|
|
|
|
# define print_val_dec(v)
|
|
|
|
# define print_val_decs(v)
|
|
|
|
# define print_val_hex8(v)
|
|
|
|
# define print_val_hex16(v)
|
|
|
|
# define print_val_hex32(v)
|
|
|
|
# define print_val_bin8(v)
|
|
|
|
# define print_val_bin16(v)
|
|
|
|
# define print_val_bin32(v)
|
|
|
|
# define print_val_bin_reverse8(v)
|
|
|
|
# define print_val_bin_reverse16(v)
|
|
|
|
# define print_val_bin_reverse32(v)
|
|
|
|
|
|
|
|
# else /* NORMAL_PRINT */
|
|
|
|
|
|
|
|
// Enable normal print
|
2015-04-09 16:32:04 +00:00
|
|
|
/* decimal */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print_dec(i) xprintf("%u", i)
|
|
|
|
# define print_decs(i) xprintf("%d", i)
|
2015-04-09 16:32:04 +00:00
|
|
|
/* hex */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print_hex4(i) xprintf("%X", i)
|
|
|
|
# define print_hex8(i) xprintf("%02X", i)
|
|
|
|
# define print_hex16(i) xprintf("%04X", i)
|
|
|
|
# define print_hex32(i) xprintf("%08lX", i)
|
2015-04-09 16:32:04 +00:00
|
|
|
/* binary */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print_bin4(i) xprintf("%04b", i)
|
|
|
|
# define print_bin8(i) xprintf("%08b", i)
|
|
|
|
# define print_bin16(i) xprintf("%016b", i)
|
|
|
|
# define print_bin32(i) xprintf("%032lb", i)
|
|
|
|
# define print_bin_reverse8(i) xprintf("%08b", bitrev(i))
|
|
|
|
# define print_bin_reverse16(i) xprintf("%016b", bitrev16(i))
|
|
|
|
# define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i))
|
2015-04-09 16:32:04 +00:00
|
|
|
/* print value utility */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define print_val_dec(v) xprintf(# v ": %u\n", v)
|
|
|
|
# define print_val_decs(v) xprintf(# v ": %d\n", v)
|
|
|
|
# define print_val_hex8(v) xprintf(# v ": %X\n", v)
|
|
|
|
# define print_val_hex16(v) xprintf(# v ": %02X\n", v)
|
|
|
|
# define print_val_hex32(v) xprintf(# v ": %04lX\n", v)
|
|
|
|
# define print_val_bin8(v) xprintf(# v ": %08b\n", v)
|
|
|
|
# define print_val_bin16(v) xprintf(# v ": %016b\n", v)
|
|
|
|
# define print_val_bin32(v) xprintf(# v ": %032lb\n", v)
|
|
|
|
# define print_val_bin_reverse8(v) xprintf(# v ": %08b\n", bitrev(v))
|
|
|
|
# define print_val_bin_reverse16(v) xprintf(# v ": %016b\n", bitrev16(v))
|
|
|
|
# define print_val_bin_reverse32(v) xprintf(# v ": %032lb\n", bitrev32(v))
|
|
|
|
|
|
|
|
# endif /* USER_PRINT / NORMAL_PRINT */
|
2016-09-08 04:50:58 +00:00
|
|
|
|
|
|
|
// User Print
|
|
|
|
|
|
|
|
/* decimal */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define uprint_dec(i) uprintf("%u", i)
|
|
|
|
# define uprint_decs(i) uprintf("%d", i)
|
2016-09-08 04:50:58 +00:00
|
|
|
/* hex */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define uprint_hex4(i) uprintf("%X", i)
|
|
|
|
# define uprint_hex8(i) uprintf("%02X", i)
|
|
|
|
# define uprint_hex16(i) uprintf("%04X", i)
|
|
|
|
# define uprint_hex32(i) uprintf("%08lX", i)
|
2016-09-08 04:50:58 +00:00
|
|
|
/* binary */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define uprint_bin4(i) uprintf("%04b", i)
|
|
|
|
# define uprint_bin8(i) uprintf("%08b", i)
|
|
|
|
# define uprint_bin16(i) uprintf("%016b", i)
|
|
|
|
# define uprint_bin32(i) uprintf("%032lb", i)
|
|
|
|
# define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i))
|
|
|
|
# define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i))
|
|
|
|
# define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i))
|
2016-09-08 04:50:58 +00:00
|
|
|
/* print value utility */
|
2019-08-30 18:19:03 +00:00
|
|
|
# define uprint_val_dec(v) uprintf(# v ": %u\n", v)
|
|
|
|
# define uprint_val_decs(v) uprintf(# v ": %d\n", v)
|
|
|
|
# define uprint_val_hex8(v) uprintf(# v ": %X\n", v)
|
|
|
|
# define uprint_val_hex16(v) uprintf(# v ": %02X\n", v)
|
|
|
|
# define uprint_val_hex32(v) uprintf(# v ": %04lX\n", v)
|
|
|
|
# define uprint_val_bin8(v) uprintf(# v ": %08b\n", v)
|
|
|
|
# define uprint_val_bin16(v) uprintf(# v ": %016b\n", v)
|
|
|
|
# define uprint_val_bin32(v) uprintf(# v ": %032lb\n", v)
|
|
|
|
# define uprint_val_bin_reverse8(v) uprintf(# v ": %08b\n", bitrev(v))
|
|
|
|
# define uprint_val_bin_reverse16(v) uprintf(# v ": %016b\n", bitrev16(v))
|
|
|
|
# define uprint_val_bin_reverse32(v) uprintf(# v ": %032lb\n", bitrev32(v))
|
|
|
|
|
|
|
|
#else /* NO_PRINT */
|
2015-04-09 16:32:04 +00:00
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
# define xprintf(fmt, ...)
|
|
|
|
# define print(s)
|
|
|
|
# define println(s)
|
|
|
|
# define print_set_sendchar(func)
|
|
|
|
# define print_dec(data)
|
|
|
|
# define print_decs(data)
|
|
|
|
# define print_hex4(data)
|
|
|
|
# define print_hex8(data)
|
|
|
|
# define print_hex16(data)
|
|
|
|
# define print_hex32(data)
|
|
|
|
# define print_bin4(data)
|
|
|
|
# define print_bin8(data)
|
|
|
|
# define print_bin16(data)
|
|
|
|
# define print_bin32(data)
|
|
|
|
# define print_bin_reverse8(data)
|
|
|
|
# define print_bin_reverse16(data)
|
|
|
|
# define print_bin_reverse32(data)
|
|
|
|
# define print_val_dec(v)
|
|
|
|
# define print_val_decs(v)
|
|
|
|
# define print_val_hex8(v)
|
|
|
|
# define print_val_hex16(v)
|
|
|
|
# define print_val_hex32(v)
|
|
|
|
# define print_val_bin8(v)
|
|
|
|
# define print_val_bin16(v)
|
|
|
|
# define print_val_bin32(v)
|
|
|
|
# define print_val_bin_reverse8(v)
|
|
|
|
# define print_val_bin_reverse16(v)
|
|
|
|
# define print_val_bin_reverse32(v)
|
|
|
|
|
|
|
|
#endif /* NO_PRINT */
|
2015-04-09 16:32:04 +00:00
|
|
|
|
|
|
|
/* Backward compatiblitly for old name */
|
2019-08-30 18:19:03 +00:00
|
|
|
#define pdec(data) print_dec(data)
|
|
|
|
#define pdec16(data) print_dec(data)
|
|
|
|
#define phex(data) print_hex8(data)
|
|
|
|
#define phex16(data) print_hex16(data)
|
|
|
|
#define pbin(data) print_bin8(data)
|
|
|
|
#define pbin16(data) print_bin16(data)
|
|
|
|
#define pbin_reverse(data) print_bin_reverse8(data)
|
|
|
|
#define pbin_reverse16(data) print_bin_reverse16(data)
|