@ -208,6 +208,7 @@ static int esp32_ipm_init(const struct device *dev)
@@ -208,6 +208,7 @@ static int esp32_ipm_init(const struct device *dev)
{
struct esp32_ipm_data * data = ( struct esp32_ipm_data * ) dev - > data ;
struct esp32_ipm_config * cfg = ( struct esp32_ipm_config * ) dev - > config ;
int ret ;
data - > this_core_id = esp_core_id ( ) ;
data - > other_core_id = ( data - > this_core_id = = 0 ) ? 1 : 0 ;
@ -219,22 +220,34 @@ static int esp32_ipm_init(const struct device *dev)
@@ -219,22 +220,34 @@ static int esp32_ipm_init(const struct device *dev)
/* pro_cpu is responsible to initialize the lock of shared memory */
if ( data - > this_core_id = = 0 ) {
esp_intr_alloc ( cfg - > irq_source_pro_cpu ,
ESP_PRIO_TO_FLAGS ( cfg - > irq_priority_pro_cpu ) | ESP_INTR_FLAG_IRAM ,
( intr_handler_t ) esp32_ipm_isr ,
( void * ) dev ,
NULL ) ;
ret = esp_intr_alloc ( cfg - > irq_source_pro_cpu ,
ESP_PRIO_TO_FLAGS ( cfg - > irq_priority_pro_cpu ) |
ESP_INTR_FLAG_IRAM ,
( intr_handler_t ) esp32_ipm_isr ,
( void * ) dev ,
NULL ) ;
if ( ret ! = 0 ) {
LOG_ERR ( " could not allocate interrupt (err %d) " , ret ) ;
return ret ;
}
atomic_set ( & data - > control - > lock , ESP32_IPM_LOCK_FREE_VAL ) ;
} else {
/* app_cpu wait for initialization from pro_cpu, then takes it,
* after that releases
*/
esp_intr_alloc ( cfg - > irq_source_app_cpu ,
ESP_PRIO_TO_FLAGS ( cfg - > irq_priority_app_cpu ) | ESP_INTR_FLAG_IRAM ,
( intr_handler_t ) esp32_ipm_isr ,
( void * ) dev ,
NULL ) ;
ret = esp_intr_alloc ( cfg - > irq_source_app_cpu ,
ESP_PRIO_TO_FLAGS ( cfg - > irq_priority_app_cpu ) |
ESP_INTR_FLAG_IRAM ,
( intr_handler_t ) esp32_ipm_isr ,
( void * ) dev ,
NULL ) ;
if ( ret ! = 0 ) {
LOG_ERR ( " could not allocate interrupt (err %d) " , ret ) ;
return ret ;
}
LOG_DBG ( " Waiting CPU0 to sync " ) ;
while ( ! atomic_cas ( & data - > control - > lock ,