Modification of mbed-src library only for STM32F030F4, very cheap microcontroller in 20-Pin TSSOP package, with 16Kbytes of Flash and 4Kbytes of Ram. **Target for online compilator must be Nucleo 32F030R8.**

Dependents:   STM32F031_blink_LED_2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pinmap_common.c Source File

pinmap_common.c

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 "pinmap.h"
00017 #include "mbed_error.h"
00018 
00019 void pinmap_pinout(PinName pin, const PinMap *map) {
00020     if (pin == NC)
00021         return;
00022 
00023     while (map->pin != NC) {
00024         if (map->pin == pin) {
00025             pin_function(pin, map->function);
00026 
00027             pin_mode(pin, PullNone);
00028             return;
00029         }
00030         map++;
00031     }
00032 //    error("could not pinout");
00033 // STM32F030F4 for flash size save 
00034     error("");
00035 }
00036 
00037 uint32_t pinmap_merge(uint32_t a, uint32_t b) {
00038     // both are the same (inc both NC)
00039     if (a == b)
00040         return a;
00041 
00042     // one (or both) is not connected
00043     if (a == (uint32_t)NC)
00044         return b;
00045     if (b == (uint32_t)NC)
00046         return a;
00047 
00048     // mis-match error case
00049 //    error("pinmap mis-match");
00050 // STM32F030F4 for flash size save 
00051     error("");
00052     return (uint32_t)NC;
00053 }
00054 
00055 uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) {
00056     while (map->pin != NC) {
00057         if (map->pin == pin)
00058             return map->peripheral;
00059         map++;
00060     }
00061     return (uint32_t)NC;
00062 }
00063 
00064 uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
00065     uint32_t peripheral = (uint32_t)NC;
00066 
00067     if (pin == (PinName)NC)
00068         return (uint32_t)NC;
00069     peripheral = pinmap_find_peripheral(pin, map);
00070     if ((uint32_t)NC == peripheral) // no mapping available
00071 //        error("pinmap not found for peripheral");
00072 // STM32F030F4 for flash size save 
00073         error("");
00074     return peripheral;
00075 }