Files
ESP32_ZACUS/plip_voice/main/es8388.h
T
clemsail 309005360b
CI / platformio (pull_request) Failing after 4m52s
feat(plip_voice): ESP-IDF port of PLIP retro telephone annex
New IDF project targeting AI-Thinker ESP32-A1S Audio Kit (ESP32, ES8388
codec). Replaces the Arduino PLIP_FIRMWARE with a proper IDF component
structure aligned on box3_voice / scenario_mesh infrastructure.

Phases implemented and hardware-verified:
- A: ES8388 I2C init + I2S TX; 440 Hz test tone exits the speaker
- B: WiFi STA + httpd :80 (GET /status, POST /game/scenario, /game/file)
- C: ESP-NOW CMD receiver via shared scenario_mesh lib; op=play dispatched
     to audio; screen/evt/led logged (no display on PLIP)
- D: Off-hook GPIO monitor (GPIO4=BOOT button stand-in); ring tone cadence;
     POST /voice/hook to master on pickup/hangup (200 OK confirmed)

MAC (first observed): a0:b7:65:e7:f6:44
IP (DHCP): 192.168.0.138

Files:
  plip_voice/CMakeLists.txt          - project root; EXTRA_COMPONENT_DIRS=../lib/scenario_mesh
  plip_voice/partitions.csv          - 4MB OTA dual-bank + SPIFFS (matches PLIP_FIRMWARE)
  plip_voice/sdkconfig.defaults      - ESP32 target, 4MB flash DIO, ch=11 hint (no creds)
  plip_voice/main/Kconfig.projbuild  - PLIP_ menu (SSID/pwd/channel/master_url/hook_gpio)
  plip_voice/main/board_config.h     - A1S pin map (I2C 32/33, I2S 0/27/25/26/35, PA=21)
  plip_voice/main/es8388.[ch]        - ES8388 I2C register init sequence (legacy i2c driver)
  plip_voice/main/audio.[ch]         - I2S TX + async play queue + ring task
  plip_voice/main/net.[ch]           - WiFi STA + httpd (NVS creds with Kconfig fallback)
  plip_voice/main/cmd_exec.[ch]      - D5 CMD executor (play→audio; screen/evt/led→log)
  plip_voice/main/hook_client.[ch]   - POST /voice/hook via esp_http_client
  plip_voice/main/phone.[ch]         - Off-hook GPIO ISR + debounce + ring control
  plip_voice/main/main.c             - app_main boot sequence (all four phases)

Build: IDF 5.4.4, target esp32, clean.
Flash: /dev/cu.usbserial-0001, 4MB flash verified.
2026-06-14 13:29:33 +02:00

41 lines
1.2 KiB
C

#pragma once
/*
* es8388.h — Minimal ES8388 codec driver for AI-Thinker ESP32-A1S (IDF 5.x).
*
* Controls the ES8388 via I2C (addr 0x10) for playback (DAC) and capture (ADC).
* I2S is configured separately via the standard IDF driver/i2s_std.h API.
*
* Thread safety: all public functions are non-reentrant; call from a single task.
*/
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Initialise the I2C master bus and configure the ES8388 registers for
* stereo playback + mic capture at 16 kHz. Must be called once before any
* other es8388_* function and after driver_i2c is available.
*
* Returns ESP_OK on success. On I2C error the register that failed is logged
* and ESP_FAIL is returned — the codec is in an undefined state.
*/
esp_err_t es8388_init(void);
/* Set output volume. vol: 0 (mute) … 100 (full). Mapped to ES8388
* OUT1 (headphone) + OUT2 (speaker) attenuation registers. */
esp_err_t es8388_set_volume(uint8_t vol);
/* Mute / unmute DAC output. */
esp_err_t es8388_mute(bool mute);
/* Read a single ES8388 register for diagnostic purposes. */
esp_err_t es8388_read_reg(uint8_t reg, uint8_t *value);
#ifdef __cplusplus
}
#endif