EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #639 background imageLoading...
Page #639 background image
Chapter 2. API Reference
(continued from previous page)
param_descriptor->cid,
(char*)param_descriptor->param_key,
(int)err,
(char*)esp_err_to_name(err));
}
} else {
ESP_LOGE(TAG, "Could not get information for characteristic %d.", cid);
}
mbc_master_set_parameter()
The function writes characteristics value defined as a name and cid parameter in corresponded slave device. The
additional data for parameter request is taken from master parameter description table.
uint8_t type = 0; // Type of parameter
uint8_t temp_data[4] = {0}; // temporary buffer
esp_err_t err = mbc_master_set_parameter(CID_TEMP_DATA_2, "Temperature_2", (uint8_
,t*)temp_data, &type);
if (err == ESP_OK) {
ESP_LOGI(TAG, "Set parameter data successfully.");
} else {
ESP_LOGE(TAG, "Set data fail, err = 0x%x (%s).", (int)err, (char*)esp_err_to_
,name(err));
}
Modbus Master Teardown This function stops Modbus communication stack and destroys controller interface
and free all used active objects.
mbc_master_destroy()
ESP_ERROR_CHECK(mbc_master_destroy());
Modbus Slave API Overview
The sections below represent typical programming workflow for the slave API which should be called in following
order:
1. Modbus Port Initialization - Initialization of Modbus controller interface for the selected port.
2. Configuring Slave Data Access - Configure data descriptors to access slave parameters.
3. Slave Communication Options - Allows to setup communication options for selected port.
4. Slave Communication - Start stack and sending / receiving data. Filter events when master accesses the register
areas.
5. Modbus Slave Teardown - Destroy Modbus controller and its resources.
Configuring Slave Data Access The following functions must be called when the Modbus controller slave port is
already initialized. Refer to Modbus Port Initialization.
The slave stack requires the user to define structures (memory storage areas) that store the Modbus parameters ac-
cessed by stack. These structures should be prepared by the user and be assigned to the Modbus controller interface
using mbc_slave_set_descriptor() API call before the start of communication. The slave task can call the
mbc_slave_check_event() function which will block until the Modbus master access the slave. The slave
task can then get information about the data being accessed.
Note: One slave can define several area descriptors per each type of Modbus register area with different start_offset.
Register area is defined by using the mb_register_area_descriptor_t structure.
Espressif Systems 628
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish