mirror of
https://github.com/demik/quack.git
synced 2025-02-16 19:30:58 +00:00
fixed indenting
This commit is contained in:
parent
6547083d3a
commit
f05ef1862b
48
main/gpio.c
48
main/gpio.c
@ -42,36 +42,36 @@ void gpio_init(void) {
|
||||
gpio_set_direction(GPIO_BLUELED, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(GPIO_YELLOWLED, GPIO_MODE_OUTPUT);
|
||||
gpio_set_direction(GPIO_REDLED, GPIO_MODE_OUTPUT);
|
||||
|
||||
/* External chips */
|
||||
gpio_reset_pin(GPIO_OE);
|
||||
gpio_set_direction(GPIO_OE, GPIO_MODE_OUTPUT);
|
||||
|
||||
/* Modes */
|
||||
gpio_reset_pin(GPIO_ADBSRC);
|
||||
gpio_reset_pin(GPIO_BTOFF);
|
||||
gpio_set_direction(GPIO_ADBSRC, GPIO_MODE_INPUT);
|
||||
gpio_set_direction(GPIO_BTOFF, GPIO_MODE_INPUT);
|
||||
/* External chips */
|
||||
gpio_reset_pin(GPIO_OE);
|
||||
gpio_set_direction(GPIO_OE, 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_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);
|
||||
/* Modes */
|
||||
gpio_reset_pin(GPIO_ADBSRC);
|
||||
gpio_reset_pin(GPIO_BTOFF);
|
||||
gpio_set_direction(GPIO_ADBSRC, GPIO_MODE_INPUT);
|
||||
gpio_set_direction(GPIO_BTOFF, GPIO_MODE_INPUT);
|
||||
|
||||
/* 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_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);
|
||||
}
|
||||
|
||||
void gpio_output_disable(void) {
|
||||
gpio_set_level(GPIO_OE, 0);
|
||||
gpio_set_level(GPIO_OE, 0);
|
||||
}
|
||||
|
||||
void gpio_output_enable(void) {
|
||||
gpio_set_level(GPIO_OE, 1);
|
||||
gpio_set_level(GPIO_OE, 1);
|
||||
}
|
||||
|
94
main/led.c
94
main/led.c
@ -50,57 +50,57 @@ void led_init(void) {
|
||||
gpio_set_level(GPIO_REDLED, 0);
|
||||
|
||||
xTaskCreate(led_task, "GREEN", 1024, (void *) GPIO_GREENLED, tskIDLE_PRIORITY, &t_green);
|
||||
xTaskCreate(led_task, "BLUE", 1024, (void *) GPIO_BLUELED, tskIDLE_PRIORITY, &t_blue);
|
||||
xTaskCreate(led_task, "YELLOW", 1024, (void *) GPIO_YELLOWLED, tskIDLE_PRIORITY, &t_yellow);
|
||||
xTaskCreate(led_task, "RED", 1024, (void *) GPIO_REDLED, tskIDLE_PRIORITY, &t_red);
|
||||
|
||||
/* blink green led fast (we are booting...) */
|
||||
xTaskNotify(t_green, LED_FAST, eSetValueWithOverwrite);
|
||||
xTaskCreate(led_task, "BLUE", 1024, (void *) GPIO_BLUELED, tskIDLE_PRIORITY, &t_blue);
|
||||
xTaskCreate(led_task, "YELLOW", 1024, (void *) GPIO_YELLOWLED, tskIDLE_PRIORITY, &t_yellow);
|
||||
xTaskCreate(led_task, "RED", 1024, (void *) GPIO_REDLED, tskIDLE_PRIORITY, &t_red);
|
||||
|
||||
/* blink green led fast (we are booting...) */
|
||||
xTaskNotify(t_green, LED_FAST, eSetValueWithOverwrite);
|
||||
}
|
||||
|
||||
void led_task(void *pvParameters) {
|
||||
unsigned int color = (unsigned int)pvParameters;
|
||||
unsigned int mode = LED_OFF;
|
||||
TickType_t wait = portMAX_DELAY;
|
||||
unsigned int color = (unsigned int)pvParameters;
|
||||
unsigned int mode = LED_OFF;
|
||||
TickType_t wait = portMAX_DELAY;
|
||||
|
||||
/* start only if there is a led specified */
|
||||
configASSERT(((uint32_t) pvParameters) > 0);
|
||||
|
||||
/* start only if there is a led specified */
|
||||
configASSERT(((uint32_t) pvParameters) > 0);
|
||||
|
||||
while (1) {
|
||||
xTaskNotifyWait(0, 0, &mode, wait);
|
||||
switch (mode)
|
||||
{
|
||||
case LED_OFF:
|
||||
gpio_set_level(color, 0);
|
||||
wait = portMAX_DELAY;
|
||||
break;
|
||||
case LED_ON:
|
||||
gpio_set_level(color, 1);
|
||||
wait = portMAX_DELAY;
|
||||
break;
|
||||
case LED_ONCE:
|
||||
gpio_set_level(color, 1);
|
||||
vTaskDelay(40 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(color, 0);
|
||||
vTaskDelay(40 / portTICK_PERIOD_MS);
|
||||
wait = portMAX_DELAY;
|
||||
break;
|
||||
case LED_FAST:
|
||||
gpio_set_level(color, 1);
|
||||
vTaskDelay(40 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(color, 0);
|
||||
wait = 40 / portTICK_PERIOD_MS;
|
||||
break;
|
||||
case LED_SLOW:
|
||||
gpio_set_level(color, 1);
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(color, 0);
|
||||
wait = 500 / portTICK_PERIOD_MS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xTaskNotifyWait(0, 0, &mode, wait);
|
||||
switch (mode)
|
||||
{
|
||||
case LED_OFF:
|
||||
gpio_set_level(color, 0);
|
||||
wait = portMAX_DELAY;
|
||||
break;
|
||||
case LED_ON:
|
||||
gpio_set_level(color, 1);
|
||||
wait = portMAX_DELAY;
|
||||
break;
|
||||
case LED_ONCE:
|
||||
gpio_set_level(color, 1);
|
||||
vTaskDelay(40 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(color, 0);
|
||||
vTaskDelay(40 / portTICK_PERIOD_MS);
|
||||
wait = portMAX_DELAY;
|
||||
break;
|
||||
case LED_FAST:
|
||||
gpio_set_level(color, 1);
|
||||
vTaskDelay(40 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(color, 0);
|
||||
wait = 40 / portTICK_PERIOD_MS;
|
||||
break;
|
||||
case LED_SLOW:
|
||||
gpio_set_level(color, 1);
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(color, 0);
|
||||
wait = 500 / portTICK_PERIOD_MS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gpio_set_level(color, 1);
|
||||
|
||||
gpio_set_level(color, 1);
|
||||
}
|
||||
|
32
main/main.c
32
main/main.c
@ -45,27 +45,27 @@ void app_main(void)
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
ESP_LOGI(TAG, "This is %s chip with %d CPU cores, WiFi%s%s, "
|
||||
"revision %d, %dMB %s flash",
|
||||
CONFIG_IDF_TARGET,
|
||||
chip_info.cores,
|
||||
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "",
|
||||
chip_info.revision,
|
||||
spi_flash_get_chip_size() / (1024 * 1024),
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
|
||||
"revision %d, %dMB %s flash",
|
||||
CONFIG_IDF_TARGET,
|
||||
chip_info.cores,
|
||||
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "",
|
||||
chip_info.revision,
|
||||
spi_flash_get_chip_size() / (1024 * 1024),
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
|
||||
|
||||
ESP_LOGI(TAG, "Minimum free heap size: %d bytes", esp_get_minimum_free_heap_size());
|
||||
|
||||
gpio_init();
|
||||
led_init();
|
||||
|
||||
/* Check /BTOFF and enable bluetooth if needed */
|
||||
if (gpio_get_level(GPIO_BTOFF) == 1)
|
||||
blue_init();
|
||||
/* Check /BTOFF and enable bluetooth if needed */
|
||||
if (gpio_get_level(GPIO_BTOFF) == 1)
|
||||
blue_init();
|
||||
|
||||
/* Blink error if no inputs (/BTOFF and no /ADBSRC) */
|
||||
if (gpio_get_level(GPIO_BTOFF) == 0 && gpio_get_level(GPIO_ADBSRC) == 1) {
|
||||
ESP_LOGE(TAG, "Bluetooth is off and ADB is in device mode!");
|
||||
xTaskNotify(t_red, LED_SLOW, eSetValueWithOverwrite);
|
||||
}
|
||||
/* Blink error if no inputs (/BTOFF and no /ADBSRC) */
|
||||
if (gpio_get_level(GPIO_BTOFF) == 0 && gpio_get_level(GPIO_ADBSRC) == 1) {
|
||||
ESP_LOGE(TAG, "Bluetooth is off and ADB is in device mode!");
|
||||
xTaskNotify(t_red, LED_SLOW, eSetValueWithOverwrite);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user