leo hendrickson
/
S
simple-mbed-cloud-client/mbed-cloud-client/ns-hal-pal/ns_hal_init.c@0:25fa8795676b, 2021-04-18 (annotated)
- Committer:
- leothedragon
- Date:
- Sun Apr 18 15:20:23 2021 +0000
- Revision:
- 0:25fa8795676b
DS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leothedragon | 0:25fa8795676b | 1 | // ---------------------------------------------------------------------------- |
leothedragon | 0:25fa8795676b | 2 | // Copyright 2016-2017 ARM Ltd. |
leothedragon | 0:25fa8795676b | 3 | // |
leothedragon | 0:25fa8795676b | 4 | // SPDX-License-Identifier: Apache-2.0 |
leothedragon | 0:25fa8795676b | 5 | // |
leothedragon | 0:25fa8795676b | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
leothedragon | 0:25fa8795676b | 7 | // you may not use this file except in compliance with the License. |
leothedragon | 0:25fa8795676b | 8 | // You may obtain a copy of the License at |
leothedragon | 0:25fa8795676b | 9 | // |
leothedragon | 0:25fa8795676b | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
leothedragon | 0:25fa8795676b | 11 | // |
leothedragon | 0:25fa8795676b | 12 | // Unless required by applicable law or agreed to in writing, software |
leothedragon | 0:25fa8795676b | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
leothedragon | 0:25fa8795676b | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
leothedragon | 0:25fa8795676b | 15 | // See the License for the specific language governing permissions and |
leothedragon | 0:25fa8795676b | 16 | // limitations under the License. |
leothedragon | 0:25fa8795676b | 17 | // ---------------------------------------------------------------------------- |
leothedragon | 0:25fa8795676b | 18 | |
leothedragon | 0:25fa8795676b | 19 | #include "ns_hal_init.h" |
leothedragon | 0:25fa8795676b | 20 | |
leothedragon | 0:25fa8795676b | 21 | #include "ns_types.h" |
leothedragon | 0:25fa8795676b | 22 | #include <stdlib.h> |
leothedragon | 0:25fa8795676b | 23 | #include <assert.h> |
leothedragon | 0:25fa8795676b | 24 | |
leothedragon | 0:25fa8795676b | 25 | #include "arm_hal_interrupt_private.h" |
leothedragon | 0:25fa8795676b | 26 | #include "ns_event_loop.h" |
leothedragon | 0:25fa8795676b | 27 | #include "eventOS_scheduler.h" |
leothedragon | 0:25fa8795676b | 28 | #include "platform/arm_hal_timer.h" |
leothedragon | 0:25fa8795676b | 29 | #include "ns_trace.h" |
leothedragon | 0:25fa8795676b | 30 | |
leothedragon | 0:25fa8795676b | 31 | |
leothedragon | 0:25fa8795676b | 32 | void ns_hal_init(void *heap, size_t h_size, void (*passed_fptr)(heap_fail_t), mem_stat_t *info_ptr) |
leothedragon | 0:25fa8795676b | 33 | { |
leothedragon | 0:25fa8795676b | 34 | static bool initted; |
leothedragon | 0:25fa8795676b | 35 | if (initted) { |
leothedragon | 0:25fa8795676b | 36 | return; |
leothedragon | 0:25fa8795676b | 37 | } |
leothedragon | 0:25fa8795676b | 38 | if (!heap) { |
leothedragon | 0:25fa8795676b | 39 | heap = malloc(h_size); |
leothedragon | 0:25fa8795676b | 40 | assert(heap); |
leothedragon | 0:25fa8795676b | 41 | if (!heap) { |
leothedragon | 0:25fa8795676b | 42 | return; |
leothedragon | 0:25fa8795676b | 43 | } |
leothedragon | 0:25fa8795676b | 44 | } |
leothedragon | 0:25fa8795676b | 45 | platform_critical_init(); |
leothedragon | 0:25fa8795676b | 46 | ns_dyn_mem_init(heap, h_size, passed_fptr, info_ptr); |
leothedragon | 0:25fa8795676b | 47 | eventOS_scheduler_init(); |
leothedragon | 0:25fa8795676b | 48 | // We do not initialise randlib, as it should be done after |
leothedragon | 0:25fa8795676b | 49 | // RF driver has started, to get MAC address and RF noise as seed. |
leothedragon | 0:25fa8795676b | 50 | // We do not initialise trace - left to application. |
leothedragon | 0:25fa8795676b | 51 | ns_event_loop_thread_create(); |
leothedragon | 0:25fa8795676b | 52 | ns_event_loop_thread_start(); |
leothedragon | 0:25fa8795676b | 53 | initted = true; |
leothedragon | 0:25fa8795676b | 54 | } |