ret_code_t pm_buffer_init(pm_buffer_t * p_buffer, uint8_t * p_buffer_memory, uint32_t buffer_memory_size, uint8_t * p_mutex_memory, uint32_t mutex_memory_size, uint32_t n_blocks, uint32_t block_size) { if ( (p_buffer != NULL) && (p_buffer_memory != NULL) && (p_mutex_memory != NULL) && (buffer_memory_size >= (n_blocks*block_size)) && (mutex_memory_size >= MUTEX_STORAGE_SIZE(n_blocks)) && (n_blocks != 0) && (block_size != 0)) { p_buffer->p_memory = p_buffer_memory; p_buffer->p_mutex = p_mutex_memory; p_buffer->n_blocks = n_blocks; p_buffer->block_size = block_size; pm_mutex_init(p_buffer->p_mutex, n_blocks); return NRF_SUCCESS; } else { return NRF_ERROR_INVALID_PARAM; } }
void peer_id_init(void) { internal_state_reset(&m_pi); pm_mutex_init(m_pi.active_peer_ids, PM_PEER_ID_N_AVAILABLE_IDS); pm_mutex_init(m_pi.deleted_peer_ids, PM_PEER_ID_N_AVAILABLE_IDS); }