fix(plip): SLIC PD push-pull HIGH (definite power-up) + /debug/slic gpio readback

This commit is contained in:
2026-06-15 00:49:30 +02:00
parent 47fbc09fea
commit ccbe5720b0
3 changed files with 45 additions and 14 deletions
+4 -5
View File
@@ -152,11 +152,10 @@ esp_err_t es8388_init(void)
* - ADCCONTROL5 (0x0D) = 0x02: ADCFsMode SINGLE SPEED RATIO=256 (16kHz@MCLK 4.096MHz)
* - ADCCONTROL8/9 (0x10/0x11) = 0x00: ADC digital volume 0dB */
if (i2c_write_reg(ES8388_ADC_CTL1, 0xBB) != ESP_OK) return ESP_FAIL; /* PGA +24dB L+R */
/* ADCCONTROL2 (0x0A): LINSEL bits [7:6] = 01 → LINPUT2; RINSEL bits [5:4] = 01 → RINPUT2.
* 0x50 = 0b01010000 → LINSEL=01 (LIN2), RINSEL=01 (RIN2).
* SLIC K50835F audio output feeds the ES8388 via LINPUT2/RINPUT2 (telephone handset mic path).
* Previous value 0x00 = LINPUT1/RINPUT1 (onboard PCB mic) → no audio from handset. */
if (i2c_write_reg(ES8388_ADC_CTL2, 0x50) != ESP_OK) return ESP_FAIL; /* LIN2/RIN2 (SLIC handset mic) */
/* ADCCONTROL2 (0x0A): LINSEL/RINSEL = 0x00 → LINPUT1/RINPUT1 (LINE IN header on A1S kit)
* 0x00 = LIN1/RIN1 differential (standard LINE IN jack where AG1171 SLIC audio is wired)
* 0x50 = LIN2/RIN2 single-ended (onboard mic path — no SLIC signal here) */
if (i2c_write_reg(ES8388_ADC_CTL2, 0x00) != ESP_OK) return ESP_FAIL; /* LIN1/RIN1 differential (LINE IN / AG1171 SLIC) */
if (i2c_write_reg(ES8388_ADC_CTL3, 0x02) != ESP_OK) return ESP_FAIL; /* DS filter sel */
if (i2c_write_reg(ES8388_ADC_CTL4, 0x0C) != ESP_OK) return ESP_FAIL; /* I2S 16-bit */
if (i2c_write_reg(ES8388_ADC_CTL5, 0x02) != ESP_OK) return ESP_FAIL; /* RATIO=256 */
+26 -2
View File
@@ -28,6 +28,9 @@
#include "cmd_exec.h"
#include "phone.h"
#include "es8388.h"
#include "slic.h"
#include "board_config.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_event.h"
#include "esp_http_server.h"
@@ -448,6 +451,22 @@ static esp_err_t handle_debug_ringstop(httpd_req_t *req)
return send_json(req, "200 OK", "{\"ok\":true,\"ringing\":false}");
}
/* ── GET /debug/slic (read GPIO levels of all 4 SLIC pins) ──────────────── */
static esp_err_t handle_debug_slic(httpd_req_t *req)
{
char buf[192];
/* gpio_get_level reads the actual pad level even for output pins. */
snprintf(buf, sizeof(buf),
"{\"rm\":%d,\"fr\":%d,\"shk\":%d,\"pd\":%d,\"offhook\":%s,\"ringing\":%s}",
gpio_get_level(PLIP_SLIC_RM), gpio_get_level(PLIP_SLIC_FR),
gpio_get_level(PLIP_SLIC_SHK), gpio_get_level(PLIP_SLIC_PD),
slic_is_offhook() ? "true" : "false",
slic_is_ringing() ? "true" : "false");
ESP_LOGI(TAG, "debug/slic: %s", buf);
return send_json(req, "200 OK", buf);
}
/* ── GET /debug/dial?number=NNNN (push digits into the dialer) ───────────── */
static esp_err_t handle_debug_dial(httpd_req_t *req)
@@ -546,7 +565,7 @@ esp_err_t net_init(void)
/* Start HTTP server. */
httpd_config_t hcfg = HTTPD_DEFAULT_CONFIG();
hcfg.server_port = 80;
hcfg.max_uri_handlers = 16;
hcfg.max_uri_handlers = 17;
hcfg.stack_size = 8192;
esp_err_t ret = httpd_start(&s_httpd, &hcfg);
@@ -591,6 +610,10 @@ esp_err_t net_init(void)
.uri = "/debug/ringstop", .method = HTTP_GET,
.handler = handle_debug_ringstop, .user_ctx = NULL,
};
static const httpd_uri_t uri_debug_slic = {
.uri = "/debug/slic", .method = HTTP_GET,
.handler = handle_debug_slic, .user_ctx = NULL,
};
httpd_register_uri_handler(s_httpd, &uri_status);
httpd_register_uri_handler(s_httpd, &uri_scenario);
httpd_register_uri_handler(s_httpd, &uri_file);
@@ -600,7 +623,8 @@ esp_err_t net_init(void)
httpd_register_uri_handler(s_httpd, &uri_debug_dial);
httpd_register_uri_handler(s_httpd, &uri_debug_ring);
httpd_register_uri_handler(s_httpd, &uri_debug_ringstop);
httpd_register_uri_handler(s_httpd, &uri_debug_slic);
ESP_LOGI(TAG, "httpd up on :80 (GET /status, GET /debug/regs, GET /debug/dial, GET /debug/ring, GET /debug/ringstop, POST /game/scenario, POST /game/file, POST /game/cmd, POST /voice/capture)");
ESP_LOGI(TAG, "httpd up on :80 (GET /status, GET /debug/regs, GET /debug/dial, GET /debug/ring, GET /debug/ringstop, GET /debug/slic, POST /game/scenario, POST /game/file, POST /game/cmd, POST /voice/capture)");
return ESP_OK;
}
+15 -7
View File
@@ -88,16 +88,24 @@ esp_err_t slic_init(void)
ret = gpio_config(&shk_cfg);
if (ret != ESP_OK) return ret;
/* PD: Power Down — open-drain output, written HIGH = released = SLIC active.
* This mirrors the Arduino: pinMode(pin_pd, OUTPUT_OPEN_DRAIN); digitalWrite(pin_pd, HIGH);
* Open-drain HIGH → line floats → SLIC PD pin sees its own pull-up → power ON. */
ret = gpio_set_direction(PLIP_SLIC_PD, GPIO_MODE_OUTPUT_OD);
/* PD: Power Down — push-pull output HIGH = SLIC active (definite power-up).
* Previous config (open-drain HIGH) left the line floating when no pull-up
* is present on the bench, keeping the SLIC in power-down.
* Push-pull HIGH drives the PD pin firmly high regardless of external resistors. */
gpio_config_t pd_cfg = {
.pin_bit_mask = (1ULL << PLIP_SLIC_PD),
.mode = GPIO_MODE_OUTPUT, /* push-pull (pas OD) */
.pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE,
};
ret = gpio_config(&pd_cfg);
if (ret != ESP_OK) return ret;
ret = gpio_set_level(PLIP_SLIC_PD, 1); /* HIGH = release = SLIC powered */
ret = gpio_set_level(PLIP_SLIC_PD, 1); /* HIGH franc = SLIC actif */
if (ret != ESP_OK) return ret;
ESP_LOGI(TAG, "SLIC power-up: PD GPIO%d open-drain HIGH (SLIC active)", PLIP_SLIC_PD);
ESP_LOGI(TAG, "SLIC pins: RM=%d FR=%d SHK=%d PD=%d hook_active_high=1",
ESP_LOGI(TAG, "slic: PD GPIO%d push-pull HIGH (SLIC power-up, franc)", PLIP_SLIC_PD);
ESP_LOGI(TAG, "slic: pins RM=%d FR=%d SHK=%d PD=%d hook_active_high=1",
PLIP_SLIC_RM, PLIP_SLIC_FR, PLIP_SLIC_SHK, PLIP_SLIC_PD);
/* Spawn the FR-toggle task (runs indefinitely, toggles only when s_ringing=true) */