dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 1:55a6170b404f 1 /* mbed Microcontroller Library
nexpaq 1:55a6170b404f 2 * Copyright (c) 2006-2013 ARM Limited
nexpaq 1:55a6170b404f 3 *
nexpaq 1:55a6170b404f 4 * Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 1:55a6170b404f 5 * you may not use this file except in compliance with the License.
nexpaq 1:55a6170b404f 6 * You may obtain a copy of the License at
nexpaq 1:55a6170b404f 7 *
nexpaq 1:55a6170b404f 8 * http://www.apache.org/licenses/LICENSE-2.0
nexpaq 1:55a6170b404f 9 *
nexpaq 1:55a6170b404f 10 * Unless required by applicable law or agreed to in writing, software
nexpaq 1:55a6170b404f 11 * distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 1:55a6170b404f 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 1:55a6170b404f 13 * See the License for the specific language governing permissions and
nexpaq 1:55a6170b404f 14 * limitations under the License.
nexpaq 1:55a6170b404f 15 */
nexpaq 1:55a6170b404f 16 #include "port_api.h"
nexpaq 1:55a6170b404f 17
nexpaq 1:55a6170b404f 18 namespace mbed {
nexpaq 1:55a6170b404f 19
nexpaq 1:55a6170b404f 20 PinName parse_pins(const char *str) {
nexpaq 1:55a6170b404f 21 #if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368)
nexpaq 1:55a6170b404f 22 static const PinName pin_names[] = {p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
nexpaq 1:55a6170b404f 23 , p15, p16, p17, p18, p19, p20, p21, p22, p23
nexpaq 1:55a6170b404f 24 , p24, p25, p26, p27, p28, p29, p30};
nexpaq 1:55a6170b404f 25 #elif defined(TARGET_LPC1114)
nexpaq 1:55a6170b404f 26 static const PinName pin_names[] = {dp1, dp2, dp4, dp5, dp6, dp9, dp10, dp11
nexpaq 1:55a6170b404f 27 , dp13, dp14, dp15, dp16, dp17, dp18, dp23
nexpaq 1:55a6170b404f 28 , dp24, dp25, dp26, dp27, dp28};
nexpaq 1:55a6170b404f 29 #elif defined(TARGET_LPC4088)
nexpaq 1:55a6170b404f 30 static const PinName pin_names[] = {NC, NC, NC, NC, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
nexpaq 1:55a6170b404f 31 , p15, p16, p17, p18, p19, p20, NC, NC, p23
nexpaq 1:55a6170b404f 32 , p24, p25, p26, p27, p28, p29, p30, p31, p32
nexpaq 1:55a6170b404f 33 , p33, p34, NC, NC, p37, p38, p39, NC, NC, NC, NC, NC, NC, NC};
nexpaq 1:55a6170b404f 34 #elif defined(TARGET_LPC4088_DM)
nexpaq 1:55a6170b404f 35 static const PinName pin_names[] = {p1, p2, p3, p4, NC, NC, p7, p8, p9, p10, p11, p12, p13, p14
nexpaq 1:55a6170b404f 36 , p15, p16, p17, p18, p19, p20, p21, p22, p23
nexpaq 1:55a6170b404f 37 , p24, p25, p26, NC, NC, p29, p30, NC, NC
nexpaq 1:55a6170b404f 38 , NC, NC, NC, NC, NC, NC, NC, NC, p41, p42, p43, p44, p45, p46};
nexpaq 1:55a6170b404f 39 #endif
nexpaq 1:55a6170b404f 40
nexpaq 1:55a6170b404f 41 #if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368) || defined(TARGET_LPC812) || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC1114) || defined(TARGET_RZ_A1H) || defined(TARGET_VK_RZ_A1H)
nexpaq 1:55a6170b404f 42 if (str[0] == 'P') { // Pn_n
nexpaq 1:55a6170b404f 43 uint32_t port = str[1] - '0';
nexpaq 1:55a6170b404f 44 uint32_t pin = str[3] - '0'; // Pn_n
nexpaq 1:55a6170b404f 45 uint32_t pin2 = str[4] - '0'; // Pn_nn
nexpaq 1:55a6170b404f 46 if (pin2 <= 9) {
nexpaq 1:55a6170b404f 47 pin = pin * 10 + pin2;
nexpaq 1:55a6170b404f 48 }
nexpaq 1:55a6170b404f 49 return port_pin((PortName)port, pin);
nexpaq 1:55a6170b404f 50
nexpaq 1:55a6170b404f 51 #elif defined(TARGET_KL25Z) || defined(TARGET_KL27Z) || defined(TARGET_KL05Z) || defined(TARGET_KL46Z) || defined(TARGET_K22F) || defined(TARGET_K64F)
nexpaq 1:55a6170b404f 52 if (str[0] == 'P' && str[1] == 'T') { // PTxn
nexpaq 1:55a6170b404f 53 uint32_t port = str[2] - 'A';
nexpaq 1:55a6170b404f 54 uint32_t pin = str[3] - '0'; // PTxn
nexpaq 1:55a6170b404f 55 uint32_t pin2 = str[4] - '0'; // PTxnn
nexpaq 1:55a6170b404f 56
nexpaq 1:55a6170b404f 57 if (pin2 <= 9) {
nexpaq 1:55a6170b404f 58 pin = pin * 10 + pin2;
nexpaq 1:55a6170b404f 59 }
nexpaq 1:55a6170b404f 60 return port_pin((PortName)port, pin);
nexpaq 1:55a6170b404f 61
nexpaq 1:55a6170b404f 62 #elif defined(TARGET_NUCLEO_F072RB) || defined(TARGET_NUCLEO_F303K8) || defined(TARGET_NUCLEO_F411RE)
nexpaq 1:55a6170b404f 63 if (str[0] == 'P') { // PX_XX e.g.PA_2 PC_15
nexpaq 1:55a6170b404f 64 uint32_t port = str[1] - 'A';
nexpaq 1:55a6170b404f 65 uint32_t pin = str[3] - '0';
nexpaq 1:55a6170b404f 66 uint32_t pin2 = str[4] - '0';
nexpaq 1:55a6170b404f 67
nexpaq 1:55a6170b404f 68 if (pin2 <= 9) {
nexpaq 1:55a6170b404f 69 pin = pin * 10 + pin2;
nexpaq 1:55a6170b404f 70 }
nexpaq 1:55a6170b404f 71 return port_pin((PortName)port, pin);
nexpaq 1:55a6170b404f 72
nexpaq 1:55a6170b404f 73 #endif
nexpaq 1:55a6170b404f 74
nexpaq 1:55a6170b404f 75
nexpaq 1:55a6170b404f 76
nexpaq 1:55a6170b404f 77 #if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368)
nexpaq 1:55a6170b404f 78 } else if (str[0] == 'p') { // pn
nexpaq 1:55a6170b404f 79 uint32_t pin = str[1] - '0'; // pn
nexpaq 1:55a6170b404f 80 uint32_t pin2 = str[2] - '0'; // pnn
nexpaq 1:55a6170b404f 81 if (pin2 <= 9) {
nexpaq 1:55a6170b404f 82 pin = pin * 10 + pin2;
nexpaq 1:55a6170b404f 83 }
nexpaq 1:55a6170b404f 84 if (pin < 5 || pin > 30) {
nexpaq 1:55a6170b404f 85 return NC;
nexpaq 1:55a6170b404f 86 }
nexpaq 1:55a6170b404f 87 return pin_names[pin - 5];
nexpaq 1:55a6170b404f 88 #elif defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM)
nexpaq 1:55a6170b404f 89 } else if (str[0] == 'p') { // pn
nexpaq 1:55a6170b404f 90 uint32_t pin = str[1] - '0'; // pn
nexpaq 1:55a6170b404f 91 uint32_t pin2 = str[2] - '0'; // pnn
nexpaq 1:55a6170b404f 92 if (pin2 <= 9) {
nexpaq 1:55a6170b404f 93 pin = pin * 10 + pin2;
nexpaq 1:55a6170b404f 94 }
nexpaq 1:55a6170b404f 95 if (pin < 1 || pin > 46) {
nexpaq 1:55a6170b404f 96 return NC;
nexpaq 1:55a6170b404f 97 }
nexpaq 1:55a6170b404f 98 return pin_names[pin - 1];
nexpaq 1:55a6170b404f 99 #endif
nexpaq 1:55a6170b404f 100 } else if (str[0] == 'L') { // LEDn
nexpaq 1:55a6170b404f 101 switch (str[3]) {
nexpaq 1:55a6170b404f 102 case '1' : return LED1;
nexpaq 1:55a6170b404f 103 case '2' : return LED2;
nexpaq 1:55a6170b404f 104 case '3' : return LED3;
nexpaq 1:55a6170b404f 105 case '4' : return LED4;
nexpaq 1:55a6170b404f 106 }
nexpaq 1:55a6170b404f 107
nexpaq 1:55a6170b404f 108 } else if (str[0] == 'U') { // USB?X
nexpaq 1:55a6170b404f 109 switch (str[3]) {
nexpaq 1:55a6170b404f 110 case 'T' : return USBTX;
nexpaq 1:55a6170b404f 111 case 'R' : return USBRX;
nexpaq 1:55a6170b404f 112 }
nexpaq 1:55a6170b404f 113 }
nexpaq 1:55a6170b404f 114
nexpaq 1:55a6170b404f 115 return NC;
nexpaq 1:55a6170b404f 116 }
nexpaq 1:55a6170b404f 117 }
nexpaq 1:55a6170b404f 118
nexpaq 1:55a6170b404f 119