arch/nrf91: fix modem initialization

This commit is contained in:
raiden00pl 2023-07-22 14:17:16 +02:00 committed by Xiang Xiao
parent e5b6d1cb29
commit b3c5e05add
2 changed files with 50 additions and 17 deletions

View File

@ -47,6 +47,47 @@
# error NRF91 modem requires using LFXO as the LFCLK source
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static void nrf91_modem_fault_handler(struct nrf_modem_fault_info *info);
/****************************************************************************
* Private Data
****************************************************************************/
/* Modem library parameters - must be allocated in data segment */
static const struct nrf_modem_init_params g_init_params =
{
.shmem =
{
.ctrl =
{
.base = NRF91_SHMEM_CTRL_BASE,
.size = NRF91_SHMEM_CTRL_SIZE
},
.tx =
{
.base = NRF91_SHMEM_TX_BASE,
.size = NRF91_SHMEM_TX_SIZE
},
.rx =
{
.base = NRF91_SHMEM_RX_BASE,
.size = NRF91_SHMEM_RX_SIZE
},
.trace =
{
.base = NRF91_SHMEM_TRACE_BASE,
.size = NRF91_SHMEM_TRACE_SIZE
}
},
.ipc_irq_prio = NVIC_SYSH_PRIORITY_DEFAULT,
.fault_handler = nrf91_modem_fault_handler
};
/****************************************************************************
* Private Functions
****************************************************************************/
@ -71,25 +112,11 @@ static void nrf91_modem_fault_handler(struct nrf_modem_fault_info *info)
int nrf91_modem_initialize(void)
{
struct nrf_modem_init_params init_params;
int ret = OK;
/* Modem parameters */
init_params.shmem.ctrl.base = NRF91_SHMEM_CTRL_BASE;
init_params.shmem.ctrl.size = NRF91_SHMEM_CTRL_SIZE;
init_params.shmem.tx.base = NRF91_SHMEM_TX_BASE;
init_params.shmem.tx.size = NRF91_SHMEM_TX_SIZE;
init_params.shmem.rx.base = NRF91_SHMEM_RX_BASE;
init_params.shmem.rx.size = NRF91_SHMEM_RX_SIZE;
init_params.shmem.trace.base = NRF91_SHMEM_TRACE_BASE;
init_params.shmem.trace.size = NRF91_SHMEM_TRACE_SIZE;
init_params.ipc_irq_prio = NVIC_SYSH_PRIORITY_DEFAULT;
init_params.fault_handler = nrf91_modem_fault_handler;
int ret = OK;
/* Initialize modem */
ret = nrf_modem_init(&init_params);
ret = nrf_modem_init(&g_init_params);
if (ret < 0)
{
nerr("nrf_modem_init failed %d\n", ret);

View File

@ -24,6 +24,8 @@
#include <nuttx/config.h>
#include <nuttx/mm/mm.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -32,12 +34,16 @@
#define NRF91_SHMEM_CTRL_SIZE (0x4e8)
/* REVISIT: heap overhead */
#define HEAP_OVERHEAD (400)
/* Shared memory configuration */
#define NRF91_SHMEM_START_ADDR (CONFIG_RAM_START)
#define NRF91_SHMEM_CTRL_BASE (NRF91_SHMEM_START_ADDR)
#define NRF91_SHMEM_TX_BASE (NRF91_SHMEM_CTRL_BASE+NRF91_SHMEM_CTRL_SIZE)
#define NRF91_SHMEM_TX_SIZE (CONFIG_NRF91_MODEM_SHMEM_TX_SIZE)
#define NRF91_SHMEM_TX_SIZE (CONFIG_NRF91_MODEM_SHMEM_TX_SIZE-HEAP_OVERHEAD)
#define NRF91_SHMEM_RX_BASE (NRF91_SHMEM_TX_BASE+NRF91_SHMEM_TX_SIZE)
#define NRF91_SHMEM_RX_SIZE (CONFIG_NRF91_MODEM_SHMEM_RX_SIZE)
#define NRF91_SHMEM_TRACE_BASE (NRF91_SHMEM_RX_BASE+NRF91_SHMEM_RX_SIZE)