1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

Add typedef for putc1, fn_putc1_t. (#6550)

* Add typedef for putc1, fn_putc1_t.
Replaced relevant usage of `(void *)` with `fn_putc1_t`.
Correct usage of `ets_putc()`, returning 0, in libc_replacement.cpp
This PR assumes PR https://github.com/esp8266/Arduino/pull/6489#issue-315018841 has merged and removes `uart_buff_switch` from `umm_performance.cpp`
Updated method of defining `_rom_putc1` to be more acceptable (I hope) to the new compiler.

* Use PROVIDE to expose ROM function entry point, ets_uart_putc1.
Added comments to ets_putc() and ets_uart_putc1() to explain their
differences. Change prototype of ets_putc() to conform with fp_putc_t.
Updated _isr_safe_printf_P to use new definition, ets_uart_putc1.
This commit is contained in:
M Hightower
2019-09-27 14:23:16 -07:00
committed by Earle F. Philhower, III
parent ff1e8e92d1
commit 831d6431bc
6 changed files with 49 additions and 27 deletions

View File

@ -33,6 +33,17 @@
extern "C" {
#endif
/*
* This "print character function" prototype is modeled after the argument for
* ets_install_putc1() found in "ESP8266_NONOS_SDK/include/osapi.h". This
* deviates away from the familiar C library definition of putchar; however, it
* agrees with the code we are working with. Note, in the ROM some "printf
* character functions" always return 0 (uart_tx_one_char and ets_putc), some
* return last character printed (buildin _putc1), and some return nothing
* (ets_write_char). Using a void return type safely represents them all.
*/
typedef void (*fp_putc_t)(char);
typedef uint32_t ETSSignal;
typedef uint32_t ETSParam;
@ -205,15 +216,41 @@ char *ets_strstr(const char *haystack, const char *needle);
int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
int ets_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
void ets_install_putc1(void* routine);
void ets_install_putc1(fp_putc_t routine);
void ets_isr_mask(int intr);
void ets_isr_unmask(int intr);
void ets_isr_attach(int intr, int_handler_t handler, void *arg);
void ets_intr_lock();
void ets_intr_unlock();
int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));
int ets_vprintf(int (*print_function)(int), const char * format, va_list arg) __attribute__ ((format (printf, 2, 0)));
int ets_putc(int);
int ets_vprintf(fp_putc_t print_function, const char * format, va_list arg) __attribute__ ((format (printf, 2, 0)));
/*
* ets_putc(), a "print character function" in ROM, prints a character to a
* UART. It always returns 0; however, the prototype here is defined with void
* return to make compatible with other usages of fp_putc_t. ets_putc() provides
* a "raw", print as is, interface. '\r' and '\n' are each printed exactly as is
* w/o addition. For a "cooked" interface use ets_uart_putc1().
* The use of this function requires a prior setup call to uart_buff_switch() to
* select the UART.
*/
void ets_putc(char);
/*
* ets_uart_putc1(), a "print character function" in ROM, prints a character to
* a UART. It returns the character printed; however, the prototype here is
* defined with void return to make compatible with other usages of fp_putc_t.
* This function provides additional processing to characters '\r' and '\n'. It
* filters out '\r'. When called with '\n', it prints characters '\r' and '\n'.
* This is sometimes refered to as a "cooked" interface. For a "raw", print as
* is, interface use ets_putc(). The use of this function requires a prior setup
* call to uart_buff_switch() to select the UART.
* ets_uart_putc1() is used internally by ets_uart_printf. It is also the
* function that gets installed by ets_uart_install_printf through a call to
* ets_install_putc1.
*/
void ets_uart_putc1(char);
bool ets_task(ETSTask task, uint8 prio, ETSEvent *queue, uint8 qlen);
bool ets_post(uint8 prio, ETSSignal sig, ETSParam par);
void ets_update_cpu_frequency(uint32_t ticks_per_us);