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 lpc43xx_scu.c
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) 2009-2016, 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 /* Includes ------------------------------------------------------------------- */
Pawel Zarembski 0:01f31e923fe2 23 #include "LPC43xx.h" /* lpc43xx definitions */
Pawel Zarembski 0:01f31e923fe2 24 #include "lpc_types.h"
Pawel Zarembski 0:01f31e923fe2 25 #include "lpc43xx_scu.h"
Pawel Zarembski 0:01f31e923fe2 26
Pawel Zarembski 0:01f31e923fe2 27 /* Pin modes
Pawel Zarembski 0:01f31e923fe2 28 * =========
Pawel Zarembski 0:01f31e923fe2 29 * The EPUN and EPD bits in the SFS registers allow the selection of weak on-chip
Pawel Zarembski 0:01f31e923fe2 30 * pull-up or pull-down resistors with a typical value of 50 kOhm for each pin or the
Pawel Zarembski 0:01f31e923fe2 31 * selection of the repeater mode.
Pawel Zarembski 0:01f31e923fe2 32 * The possible on-chip resistor configurations are pull-up enabled, pull-down enabled, or no
Pawel Zarembski 0:01f31e923fe2 33 * pull-up/pull-down. The default value is pull-up enabled.
Pawel Zarembski 0:01f31e923fe2 34 *
Pawel Zarembski 0:01f31e923fe2 35 * The repeater mode enables the pull-up resistor if the pin is at a logic HIGH and enables
Pawel Zarembski 0:01f31e923fe2 36 * the pull-down resistor if the pin is at a logic LOW. This causes the pin to retain its last
Pawel Zarembski 0:01f31e923fe2 37 * known state if it is configured as an input and is not driven externally. Repeater mode may
Pawel Zarembski 0:01f31e923fe2 38 * typically be used to prevent a pin from floating (and potentially using significant power if it
Pawel Zarembski 0:01f31e923fe2 39 * floats to an indeterminate state) if it is temporarily not driven.
Pawel Zarembski 0:01f31e923fe2 40 * Repeater mode is enabled when both pull-up and pull-down are enabled.
Pawel Zarembski 0:01f31e923fe2 41 *
Pawel Zarembski 0:01f31e923fe2 42 * To be able to receive a digital signal, the input buffer must be enabled through bit EZI in
Pawel Zarembski 0:01f31e923fe2 43 * the pin configuration registers. By default, the input buffer is disabled.
Pawel Zarembski 0:01f31e923fe2 44 * For pads that support both a digital and an analog function, the input buffer must be
Pawel Zarembski 0:01f31e923fe2 45 * disabled before enabling the analog function.
Pawel Zarembski 0:01f31e923fe2 46 *
Pawel Zarembski 0:01f31e923fe2 47 * All digital pins support a programmable glitch filter (bit ZIF), which can be switched on or
Pawel Zarembski 0:01f31e923fe2 48 * off. By default, the glitch filter is on. The glitch filter should be disabled for
Pawel Zarembski 0:01f31e923fe2 49 * clocking signals with frequencies higher than 30 MHz.
Pawel Zarembski 0:01f31e923fe2 50 *
Pawel Zarembski 0:01f31e923fe2 51 * Normal-drive and high-speed pins support a programmable slew rate (bit EHS) to select
Pawel Zarembski 0:01f31e923fe2 52 * between lower noise and low speed or higher noise and high speed . The typical
Pawel Zarembski 0:01f31e923fe2 53 * frequencies supported are 50 MHz/80 MHz for normal-drive pins and 75 MHz/180 MHz for
Pawel Zarembski 0:01f31e923fe2 54 * high-speed pins.
Pawel Zarembski 0:01f31e923fe2 55 */
Pawel Zarembski 0:01f31e923fe2 56
Pawel Zarembski 0:01f31e923fe2 57 /*********************************************************************//**
Pawel Zarembski 0:01f31e923fe2 58 * @brief Configure pin function
Pawel Zarembski 0:01f31e923fe2 59 * @param[in] port Port number, should be: 0..15
Pawel Zarembski 0:01f31e923fe2 60 * @param[in] pin Pin number, should be: 0..31
Pawel Zarembski 0:01f31e923fe2 61 * @param[in] mode Pin mode, should be:
Pawel Zarembski 0:01f31e923fe2 62 * - MD_PUP :Pull-up enabled
Pawel Zarembski 0:01f31e923fe2 63 * - MD_BUK :Plain input
Pawel Zarembski 0:01f31e923fe2 64 * - MD_PLN :Repeater mode
Pawel Zarembski 0:01f31e923fe2 65 * - MD_PDN :Pull-down enabled
Pawel Zarembski 0:01f31e923fe2 66 * - MD_EHS :Slew rate
Pawel Zarembski 0:01f31e923fe2 67 * - MD_EZI :Input buffer enable
Pawel Zarembski 0:01f31e923fe2 68 * - MD_ZI :Glitch filter enabled
Pawel Zarembski 0:01f31e923fe2 69 * - MD_EHD0 :High drive 8 mA
Pawel Zarembski 0:01f31e923fe2 70 * - MD_EHD1 :High drive 14 mA
Pawel Zarembski 0:01f31e923fe2 71 * - MD_EHD2 :High drive 20 mA
Pawel Zarembski 0:01f31e923fe2 72 * @param[in] func Function mode, should be:
Pawel Zarembski 0:01f31e923fe2 73 * - FUNC0 :Function 0
Pawel Zarembski 0:01f31e923fe2 74 * - FUNC1 :Function 1
Pawel Zarembski 0:01f31e923fe2 75 * - FUNC2 :Function 2
Pawel Zarembski 0:01f31e923fe2 76 * - FUNC3 :Function 3
Pawel Zarembski 0:01f31e923fe2 77 * - FUNC4 :Function 4
Pawel Zarembski 0:01f31e923fe2 78 * - FUNC5 :Function 5
Pawel Zarembski 0:01f31e923fe2 79 * - FUNC6 :Function 6
Pawel Zarembski 0:01f31e923fe2 80 * - FUNC7 :Function 7
Pawel Zarembski 0:01f31e923fe2 81 * @return None
Pawel Zarembski 0:01f31e923fe2 82 **********************************************************************/
Pawel Zarembski 0:01f31e923fe2 83 void scu_pinmux(uint8_t port, uint8_t pin, uint8_t mode, uint8_t func)
Pawel Zarembski 0:01f31e923fe2 84 {
Pawel Zarembski 0:01f31e923fe2 85 uint32_t *scu_base = (uint32_t *)(LPC_SCU_BASE);
Pawel Zarembski 0:01f31e923fe2 86 scu_base[(PORT_OFFSET * port + PIN_OFFSET * pin) / 4] = mode + func;
Pawel Zarembski 0:01f31e923fe2 87 } /* scu_pinmux */