ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers parse_pins.cpp Source File

parse_pins.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #include "port_api.h"
00017 
00018 namespace mbed {
00019 
00020 PinName parse_pins(const char *str) {
00021 #if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368)
00022     static const PinName pin_names[] = {p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
00023                                 , p15, p16, p17, p18, p19, p20, p21, p22, p23
00024                                 , p24, p25, p26, p27, p28, p29, p30};
00025 #elif defined(TARGET_LPC1114)
00026     static const PinName pin_names[] = {dp1, dp2, dp4, dp5, dp6, dp9, dp10, dp11
00027                                 , dp13, dp14, dp15, dp16, dp17, dp18, dp23
00028                                 , dp24, dp25, dp26, dp27, dp28};
00029 #elif defined(TARGET_LPC4088)                                
00030     static const PinName pin_names[] = {p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
00031                                 , p15, p16, p17, p18, p19, p20, NC, NC, p23
00032                                 , p24, p25, p26, p27, p28, p29, p30, p31, p32
00033                                 , p33, p34, NC, NC, p37, p38, p39};
00034 #endif
00035 
00036 #if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368) || defined(TARGET_LPC812) || defined(TARGET_LPC4088)|| defined(TARGET_LPC1114)
00037     if (str[0] == 'P') {              // Pn_n
00038         uint32_t port = str[1] - '0';
00039         uint32_t pin  = str[3] - '0'; // Pn_n
00040         uint32_t pin2 = str[4] - '0'; // Pn_nn
00041         if (pin2 <= 9) {
00042             pin = pin * 10 + pin2;
00043         }
00044         return port_pin((PortName)port, pin);
00045 
00046 #elif defined(TARGET_KL25Z)
00047         if (str[0] == 'P' && str[1] == 'T') {   // PTx_n
00048             uint32_t port = str[2] - 'A';
00049             uint32_t pin  = str[3] - '0'; // PTxn
00050             uint32_t pin2 = str[4] - '0'; // PTxnn
00051 
00052             if (pin2 <= 9) {
00053                 pin = pin * 10 + pin2;
00054             }
00055             return port_pin((PortName)port, pin);
00056 #endif
00057 
00058 #if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368) 
00059     } else if (str[0] == 'p') {       // pn
00060         uint32_t pin  = str[1] - '0'; // pn
00061         uint32_t pin2 = str[2] - '0'; // pnn
00062         if (pin2 <= 9) {
00063             pin = pin * 10 + pin2;
00064         }
00065         if (pin < 5 || pin > 30) {
00066             return NC;
00067         }
00068         return pin_names[pin - 5];
00069 #elif defined(TARGET_LPC4088)        
00070     } else if (str[0] == 'p') {       // pn
00071         uint32_t pin  = str[1] - '0'; // pn
00072         uint32_t pin2 = str[2] - '0'; // pnn
00073         if (pin2 <= 9) {
00074             pin = pin * 10 + pin2;
00075         }
00076         if (pin < 5 || pin > 39) {
00077             return NC;
00078         }
00079         return pin_names[pin - 5];
00080 #endif
00081 
00082     } else if (str[0] == 'L') {  // LEDn
00083         switch (str[3]) {
00084             case '1' : return LED1;
00085             case '2' : return LED2;
00086             case '3' : return LED3;
00087             case '4' : return LED4;
00088         }
00089 
00090     } else if (str[0] == 'U') {  // USB?X
00091         switch (str[3]) {
00092             case 'T' : return USBTX;
00093             case 'R' : return USBRX;
00094         }
00095     }
00096 
00097     return NC;
00098 }
00099 
00100 }