Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: targets/hal/TARGET_ONSEMI/TARGET_NCS36510/Pad.c
- Revision:
- 144:ef7eb2e8f9f7
- Child:
- 147:30b64687e01f
diff -r 423e1876dc07 -r ef7eb2e8f9f7 targets/hal/TARGET_ONSEMI/TARGET_NCS36510/Pad.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/hal/TARGET_ONSEMI/TARGET_NCS36510/Pad.c Fri Sep 02 15:07:44 2016 +0100
@@ -0,0 +1,140 @@
+#ifdef REVD
+/**
+******************************************************************************
+* @file pad.c
+* @brief PAD management support code
+* @internal
+* @author ON Semiconductor
+* $Rev: 2848 $
+* $Date: 2014-04-01 22:48:18 +0530 (Tue, 01 Apr 2014) $
+******************************************************************************
+* @copyright (c) 2012 ON Semiconductor. All rights reserved.
+* ON Semiconductor is supplying this software for use with ON Semiconductor
+* processor based microcontrollers only.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+* ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,
+* INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+* @endinternal
+*
+* @ingroup pad
+*
+* @details
+*/
+
+/*************************************************************************************************
+* *
+* Header files *
+* *
+*************************************************************************************************/
+
+#include "memory_map.h"
+#include "pad_map.h"
+#include "clock.h"
+
+/*************************************************************************************************
+* *
+* Symbolic Constants *
+* *
+*************************************************************************************************/
+#define PAD_CTRL_OP_DRIVE_STRENGTH_MASK (uint32_t)0x1C
+#define PAD_NUM_OF_IO 17
+#define PAD_OP_DRIVE_STRGTH_MAX 7
+#define PAD_OP_DRIVE_TYPE_MAX 1
+#define PAD_OP_PULL_TYPE_MAX 3
+
+#define PAD_REG_ADRS_BYTE_SIZE 4
+
+#define PAD_OP_DRIVE_STRGTH_BIT_POS 2
+#define PAD_OP_DRIVE_TYPE_BIT_POS 5
+#define PAD_OP_PULL_TYPE_BIT_POS 0
+
+/*************************************************************************************************
+* *
+* Global variables *
+* *
+*************************************************************************************************/
+
+/* Peripheral PAD register mutex */
+/* sem_pt GlobMutexPadReg; */
+
+/*************************************************************************************************
+* *
+* Functions *
+* *
+*************************************************************************************************/
+
+/** Find description at pad.h */
+void fPadInit()
+{
+ /** - Enable the clock for PAD peripheral device */
+ CLOCK_ENABLE(CLOCK_PAD);
+
+ /** - Set pad parameters, output drive strength, pull piece control, output drive type */
+ PADREG->PADIO0.WORD = PAD_OUTPUT_PN_L1_OD; /* UART1 TXD */
+ PADREG->PADIO1.WORD = PAD_INPUT_PD_L1_PP; /* UART1 RXD */
+ PADREG->PADIO2.WORD = PAD_INPUT_PD_L1_PP; /* UART1 CTS */
+ PADREG->PADIO3.WORD = PAD_OUTPUT_PN_L1_OD; /* UART1 RTS */
+ PADREG->PADIO4.WORD = PAD_UNUSED_PD_L0_PP;
+ PADREG->PADIO5.WORD = PAD_UNUSED_PD_L0_PP;
+ PADREG->PADIO6.WORD = PAD_UNUSED_PD_L0_PP;
+ PADREG->PADIO7.WORD = PAD_UNUSED_PD_L0_PP;
+ PADREG->PADIO8.WORD = PAD_OUTPUT_PN_L1_OD; /* UART2 TXD */
+ PADREG->PADIO9.WORD = PAD_INPUT_PD_L1_PP; /* UART2 RXD */
+ PADREG->PADIO10.WORD = PAD_UNUSED_PD_L0_PP;
+ PADREG->PADIO11.WORD = PAD_INPUT_PD_L1_PP; /* SWO */
+ PADREG->PADIO12.WORD = PAD_INPUT_PD_L1_PP; /* SWCLK */
+ PADREG->PADIO13.WORD = PAD_INPUT_PD_L1_PP; /* SWDIO */
+ PADREG->PADIO14.WORD = PAD_INPUT_PD_L1_PP;
+ PADREG->PADIO15.WORD = PAD_UNUSED_PD_L0_PP;
+ PADREG->PADIO16.WORD = PAD_UNUSED_PD_L0_PP;
+ PADREG->PADIO17.WORD = PAD_UNUSED_PD_L0_PP;
+
+ /** - Disable the clock for PAD peripheral device */
+ CLOCK_DISABLE(CLOCK_PAD);
+
+}
+
+/** Find description at pad.h */
+boolean fPadIOCtrl(uint8_t PadNum, uint8_t OutputDriveStrength, uint8_t OutputDriveType, uint8_t PullType)
+{
+ PadReg_t *PadRegOffset;
+ /** \verbatim
+ Table: O/p drive strength
+
+ Drive strength 3.3V (min/typ/max) 1V (min/typ/max)
+ 000 1/1.4/2.1 mA 0.043/0.07/0.11 mA
+ 001 2/2.7/4.1 mA 0.086/0.15/0.215 mA
+ 010 4.1/5.3/7.8 mA 0.188/0.3/0.4 mA
+ 011 8.1/10.4/15 8 mA 0.4/0.6/0.81 mA
+ 100 20.8/26/37 mA* 1/1.6/2.2 mA
+ 101 40.5/50/70 mA* 2/3/4.3 mA
+ 11x 57/73/102 mA* 3/4.6/6.2 mA
+
+ *Values are only accessible when CDBGPWRUPREQ is high. This limits the maximum output current in functional mode. \endverbatim */
+
+
+ if((PadNum <= PAD_NUM_OF_IO) &&
+ (OutputDriveStrength <= PAD_OP_DRIVE_STRGTH_MAX) &&
+ (OutputDriveType <= PAD_OP_DRIVE_TYPE_MAX) && (PullType <= PAD_OP_PULL_TYPE_MAX)) {
+ /** - Get PAD IO register address for the PAD number */
+ PadRegOffset = (PadReg_t*)(PADREG_BASE + (PadNum * PAD_REG_ADRS_BYTE_SIZE));
+
+ /** - Enable the clock for PAD peripheral device */
+ CLOCK_ENABLE(CLOCK_PAD);
+
+ /** - Set drive type, pulltype & drive strength */
+ PadRegOffset->PADIO0.WORD = (uint32_t)((PullType << PAD_OP_PULL_TYPE_BIT_POS) |
+ (OutputDriveStrength << PAD_OP_DRIVE_STRGTH_BIT_POS) |
+ (OutputDriveType << PAD_OP_DRIVE_TYPE_BIT_POS));
+
+ /** - Disable the clock for PAD peripheral device */
+ CLOCK_DISABLE(CLOCK_PAD);
+ return True;
+ }
+ /* Invalid parameter/s */
+ return False;
+}
+#endif /* REVD */


