mirror of
https://github.com/demik/quack.git
synced 2024-12-22 20:30:48 +00:00
try to init adb
This commit is contained in:
parent
f05ef1862b
commit
24b4fc1413
@ -1,4 +1,5 @@
|
||||
set(srcs "blue.c"
|
||||
set(srcs "adb.c"
|
||||
"blue.c"
|
||||
"esp_hid_gap.c"
|
||||
"gpio.c"
|
||||
"led.c"
|
||||
|
63
main/adb.c
Normal file
63
main/adb.c
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* adb.c
|
||||
* quack
|
||||
*
|
||||
* Created by Michel DEPEIGE on 7/01/2020.
|
||||
* Copyright (c) 2020 Michel DEPEIGE.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program (see the file COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "driver/gpio.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
#include "adb.h"
|
||||
#include "gpio.h"
|
||||
|
||||
void adb_init(void) {
|
||||
gpio_set_pull_mode(GPIO_ADB, GPIO_PULLUP_ONLY);
|
||||
|
||||
/* If jumper is set, switch to ADB host mode */
|
||||
if (gpio_get_level(GPIO_ADBSRC) == 0)
|
||||
xTaskCreatePinnedToCore(&adb_task_host, "ADB_HOST", 6 * 1024, NULL, 4, NULL, 1);
|
||||
else
|
||||
xTaskCreatePinnedToCore(&adb_task_mouse, "ADB_MOUSE", 6 * 1024, NULL, 4, NULL, 1);
|
||||
}
|
||||
|
||||
void adb_task_host(void *pvParameters) {
|
||||
adb_send_reset();
|
||||
|
||||
while (1) {
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
void adb_task_mouse(void *pvParameters) {
|
||||
|
||||
}
|
||||
|
||||
void adb_send_reset() {
|
||||
gpio_set_level(GPIO_ADB, 0);
|
||||
vTaskDelay(3 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(GPIO_ADB, 1);
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
}
|
@ -53,18 +53,27 @@ void gpio_init(void) {
|
||||
gpio_set_direction(GPIO_ADBSRC, GPIO_MODE_INPUT);
|
||||
gpio_set_direction(GPIO_BTOFF, GPIO_MODE_INPUT);
|
||||
|
||||
/* ADB */
|
||||
gpio_set_direction(GPIO_ADB, GPIO_MODE_INPUT|GPIO_MODE_OUTPUT);
|
||||
|
||||
/* Quadrature mouse */
|
||||
gpio_reset_pin(GPIO_CLICK);
|
||||
gpio_reset_pin(GPIO_QX1);
|
||||
gpio_reset_pin(GPIO_QX2);
|
||||
gpio_reset_pin(GPIO_QY1);
|
||||
gpio_reset_pin(GPIO_QY2);
|
||||
gpio_set_pull_mode(GPIO_CLICK, GPIO_PULLDOWN_ONLY);
|
||||
gpio_set_pull_mode(GPIO_QX1, GPIO_PULLDOWN_ONLY);
|
||||
gpio_set_pull_mode(GPIO_QX2, GPIO_PULLDOWN_ONLY);
|
||||
gpio_set_pull_mode(GPIO_QY1, GPIO_PULLDOWN_ONLY);
|
||||
gpio_set_pull_mode(GPIO_QY2, GPIO_PULLDOWN_ONLY);
|
||||
gpio_set_direction(GPIO_CLICK, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(GPIO_QX1, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(GPIO_QX2, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(GPIO_QY1, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(GPIO_QY2, GPIO_MODE_OUTPUT);
|
||||
|
||||
|
||||
gpio_set_level(GPIO_CLICK, 1);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "esp_system.h"
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
#include "adb.h"
|
||||
#include "blue.h"
|
||||
#include "led.h"
|
||||
#include "gpio.h"
|
||||
@ -58,10 +59,16 @@ void app_main(void)
|
||||
|
||||
gpio_init();
|
||||
led_init();
|
||||
adb_init();
|
||||
|
||||
/* Check /BTOFF and enable bluetooth if needed */
|
||||
/*
|
||||
* Check /BTOFF and enable bluetooth if needed
|
||||
* of bluetooth is disabled, enable ADB and Quadrature outputs
|
||||
*/
|
||||
if (gpio_get_level(GPIO_BTOFF) == 1)
|
||||
blue_init();
|
||||
else
|
||||
gpio_output_enable();
|
||||
|
||||
/* Blink error if no inputs (/BTOFF and no /ADBSRC) */
|
||||
if (gpio_get_level(GPIO_BTOFF) == 0 && gpio_get_level(GPIO_ADBSRC) == 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user