嗨,我正在尝试读取以下示例中* rx_buffer的值,该值是spi_transaction_t结构的成员。
struct spi_transaction_t {
[...]
union {
void *rx_buffer; //< Pointer to receive buffer, or NULL for no MISO phase. Written by 4 bytes-unit if DMA is used.
uint8_t rx_data[4]; //< If SPI_USE_RXDATA is set, data is received directly to this variable
};
};
//Queue transaction
static void send_lines(spi_device_handle_t spi)
{
esp_err_t ret;
int x;
[...]
for (x=0; x<6; x++) {
ret=spi_device_queue_trans(spi, &trans[x], portMAX_DELAY);
assert(ret==ESP_OK);
}
}
//Dequeue transaction
static void send_line_finish(spi_device_handle_t spi)
{
spi_transaction_t *rtrans;
esp_err_t ret;
for (int x=0; x<6; x++) {
ret=spi_device_get_trans_result(spi, &rtrans, portMAX_DELAY);
assert(ret==ESP_OK);
}
}
我现在正试图从* rx_buffer出队数据并将其写入另一个缓冲区。类似于以下内容,但是我正在努力使用指向指针结构的指针。
//Dequeue transaction
static void send_line_finish(spi_device_handle_t spi)
{
spi_transaction_t *rtrans;
esp_err_t ret;
int16_t data_buffer[6];
for (int x=0; x<6; x++) {
ret=spi_device_get_trans_result(spi, &rtrans, portMAX_DELAY);
assert(ret==ESP_OK);
data_buffer[x] = (int16_t**)rtrans->rx_buffer;
}
}
编辑: 文档说:
通常,将从以下设备读取要传输到设备的数据: 或写入rx_buffer和 事务结构的tx_buffer成员。启用DMA时 对于传输,强烈建议使用这些缓冲区[...]
https://github.com/espressif/esp-idf/blob/master/docs/en/api-reference/peripherals/spi_master.rst