debuggy but working with RX/TX on 22/23, gpio 0 must be pulled down by arduino for flow control
This commit is contained in:
@@ -34,7 +34,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define SPI_BUFFER_LEN SPI_MAX_DMA_LEN
|
#define SPI_BUFFER_LEN SPI_MAX_DMA_LEN
|
||||||
|
|
||||||
int debug = 0;
|
int debug = 1;
|
||||||
|
|
||||||
uint8_t* commandBuffer;
|
uint8_t* commandBuffer;
|
||||||
uint8_t* responseBuffer;
|
uint8_t* responseBuffer;
|
||||||
@@ -103,30 +103,49 @@ void setup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UNO_WIFI_REV2
|
#define AIRLIFT 1
|
||||||
|
|
||||||
void setupBluetooth() {
|
void setupBluetooth() {
|
||||||
|
if (debug) ets_printf("setup periph\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
vTaskDelay(portMAX_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
periph_module_enable(PERIPH_UART1_MODULE);
|
periph_module_enable(PERIPH_UART1_MODULE);
|
||||||
periph_module_enable(PERIPH_UHCI0_MODULE);
|
periph_module_enable(PERIPH_UHCI0_MODULE);
|
||||||
|
|
||||||
|
if (debug) ets_printf("setup pins\n");
|
||||||
|
|
||||||
#ifdef UNO_WIFI_REV2
|
#ifdef UNO_WIFI_REV2
|
||||||
uart_set_pin(UART_NUM_1, 1, 3, 33, 0); // TX, RX, RTS, CTS
|
uart_set_pin(UART_NUM_1, 1, 3, 33, 0); // TX, RX, RTS, CTS
|
||||||
|
#elif defined(AIRLIFT)
|
||||||
|
// TX GPIO1 & RX GPIO3 on ESP32 'hardware' UART
|
||||||
|
// RTS on ESP_BUSY (GPIO33)
|
||||||
|
// CTS on GPIO0 (GPIO0)
|
||||||
|
uart_set_pin(UART_NUM_1, 22, 23, 33, 0);
|
||||||
#else
|
#else
|
||||||
uart_set_pin(UART_NUM_1, 23, 12, 18, 5);
|
uart_set_pin(UART_NUM_1, 23, 12, 18, 5);
|
||||||
#endif
|
|
||||||
uart_set_hw_flow_ctrl(UART_NUM_1, UART_HW_FLOWCTRL_CTS_RTS, 5);
|
uart_set_hw_flow_ctrl(UART_NUM_1, UART_HW_FLOWCTRL_CTS_RTS, 5);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (debug) ets_printf("setup controller\n");
|
||||||
|
|
||||||
esp_bt_controller_config_t btControllerConfig = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t btControllerConfig = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
|
|
||||||
btControllerConfig.hci_uart_no = UART_NUM_1;
|
btControllerConfig.hci_uart_no = UART_NUM_1;
|
||||||
#ifdef UNO_WIFI_REV2
|
#ifdef UNO_WIFI_REV2
|
||||||
btControllerConfig.hci_uart_baudrate = 115200;
|
btControllerConfig.hci_uart_baudrate = 115200;
|
||||||
|
#elif defined(AIRLIFT)
|
||||||
|
btControllerConfig.hci_uart_baudrate = 115200;
|
||||||
#else
|
#else
|
||||||
btControllerConfig.hci_uart_baudrate = 912600;
|
btControllerConfig.hci_uart_baudrate = 912600;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
esp_bt_controller_init(&btControllerConfig);
|
esp_bt_controller_init(&btControllerConfig);
|
||||||
while (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE);
|
while (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
if (debug) ets_printf("idle\n");
|
||||||
|
}
|
||||||
esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
esp_bt_sleep_enable();
|
esp_bt_sleep_enable();
|
||||||
|
|
||||||
@@ -134,6 +153,7 @@ void setupBluetooth() {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelay(portMAX_DELAY);
|
vTaskDelay(portMAX_DELAY);
|
||||||
|
if (debug) ets_printf(".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +166,7 @@ void setupWiFi() {
|
|||||||
if (debug) ets_printf("*** NOSHIELD\n");
|
if (debug) ets_printf("*** NOSHIELD\n");
|
||||||
while (1); // no shield
|
while (1); // no shield
|
||||||
}
|
}
|
||||||
|
|
||||||
commandBuffer = (uint8_t*)heap_caps_malloc(SPI_BUFFER_LEN, MALLOC_CAP_DMA);
|
commandBuffer = (uint8_t*)heap_caps_malloc(SPI_BUFFER_LEN, MALLOC_CAP_DMA);
|
||||||
responseBuffer = (uint8_t*)heap_caps_malloc(SPI_BUFFER_LEN, MALLOC_CAP_DMA);
|
responseBuffer = (uint8_t*)heap_caps_malloc(SPI_BUFFER_LEN, MALLOC_CAP_DMA);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user