Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
simple-mbed-cloud-client/mbed-cloud-client/ns-hal-pal/ns_hal_init.c@1:521604503e81, 2018-10-19 (annotated)
- Committer:
- JimCarver
- Date:
- Fri Oct 19 02:01:38 2018 +0000
- Revision:
- 1:521604503e81
- Parent:
- 0:6b753f761943
bug fix
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimCarver | 0:6b753f761943 | 1 | // ---------------------------------------------------------------------------- |
JimCarver | 0:6b753f761943 | 2 | // Copyright 2016-2017 ARM Ltd. |
JimCarver | 0:6b753f761943 | 3 | // |
JimCarver | 0:6b753f761943 | 4 | // SPDX-License-Identifier: Apache-2.0 |
JimCarver | 0:6b753f761943 | 5 | // |
JimCarver | 0:6b753f761943 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
JimCarver | 0:6b753f761943 | 7 | // you may not use this file except in compliance with the License. |
JimCarver | 0:6b753f761943 | 8 | // You may obtain a copy of the License at |
JimCarver | 0:6b753f761943 | 9 | // |
JimCarver | 0:6b753f761943 | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
JimCarver | 0:6b753f761943 | 11 | // |
JimCarver | 0:6b753f761943 | 12 | // Unless required by applicable law or agreed to in writing, software |
JimCarver | 0:6b753f761943 | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
JimCarver | 0:6b753f761943 | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
JimCarver | 0:6b753f761943 | 15 | // See the License for the specific language governing permissions and |
JimCarver | 0:6b753f761943 | 16 | // limitations under the License. |
JimCarver | 0:6b753f761943 | 17 | // ---------------------------------------------------------------------------- |
JimCarver | 0:6b753f761943 | 18 | |
JimCarver | 0:6b753f761943 | 19 | #include "ns_hal_init.h" |
JimCarver | 0:6b753f761943 | 20 | |
JimCarver | 0:6b753f761943 | 21 | #include "ns_types.h" |
JimCarver | 0:6b753f761943 | 22 | #include <stdlib.h> |
JimCarver | 0:6b753f761943 | 23 | #include <assert.h> |
JimCarver | 0:6b753f761943 | 24 | |
JimCarver | 0:6b753f761943 | 25 | #include "arm_hal_interrupt_private.h" |
JimCarver | 0:6b753f761943 | 26 | #include "ns_event_loop.h" |
JimCarver | 0:6b753f761943 | 27 | #include "eventOS_scheduler.h" |
JimCarver | 0:6b753f761943 | 28 | #include "platform/arm_hal_timer.h" |
JimCarver | 0:6b753f761943 | 29 | #include "ns_trace.h" |
JimCarver | 0:6b753f761943 | 30 | |
JimCarver | 0:6b753f761943 | 31 | |
JimCarver | 0:6b753f761943 | 32 | void ns_hal_init(void *heap, size_t h_size, void (*passed_fptr)(heap_fail_t), mem_stat_t *info_ptr) |
JimCarver | 0:6b753f761943 | 33 | { |
JimCarver | 0:6b753f761943 | 34 | static bool initted; |
JimCarver | 0:6b753f761943 | 35 | if (initted) { |
JimCarver | 0:6b753f761943 | 36 | return; |
JimCarver | 0:6b753f761943 | 37 | } |
JimCarver | 0:6b753f761943 | 38 | if (!heap) { |
JimCarver | 0:6b753f761943 | 39 | heap = malloc(h_size); |
JimCarver | 0:6b753f761943 | 40 | assert(heap); |
JimCarver | 0:6b753f761943 | 41 | if (!heap) { |
JimCarver | 0:6b753f761943 | 42 | return; |
JimCarver | 0:6b753f761943 | 43 | } |
JimCarver | 0:6b753f761943 | 44 | } |
JimCarver | 0:6b753f761943 | 45 | platform_critical_init(); |
JimCarver | 0:6b753f761943 | 46 | ns_dyn_mem_init(heap, h_size, passed_fptr, info_ptr); |
JimCarver | 0:6b753f761943 | 47 | eventOS_scheduler_init(); |
JimCarver | 0:6b753f761943 | 48 | // We do not initialise randlib, as it should be done after |
JimCarver | 0:6b753f761943 | 49 | // RF driver has started, to get MAC address and RF noise as seed. |
JimCarver | 0:6b753f761943 | 50 | // We do not initialise trace - left to application. |
JimCarver | 0:6b753f761943 | 51 | ns_event_loop_thread_create(); |
JimCarver | 0:6b753f761943 | 52 | ns_event_loop_thread_start(); |
JimCarver | 0:6b753f761943 | 53 | initted = true; |
JimCarver | 0:6b753f761943 | 54 | } |