123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- /* main.c -- MQTT client example
- *
- * Copyright (c) 2014-2015, Tuan PM <tuanpm at live dot com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Redis nor the names of its contributors may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
- #include "esp_common.h"
- #include "driver/uart.h"
- #include "driver/spi_interface.h"
- #include "gpio.h"
- #include "log/esp_log.h"
- #include "gdbstub/gdbstub.h"
- #include "hal/lsm6ds3.h"
- #include "hal/max17043.h"
- #include "hal/lps25hb.h"
- #include "hal/ws2812.h"
- #include "user_config.h"
- static const char* TAG = "main.c";
- // void wifi_handle_event_cb(System_Event_t *evt)
- // {
- // switch(evt->event)
- // {
- // case EVENT_STAMODE_CONNECTED:
- // break;
- // case EVENT_STAMODE_DISCONNECTED:
- // break;
- // case EVENT_STAMODE_AUTHMODE_CHANGE:
- // break;
- // case EVENT_STAMODE_GOT_IP:
- // break;
- // case EVENT_SOFTAPMODE_PROBEREQRECVED:
- // break;
- // case EVENT_SOFTAPMODE_STACONNECTED:
- // break;
- // case EVENT_SOFTAPMODE_STADISCONNECTED:
- // break;
- // default:
- // break;
- // }
- // }
- void ICACHE_FLASH_ATTR app_init(void)
- {
- uart_init(BIT_RATE_115200, BIT_RATE_115200, DISABLE_UART1);
- ESP_LOGI(TAG, "LSM6DS3, MAX17043, and LPS25HB Testing...");
- //while(true)
- {
- LSM6DS3_Enable_I2C_Bridge(1);
- uint16_t x = max17043_getVoltage();
- ESP_LOGI(TAG, "MAX17043 Voltage %d", x);
- uint8_t y;
- LPS25HB_Get_DeviceID(&y);
- ESP_LOGI(TAG, "DEVICEID %x", y);
- // uint8_t i;
- // for(i=0;i<8;i++)
- // ESP_LOGI(TAG, "RX SPI Value: %x", data[i]);
- //os_delay_us(1000000);
- system_soft_wdt_feed();
- }
- ESP_LOGI(TAG, "WS2812B Testing...");
- //while(true)
- {
- ESP_LOGI(TAG, "Setting WS2812B");
- PIN_FUNC_SELECT(STATLED_MUX, STATLED_FUNC);
- gpio_output_set(BIT(SHDN), BIT(STATLED), (BIT(SHDN)|BIT(STATLED)), (BIT(PBA)|BIT(PBB)));
- WS2812_SetColor(WS2812_ORANGE, WS2812_PULSE);
- }
- ESP_LOGI(TAG, "Encoder IO Testing...")
- {
- Encoder_InitIO();
- //Encoder_SetSwitchCallback(os_printf("SWITCH_A"), os_printf("SWITCH_B"));
- //Encoder_SetIMUCallback(os_printf("IMU"));
- LSM6DS3_EnableMotion();
- Encoder_EnableIOInterrupts();
- }
- }
- void user_init(void)
- {
- wifi_set_opmode(STATION_MODE);
- wifi_station_ap_number_set(5);
- system_init_done_cb(app_init);
- }
|