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 * Copyright (c) 2015, Freescale Semiconductor, Inc.
Pawel Zarembski 0:01f31e923fe2 3 * Copyright 2016-2017 NXP
Pawel Zarembski 0:01f31e923fe2 4 * All rights reserved.
Pawel Zarembski 0:01f31e923fe2 5 *
Pawel Zarembski 0:01f31e923fe2 6 * SPDX-License-Identifier: BSD-3-Clause
Pawel Zarembski 0:01f31e923fe2 7 */
Pawel Zarembski 0:01f31e923fe2 8
Pawel Zarembski 0:01f31e923fe2 9 #include "fsl_dmamux.h"
Pawel Zarembski 0:01f31e923fe2 10 #include "fsl_clock.h"
Pawel Zarembski 0:01f31e923fe2 11
Pawel Zarembski 0:01f31e923fe2 12 /*******************************************************************************
Pawel Zarembski 0:01f31e923fe2 13 * Definitions
Pawel Zarembski 0:01f31e923fe2 14 ******************************************************************************/
Pawel Zarembski 0:01f31e923fe2 15
Pawel Zarembski 0:01f31e923fe2 16 /* Component ID definition, used by tools. */
Pawel Zarembski 0:01f31e923fe2 17 #ifndef FSL_COMPONENT_ID
Pawel Zarembski 0:01f31e923fe2 18 #define FSL_COMPONENT_ID "platform.drivers.dmamux"
Pawel Zarembski 0:01f31e923fe2 19 #endif
Pawel Zarembski 0:01f31e923fe2 20
Pawel Zarembski 0:01f31e923fe2 21 /*******************************************************************************
Pawel Zarembski 0:01f31e923fe2 22 * Prototypes
Pawel Zarembski 0:01f31e923fe2 23 ******************************************************************************/
Pawel Zarembski 0:01f31e923fe2 24
Pawel Zarembski 0:01f31e923fe2 25 /*!
Pawel Zarembski 0:01f31e923fe2 26 * @brief Get instance number for DMAMUX.
Pawel Zarembski 0:01f31e923fe2 27 *
Pawel Zarembski 0:01f31e923fe2 28 * @param base DMAMUX peripheral base address.
Pawel Zarembski 0:01f31e923fe2 29 */
Pawel Zarembski 0:01f31e923fe2 30 static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base);
Pawel Zarembski 0:01f31e923fe2 31
Pawel Zarembski 0:01f31e923fe2 32 /*******************************************************************************
Pawel Zarembski 0:01f31e923fe2 33 * Variables
Pawel Zarembski 0:01f31e923fe2 34 ******************************************************************************/
Pawel Zarembski 0:01f31e923fe2 35
Pawel Zarembski 0:01f31e923fe2 36 /*! @brief Array to map DMAMUX instance number to base pointer. */
Pawel Zarembski 0:01f31e923fe2 37 static DMAMUX_Type *const s_dmamuxBases[] = DMAMUX_BASE_PTRS;
Pawel Zarembski 0:01f31e923fe2 38
Pawel Zarembski 0:01f31e923fe2 39 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
Pawel Zarembski 0:01f31e923fe2 40 /*! @brief Array to map DMAMUX instance number to clock name. */
Pawel Zarembski 0:01f31e923fe2 41 static const clock_ip_name_t s_dmamuxClockName[] = DMAMUX_CLOCKS;
Pawel Zarembski 0:01f31e923fe2 42 #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
Pawel Zarembski 0:01f31e923fe2 43
Pawel Zarembski 0:01f31e923fe2 44 /*******************************************************************************
Pawel Zarembski 0:01f31e923fe2 45 * Code
Pawel Zarembski 0:01f31e923fe2 46 ******************************************************************************/
Pawel Zarembski 0:01f31e923fe2 47 static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base)
Pawel Zarembski 0:01f31e923fe2 48 {
Pawel Zarembski 0:01f31e923fe2 49 uint32_t instance;
Pawel Zarembski 0:01f31e923fe2 50
Pawel Zarembski 0:01f31e923fe2 51 /* Find the instance index from base address mappings. */
Pawel Zarembski 0:01f31e923fe2 52 for (instance = 0; instance < ARRAY_SIZE(s_dmamuxBases); instance++)
Pawel Zarembski 0:01f31e923fe2 53 {
Pawel Zarembski 0:01f31e923fe2 54 if (s_dmamuxBases[instance] == base)
Pawel Zarembski 0:01f31e923fe2 55 {
Pawel Zarembski 0:01f31e923fe2 56 break;
Pawel Zarembski 0:01f31e923fe2 57 }
Pawel Zarembski 0:01f31e923fe2 58 }
Pawel Zarembski 0:01f31e923fe2 59
Pawel Zarembski 0:01f31e923fe2 60 assert(instance < ARRAY_SIZE(s_dmamuxBases));
Pawel Zarembski 0:01f31e923fe2 61
Pawel Zarembski 0:01f31e923fe2 62 return instance;
Pawel Zarembski 0:01f31e923fe2 63 }
Pawel Zarembski 0:01f31e923fe2 64
Pawel Zarembski 0:01f31e923fe2 65 /*!
Pawel Zarembski 0:01f31e923fe2 66 * brief Initializes the DMAMUX peripheral.
Pawel Zarembski 0:01f31e923fe2 67 *
Pawel Zarembski 0:01f31e923fe2 68 * This function ungates the DMAMUX clock.
Pawel Zarembski 0:01f31e923fe2 69 *
Pawel Zarembski 0:01f31e923fe2 70 * param base DMAMUX peripheral base address.
Pawel Zarembski 0:01f31e923fe2 71 *
Pawel Zarembski 0:01f31e923fe2 72 */
Pawel Zarembski 0:01f31e923fe2 73 void DMAMUX_Init(DMAMUX_Type *base)
Pawel Zarembski 0:01f31e923fe2 74 {
Pawel Zarembski 0:01f31e923fe2 75 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
Pawel Zarembski 0:01f31e923fe2 76 CLOCK_EnableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]);
Pawel Zarembski 0:01f31e923fe2 77 #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
Pawel Zarembski 0:01f31e923fe2 78 }
Pawel Zarembski 0:01f31e923fe2 79
Pawel Zarembski 0:01f31e923fe2 80 /*!
Pawel Zarembski 0:01f31e923fe2 81 * brief Deinitializes the DMAMUX peripheral.
Pawel Zarembski 0:01f31e923fe2 82 *
Pawel Zarembski 0:01f31e923fe2 83 * This function gates the DMAMUX clock.
Pawel Zarembski 0:01f31e923fe2 84 *
Pawel Zarembski 0:01f31e923fe2 85 * param base DMAMUX peripheral base address.
Pawel Zarembski 0:01f31e923fe2 86 */
Pawel Zarembski 0:01f31e923fe2 87 void DMAMUX_Deinit(DMAMUX_Type *base)
Pawel Zarembski 0:01f31e923fe2 88 {
Pawel Zarembski 0:01f31e923fe2 89 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
Pawel Zarembski 0:01f31e923fe2 90 CLOCK_DisableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]);
Pawel Zarembski 0:01f31e923fe2 91 #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
Pawel Zarembski 0:01f31e923fe2 92 }