mbed library sources: Modified to operate FRDM-KL25Z at 48MHz from internal 32kHz oscillator (nothing else changed).

Fork of mbed-src by mbed official

The only file that changed is: mbed-src-FLL48/targets/cmsis/TARGET_Freescale/TARGET_KL25Z/system_MKL25Z4.h

Committer:
bogdanm
Date:
Tue Sep 10 15:14:19 2013 +0300
Revision:
20:4263a77256ae
Sync with git revision 171dda705c947bf910926a0b73d6a4797802554d

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 20:4263a77256ae 1 /* mbed Microcontroller Library
bogdanm 20:4263a77256ae 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 20:4263a77256ae 3 *
bogdanm 20:4263a77256ae 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 20:4263a77256ae 5 * you may not use this file except in compliance with the License.
bogdanm 20:4263a77256ae 6 * You may obtain a copy of the License at
bogdanm 20:4263a77256ae 7 *
bogdanm 20:4263a77256ae 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 20:4263a77256ae 9 *
bogdanm 20:4263a77256ae 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 20:4263a77256ae 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 20:4263a77256ae 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 20:4263a77256ae 13 * See the License for the specific language governing permissions and
bogdanm 20:4263a77256ae 14 * limitations under the License.
bogdanm 20:4263a77256ae 15 */
bogdanm 20:4263a77256ae 16 #include "port_api.h"
bogdanm 20:4263a77256ae 17 #include "pinmap.h"
bogdanm 20:4263a77256ae 18 #include "gpio_api.h"
bogdanm 20:4263a77256ae 19
bogdanm 20:4263a77256ae 20 PinName port_pin(PortName port, int pin_n) {
bogdanm 20:4263a77256ae 21 return (PinName)((port << PORT_SHIFT) | (pin_n << 2));
bogdanm 20:4263a77256ae 22 }
bogdanm 20:4263a77256ae 23
bogdanm 20:4263a77256ae 24 void port_init(port_t *obj, PortName port, int mask, PinDirection dir) {
bogdanm 20:4263a77256ae 25 obj->port = port;
bogdanm 20:4263a77256ae 26 obj->mask = mask;
bogdanm 20:4263a77256ae 27
bogdanm 20:4263a77256ae 28 FGPIO_Type *reg = (FGPIO_Type *)(FPTA_BASE + port * 0x40);
bogdanm 20:4263a77256ae 29
bogdanm 20:4263a77256ae 30 obj->reg_out = &reg->PDOR;
bogdanm 20:4263a77256ae 31 obj->reg_in = &reg->PDIR;
bogdanm 20:4263a77256ae 32 obj->reg_dir = &reg->PDDR;
bogdanm 20:4263a77256ae 33
bogdanm 20:4263a77256ae 34 uint32_t i;
bogdanm 20:4263a77256ae 35 // The function is set per pin: reuse gpio logic
bogdanm 20:4263a77256ae 36 for (i=0; i<32; i++) {
bogdanm 20:4263a77256ae 37 if (obj->mask & (1<<i)) {
bogdanm 20:4263a77256ae 38 gpio_set(port_pin(obj->port, i));
bogdanm 20:4263a77256ae 39 }
bogdanm 20:4263a77256ae 40 }
bogdanm 20:4263a77256ae 41
bogdanm 20:4263a77256ae 42 port_dir(obj, dir);
bogdanm 20:4263a77256ae 43 }
bogdanm 20:4263a77256ae 44
bogdanm 20:4263a77256ae 45 void port_mode(port_t *obj, PinMode mode) {
bogdanm 20:4263a77256ae 46 uint32_t i;
bogdanm 20:4263a77256ae 47 // The mode is set per pin: reuse pinmap logic
bogdanm 20:4263a77256ae 48 for (i=0; i<32; i++) {
bogdanm 20:4263a77256ae 49 if (obj->mask & (1<<i)) {
bogdanm 20:4263a77256ae 50 pin_mode(port_pin(obj->port, i), mode);
bogdanm 20:4263a77256ae 51 }
bogdanm 20:4263a77256ae 52 }
bogdanm 20:4263a77256ae 53 }
bogdanm 20:4263a77256ae 54
bogdanm 20:4263a77256ae 55 void port_dir(port_t *obj, PinDirection dir) {
bogdanm 20:4263a77256ae 56 switch (dir) {
bogdanm 20:4263a77256ae 57 case PIN_INPUT:
bogdanm 20:4263a77256ae 58 *obj->reg_dir &= ~obj->mask;
bogdanm 20:4263a77256ae 59 break;
bogdanm 20:4263a77256ae 60 case PIN_OUTPUT:
bogdanm 20:4263a77256ae 61 *obj->reg_dir |= obj->mask;
bogdanm 20:4263a77256ae 62 break;
bogdanm 20:4263a77256ae 63 }
bogdanm 20:4263a77256ae 64 }
bogdanm 20:4263a77256ae 65
bogdanm 20:4263a77256ae 66 void port_write(port_t *obj, int value) {
bogdanm 20:4263a77256ae 67 *obj->reg_out = (*obj->reg_in & ~obj->mask) | (value & obj->mask);
bogdanm 20:4263a77256ae 68 }
bogdanm 20:4263a77256ae 69
bogdanm 20:4263a77256ae 70 int port_read(port_t *obj) {
bogdanm 20:4263a77256ae 71 return (*obj->reg_in & obj->mask);
bogdanm 20:4263a77256ae 72 }