user_main.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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);
  66. ESP_LOGI(TAG, "Starting LSM6DS3 Demo\n");
  67. while(true)
  68. {
  69. LSM6DS3_Enable_I2C_Bridge(1);
  70. uint16_t x = max17043_getVoltage();
  71. ESP_LOGI(TAG, "MAX17043 Voltage %d", x);
  72. uint8_t y;
  73. LPS25HB_Get_DeviceID(&y);
  74. ESP_LOGI(TAG, "DEVICEID %x", y);
  75. // uint8_t i;
  76. // for(i=0;i<8;i++)
  77. // ESP_LOGI(TAG, "RX SPI Value: %x", data[i]);
  78. os_delay_us(1000000);
  79. system_soft_wdt_feed();
  80. }
  81. // wifi_set_opmode(STATION_MODE);
  82. // wifi_station_ap_number_set(MAX_APS);
  83. // wifi_station_set_auto_connect(true);
  84. //
  85. // wifi_station_get_ap_info()
  86. // wifi_station_ap_change()
  87. // wifi_staiton_get_current_ap_id()
  88. // wifi_set_sleep_type(MODEM_SLEEP_T);
  89. // wifi_enable_gpio_wakeup()
  90. //
  91. // if (wifi_station_get_config())
  92. // os_printf("zero wifi_config\n");
  93. // else
  94. // os_printf("there is a stored config");
  95. }
  96. void user_init(void)
  97. {
  98. system_init_done_cb(app_init);
  99. }