|
33 | 33 | extern "C" {
|
34 | 34 | #endif
|
35 | 35 |
|
| 36 | +/* |
| 37 | + * This "print character function" prototype is modeled after the argument for |
| 38 | + * ets_install_putc1() found in "ESP8266_NONOS_SDK/include/osapi.h". This |
| 39 | + * deviates away from the familiar C library definition of putchar; however, it |
| 40 | + * agrees with the code we are working with. Note, in the ROM some "printf |
| 41 | + * character functions" always return 0 (uart_tx_one_char and ets_putc), some |
| 42 | + * return last character printed (buildin _putc1), and some return nothing |
| 43 | + * (ets_write_char). Using a void return type safely represents them all. |
| 44 | + */ |
| 45 | +typedef void (*fp_putc_t)(char); |
| 46 | + |
36 | 47 | typedef uint32_t ETSSignal;
|
37 | 48 | typedef uint32_t ETSParam;
|
38 | 49 |
|
@@ -205,15 +216,41 @@ char *ets_strstr(const char *haystack, const char *needle);
|
205 | 216 | int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
206 | 217 | int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
|
207 | 218 | int ets_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
208 |
| -void ets_install_putc1(void* routine); |
| 219 | +void ets_install_putc1(fp_putc_t routine); |
209 | 220 | void ets_isr_mask(int intr);
|
210 | 221 | void ets_isr_unmask(int intr);
|
211 | 222 | void ets_isr_attach(int intr, int_handler_t handler, void *arg);
|
212 | 223 | void ets_intr_lock();
|
213 | 224 | void ets_intr_unlock();
|
214 | 225 | int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));
|
215 |
| -int ets_vprintf(int (*print_function)(int), const char * format, va_list arg) __attribute__ ((format (printf, 2, 0))); |
216 |
| -int ets_putc(int); |
| 226 | +int ets_vprintf(fp_putc_t print_function, const char * format, va_list arg) __attribute__ ((format (printf, 2, 0))); |
| 227 | + |
| 228 | +/* |
| 229 | + * ets_putc(), a "print character function" in ROM, prints a character to a |
| 230 | + * UART. It always returns 0; however, the prototype here is defined with void |
| 231 | + * return to make compatible with other usages of fp_putc_t. ets_putc() provides |
| 232 | + * a "raw", print as is, interface. '\r' and '\n' are each printed exactly as is |
| 233 | + * w/o addition. For a "cooked" interface use ets_uart_putc1(). |
| 234 | + * The use of this function requires a prior setup call to uart_buff_switch() to |
| 235 | + * select the UART. |
| 236 | + */ |
| 237 | +void ets_putc(char); |
| 238 | + |
| 239 | +/* |
| 240 | + * ets_uart_putc1(), a "print character function" in ROM, prints a character to |
| 241 | + * a UART. It returns the character printed; however, the prototype here is |
| 242 | + * defined with void return to make compatible with other usages of fp_putc_t. |
| 243 | + * This function provides additional processing to characters '\r' and '\n'. It |
| 244 | + * filters out '\r'. When called with '\n', it prints characters '\r' and '\n'. |
| 245 | + * This is sometimes refered to as a "cooked" interface. For a "raw", print as |
| 246 | + * is, interface use ets_putc(). The use of this function requires a prior setup |
| 247 | + * call to uart_buff_switch() to select the UART. |
| 248 | + * ets_uart_putc1() is used internally by ets_uart_printf. It is also the |
| 249 | + * function that gets installed by ets_uart_install_printf through a call to |
| 250 | + * ets_install_putc1. |
| 251 | + */ |
| 252 | +void ets_uart_putc1(char); |
| 253 | + |
217 | 254 | bool ets_task(ETSTask task, uint8 prio, ETSEvent *queue, uint8 qlen);
|
218 | 255 | bool ets_post(uint8 prio, ETSSignal sig, ETSParam par);
|
219 | 256 | void ets_update_cpu_frequency(uint32_t ticks_per_us);
|
|
0 commit comments