Middleware for the AT peripheral module on RAFW MCUs. This module implements the AT Interface.
Overview
Features
The ATCMD_W module supports the following features:
- APB data bus widths of 32 bits
- Use PERI_CLK with separate system resets for each clock domain to prevent metastability
- Programmable FIFO enable/disable
- Internal transceiver FIFO depths are 32 bytes
- DMA interface signals with high polarity
- Auto Flow Control mode support
- False start bit detection
- AT busy or idle functionality
- Full-duplex AT communication
- Invoking the user-callback function with an event code (RX/TX complete, TX data empty, RX char, error, etc)
- Baud-rate change at run-time
Configuration
Build Time Configurations for rm_atcmd_w
The following build time configurations are defined in fsp_cfg/rm_atcmd_w_cfg.h:
| Configuration | Options | Default | Description |
| Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
| ATCMD Task Support |
| Enable | Enable support for the AT interface. |
| UART Support |
| Enable | Enable UART support for the AT module. |
| Assume MCU always ON |
| Disable | Allow MCU to skip sending AT+PMGRMCUWUDONE when MCU wakes up |
| SPI Support |
| Disable | Enable SPI support for the AT module. |
| SDIO Support |
| Disable | Enable SDIO support for the AT module. |
| ATCMD BLEBRG Support |
| Disable | Enable Support for atcmd blebrg. |
| RF Support |
| Enable | Select RF support for the AT module. |
| ATCMD response max len |
| 1024 | Select ATCMD response max length. |
| AT+PMGRMCUWUDONE Wait Maximum Timeout (ms) | Timeout must be an integer greater than 0 | 150 | Timeout for receiving AT+PMGRMCUWUDONE in milliseconds at DPM wakeup. |
| AT+PMGRCONSTRAINT Wait Maximum Timeout (ms) | Timeout must be an integer greater than 0 | 100 | Timeout for receiving AT+PMGRCONSTRAINT=1,1/4 in milliseconds at DPM wakeup. |
Configurations for Networking > AT Middleware (rm_atcmd_w)
This module can be added to the Stacks tab via New Stack > Networking > AT Middleware (rm_atcmd_w).
| Configuration | Options | Default | Description |
| General |
| Name | Name must be a valid C symbol | g_at0 | Module name. |
Clock Configuration
The AT peripheral uses the PERI_CLK for for the baud-rate clock generator
Pin Configuration
This module uses the TXD,RTS,CST,and RXD pins to communicate with external devices. When autoflow control is configured, the pins of rts and cts must be pinmux as corresponding functions. When in RS-485 mode, an additional AT_TXDOE signal is provided to indicate the TXD active intervals. This signal can be assigned to any of the unused GPIO pins through the PPA.
Usage Notes
When the auto flow control is enabled, the RTS pin will be automatically pulled up. When the receiving water level of the fifo reaches the set threshold. If need to use auto flow control, also need to configure the corresponding pinmux for RTS and CTS.
Examples
ATCMD_W Example
{
p_at_conf->
conf.p_i2c_master = &g_atcmd_i2c_instance;
p_at_conf->
conf.p_adc = &g_atcmd_adc_instance;
p_at_conf->
conf.p_transport_instance = &g_transport_inst_app;
}
fsp_err_t atcmd_w_core_init (atcmd_w_core_instance_t *p_at_core_instance)
{
at_config_example(&p_at_core_instance->at_conf);
memset((atcmd_w_tx_queue_t *)&p_at_core_instance->tx_queue, 0x00, sizeof(p_at_core_instance->tx_queue));
err = g_at_core.
open(&p_at_core_instance->at_ctrl, &p_at_core_instance->at_conf.conf);
return err;
}
void at_basic_example ()
{
g_transport_inst_app.p_ctrl = &g_rm_atcmd_transport_instance;
g_transport_inst_app.p_api = &g_atcmd_transport_on_uart;
g_transport_inst_app.p_cfg = &g_transport0_cfg;
err = atcmd_w_core_init(&g_at_core_instance);
assert(FSP_SUCCESS == err);
err = g_atcmd_transport_on_uart.
open(g_transport_inst_app.p_ctrl,
&g_transport0_cfg,
&g_at_core_instance.at_ctrl);
assert(FSP_SUCCESS == err);
while(EXAMPLE_RUN_FOREVER)
{
}
}
◆ atcmd_w_conf_t
| Data Fields |
|
atcmd_w_cfg_t |
conf |
Instruction configuration for the AT module. |
◆ RM_ATCMD_W_CORE_Open()
This functions initializes the AT communication module. Implements atcmd_w_api_t::open.
This function performs the following tasks:
- Performs parameter checking and processes error conditions.
- Configures the peripheral registers according to the configuration.
- Initialize the control structure for use in other AT Interface functions.
- Return values
-
| FSP_SUCCESS | Module initialized successfully. |
| FSP_ERR_ALREADY_OPEN | Instance was already initialized. |
- Returns
- See Common Error Codes or functions called by this function for other possible return codes. This function calls: transfer_api_t::open
- Note
- This function is reentrant.
◆ RM_ATCMD_W_CORE_Read()
This function receives data from a AT transport layer. Implements atcmd_w_api_t::read.
The function performs the following tasks:
- Performs parameter checking and processes error conditions.
- Sets up the instance to complete a AT read operation.
- Return values
-
| FSP_SUCCESS | Read operation successfully completed. |
| FSP_ERR_ASSERTION | NULL pointer to control or destination parameters or transfer length is zero. |
| FSP_ERR_NOT_OPEN | The transport has not been opened. Open transport first. |
| FSP_ERR_IN_USE | A transfer is already in progress. |
| FSP_ERR_TIMEOUT | Timeout reading data. |
◆ RM_ATCMD_W_CORE_DataRead()
| fsp_err_t RM_ATCMD_W_CORE_DataRead |
( |
atcmd_w_ctrl_t *const |
p_at_ctrl, |
|
|
uint8_t *const |
p_dest, |
|
|
uint32_t const |
bytes |
|
) |
| |
This function receives data from a AT input command buffer. Implements atcmd_w_api_t::dataRead.
The function performs the following tasks:
- Performs parameter checking and processes error conditions.
- Sets up the instance to complete a AT read operation.
- Return values
-
| FSP_SUCCESS | Read operation successfully completed. |
| FSP_ERR_ASSERTION | NULL pointer to control or destination parameters or transfer length is zero. |
| FSP_ERR_NOT_OPEN | The transport has not been opened. Open transport first. |
| FSP_ERR_IN_USE | A transfer is already in progress. |
| FSP_ERR_TIMEOUT | Timeout reading data. |
| FSP_ERR_BUFFER_EMPTY | Incomplete or invalid command received. |
◆ RM_ATCMD_W_CORE_Write()
| fsp_err_t RM_ATCMD_W_CORE_Write |
( |
atcmd_w_ctrl_t *const |
p_at_ctrl, |
|
|
uint8_t const *const |
p_src, |
|
|
uint32_t const |
bytes |
|
) |
| |
This function transmits data to a AT transport layer. Implements atcmd_w_api_t::write.
The function performs the following tasks:
- Performs parameter checking and processes error conditions.
- Sets up the instance to complete a AT write operation.
- Return values
-
| FSP_SUCCESS | Write operation successfully completed. |
| FSP_ERR_ASSERTION | NULL pointer to control or source parameters or transfer length is zero. |
| FSP_ERR_NOT_OPEN | The transport has not been opened. Open the transport first. |
| FSP_ERR_IN_USE | A transfer is already in progress. |
◆ RM_ATCMD_W_CORE_InfoGet()
Provides the middleware information, including the maximum number of bytes that can be received or transmitted at a time. Implements atcmd_w_api_t::infoGet
- Return values
-
| FSP_SUCCESS | Information stored in provided p_info. |
| FSP_ERR_ASSERTION | Pointer to AT control block is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened |
◆ RM_ATCMD_W_CORE_Close()
This function manages the closing of the module by the following task. Implements atcmd_w_api_t::close.
Disables AT operations by disabling the selected communication bus (UART,SPI or SDIO).
- Disables the AT peripheral.
- Disables all the associated interrupts.
- Update control structure so it will not work with AT Interface functions.
- Return values
-
| FSP_SUCCESS | Module successfully closed. |
| FSP_ERR_ASSERTION | A required pointer argument is NULL. |
| FSP_ERR_NOT_OPEN | The module has not been opened. Open the module first. |
◆ RM_ATCMD_W_CORE_SecureChannelKeySet()
Sets the secure channel key for AT command core.
This function copies the provided key into the internal control structure if secure channel support is enabled (ATCMD_SECURE_CHANNEL == 1).
- Parameters
-
| [in] | p_at_ctrl | Pointer to the AT command control structure. |
| [in] | key | Pointer to the secure key to be set. |
- Return values
-
| FSP_SUCCESS | Key was set successfully (or no operation if secure channel is disabled). |