Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_pinmap_default.c Source File

mbed_pinmap_default.c

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #include <stdlib.h>
00019 #include "hal/pinmap.h"
00020 #include "platform/mbed_toolchain.h"
00021 #include "platform/mbed_assert.h"
00022 #include "device.h"
00023 
00024 //*** Common form factors ***
00025 #ifdef TARGET_FF_ARDUINO
00026 
00027 static const PinName ff_arduino_pins[] = {
00028     D0, D1, D2, D3, D4, D5, D6, D7,
00029     D8, D9, D10, D11, D12, D13, D14, D15,
00030     A0, A1, A2, A3, A4, A5
00031 };
00032 
00033 static const char *ff_arduino_names[] = {
00034     "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
00035     "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15",
00036     "A0", "A1", "A2", "A3", "A4", "A5"
00037 };
00038 
00039 static const PinList ff_arduino_list = {
00040     sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]),
00041     ff_arduino_pins
00042 };
00043 
00044 MBED_STATIC_ASSERT(sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]) == sizeof(ff_arduino_names) / sizeof(ff_arduino_names[0]),
00045                    "Arrays must have the same length");
00046 
00047 const PinList *pinmap_ff_arduino_pins()
00048 {
00049     return &ff_arduino_list;
00050 }
00051 
00052 const char *pinmap_ff_arduino_pin_to_string(PinName pin)
00053 {
00054     if (pin == NC) {
00055         return "NC";
00056     }
00057     for (size_t i = 0; i < ff_arduino_list.count; i++) {
00058         if (ff_arduino_list.pins[i] == pin) {
00059             return ff_arduino_names[i];
00060         }
00061     }
00062     return "Unknown";
00063 }
00064 
00065 #endif
00066 
00067 //*** Default restricted pins ***
00068 MBED_WEAK const PinList *pinmap_restricted_pins()
00069 {
00070     static const PinName pins[] = {
00071         USBTX, USBRX
00072     };
00073     static const PinList pin_list = {
00074         sizeof(pins) / sizeof(pins[0]),
00075         pins
00076     };
00077     return &pin_list;
00078 }
00079 
00080 //*** Default restricted peripherals ***
00081 MBED_WEAK const PeripheralList *pinmap_restricted_peripherals()
00082 {
00083     static const PeripheralList peripheral_list = {
00084         0,
00085         0
00086     };
00087     return &peripheral_list;
00088 }