Mouse code for the MacroRat
mbed-dev/targets/TARGET_ONSEMI/TARGET_NCS36510/pinmap.c@18:6a4db94011d3, 2017-05-14 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sun May 14 23:18:57 2017 +0000
- Revision:
- 18:6a4db94011d3
Publishing again
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /* mbed Microcontroller Library |
sahilmgandhi | 18:6a4db94011d3 | 2 | * Copyright (c) 2006-2013 ARM Limited |
sahilmgandhi | 18:6a4db94011d3 | 3 | * |
sahilmgandhi | 18:6a4db94011d3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
sahilmgandhi | 18:6a4db94011d3 | 5 | * you may not use this file except in compliance with the License. |
sahilmgandhi | 18:6a4db94011d3 | 6 | * You may obtain a copy of the License at |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
sahilmgandhi | 18:6a4db94011d3 | 9 | * |
sahilmgandhi | 18:6a4db94011d3 | 10 | * Unless required by applicable law or agreed to in writing, software |
sahilmgandhi | 18:6a4db94011d3 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
sahilmgandhi | 18:6a4db94011d3 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
sahilmgandhi | 18:6a4db94011d3 | 13 | * See the License for the specific language governing permissions and |
sahilmgandhi | 18:6a4db94011d3 | 14 | * limitations under the License. |
sahilmgandhi | 18:6a4db94011d3 | 15 | */ |
sahilmgandhi | 18:6a4db94011d3 | 16 | |
sahilmgandhi | 18:6a4db94011d3 | 17 | /* Orion specific header files */ |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | #include "pad.h" |
sahilmgandhi | 18:6a4db94011d3 | 20 | |
sahilmgandhi | 18:6a4db94011d3 | 21 | /* MBED header files */ |
sahilmgandhi | 18:6a4db94011d3 | 22 | #include "pinmap.h" |
sahilmgandhi | 18:6a4db94011d3 | 23 | |
sahilmgandhi | 18:6a4db94011d3 | 24 | void pin_function(PinName pin, int function) |
sahilmgandhi | 18:6a4db94011d3 | 25 | { |
sahilmgandhi | 18:6a4db94011d3 | 26 | /** - Enable the clock for PAD peripheral device */ |
sahilmgandhi | 18:6a4db94011d3 | 27 | CLOCK_ENABLE(CLOCK_CROSSB); |
sahilmgandhi | 18:6a4db94011d3 | 28 | |
sahilmgandhi | 18:6a4db94011d3 | 29 | /* Note: GPIO 0,1,2,3 are used for UART 1, GPIO 8,9 are used for UART 2 */ |
sahilmgandhi | 18:6a4db94011d3 | 30 | CrossbReg_pt crossBar = (CrossbReg_t *)(CROSSBREG_BASE + (pin * CROSS_REG_ADRS_BYTE_SIZE)); |
sahilmgandhi | 18:6a4db94011d3 | 31 | crossBar->DIOCTRL0 = function; |
sahilmgandhi | 18:6a4db94011d3 | 32 | |
sahilmgandhi | 18:6a4db94011d3 | 33 | /** - Disable the clock for PAD peripheral device */ |
sahilmgandhi | 18:6a4db94011d3 | 34 | CLOCK_DISABLE(CLOCK_CROSSB); |
sahilmgandhi | 18:6a4db94011d3 | 35 | } |
sahilmgandhi | 18:6a4db94011d3 | 36 | |
sahilmgandhi | 18:6a4db94011d3 | 37 | void pin_mode(PinName pin, PinMode mode) |
sahilmgandhi | 18:6a4db94011d3 | 38 | { |
sahilmgandhi | 18:6a4db94011d3 | 39 | /** - Get PAD IO register address for the PAD number */ |
sahilmgandhi | 18:6a4db94011d3 | 40 | PadReg_t *padRegOffset = (PadReg_t*)(PADREG_BASE + (pin * PAD_REG_ADRS_BYTE_SIZE)); |
sahilmgandhi | 18:6a4db94011d3 | 41 | |
sahilmgandhi | 18:6a4db94011d3 | 42 | /** - Enable the clock for PAD peripheral device */ |
sahilmgandhi | 18:6a4db94011d3 | 43 | CLOCK_ENABLE(CLOCK_PAD); |
sahilmgandhi | 18:6a4db94011d3 | 44 | |
sahilmgandhi | 18:6a4db94011d3 | 45 | switch (mode) { |
sahilmgandhi | 18:6a4db94011d3 | 46 | case PushPullPullDown: |
sahilmgandhi | 18:6a4db94011d3 | 47 | padRegOffset->PADIO0.BITS.TYPE = PAD_OUTCFG_PUSHPULL; |
sahilmgandhi | 18:6a4db94011d3 | 48 | padRegOffset->PADIO0.BITS.PULL = PAD_PULL_DOWN; |
sahilmgandhi | 18:6a4db94011d3 | 49 | break; |
sahilmgandhi | 18:6a4db94011d3 | 50 | |
sahilmgandhi | 18:6a4db94011d3 | 51 | case PushPullNoPull: |
sahilmgandhi | 18:6a4db94011d3 | 52 | padRegOffset->PADIO0.BITS.TYPE = PAD_OUTCFG_PUSHPULL; |
sahilmgandhi | 18:6a4db94011d3 | 53 | padRegOffset->PADIO0.BITS.PULL = PAD_PULL_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 54 | break; |
sahilmgandhi | 18:6a4db94011d3 | 55 | |
sahilmgandhi | 18:6a4db94011d3 | 56 | case PushPullPullUp: |
sahilmgandhi | 18:6a4db94011d3 | 57 | padRegOffset->PADIO0.BITS.TYPE = PAD_OUTCFG_PUSHPULL; |
sahilmgandhi | 18:6a4db94011d3 | 58 | padRegOffset->PADIO0.BITS.PULL = PAD_PULL_UP; |
sahilmgandhi | 18:6a4db94011d3 | 59 | break; |
sahilmgandhi | 18:6a4db94011d3 | 60 | |
sahilmgandhi | 18:6a4db94011d3 | 61 | case OpenDrainPullDown: |
sahilmgandhi | 18:6a4db94011d3 | 62 | padRegOffset->PADIO0.BITS.TYPE = PAD_OOUTCFG_OPENDRAIN; |
sahilmgandhi | 18:6a4db94011d3 | 63 | padRegOffset->PADIO0.BITS.PULL = PAD_PULL_DOWN; |
sahilmgandhi | 18:6a4db94011d3 | 64 | break; |
sahilmgandhi | 18:6a4db94011d3 | 65 | |
sahilmgandhi | 18:6a4db94011d3 | 66 | case OpenDrainNoPull: |
sahilmgandhi | 18:6a4db94011d3 | 67 | padRegOffset->PADIO0.BITS.TYPE = PAD_OOUTCFG_OPENDRAIN; |
sahilmgandhi | 18:6a4db94011d3 | 68 | padRegOffset->PADIO0.BITS.PULL = PAD_PULL_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 69 | break; |
sahilmgandhi | 18:6a4db94011d3 | 70 | |
sahilmgandhi | 18:6a4db94011d3 | 71 | case OpenDrainPullUp: |
sahilmgandhi | 18:6a4db94011d3 | 72 | padRegOffset->PADIO0.BITS.TYPE = PAD_OOUTCFG_OPENDRAIN; |
sahilmgandhi | 18:6a4db94011d3 | 73 | padRegOffset->PADIO0.BITS.PULL = PAD_PULL_UP; |
sahilmgandhi | 18:6a4db94011d3 | 74 | break; |
sahilmgandhi | 18:6a4db94011d3 | 75 | |
sahilmgandhi | 18:6a4db94011d3 | 76 | default: |
sahilmgandhi | 18:6a4db94011d3 | 77 | break; |
sahilmgandhi | 18:6a4db94011d3 | 78 | } |
sahilmgandhi | 18:6a4db94011d3 | 79 | |
sahilmgandhi | 18:6a4db94011d3 | 80 | /** - Disable the clock for PAD peripheral device */ |
sahilmgandhi | 18:6a4db94011d3 | 81 | CLOCK_DISABLE(CLOCK_PAD); |
sahilmgandhi | 18:6a4db94011d3 | 82 | |
sahilmgandhi | 18:6a4db94011d3 | 83 | } |