|
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 "character |
| 41 | + * print functions" always return 0 (uart_tx_one_char and ets_putc), some return |
| 42 | + * 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,20 @@ 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 | + * ets_putc(), a "print character function" in ROM, prints a character to a |
| 229 | + * UART. It always returns 0. The use of this function requires a prior setup |
| 230 | + * call to uart_buff_switch() to select the UART. |
| 231 | + */ |
| 232 | +int ets_putc(char); |
217 | 233 | bool ets_task(ETSTask task, uint8 prio, ETSEvent *queue, uint8 qlen);
|
218 | 234 | bool ets_post(uint8 prio, ETSSignal sig, ETSParam par);
|
219 | 235 | void ets_update_cpu_frequency(uint32_t ticks_per_us);
|
|
0 commit comments