|
34 | 34 | #include <zephyr/kernel.h>
|
35 | 35 | #include <zephyr/sys/printk.h>
|
36 | 36 | #include <zephyr/random/random.h>
|
37 |
| -#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h> |
| 37 | +#include <zephyr/drivers/interrupt_controller/intc_esp32.h> |
38 | 38 |
|
39 | 39 | #include <zephyr/logging/log.h>
|
40 | 40 | LOG_MODULE_REGISTER(esp32_bt_adapter, CONFIG_LOG_DEFAULT_LEVEL);
|
@@ -113,17 +113,17 @@ typedef struct {
|
113 | 113 | int flags; /*!< ISR alloc flag */
|
114 | 114 | void (*fn)(void *); /*!< ISR function */
|
115 | 115 | void *arg; /*!< ISR function args*/
|
116 |
| - isr_handler_t *handle; /*!< ISR handle */ |
| 116 | + struct intr_handle_data_t *handle; /*!< ISR handle */ |
117 | 117 | esp_err_t ret;
|
118 | 118 | } btdm_isr_alloc_t;
|
119 | 119 |
|
120 | 120 | /* OSI function */
|
121 | 121 | struct osi_funcs_t {
|
122 | 122 | uint32_t _magic;
|
123 | 123 | uint32_t _version;
|
124 |
| - int (* _interrupt_alloc)(int cpu_id, int source, isr_handler_t handler, void *arg, void **ret_handle); |
| 124 | + int (* _interrupt_alloc)(int cpu_id, int source, intr_handler_t handler, void *arg, void **ret_handle); |
125 | 125 | int (* _interrupt_free)(void *handle);
|
126 |
| - void (*_interrupt_handler_set_rsv)(int interrupt_no, isr_handler_t fn, void *arg); |
| 126 | + void (*_interrupt_handler_set_rsv)(int interrupt_no, intr_handler_t fn, void *arg); |
127 | 127 | void (*_global_intr_disable)(void);
|
128 | 128 | void (*_global_intr_restore)(void);
|
129 | 129 | void (*_task_yield)(void);
|
@@ -237,7 +237,7 @@ extern void ets_backup_dma_copy(uint32_t reg, uint32_t mem_addr, uint32_t num, b
|
237 | 237 | extern void btdm_cca_feature_enable(void);
|
238 | 238 | extern void btdm_aa_check_enhance_enable(void);
|
239 | 239 |
|
240 |
| -static int interrupt_alloc_wrapper(int cpu_id, int source, isr_handler_t handler, void *arg, void **ret_handle); |
| 240 | +static int interrupt_alloc_wrapper(int cpu_id, int source, intr_handler_t handler, void *arg, void **ret_handle); |
241 | 241 | static int interrupt_free_wrapper(void *handle);
|
242 | 242 | static void global_interrupt_disable(void);
|
243 | 243 | static void global_interrupt_restore(void);
|
@@ -437,39 +437,34 @@ static inline void esp_bt_power_domain_off(void)
|
437 | 437 | static void btdm_intr_alloc(void *arg)
|
438 | 438 | {
|
439 | 439 | btdm_isr_alloc_t *p = arg;
|
440 |
| - p->ret = esp_intr_alloc(p->source, p->flags, (isr_handler_t)p->fn, p->arg, NULL); |
| 440 | + p->ret = esp_intr_alloc(p->source, p->flags, p->fn, p->arg, &p->handle); |
441 | 441 | }
|
442 | 442 |
|
443 |
| -static int interrupt_alloc_wrapper(int cpu_id, int source, isr_handler_t handler, void *arg, void **ret_handle) |
| 443 | +static int interrupt_alloc_wrapper(int cpu_id, int source, intr_handler_t handler, void *arg, void **ret_handle) |
444 | 444 | {
|
445 | 445 | btdm_isr_alloc_t p;
|
446 | 446 | p.source = source;
|
447 | 447 | p.flags = ESP_INTR_FLAG_LEVEL3 | ESP_INTR_FLAG_IRAM;
|
448 |
| - p.fn = (void *)handler; |
| 448 | + p.fn = handler; |
449 | 449 | p.arg = arg;
|
450 |
| - p.handle = (isr_handler_t *)ret_handle; |
| 450 | + p.handle = (struct intr_handle_data_t *)ret_handle; |
451 | 451 | btdm_intr_alloc(&p);
|
452 | 452 | return p.ret;
|
453 | 453 | }
|
454 | 454 |
|
455 | 455 | static int interrupt_free_wrapper(void *handle)
|
456 | 456 | {
|
457 |
| - /* TODO: implement esp_intr_free() for ESP32-C3 */ |
458 |
| - return ESP_OK; |
| 457 | + return esp_intr_free((struct intr_handle_data_t *)handle); |
459 | 458 | }
|
460 | 459 |
|
461 | 460 | static int interrupt_enable_wrapper(void *handle)
|
462 | 461 | {
|
463 |
| - ARG_UNUSED(handle); |
464 |
| - |
465 |
| - return ESP_OK; |
| 462 | + return esp_intr_enable((struct intr_handle_data_t *)handle); |
466 | 463 | }
|
467 | 464 |
|
468 | 465 | static int interrupt_disable_wrapper(void *handle)
|
469 | 466 | {
|
470 |
| - ARG_UNUSED(handle); |
471 |
| - |
472 |
| - return ESP_OK; |
| 467 | + return esp_intr_disable((struct intr_handle_data_t *)handle); |
473 | 468 | }
|
474 | 469 |
|
475 | 470 | static void IRAM_ATTR global_interrupt_disable(void)
|
@@ -721,11 +716,7 @@ static void task_delete_wrapper(void *task_handle)
|
721 | 716 |
|
722 | 717 | static void *malloc_internal_wrapper(size_t size)
|
723 | 718 | {
|
724 |
| - void *ptr = esp_bt_malloc_func(size); |
725 |
| - if (ptr == NULL) { |
726 |
| - ets_printf("malloc_internal failed\n"); |
727 |
| - } |
728 |
| - return ptr; |
| 719 | + return esp_bt_malloc_func(sizeof(uint8_t) * size); |
729 | 720 | }
|
730 | 721 |
|
731 | 722 | static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
|
@@ -1249,9 +1240,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
1249 | 1240 | periph_module_enable(PERIPH_BT_MODULE);
|
1250 | 1241 | periph_module_reset(PERIPH_BT_MODULE);
|
1251 | 1242 |
|
1252 |
| - err = btdm_controller_init(cfg); |
1253 |
| - if (err != ESP_OK) { |
1254 |
| - ets_printf("BT controller init failed=%X\r\n", err); |
| 1243 | + if (btdm_controller_init(cfg) != 0) { |
| 1244 | + err = ESP_ERR_NO_MEM; |
1255 | 1245 | goto error;
|
1256 | 1246 | }
|
1257 | 1247 |
|
|
0 commit comments