The AG3352 GNSS engine in the RYS352A ships at 115200 8N1 per the datasheet spec table. 9600 was a generic assumption that would cause the UART to read garbage and never acquire a fix.
68 lines
2.3 KiB
C
68 lines
2.3 KiB
C
#pragma once
|
|
|
|
// --- GPIO Pin Assignments ---
|
|
// UART1 to RS-422 module via 3.3V<->5V level shifter
|
|
#define PIN_RS422_TX 17 // ESP32 TX -> level shifter -> MAX485₁ DI
|
|
#define PIN_RS422_RX 18 // MAX485₂ RO -> level shifter -> ESP32 RX
|
|
|
|
// GPS UART (UART2) — RYS352A
|
|
#define PIN_GPS_RX 5 // ESP32 RX <- GPS TX (NMEA out)
|
|
#define PIN_GPS_TX 6 // ESP32 TX -> GPS RX (config in, optional)
|
|
#define PIN_GPS_PPS 7 // 1Hz PPS rising edge (interrupt)
|
|
#define GPS_BAUD 115200
|
|
|
|
// I2C Sensor Bus
|
|
#define PIN_I2C_SDA 8
|
|
#define PIN_I2C_SCL 9
|
|
#define I2C_FREQ 400000 // 400kHz
|
|
|
|
// Sensor I2C addresses
|
|
#define MPU9250_ADDR 0x68
|
|
#define BMP388_ADDR 0x76
|
|
|
|
// Onboard RGB LED (WS2812, DevKitC-1 V1.1)
|
|
#define PIN_LED 38
|
|
|
|
// --- RS-422 UART (UART1) ---
|
|
#define RS422_BAUD 115200
|
|
#define RS422_CONFIG SERIAL_8N1
|
|
|
|
// --- BLE Configuration ---
|
|
#define BLE_DEVICE_NAME "Travler-G2"
|
|
#define BLE_MTU 517
|
|
// Max payload per NUS notification (must fit in ATT_MTU - 3)
|
|
#define BLE_NOTIFY_MAX 240
|
|
|
|
// Nordic UART Service UUIDs
|
|
#define NUS_SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"
|
|
#define NUS_RX_UUID "6E400002-B5A3-F393-E0A9-E50E24DCCA9E" // Client writes here
|
|
#define NUS_TX_UUID "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" // ESP32 notifies here
|
|
|
|
// Sensor Service UUIDs (custom, A0E7xxxx block)
|
|
#define SENSOR_SERVICE_UUID "A0E70001-B5A3-F393-E0A9-E50E24DCCA9E"
|
|
#define SENSOR_GPS_UUID "A0E70002-B5A3-F393-E0A9-E50E24DCCA9E"
|
|
#define SENSOR_ORIENT_UUID "A0E70003-B5A3-F393-E0A9-E50E24DCCA9E"
|
|
#define SENSOR_ENV_UUID "A0E70004-B5A3-F393-E0A9-E50E24DCCA9E"
|
|
#define SENSOR_PPS_UUID "A0E70005-B5A3-F393-E0A9-E50E24DCCA9E"
|
|
|
|
// --- Timing ---
|
|
// Inter-byte coalescing window: collect bytes arriving within this
|
|
// gap into one BLE notification instead of sending byte-by-byte
|
|
#define COALESCE_MS 3
|
|
|
|
// LED refresh interval
|
|
#define LED_UPDATE_MS 50
|
|
|
|
// Sensor read/report intervals
|
|
#define GPS_REPORT_MS 1000 // 1Hz GPS position reports
|
|
#define IMU_REPORT_MS 100 // 10Hz orientation updates
|
|
#define BARO_REPORT_MS 1000 // 1Hz pressure/temperature
|
|
#define STATUS_PRINT_MS 1000 // 1Hz USB serial status line
|
|
|
|
// --- LED ---
|
|
#define LED_BRIGHTNESS 30 // 0-255, keep low to avoid blinding in enclosure
|
|
#define LED_COUNT 1
|
|
|
|
// --- Buffers ---
|
|
#define UART_RX_BUF_SIZE 512
|