![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/targets/TARGET_Atmel/TARGET_SAM_CortexM4/port_api.c@0:8fdf9a60065b, 2018-10-10 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | /* mbed Microcontroller Library |
kadonotakashi | 0:8fdf9a60065b | 2 | * Copyright (c) 2006-2015 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 "port_api.h" |
kadonotakashi | 0:8fdf9a60065b | 17 | #include "pinmap.h" |
kadonotakashi | 0:8fdf9a60065b | 18 | #include "gpio_api.h" |
kadonotakashi | 0:8fdf9a60065b | 19 | #include "ioport.h" |
kadonotakashi | 0:8fdf9a60065b | 20 | |
kadonotakashi | 0:8fdf9a60065b | 21 | extern uint8_t g_sys_init; |
kadonotakashi | 0:8fdf9a60065b | 22 | |
kadonotakashi | 0:8fdf9a60065b | 23 | void port_init(port_t *obj, PortName port, int mask, PinDirection dir) |
kadonotakashi | 0:8fdf9a60065b | 24 | { |
kadonotakashi | 0:8fdf9a60065b | 25 | MBED_ASSERT(obj); |
kadonotakashi | 0:8fdf9a60065b | 26 | if (g_sys_init == 0) { |
kadonotakashi | 0:8fdf9a60065b | 27 | sysclk_init(); |
kadonotakashi | 0:8fdf9a60065b | 28 | system_board_init(); |
kadonotakashi | 0:8fdf9a60065b | 29 | g_sys_init = 1; |
kadonotakashi | 0:8fdf9a60065b | 30 | } |
kadonotakashi | 0:8fdf9a60065b | 31 | obj->port = port; |
kadonotakashi | 0:8fdf9a60065b | 32 | obj->mask = mask; |
kadonotakashi | 0:8fdf9a60065b | 33 | |
kadonotakashi | 0:8fdf9a60065b | 34 | switch (dir) { |
kadonotakashi | 0:8fdf9a60065b | 35 | case PIN_INPUT : |
kadonotakashi | 0:8fdf9a60065b | 36 | ioport_set_port_dir(port, mask, IOPORT_DIR_INPUT); |
kadonotakashi | 0:8fdf9a60065b | 37 | break; |
kadonotakashi | 0:8fdf9a60065b | 38 | case PIN_OUTPUT: |
kadonotakashi | 0:8fdf9a60065b | 39 | ioport_set_port_dir(port, mask, IOPORT_DIR_OUTPUT); |
kadonotakashi | 0:8fdf9a60065b | 40 | break; |
kadonotakashi | 0:8fdf9a60065b | 41 | case PIN_INPUT_OUTPUT: |
kadonotakashi | 0:8fdf9a60065b | 42 | ioport_set_port_dir(port, mask, IOPORT_DIR_OUTPUT); |
kadonotakashi | 0:8fdf9a60065b | 43 | break; |
kadonotakashi | 0:8fdf9a60065b | 44 | } |
kadonotakashi | 0:8fdf9a60065b | 45 | ioport_set_port_mode(port, mask, IOPORT_MODE_PULLUP); |
kadonotakashi | 0:8fdf9a60065b | 46 | } |
kadonotakashi | 0:8fdf9a60065b | 47 | |
kadonotakashi | 0:8fdf9a60065b | 48 | void port_mode(port_t *obj, PinMode mode) |
kadonotakashi | 0:8fdf9a60065b | 49 | { |
kadonotakashi | 0:8fdf9a60065b | 50 | MBED_ASSERT(obj); |
kadonotakashi | 0:8fdf9a60065b | 51 | obj->mode = mode; |
kadonotakashi | 0:8fdf9a60065b | 52 | switch (mode) { |
kadonotakashi | 0:8fdf9a60065b | 53 | case PullNone : |
kadonotakashi | 0:8fdf9a60065b | 54 | ioport_set_port_mode(obj->port, obj->mask, IOPORT_MODE_OPEN_DRAIN); |
kadonotakashi | 0:8fdf9a60065b | 55 | break; |
kadonotakashi | 0:8fdf9a60065b | 56 | case PullUp: |
kadonotakashi | 0:8fdf9a60065b | 57 | ioport_set_port_mode(obj->port, obj->mask, IOPORT_MODE_PULLUP); |
kadonotakashi | 0:8fdf9a60065b | 58 | break; |
kadonotakashi | 0:8fdf9a60065b | 59 | case PullDown: |
kadonotakashi | 0:8fdf9a60065b | 60 | ioport_set_port_mode(obj->port, obj->mask, IOPORT_MODE_PULLDOWN); |
kadonotakashi | 0:8fdf9a60065b | 61 | break; |
kadonotakashi | 0:8fdf9a60065b | 62 | } |
kadonotakashi | 0:8fdf9a60065b | 63 | } |
kadonotakashi | 0:8fdf9a60065b | 64 | |
kadonotakashi | 0:8fdf9a60065b | 65 | void port_dir(port_t *obj, PinDirection dir) |
kadonotakashi | 0:8fdf9a60065b | 66 | { |
kadonotakashi | 0:8fdf9a60065b | 67 | MBED_ASSERT(obj); |
kadonotakashi | 0:8fdf9a60065b | 68 | obj->direction = dir; |
kadonotakashi | 0:8fdf9a60065b | 69 | switch (dir) { |
kadonotakashi | 0:8fdf9a60065b | 70 | case PIN_INPUT : |
kadonotakashi | 0:8fdf9a60065b | 71 | ioport_set_port_dir(obj->port, obj->mask, IOPORT_DIR_INPUT); |
kadonotakashi | 0:8fdf9a60065b | 72 | break; |
kadonotakashi | 0:8fdf9a60065b | 73 | case PIN_OUTPUT: |
kadonotakashi | 0:8fdf9a60065b | 74 | ioport_set_port_dir(obj->port, obj->mask, IOPORT_DIR_OUTPUT); |
kadonotakashi | 0:8fdf9a60065b | 75 | break; |
kadonotakashi | 0:8fdf9a60065b | 76 | case PIN_INPUT_OUTPUT: |
kadonotakashi | 0:8fdf9a60065b | 77 | ioport_set_port_dir(obj->port, obj->mask, IOPORT_DIR_OUTPUT); |
kadonotakashi | 0:8fdf9a60065b | 78 | break; |
kadonotakashi | 0:8fdf9a60065b | 79 | } |
kadonotakashi | 0:8fdf9a60065b | 80 | } |
kadonotakashi | 0:8fdf9a60065b | 81 | |
kadonotakashi | 0:8fdf9a60065b | 82 | void port_write(port_t *obj, int value) |
kadonotakashi | 0:8fdf9a60065b | 83 | { |
kadonotakashi | 0:8fdf9a60065b | 84 | MBED_ASSERT(obj); |
kadonotakashi | 0:8fdf9a60065b | 85 | ioport_set_port_level(obj->port, obj->mask, value); |
kadonotakashi | 0:8fdf9a60065b | 86 | } |
kadonotakashi | 0:8fdf9a60065b | 87 | |
kadonotakashi | 0:8fdf9a60065b | 88 | int port_read(port_t *obj) |
kadonotakashi | 0:8fdf9a60065b | 89 | { |
kadonotakashi | 0:8fdf9a60065b | 90 | MBED_ASSERT(obj); |
kadonotakashi | 0:8fdf9a60065b | 91 | return ioport_get_port_level(obj->port, obj->mask); |
kadonotakashi | 0:8fdf9a60065b | 92 | } |