Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
source/target/target_board.c@0:01f31e923fe2, 2020-04-07 (annotated)
- Committer:
- Pawel Zarembski
- Date:
- Tue Apr 07 12:55:42 2020 +0200
- Revision:
- 0:01f31e923fe2
hani: DAPLink with reset workaround
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pawel Zarembski |
0:01f31e923fe2 | 1 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 2 | * @file target_board.c |
Pawel Zarembski |
0:01f31e923fe2 | 3 | * @brief Implementation of target_family.h |
Pawel Zarembski |
0:01f31e923fe2 | 4 | * |
Pawel Zarembski |
0:01f31e923fe2 | 5 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 6 | * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 7 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 8 | * |
Pawel Zarembski |
0:01f31e923fe2 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 10 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 11 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 12 | * |
Pawel Zarembski |
0:01f31e923fe2 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 14 | * |
Pawel Zarembski |
0:01f31e923fe2 | 15 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 18 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 19 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 20 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 21 | |
Pawel Zarembski |
0:01f31e923fe2 | 22 | #include <string.h> |
Pawel Zarembski |
0:01f31e923fe2 | 23 | #include "target_board.h" |
Pawel Zarembski |
0:01f31e923fe2 | 24 | |
Pawel Zarembski |
0:01f31e923fe2 | 25 | // Default empty board info. |
Pawel Zarembski |
0:01f31e923fe2 | 26 | __attribute__((weak)) |
Pawel Zarembski |
0:01f31e923fe2 | 27 | const board_info_t g_board_info = { |
Pawel Zarembski |
0:01f31e923fe2 | 28 | .info_version = kBoardInfoVersion, |
Pawel Zarembski |
0:01f31e923fe2 | 29 | .board_id = "0000", |
Pawel Zarembski |
0:01f31e923fe2 | 30 | .daplink_url_name = "MBED HTM", |
Pawel Zarembski |
0:01f31e923fe2 | 31 | .daplink_drive_name = "DAPLINK ", |
Pawel Zarembski |
0:01f31e923fe2 | 32 | .daplink_target_url = "https://mbed.org/device/?code=@U?version=@V?target_id=@T", |
Pawel Zarembski |
0:01f31e923fe2 | 33 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 34 | |
Pawel Zarembski |
0:01f31e923fe2 | 35 | |
Pawel Zarembski |
0:01f31e923fe2 | 36 | const char * get_board_id(void) |
Pawel Zarembski |
0:01f31e923fe2 | 37 | { |
Pawel Zarembski |
0:01f31e923fe2 | 38 | if (g_board_info.target_cfg && g_board_info.target_cfg->rt_board_id) { |
Pawel Zarembski |
0:01f31e923fe2 | 39 | return g_board_info.target_cfg->rt_board_id; //flexible board id |
Pawel Zarembski |
0:01f31e923fe2 | 40 | }else{ |
Pawel Zarembski |
0:01f31e923fe2 | 41 | return g_board_info.board_id; |
Pawel Zarembski |
0:01f31e923fe2 | 42 | } |
Pawel Zarembski |
0:01f31e923fe2 | 43 | } |
Pawel Zarembski |
0:01f31e923fe2 | 44 | |
Pawel Zarembski |
0:01f31e923fe2 | 45 | uint16_t get_family_id(void) |
Pawel Zarembski |
0:01f31e923fe2 | 46 | { |
Pawel Zarembski |
0:01f31e923fe2 | 47 | if (g_board_info.target_cfg && g_board_info.target_cfg->rt_family_id) { |
Pawel Zarembski |
0:01f31e923fe2 | 48 | return g_board_info.target_cfg->rt_family_id; //flexible family id |
Pawel Zarembski |
0:01f31e923fe2 | 49 | }else{ |
Pawel Zarembski |
0:01f31e923fe2 | 50 | return g_board_info.family_id; |
Pawel Zarembski |
0:01f31e923fe2 | 51 | } |
Pawel Zarembski |
0:01f31e923fe2 | 52 | } |
Pawel Zarembski |
0:01f31e923fe2 | 53 | |
Pawel Zarembski |
0:01f31e923fe2 | 54 | #if (defined(__ICCARM__)) |
Pawel Zarembski |
0:01f31e923fe2 | 55 | #pragma optimize = none |
Pawel Zarembski |
0:01f31e923fe2 | 56 | uint8_t flash_algo_valid(void) |
Pawel Zarembski |
0:01f31e923fe2 | 57 | #elif (defined(__CC_ARM)) |
Pawel Zarembski |
0:01f31e923fe2 | 58 | #pragma push |
Pawel Zarembski |
0:01f31e923fe2 | 59 | #pragma O0 |
Pawel Zarembski |
0:01f31e923fe2 | 60 | uint8_t flash_algo_valid(void) |
Pawel Zarembski |
0:01f31e923fe2 | 61 | #elif (!defined(__GNUC__)) |
Pawel Zarembski |
0:01f31e923fe2 | 62 | /* #pragma GCC push_options */ |
Pawel Zarembski |
0:01f31e923fe2 | 63 | /* #pragma GCC optimize("O0") */ |
Pawel Zarembski |
0:01f31e923fe2 | 64 | uint8_t __attribute__((optimize("O0"))) flash_algo_valid(void) |
Pawel Zarembski |
0:01f31e923fe2 | 65 | #else |
Pawel Zarembski |
0:01f31e923fe2 | 66 | #error "Unknown compiler" |
Pawel Zarembski |
0:01f31e923fe2 | 67 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 68 | { |
Pawel Zarembski |
0:01f31e923fe2 | 69 | return (g_board_info.target_cfg != 0); |
Pawel Zarembski |
0:01f31e923fe2 | 70 | } |
Pawel Zarembski |
0:01f31e923fe2 | 71 | |
Pawel Zarembski |
0:01f31e923fe2 | 72 | #if (defined(__CC_ARM)) |
Pawel Zarembski |
0:01f31e923fe2 | 73 | #pragma pop |
Pawel Zarembski |
0:01f31e923fe2 | 74 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 75 | #if (defined(__GNUC__)) |
Pawel Zarembski |
0:01f31e923fe2 | 76 | /* #pragma GCC pop_options */ |
Pawel Zarembski |
0:01f31e923fe2 | 77 | #endif |