Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_uc_hw_plat.c Source File

arm_uc_hw_plat.c

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #include "update-client-common/arm_uc_hw_plat.h"
00020 #include "update-client-common/arm_uc_utilities.h"
00021 #include "update-client-common/arm_uc_error.h"
00022 #include "update-client-common/arm_uc_config.h"
00023 
00024 #include <string.h>
00025 #include <stdlib.h>
00026 #include <stdio.h>
00027 
00028 #ifdef __linux__
00029 #include <sys/reboot.h>
00030 #endif
00031 
00032 #if defined(TARGET_LIKE_MBED)
00033 #define RESET_MASK_FOR_CORTEX_M_SERIES  0x5fa0004
00034 volatile unsigned int *AIRCR_REG = (volatile unsigned int *)(
00035                                        0xE000ED0C);   //This register address is true for the Cortex M family
00036 #endif
00037 
00038 /**
00039  * @brief Issue a platform-specific Hard-reboot
00040  *
00041  */
00042 void arm_uc_plat_reboot(void)
00043 {
00044 #if defined(TARGET_LIKE_MBED)
00045     *AIRCR_REG = RESET_MASK_FOR_CORTEX_M_SERIES;
00046     while (1); /* wait until reset */
00047 #elif __linux__
00048     // Reboot the device
00049     reboot(RB_AUTOBOOT);
00050     while (1); /* wait until reset */
00051 #else
00052 #warning "No Reboot implemented for this platform, continuing operation!"
00053 #endif
00054 }