Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #ifdef __cplusplus
  2. extern "C"
  3. {
  4. #endif
  5.  
  6. #include <ets_sys.h>
  7. #include <osapi.h>
  8. #include <gpio.h>
  9. #include <os_type.h>
  10. #include <user_interface.h>
  11. #include <espmissingincludes.h>
  12.  
  13. int user_init();
  14.  
  15. #ifdef __cplusplus
  16. }
  17. #endif
  18.  
  19. #ifdef ESP8266_GDBSTUB
  20. #include <gdbstub.h>
  21. #endif
  22.  
  23. static os_timer_t s_Timer;
  24. int s_Tick = 0;
  25.  
  26. void TimerFunction(void *arg)
  27. {
  28. s_Tick++;
  29.  
  30. //Uncomment the line below to disable the software watchdog that will restart the ESP8266 system after it spends more than ~1 second stopped at a breakpoint.
  31. //system_soft_wdt_stop();
  32.  
  33. if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & BIT1)
  34. {
  35. gpio_output_set(0, BIT1, BIT1, 0);
  36. }
  37. else
  38. {
  39. gpio_output_set(BIT1, 0, BIT1, 0);
  40. }
  41. }
  42.  
  43. int user_init()
  44. {
  45. #ifdef ESP8266_GDBSTUB
  46. gdbstub_init();
  47. #endif
  48. gpio_init();
  49.  
  50. //#ifdef ESP8266_GDBSTUB
  51. //#error The LED on the Olimex board is multiplexed with the TXD line used by the GDB stub. In order to use the stub, select a different LED pin below.
  52. //#endif
  53. PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);
  54.  
  55. gpio_output_set(0, BIT1, BIT1, 0);
  56. os_timer_setfn(&s_Timer, TimerFunction, NULL);
  57. os_timer_arm(&s_Timer, 300, 1);
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement