osapi.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * ESPRESSIF MIT License
  3. *
  4. * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
  5. *
  6. * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
  7. * it is free of charge, to any person obtaining a copy of this software and associated
  8. * documentation files (the "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
  11. * to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or
  14. * 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, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef _OSAPI_H_
  25. #define _OSAPI_H_
  26. #include <string.h>
  27. #include "os_type.h"
  28. #include "user_config.h"
  29. void ets_bzero(void *s, size_t n);
  30. void ets_delay_us(uint16_t us);
  31. void ets_install_putc1(void (*p)(char c));
  32. #define os_bzero ets_bzero
  33. #define os_delay_us ets_delay_us
  34. #define os_install_putc1 ets_install_putc1
  35. int ets_memcmp(const void *str1, const void *str2, unsigned int nbyte);
  36. void *ets_memcpy(void *dest, const void *src, unsigned int nbyte);
  37. void *ets_memmove(void *dest, const void *src, unsigned int nbyte);
  38. void *ets_memset(void *dest, int val, unsigned int nbyte);
  39. int ets_strcmp(const char *s1, const char *s2);
  40. char *ets_strcpy(char *s1, const char *s2);
  41. int ets_strlen(const char *s);
  42. int ets_strncmp(const char *s1, const char *s2, unsigned int n);
  43. char *ets_strncpy(char *s1, const char *s2, unsigned int n);
  44. char *ets_strstr(const char *s1, const char *s2);
  45. #define os_memcmp ets_memcmp
  46. #define os_memcpy ets_memcpy
  47. #define os_memmove ets_memmove
  48. #define os_memset ets_memset
  49. #define os_strcat strcat
  50. #define os_strchr strchr
  51. #define os_strcmp ets_strcmp
  52. #define os_strcpy ets_strcpy
  53. #define os_strlen ets_strlen
  54. #define os_strncmp ets_strncmp
  55. #define os_strncpy ets_strncpy
  56. #define os_strstr ets_strstr
  57. void ets_timer_arm_new(os_timer_t *ptimer, uint32_t time, bool repeat_flag, bool ms_flag);
  58. void ets_timer_disarm(os_timer_t *ptimer);
  59. void ets_timer_setfn(os_timer_t *ptimer, os_timer_func_t *pfunction, void *parg);
  60. #ifdef USE_US_TIMER
  61. #define os_timer_arm_us(a, b, c) ets_timer_arm_new(a, b, c, 0)
  62. #endif
  63. #define os_timer_arm(a, b, c) ets_timer_arm_new(a, b, c, 1)
  64. #define os_timer_disarm ets_timer_disarm
  65. #define os_timer_setfn ets_timer_setfn
  66. int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
  67. int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
  68. #define os_sprintf ets_sprintf
  69. #ifdef USE_OPTIMIZE_PRINTF
  70. #define os_printf(fmt, ...) do { \
  71. static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
  72. os_printf_plus(flash_str, ##__VA_ARGS__); \
  73. } while(0)
  74. #else
  75. #define os_printf os_printf_plus
  76. #endif
  77. unsigned long os_random(void);
  78. int os_get_random(unsigned char *buf, size_t len);
  79. #endif