Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.

Upstream: https://github.com/ARMmbed/DAPLink

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?

UserRevisionLine numberNew contents of line
Pawel Zarembski 0:01f31e923fe2 1 /**
Pawel Zarembski 0:01f31e923fe2 2 * @file target_board.h
Pawel Zarembski 0:01f31e923fe2 3 * @brief
Pawel Zarembski 0:01f31e923fe2 4 *
Pawel Zarembski 0:01f31e923fe2 5 * DAPLink Interface Firmware
Pawel Zarembski 0:01f31e923fe2 6 * Copyright (c) 2018-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 #ifndef TARGET_BOARD_H
Pawel Zarembski 0:01f31e923fe2 23 #define TARGET_BOARD_H
Pawel Zarembski 0:01f31e923fe2 24
Pawel Zarembski 0:01f31e923fe2 25 #include <stdint.h>
Pawel Zarembski 0:01f31e923fe2 26 #include "target_config.h"
Pawel Zarembski 0:01f31e923fe2 27 #include "target_family.h"
Pawel Zarembski 0:01f31e923fe2 28 #include "virtual_fs.h"
Pawel Zarembski 0:01f31e923fe2 29
Pawel Zarembski 0:01f31e923fe2 30 //! @brief Current board info version.
Pawel Zarembski 0:01f31e923fe2 31 //!
Pawel Zarembski 0:01f31e923fe2 32 //! - Version 1: Initial version.
Pawel Zarembski 0:01f31e923fe2 33 enum _board_info_version {
Pawel Zarembski 0:01f31e923fe2 34 kBoardInfoVersion = 1, //!< The current board info version.
Pawel Zarembski 0:01f31e923fe2 35 };
Pawel Zarembski 0:01f31e923fe2 36
Pawel Zarembski 0:01f31e923fe2 37 //! @brief Flags for board_info
Pawel Zarembski 0:01f31e923fe2 38 enum _board_info_flags {
Pawel Zarembski 0:01f31e923fe2 39 kEnablePageErase = (1 << 0), /*!< Enable page programming and sector erase for drag and drop */
Pawel Zarembski 0:01f31e923fe2 40 kEnableUnderResetConnect = (1 << 1), /*!< Enable under reset connection when enabling debug mode */
Pawel Zarembski 0:01f31e923fe2 41 };
Pawel Zarembski 0:01f31e923fe2 42
Pawel Zarembski 0:01f31e923fe2 43 /*!
Pawel Zarembski 0:01f31e923fe2 44 * @brief Board customization info.
Pawel Zarembski 0:01f31e923fe2 45 *
Pawel Zarembski 0:01f31e923fe2 46 * Each board must have a unique 4-character Board ID. For Mbed OS targets, the Board ID is the same
Pawel Zarembski 0:01f31e923fe2 47 * as the Mbed Platform ID. These IDs are nominally allocated by Arm in order to guarantee there are
Pawel Zarembski 0:01f31e923fe2 48 * no conflicts between boards. Please see the DAPLink documentation for more.
Pawel Zarembski 0:01f31e923fe2 49 *
Pawel Zarembski 0:01f31e923fe2 50 * The family_id member tells DAPLink which device family the on-board target belongs to. This then
Pawel Zarembski 0:01f31e923fe2 51 * determines certain behaviours, such as how to reset the target. Family IDs are defined in the
Pawel Zarembski 0:01f31e923fe2 52 * #family_id_t enumeration.
Pawel Zarembski 0:01f31e923fe2 53 *
Pawel Zarembski 0:01f31e923fe2 54 * The board initialization function pointers allow the board to override the routines defined
Pawel Zarembski 0:01f31e923fe2 55 * by the device family.
Pawel Zarembski 0:01f31e923fe2 56 */
Pawel Zarembski 0:01f31e923fe2 57 typedef struct __attribute__((__packed__)) board_info {
Pawel Zarembski 0:01f31e923fe2 58 uint16_t info_version; /*!< Version number of the board info */
Pawel Zarembski 0:01f31e923fe2 59 uint16_t family_id; /*!< Use to select or identify target family from defined target family or custom ones */
Pawel Zarembski 0:01f31e923fe2 60 char board_id[5]; /*!< 4-char board ID plus null terminator */
Pawel Zarembski 0:01f31e923fe2 61 uint8_t _padding[3];
Pawel Zarembski 0:01f31e923fe2 62 uint32_t flags; /*!< Flags from #_board_info_flags */
Pawel Zarembski 0:01f31e923fe2 63 target_cfg_t *target_cfg; /*!< Specific chip configuration for the target and enables MSD when non-NULL */
Pawel Zarembski 0:01f31e923fe2 64
Pawel Zarembski 0:01f31e923fe2 65 //! @name MSD customization
Pawel Zarembski 0:01f31e923fe2 66 //@{
Pawel Zarembski 0:01f31e923fe2 67 vfs_filename_t daplink_url_name; /*!< Customize the URL file name */
Pawel Zarembski 0:01f31e923fe2 68 vfs_filename_t daplink_drive_name; /*!< Customize the MSD DAPLink drive name */
Pawel Zarembski 0:01f31e923fe2 69 char daplink_target_url[64]; /*!< Customize the target url in DETAILS.TXT */
Pawel Zarembski 0:01f31e923fe2 70 //@}
Pawel Zarembski 0:01f31e923fe2 71
Pawel Zarembski 0:01f31e923fe2 72 //! @name Board initialization customization
Pawel Zarembski 0:01f31e923fe2 73 //@{
Pawel Zarembski 0:01f31e923fe2 74 void (*prerun_board_config)(void); /*!< Specific board debug/ID related initialization */
Pawel Zarembski 0:01f31e923fe2 75 void (*swd_set_target_reset)(uint8_t asserted); /*!< Boards can customize how to send reset to the target with precedence over target family */
Pawel Zarembski 0:01f31e923fe2 76 uint8_t (*target_set_state)(target_state_t state); /*!< Boards can customize target debug states with precedence over target family */
Pawel Zarembski 0:01f31e923fe2 77 uint32_t soft_reset_type; /*!< Boards can override software reset type to VECTRESET or SYSRESETREQ */
Pawel Zarembski 0:01f31e923fe2 78 //@}
Pawel Zarembski 0:01f31e923fe2 79 } board_info_t;
Pawel Zarembski 0:01f31e923fe2 80
Pawel Zarembski 0:01f31e923fe2 81 //! @brief Information describing the board on which DAPLink is running.
Pawel Zarembski 0:01f31e923fe2 82 extern const board_info_t g_board_info;
Pawel Zarembski 0:01f31e923fe2 83
Pawel Zarembski 0:01f31e923fe2 84 #ifdef __cplusplus
Pawel Zarembski 0:01f31e923fe2 85 extern "C" {
Pawel Zarembski 0:01f31e923fe2 86 #endif
Pawel Zarembski 0:01f31e923fe2 87
Pawel Zarembski 0:01f31e923fe2 88 //! @brief Returns the 4-char ID of the board used by the running firmware.
Pawel Zarembski 0:01f31e923fe2 89 //!
Pawel Zarembski 0:01f31e923fe2 90 //! For firmware with no board, the board ID is "0000".
Pawel Zarembski 0:01f31e923fe2 91 const char * get_board_id(void);
Pawel Zarembski 0:01f31e923fe2 92
Pawel Zarembski 0:01f31e923fe2 93 //! @brief Returns the family ID for the target associated with the board.
Pawel Zarembski 0:01f31e923fe2 94 //!
Pawel Zarembski 0:01f31e923fe2 95 //! The family ID will be 0 if there is no board.
Pawel Zarembski 0:01f31e923fe2 96 uint16_t get_family_id(void);
Pawel Zarembski 0:01f31e923fe2 97
Pawel Zarembski 0:01f31e923fe2 98 //! @brief Whether the board has a valid flash algo.
Pawel Zarembski 0:01f31e923fe2 99 uint8_t flash_algo_valid(void);
Pawel Zarembski 0:01f31e923fe2 100
Pawel Zarembski 0:01f31e923fe2 101 //! @brief Returns the MSD HTML help filename or a default.
Pawel Zarembski 0:01f31e923fe2 102 static inline const char * get_daplink_url_name ( void ) { return ((g_board_info.daplink_url_name[0] != 0) ? g_board_info.daplink_url_name : "MBED HTM"); }
Pawel Zarembski 0:01f31e923fe2 103
Pawel Zarembski 0:01f31e923fe2 104 //! @brief Returns the MSD volume name or a default.
Pawel Zarembski 0:01f31e923fe2 105 static inline const char * get_daplink_drive_name ( void ) { return ((g_board_info.daplink_drive_name[0] != 0) ? g_board_info.daplink_drive_name : "DAPLINK "); }
Pawel Zarembski 0:01f31e923fe2 106
Pawel Zarembski 0:01f31e923fe2 107 //! @brief Returns the target information URL or a default.
Pawel Zarembski 0:01f31e923fe2 108 static inline const char * get_daplink_target_url ( void ) { return ((g_board_info.daplink_target_url[0] != 0) ? g_board_info.daplink_target_url : "https://mbed.org/device/?code=@U?version=@V?target_id=@T"); }
Pawel Zarembski 0:01f31e923fe2 109
Pawel Zarembski 0:01f31e923fe2 110 #ifdef __cplusplus
Pawel Zarembski 0:01f31e923fe2 111 }
Pawel Zarembski 0:01f31e923fe2 112 #endif
Pawel Zarembski 0:01f31e923fe2 113
Pawel Zarembski 0:01f31e923fe2 114 #endif