Forked mbed-dev as I use an 20 pins stm32F042 and not the 32 pins version

Dependents:   Numitron_clock

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Tue Nov 08 17:45:16 2016 +0000
Revision:
150:02e0a0aed4ec
This updates the lib to the mbed lib v129

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 150:02e0a0aed4ec 1 /* mbed Microcontroller Library
<> 150:02e0a0aed4ec 2 * Copyright (c) 2016 u-blox
<> 150:02e0a0aed4ec 3 *
<> 150:02e0a0aed4ec 4 * Licensed under the Apache License, Version 2.0 (the "License");
<> 150:02e0a0aed4ec 5 * you may not use this file except in compliance with the License.
<> 150:02e0a0aed4ec 6 * You may obtain a copy of the License at
<> 150:02e0a0aed4ec 7 *
<> 150:02e0a0aed4ec 8 * http://www.apache.org/licenses/LICENSE-2.0
<> 150:02e0a0aed4ec 9 *
<> 150:02e0a0aed4ec 10 * Unless required by applicable law or agreed to in writing, software
<> 150:02e0a0aed4ec 11 * distributed under the License is distributed on an "AS IS" BASIS,
<> 150:02e0a0aed4ec 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 150:02e0a0aed4ec 13 * See the License for the specific language governing permissions and
<> 150:02e0a0aed4ec 14 * limitations under the License.
<> 150:02e0a0aed4ec 15 */
<> 150:02e0a0aed4ec 16
<> 150:02e0a0aed4ec 17 #include <stdint.h>
<> 150:02e0a0aed4ec 18 #include <stdbool.h>
<> 150:02e0a0aed4ec 19 #include "mbed_assert.h"
<> 150:02e0a0aed4ec 20 #include "cmsis.h"
<> 150:02e0a0aed4ec 21 #include "hi2110_init.h"
<> 150:02e0a0aed4ec 22
<> 150:02e0a0aed4ec 23 /* ----------------------------------------------------------------
<> 150:02e0a0aed4ec 24 * MACROS
<> 150:02e0a0aed4ec 25 * ----------------------------------------------------------------*/
<> 150:02e0a0aed4ec 26
<> 150:02e0a0aed4ec 27 /* ----------------------------------------------------------------
<> 150:02e0a0aed4ec 28 * FUNCTION PROTOTYPES
<> 150:02e0a0aed4ec 29 * ----------------------------------------------------------------*/
<> 150:02e0a0aed4ec 30
<> 150:02e0a0aed4ec 31 static uint8_t get_owner(uint8_t pin);
<> 150:02e0a0aed4ec 32
<> 150:02e0a0aed4ec 33 /* ----------------------------------------------------------------
<> 150:02e0a0aed4ec 34 * NON-API FUNCTIONS
<> 150:02e0a0aed4ec 35 * ----------------------------------------------------------------*/
<> 150:02e0a0aed4ec 36
<> 150:02e0a0aed4ec 37 /* Determine which core owns a given pin
<> 150:02e0a0aed4ec 38 * 0: None
<> 150:02e0a0aed4ec 39 * 1: security core
<> 150:02e0a0aed4ec 40 * 2: protocol core
<> 150:02e0a0aed4ec 41 * 3: apps core */
<> 150:02e0a0aed4ec 42 static uint8_t get_owner(uint8_t pin)
<> 150:02e0a0aed4ec 43 {
<> 150:02e0a0aed4ec 44 uint8_t value;
<> 150:02e0a0aed4ec 45 uint8_t pio_owner_shift = (pin & 0x0F) << 1;
<> 150:02e0a0aed4ec 46 volatile uint32_t * pio_owner_reg = (&PIO_OWNER0 + (pin >> 4));
<> 150:02e0a0aed4ec 47
<> 150:02e0a0aed4ec 48 value = 0x03 & (*pio_owner_reg >> pio_owner_shift);
<> 150:02e0a0aed4ec 49
<> 150:02e0a0aed4ec 50 return value;
<> 150:02e0a0aed4ec 51 }
<> 150:02e0a0aed4ec 52
<> 150:02e0a0aed4ec 53 /* ----------------------------------------------------------------
<> 150:02e0a0aed4ec 54 * MBED API FUNCTIONS
<> 150:02e0a0aed4ec 55 * ----------------------------------------------------------------*/
<> 150:02e0a0aed4ec 56
<> 150:02e0a0aed4ec 57 void HI2110_init(void)
<> 150:02e0a0aed4ec 58 {
<> 150:02e0a0aed4ec 59 __attribute__ ((unused)) uint8_t owner[20];
<> 150:02e0a0aed4ec 60
<> 150:02e0a0aed4ec 61 /* This purely for diagnostics to see who owns which PIO pin.
<> 150:02e0a0aed4ec 62 * Put a break-point at the end of this function and take a look
<> 150:02e0a0aed4ec 63 * at the array.
<> 150:02e0a0aed4ec 64 * Any items marked as 1 or 2 belong to the security or protocol
<> 150:02e0a0aed4ec 65 * cores. Otherwise they are up for grabs. */
<> 150:02e0a0aed4ec 66 for (uint8_t x = 0; x < 20; x++) {
<> 150:02e0a0aed4ec 67 owner[x] = get_owner(x);
<> 150:02e0a0aed4ec 68 }
<> 150:02e0a0aed4ec 69 }