Mising header "driver/rmt.h" when trying to compile C code into mpy files #15469
-
I wrote a C library to interface with RF433. For this I use the library "driver/rmt.h" (https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/rmt.html). And here is original code. But when I try to compile the file I get the following error: GEN build/rmt_tx.config.h
CC rmt_tx.c
rmt_tx.c:2:10: fatal error: driver/rmt.h: No such file or directory
2 | #include "driver/rmt.h"
| ^~~~~~~~~~~~~~
compilation terminated.
make: *** [/home/mark/Desktop/dev/python/micropython/py/dynruntime.mk:135: build/rmt_tx.o] Error 1 Here is my rmt_tx.c: #include "py/dynruntime.h"
#include "driver/rmt.h"
#define RMT_TX_CHANNEL RMT_CHANNEL_0
#define RTM_TX_GPIO_NUM 26
#define RTM_BLOCK_NUM 1
#define RMT_CLK_DIV 80
#define RMT_1US_TICKS (80000000 / RMT_CLK_DIV / 1000000)
#define RMT_1MS_TICKS (RMT_1US_TICKS * 1000)
rmt_item32_t rmtbuff[2048];
#define T0H 670
#define T1H 320
#define T0L 348
#define T1L 642
#define RMT_CODE_H { 670, 1, 320, 0 }
#define RMT_CODE_L { 348, 1, 642, 0 }
#define RMT_START_CODE0 { 4868, 1, 2469, 0 }
#define RMT_START_CODE1 { 1647, 1, 315, 0 }
static void initRMT_TX() {
rmt_config_t txconfig;
txconfig.rmt_mode = RMT_MODE_TX;
txconfig.channel = RMT_TX_CHANNEL;
txconfig.gpio_num = RTM_TX_GPIO_NUM;
txconfig.mem_block_num = RTM_BLOCK_NUM;
txconfig.tx_config.loop_en = false;
txconfig.tx_config.carrier_en = false;
txconfig.tx_config.idle_output_en = true;
txconfig.tx_config.idle_level = RMT_IDLE_LEVEL_LOW;
txconfig.clk_div = RMT_CLK_DIV;
ESP_ERROR_CHECK(rmt_config(&txconfig));
ESP_ERROR_CHECK(rmt_driver_install(txconfig.channel, 0, 0));
}
static void send(uint8_t* buff, size_t size) {
rmtbuff[0] = (rmt_item32_t)RMT_START_CODE0;
rmtbuff[1] = (rmt_item32_t)RMT_START_CODE1;
for (int i = 0; i < size; i++) {
uint8_t mark = 0x80;
for (int n = 0; n < 8; n++) {
rmtbuff[2 + i * 8 + n] = ((buff[i] & mark)) ? (rmt_item32_t)RMT_CODE_H : (rmt_item32_t)RMT_CODE_L;
mark >>= 1;
}
}
for (int i = 0; i < 8; i++) {
ESP_ERROR_CHECK(rmt_write_items(RMT_TX_CHANNEL, rmtbuff, 42, false));
ESP_ERROR_CHECK(rmt_wait_tx_done(RMT_TX_CHANNEL, portMAX_DELAY));
}
}
static mp_obj_t py_send(mp_obj_t data_obj) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ);
send(bufinfo.buf, bufinfo.len);
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_1(py_send_obj, py_send);
mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) {
MP_DYNRUNTIME_INIT_ENTRY
initRMT_TX();
mp_store_global(MP_QSTR_send, MP_OBJ_FROM_PTR(&py_send_obj));
MP_DYNRUNTIME_INIT_EXIT
} And here is Makefile: # Location of top-level MicroPython directory
MPY_DIR = $(HOME)/Desktop/dev/python/micropython
# Name of module
MOD = rf433
# Source files (.c or .py)
SRC = rf433_tx.c
# Architecture to build for (x86, x64, armv6m, armv7m, xtensa, xtensawin)
ARCH = xtensawin
# Include to get the rules for compiling and linking the module
include $(MPY_DIR)/py/dynruntime.mk I tried adding CFLAGS, but that didn't work: ESP_IDF_DIR = /home/mark/esp/esp-idf
CFLAGS += -I$(ESP_IDF_DIR)/components/driver/include/esp_private
CFLAGS += -I$(ESP_IDF_DIR)/components/esp_common/include
CFLAGS += -I$(ESP_IDF_DIR)/components/esp_system/include
CFLAGS += -I$(ESP_IDF_DIR)/components/esp32/include
CFLAGS += -I$(ESP_IDF_DIR)/components/xtensa/include
CFLAGS += -I$(ESP_IDF_DIR)/components/soc/include
CFLAGS += -I$(ESP_IDF_DIR)/components/freertos/include |
Beta Was this translation helpful? Give feedback.
Answered by
sophiedegran
Jul 16, 2024
Replies: 1 comment
-
In esp-idf 5.0.4 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MarkHmnv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In esp-idf 5.0.4
It seem the rmt.h exist but is depreciated.. (esp-idf/components/driver/depreciated/driver)
You have to use rmt_tx.h or rmt_rx.h in driver