Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
how to make mbed librry

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 /* mbed Microcontroller Library
kadonotakashi 0:8fdf9a60065b 2 * Copyright (c) 2006-2013 ARM Limited
kadonotakashi 0:8fdf9a60065b 3 *
kadonotakashi 0:8fdf9a60065b 4 * Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 5 * you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 6 * You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 7 *
kadonotakashi 0:8fdf9a60065b 8 * http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 9 *
kadonotakashi 0:8fdf9a60065b 10 * Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 11 * distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 13 * See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 14 * limitations under the License.
kadonotakashi 0:8fdf9a60065b 15 */
kadonotakashi 0:8fdf9a60065b 16 #include "hal/pinmap.h"
kadonotakashi 0:8fdf9a60065b 17 #include "platform/mbed_error.h"
kadonotakashi 0:8fdf9a60065b 18
kadonotakashi 0:8fdf9a60065b 19 void pinmap_pinout(PinName pin, const PinMap *map)
kadonotakashi 0:8fdf9a60065b 20 {
kadonotakashi 0:8fdf9a60065b 21 if (pin == NC) {
kadonotakashi 0:8fdf9a60065b 22 return;
kadonotakashi 0:8fdf9a60065b 23 }
kadonotakashi 0:8fdf9a60065b 24
kadonotakashi 0:8fdf9a60065b 25 while (map->pin != NC) {
kadonotakashi 0:8fdf9a60065b 26 if (map->pin == pin) {
kadonotakashi 0:8fdf9a60065b 27 pin_function(pin, map->function);
kadonotakashi 0:8fdf9a60065b 28
kadonotakashi 0:8fdf9a60065b 29 pin_mode(pin, PullNone);
kadonotakashi 0:8fdf9a60065b 30 return;
kadonotakashi 0:8fdf9a60065b 31 }
kadonotakashi 0:8fdf9a60065b 32 map++;
kadonotakashi 0:8fdf9a60065b 33 }
kadonotakashi 0:8fdf9a60065b 34 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "could not pinout", pin);
kadonotakashi 0:8fdf9a60065b 35 }
kadonotakashi 0:8fdf9a60065b 36
kadonotakashi 0:8fdf9a60065b 37 uint32_t pinmap_merge(uint32_t a, uint32_t b)
kadonotakashi 0:8fdf9a60065b 38 {
kadonotakashi 0:8fdf9a60065b 39 // both are the same (inc both NC)
kadonotakashi 0:8fdf9a60065b 40 if (a == b) {
kadonotakashi 0:8fdf9a60065b 41 return a;
kadonotakashi 0:8fdf9a60065b 42 }
kadonotakashi 0:8fdf9a60065b 43
kadonotakashi 0:8fdf9a60065b 44 // one (or both) is not connected
kadonotakashi 0:8fdf9a60065b 45 if (a == (uint32_t)NC) {
kadonotakashi 0:8fdf9a60065b 46 return b;
kadonotakashi 0:8fdf9a60065b 47 }
kadonotakashi 0:8fdf9a60065b 48 if (b == (uint32_t)NC) {
kadonotakashi 0:8fdf9a60065b 49 return a;
kadonotakashi 0:8fdf9a60065b 50 }
kadonotakashi 0:8fdf9a60065b 51
kadonotakashi 0:8fdf9a60065b 52 // mis-match error case
kadonotakashi 0:8fdf9a60065b 53 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a);
kadonotakashi 0:8fdf9a60065b 54 return (uint32_t)NC;
kadonotakashi 0:8fdf9a60065b 55 }
kadonotakashi 0:8fdf9a60065b 56
kadonotakashi 0:8fdf9a60065b 57 uint32_t pinmap_find_peripheral(PinName pin, const PinMap *map)
kadonotakashi 0:8fdf9a60065b 58 {
kadonotakashi 0:8fdf9a60065b 59 while (map->pin != NC) {
kadonotakashi 0:8fdf9a60065b 60 if (map->pin == pin) {
kadonotakashi 0:8fdf9a60065b 61 return map->peripheral;
kadonotakashi 0:8fdf9a60065b 62 }
kadonotakashi 0:8fdf9a60065b 63 map++;
kadonotakashi 0:8fdf9a60065b 64 }
kadonotakashi 0:8fdf9a60065b 65 return (uint32_t)NC;
kadonotakashi 0:8fdf9a60065b 66 }
kadonotakashi 0:8fdf9a60065b 67
kadonotakashi 0:8fdf9a60065b 68 uint32_t pinmap_peripheral(PinName pin, const PinMap *map)
kadonotakashi 0:8fdf9a60065b 69 {
kadonotakashi 0:8fdf9a60065b 70 uint32_t peripheral = (uint32_t)NC;
kadonotakashi 0:8fdf9a60065b 71
kadonotakashi 0:8fdf9a60065b 72 if (pin == (PinName)NC) {
kadonotakashi 0:8fdf9a60065b 73 return (uint32_t)NC;
kadonotakashi 0:8fdf9a60065b 74 }
kadonotakashi 0:8fdf9a60065b 75 peripheral = pinmap_find_peripheral(pin, map);
kadonotakashi 0:8fdf9a60065b 76 if ((uint32_t)NC == peripheral) { // no mapping available
kadonotakashi 0:8fdf9a60065b 77 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral);
kadonotakashi 0:8fdf9a60065b 78 }
kadonotakashi 0:8fdf9a60065b 79 return peripheral;
kadonotakashi 0:8fdf9a60065b 80 }
kadonotakashi 0:8fdf9a60065b 81
kadonotakashi 0:8fdf9a60065b 82 uint32_t pinmap_find_function(PinName pin, const PinMap *map)
kadonotakashi 0:8fdf9a60065b 83 {
kadonotakashi 0:8fdf9a60065b 84 while (map->pin != NC) {
kadonotakashi 0:8fdf9a60065b 85 if (map->pin == pin) {
kadonotakashi 0:8fdf9a60065b 86 return map->function;
kadonotakashi 0:8fdf9a60065b 87 }
kadonotakashi 0:8fdf9a60065b 88 map++;
kadonotakashi 0:8fdf9a60065b 89 }
kadonotakashi 0:8fdf9a60065b 90 return (uint32_t)NC;
kadonotakashi 0:8fdf9a60065b 91 }
kadonotakashi 0:8fdf9a60065b 92
kadonotakashi 0:8fdf9a60065b 93 uint32_t pinmap_function(PinName pin, const PinMap *map)
kadonotakashi 0:8fdf9a60065b 94 {
kadonotakashi 0:8fdf9a60065b 95 uint32_t function = (uint32_t)NC;
kadonotakashi 0:8fdf9a60065b 96
kadonotakashi 0:8fdf9a60065b 97 if (pin == (PinName)NC) {
kadonotakashi 0:8fdf9a60065b 98 return (uint32_t)NC;
kadonotakashi 0:8fdf9a60065b 99 }
kadonotakashi 0:8fdf9a60065b 100 function = pinmap_find_function(pin, map);
kadonotakashi 0:8fdf9a60065b 101 if ((uint32_t)NC == function) { // no mapping available
kadonotakashi 0:8fdf9a60065b 102 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function);
kadonotakashi 0:8fdf9a60065b 103 }
kadonotakashi 0:8fdf9a60065b 104 return function;
kadonotakashi 0:8fdf9a60065b 105 }