/// @note      Network Core

// System Includes
#include <zephyr.h>
#include <logging/log.h>
#include <nrfx_ipc.h>

// Project Includes
#include "ipc.h"

LOG_MODULE_REGISTER(ipc, LOG_LEVEL_DBG);

void ipc_event_handler(uint32_t event_mask, void * p_context)
{
    ARG_UNUSED( p_context );
    printk( "callback %d\r\n", event_mask );      
}

void ipc_init( void )
{
    IRQ_CONNECT (IPC_IRQn, IRQ_PRIO_LOWEST, nrfx_ipc_irq_handler, 0, 0 );
    nrfx_err_t err = nrfx_ipc_init( 0, ipc_event_handler, NULL );
    if (err != NRFX_SUCCESS)
    {
        LOG_ERR( "nrfx_ipc_init() failed. Error 0x%x\r\n", err );
    }
    nrfx_ipc_send_task_channel_assign( 0, 0 );
}

void ipc_sendSignal( uint8_t sigNum )
{
    nrfx_ipc_signal( sigNum );
    LOG_INF( "Sending IPC %d\n", sigNum );
}
