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.
rapid_iot.c
00001 /** 00002 * @file rapiod_iot.c 00003 * 00004 * DAPLink Interface Firmware 00005 * Copyright (c) 2018, ARM Limited, All Rights Reserved 00006 * SPDX-License-Identifier: Apache-2.0 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00009 * not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00016 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 */ 00020 00021 #include "swd_host.h" 00022 #include "target_board.h" 00023 #include "target_family.h" 00024 00025 char *board_id_kw41z = "0234"; 00026 00027 #define MDM_STATUS 0x01000000 00028 #define MDM_CTRL 0x01000004 00029 #define MDM_IDR 0x010000fc 00030 #define MDM_ID_K64 0x001c0000 // K64 00031 #define MDM_ID_KW4 0x001c0020 // KW4 00032 00033 /* Kinetis series ID */ 00034 #define K_SERIES 0 00035 #define KW_SERIES 5 00036 00037 /* KW4 subfamily defines */ 00038 #define KW40 0 00039 #define KW41 1 00040 00041 00042 static void prerun_board_config(void); 00043 00044 00045 const board_info_t g_board_info = { 00046 .info_version = kBoardInfoVersion, 00047 .board_id = "0228", 00048 .family_id = kNXP_RapidIot_FamilyID, 00049 .flags = kEnablePageErase , 00050 .daplink_url_name = "PRODINFOHTM", 00051 .daplink_drive_name = "IOT-DAPLINK", 00052 .daplink_target_url = "http://www.nxp.com/rapid-iot", 00053 .target_cfg = &target_device, 00054 .prerun_board_config = prerun_board_config, 00055 }; 00056 00057 static void prerun_board_config(void) 00058 { 00059 // SIM peripheral 0x40047000 00060 // address offset 0x 1024 00061 uint32_t SDID = 0x40048024; 00062 uint32_t sdid; 00063 00064 // get a hold of the target 00065 if (target_set_state(HALT) == 0) { 00066 /* 00067 * When the Kinetis flash is empty the reset line toggles. This causes failures 00068 * when trying to halt the target. Use the reset halt method in this case. 00069 */ 00070 target_set_state(RESET_PROGRAM); 00071 } 00072 00073 // Read the system identification register 00074 swd_read_memory(SDID, (uint8_t *)&sdid, 4); 00075 00076 // Set the target flash algorithm 00077 if (((sdid >> 20) & 0xF) == KW_SERIES) { 00078 //mdm_id = MDM_ID_KW4; 00079 00080 if (((sdid >> 24) & 0x3) == KW40) { 00081 // Program to the KW40 flash 00082 extern target_cfg_t target_device_kw40; 00083 target_device = target_device_kw40; 00084 } else { 00085 // Program to the KW41 flash 00086 extern target_cfg_t target_device_kw41; 00087 target_device = target_device_kw41; 00088 target_device.rt_board_id = board_id_kw41z; 00089 } 00090 } 00091 00092 // Let the target run 00093 target_set_state(RUN); 00094 }
Generated on Tue Jul 12 2022 15:37:22 by
1.7.2