mbed library sources. Supersedes mbed-src.

Fork of mbed by teralytic

Committer:
rodriguise
Date:
Mon Oct 17 18:47:01 2016 +0000
Revision:
148:4802eb17e82b
Parent:
147:30b64687e01f
backup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 #ifdef REVD
<> 144:ef7eb2e8f9f7 2 /**
<> 144:ef7eb2e8f9f7 3 ******************************************************************************
<> 144:ef7eb2e8f9f7 4 * @file pad.c
<> 144:ef7eb2e8f9f7 5 * @brief PAD management support code
<> 144:ef7eb2e8f9f7 6 * @internal
<> 144:ef7eb2e8f9f7 7 * @author ON Semiconductor
<> 144:ef7eb2e8f9f7 8 * $Rev: 2848 $
<> 144:ef7eb2e8f9f7 9 * $Date: 2014-04-01 22:48:18 +0530 (Tue, 01 Apr 2014) $
<> 144:ef7eb2e8f9f7 10 ******************************************************************************
<> 147:30b64687e01f 11 * Copyright 2016 Semiconductor Components Industries LLC (d/b/a “ON Semiconductor”).
<> 147:30b64687e01f 12 * All rights reserved. This software and/or documentation is licensed by ON Semiconductor
<> 147:30b64687e01f 13 * under limited terms and conditions. The terms and conditions pertaining to the software
<> 147:30b64687e01f 14 * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf
<> 147:30b64687e01f 15 * (“ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software”) and
<> 147:30b64687e01f 16 * if applicable the software license agreement. Do not use this software and/or
<> 147:30b64687e01f 17 * documentation unless you have carefully read and you agree to the limited terms and
<> 147:30b64687e01f 18 * conditions. By using this software and/or documentation, you agree to the limited
<> 147:30b64687e01f 19 * terms and conditions.
<> 144:ef7eb2e8f9f7 20 *
<> 144:ef7eb2e8f9f7 21 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
<> 144:ef7eb2e8f9f7 22 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
<> 144:ef7eb2e8f9f7 23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
<> 144:ef7eb2e8f9f7 24 * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,
<> 144:ef7eb2e8f9f7 25 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
<> 144:ef7eb2e8f9f7 26 * @endinternal
<> 144:ef7eb2e8f9f7 27 *
<> 144:ef7eb2e8f9f7 28 * @ingroup pad
<> 144:ef7eb2e8f9f7 29 *
<> 144:ef7eb2e8f9f7 30 * @details
<> 144:ef7eb2e8f9f7 31 */
<> 144:ef7eb2e8f9f7 32
<> 144:ef7eb2e8f9f7 33 /*************************************************************************************************
<> 144:ef7eb2e8f9f7 34 * *
<> 144:ef7eb2e8f9f7 35 * Header files *
<> 144:ef7eb2e8f9f7 36 * *
<> 144:ef7eb2e8f9f7 37 *************************************************************************************************/
<> 144:ef7eb2e8f9f7 38
<> 144:ef7eb2e8f9f7 39 #include "memory_map.h"
<> 144:ef7eb2e8f9f7 40 #include "pad_map.h"
<> 144:ef7eb2e8f9f7 41 #include "clock.h"
<> 144:ef7eb2e8f9f7 42
<> 144:ef7eb2e8f9f7 43 /*************************************************************************************************
<> 144:ef7eb2e8f9f7 44 * *
<> 144:ef7eb2e8f9f7 45 * Symbolic Constants *
<> 144:ef7eb2e8f9f7 46 * *
<> 144:ef7eb2e8f9f7 47 *************************************************************************************************/
<> 144:ef7eb2e8f9f7 48 #define PAD_CTRL_OP_DRIVE_STRENGTH_MASK (uint32_t)0x1C
<> 144:ef7eb2e8f9f7 49 #define PAD_NUM_OF_IO 17
<> 144:ef7eb2e8f9f7 50 #define PAD_OP_DRIVE_STRGTH_MAX 7
<> 144:ef7eb2e8f9f7 51 #define PAD_OP_DRIVE_TYPE_MAX 1
<> 144:ef7eb2e8f9f7 52 #define PAD_OP_PULL_TYPE_MAX 3
<> 144:ef7eb2e8f9f7 53
<> 144:ef7eb2e8f9f7 54 #define PAD_REG_ADRS_BYTE_SIZE 4
<> 144:ef7eb2e8f9f7 55
<> 144:ef7eb2e8f9f7 56 #define PAD_OP_DRIVE_STRGTH_BIT_POS 2
<> 144:ef7eb2e8f9f7 57 #define PAD_OP_DRIVE_TYPE_BIT_POS 5
<> 144:ef7eb2e8f9f7 58 #define PAD_OP_PULL_TYPE_BIT_POS 0
<> 144:ef7eb2e8f9f7 59
<> 144:ef7eb2e8f9f7 60 /*************************************************************************************************
<> 144:ef7eb2e8f9f7 61 * *
<> 144:ef7eb2e8f9f7 62 * Global variables *
<> 144:ef7eb2e8f9f7 63 * *
<> 144:ef7eb2e8f9f7 64 *************************************************************************************************/
<> 144:ef7eb2e8f9f7 65
<> 144:ef7eb2e8f9f7 66 /* Peripheral PAD register mutex */
<> 144:ef7eb2e8f9f7 67 /* sem_pt GlobMutexPadReg; */
<> 144:ef7eb2e8f9f7 68
<> 144:ef7eb2e8f9f7 69 /*************************************************************************************************
<> 144:ef7eb2e8f9f7 70 * *
<> 144:ef7eb2e8f9f7 71 * Functions *
<> 144:ef7eb2e8f9f7 72 * *
<> 144:ef7eb2e8f9f7 73 *************************************************************************************************/
<> 144:ef7eb2e8f9f7 74
<> 144:ef7eb2e8f9f7 75 /** Find description at pad.h */
<> 144:ef7eb2e8f9f7 76 void fPadInit()
<> 144:ef7eb2e8f9f7 77 {
<> 144:ef7eb2e8f9f7 78 /** - Enable the clock for PAD peripheral device */
<> 144:ef7eb2e8f9f7 79 CLOCK_ENABLE(CLOCK_PAD);
<> 144:ef7eb2e8f9f7 80
<> 144:ef7eb2e8f9f7 81 /** - Set pad parameters, output drive strength, pull piece control, output drive type */
<> 144:ef7eb2e8f9f7 82 PADREG->PADIO0.WORD = PAD_OUTPUT_PN_L1_OD; /* UART1 TXD */
<> 144:ef7eb2e8f9f7 83 PADREG->PADIO1.WORD = PAD_INPUT_PD_L1_PP; /* UART1 RXD */
<> 144:ef7eb2e8f9f7 84 PADREG->PADIO2.WORD = PAD_INPUT_PD_L1_PP; /* UART1 CTS */
<> 144:ef7eb2e8f9f7 85 PADREG->PADIO3.WORD = PAD_OUTPUT_PN_L1_OD; /* UART1 RTS */
<> 144:ef7eb2e8f9f7 86 PADREG->PADIO4.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 87 PADREG->PADIO5.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 88 PADREG->PADIO6.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 89 PADREG->PADIO7.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 90 PADREG->PADIO8.WORD = PAD_OUTPUT_PN_L1_OD; /* UART2 TXD */
<> 144:ef7eb2e8f9f7 91 PADREG->PADIO9.WORD = PAD_INPUT_PD_L1_PP; /* UART2 RXD */
<> 144:ef7eb2e8f9f7 92 PADREG->PADIO10.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 93 PADREG->PADIO11.WORD = PAD_INPUT_PD_L1_PP; /* SWO */
<> 144:ef7eb2e8f9f7 94 PADREG->PADIO12.WORD = PAD_INPUT_PD_L1_PP; /* SWCLK */
<> 144:ef7eb2e8f9f7 95 PADREG->PADIO13.WORD = PAD_INPUT_PD_L1_PP; /* SWDIO */
<> 144:ef7eb2e8f9f7 96 PADREG->PADIO14.WORD = PAD_INPUT_PD_L1_PP;
<> 144:ef7eb2e8f9f7 97 PADREG->PADIO15.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 98 PADREG->PADIO16.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 99 PADREG->PADIO17.WORD = PAD_UNUSED_PD_L0_PP;
<> 144:ef7eb2e8f9f7 100
<> 144:ef7eb2e8f9f7 101 /** - Disable the clock for PAD peripheral device */
<> 144:ef7eb2e8f9f7 102 CLOCK_DISABLE(CLOCK_PAD);
<> 144:ef7eb2e8f9f7 103
<> 144:ef7eb2e8f9f7 104 }
<> 144:ef7eb2e8f9f7 105
<> 144:ef7eb2e8f9f7 106 /** Find description at pad.h */
<> 144:ef7eb2e8f9f7 107 boolean fPadIOCtrl(uint8_t PadNum, uint8_t OutputDriveStrength, uint8_t OutputDriveType, uint8_t PullType)
<> 144:ef7eb2e8f9f7 108 {
<> 144:ef7eb2e8f9f7 109 PadReg_t *PadRegOffset;
<> 144:ef7eb2e8f9f7 110 /** \verbatim
<> 144:ef7eb2e8f9f7 111 Table: O/p drive strength
<> 144:ef7eb2e8f9f7 112
<> 144:ef7eb2e8f9f7 113 Drive strength 3.3V (min/typ/max) 1V (min/typ/max)
<> 144:ef7eb2e8f9f7 114 000 1/1.4/2.1 mA 0.043/0.07/0.11 mA
<> 144:ef7eb2e8f9f7 115 001 2/2.7/4.1 mA 0.086/0.15/0.215 mA
<> 144:ef7eb2e8f9f7 116 010 4.1/5.3/7.8 mA 0.188/0.3/0.4 mA
<> 144:ef7eb2e8f9f7 117 011 8.1/10.4/15 8 mA 0.4/0.6/0.81 mA
<> 144:ef7eb2e8f9f7 118 100 20.8/26/37 mA* 1/1.6/2.2 mA
<> 144:ef7eb2e8f9f7 119 101 40.5/50/70 mA* 2/3/4.3 mA
<> 144:ef7eb2e8f9f7 120 11x 57/73/102 mA* 3/4.6/6.2 mA
<> 144:ef7eb2e8f9f7 121
<> 144:ef7eb2e8f9f7 122 *Values are only accessible when CDBGPWRUPREQ is high. This limits the maximum output current in functional mode. \endverbatim */
<> 144:ef7eb2e8f9f7 123
<> 144:ef7eb2e8f9f7 124
<> 144:ef7eb2e8f9f7 125 if((PadNum <= PAD_NUM_OF_IO) &&
<> 144:ef7eb2e8f9f7 126 (OutputDriveStrength <= PAD_OP_DRIVE_STRGTH_MAX) &&
<> 144:ef7eb2e8f9f7 127 (OutputDriveType <= PAD_OP_DRIVE_TYPE_MAX) && (PullType <= PAD_OP_PULL_TYPE_MAX)) {
<> 144:ef7eb2e8f9f7 128 /** - Get PAD IO register address for the PAD number */
<> 144:ef7eb2e8f9f7 129 PadRegOffset = (PadReg_t*)(PADREG_BASE + (PadNum * PAD_REG_ADRS_BYTE_SIZE));
<> 144:ef7eb2e8f9f7 130
<> 144:ef7eb2e8f9f7 131 /** - Enable the clock for PAD peripheral device */
<> 144:ef7eb2e8f9f7 132 CLOCK_ENABLE(CLOCK_PAD);
<> 144:ef7eb2e8f9f7 133
<> 144:ef7eb2e8f9f7 134 /** - Set drive type, pulltype & drive strength */
<> 144:ef7eb2e8f9f7 135 PadRegOffset->PADIO0.WORD = (uint32_t)((PullType << PAD_OP_PULL_TYPE_BIT_POS) |
<> 144:ef7eb2e8f9f7 136 (OutputDriveStrength << PAD_OP_DRIVE_STRGTH_BIT_POS) |
<> 144:ef7eb2e8f9f7 137 (OutputDriveType << PAD_OP_DRIVE_TYPE_BIT_POS));
<> 144:ef7eb2e8f9f7 138
<> 144:ef7eb2e8f9f7 139 /** - Disable the clock for PAD peripheral device */
<> 144:ef7eb2e8f9f7 140 CLOCK_DISABLE(CLOCK_PAD);
<> 144:ef7eb2e8f9f7 141 return True;
<> 144:ef7eb2e8f9f7 142 }
<> 144:ef7eb2e8f9f7 143 /* Invalid parameter/s */
<> 144:ef7eb2e8f9f7 144 return False;
<> 144:ef7eb2e8f9f7 145 }
<> 144:ef7eb2e8f9f7 146 #endif /* REVD */