user_main.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* main.c -- MQTT client example
  2. *
  3. * Copyright (c) 2014-2015, Tuan PM <tuanpm at live dot com>
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright notice,
  10. * this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Redis nor the names of its contributors may be used
  15. * to endorse or promote products derived from this software without
  16. * specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  22. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. * POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #include "esp_common.h"
  31. #include "driver/uart.h"
  32. #include "driver/spi_interface.h"
  33. #include "gpio.h"
  34. #include "log/esp_log.h"
  35. #include "gdbstub/gdbstub.h"
  36. #include "hal/lsm6ds3.h"
  37. #include "hal/max17043.h"
  38. #include "hal/lps25hb.h"
  39. #include "user_config.h"
  40. static const char* TAG = "main.c";
  41. void wifi_handle_event_cb(System_Event_t *evt)
  42. {
  43. switch(evt->event)
  44. {
  45. case EVENT_STAMODE_CONNECTED:
  46. break;
  47. case EVENT_STAMODE_DISCONNECTED:
  48. break;
  49. case EVENT_STAMODE_AUTHMODE_CHANGE:
  50. break;
  51. case EVENT_STAMODE_GOT_IP:
  52. break;
  53. case EVENT_SOFTAPMODE_PROBEREQRECVED:
  54. break;
  55. case EVENT_SOFTAPMODE_STACONNECTED:
  56. break;
  57. case EVENT_SOFTAPMODE_STADISCONNECTED:
  58. break;
  59. default:
  60. break;
  61. }
  62. }
  63. void ICACHE_FLASH_ATTR app_init(void)
  64. {
  65. uart_init(BIT_RATE_115200, BIT_RATE_115200, DISABLE_UART1);
  66. ESP_LOGI(TAG, "Starting LSM6DS3 Demo\n");
  67. ESP_LOGI(TAG, "WiFi Testing \n");
  68. //while(true)
  69. {
  70. LSM6DS3_Enable_I2C_Bridge(1);
  71. uint16_t x = max17043_getVoltage();
  72. ESP_LOGI(TAG, "MAX17043 Voltage %d", x);
  73. uint8_t y;
  74. LPS25HB_Get_DeviceID(&y);
  75. ESP_LOGI(TAG, "DEVICEID %x", y);
  76. // uint8_t i;
  77. // for(i=0;i<8;i++)
  78. // ESP_LOGI(TAG, "RX SPI Value: %x", data[i]);
  79. os_delay_us(1000000);
  80. system_soft_wdt_feed();
  81. }
  82. {
  83. }
  84. // wifi_set_opmode(STATION_MODE);
  85. // wifi_station_ap_number_set(MAX_APS);
  86. // wifi_station_set_auto_connect(true);
  87. //
  88. // wifi_station_get_ap_info()
  89. // wifi_station_ap_change()
  90. // wifi_staiton_get_current_ap_id()
  91. // wifi_set_sleep_type(MODEM_SLEEP_T);
  92. // wifi_enable_gpio_wakeup()
  93. //
  94. // if (wifi_station_get_config())
  95. // os_printf("zero wifi_config\n");
  96. // else
  97. // os_printf("there is a stored config");
  98. }
  99. void user_init(void)
  100. {
  101. wifi_set_opmode(STATION_MODE);
  102. wifi_station_ap_number_set(5);
  103. system_init_done_cb(app_init);
  104. }