Using AT Commands via USB Interface
Overview
In Host Control Mode, the USB peripheral interface is used for data transmission to fulfill plug-and-play and high compatibility requirements.
The master device and AT device connect in the following modes:
Mode 1: Master as USB Host, AT device as USB Device
Mode 2: Master as USB Device, AT device as USB Host
Both parties use the USB CDC-ACM protocol for AT command interaction. Configuration steps:
Refer to AT Configuration Modification to specify the USB interface for the AT module.
Refer to Configuring SDK (menuconfig) to enter
CONFIG USB
settings and selectUSB Mode
andCDC ACM
.
Note
USB Mode
parameter definition in atcmd_config.json:0
: USB Device1
: USB Host
This parameter must match the configuration in Menuconfig.
Master Reference Examples
Select the corresponding example based on the master role:
USB Host Mode: https://github.com/Ameba-AIoT/ameba-rtos/tree/master/component/example/atcmd_host/atcmd_usbd_host. Requires AT module in USB Device Mode.
USB Device Mode: https://github.com/Ameba-AIoT/ameba-rtos/tree/master/component/example/atcmd_host/atcmd_usbh_host. Requires AT module in USB Host Mode.
These examples demonstrate full USB host-device communication flow. It is recommended to run these code samples before development to verify connection and configuration correctness. Subsequently, adapt them to specific MCU platforms based on the reference code.
The example code adds a UART task to receive AT commands and print responses. Overall data flow:
Note
USB Host initialization requires waiting for device enumeration to complete.
Communication Speed
For USB link speed testing, refer to AT+TEST command.
Note
USB link speed is affected by:
AT module’s USB role (Host/Device)
AT module’s supported USB speed mode (Full-Speed/High-Speed)