Mbed SDK for XRange SX1272 LoRa module
Dependents: XRangePingPong XRange-LoRaWAN-lmic-app lora-transceiver
SX1272 LoRa RF module
https://www.netblocks.eu/xrange-sx1272-lora-datasheet/
targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_object.h@339:ac6f3fd999f3, 2016-01-07 (annotated)
- Committer:
- netblocks
- Date:
- Thu Jan 07 13:01:25 2016 +0000
- Revision:
- 339:ac6f3fd999f3
- Parent:
- 336:1e18a06a987b
HSE_VALUE set for XTAL 16Mhz
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudmuck | 336:1e18a06a987b | 1 | /* mbed Microcontroller Library |
dudmuck | 336:1e18a06a987b | 2 | ******************************************************************************* |
dudmuck | 336:1e18a06a987b | 3 | * Copyright (c) 2014, STMicroelectronics |
dudmuck | 336:1e18a06a987b | 4 | * All rights reserved. |
dudmuck | 336:1e18a06a987b | 5 | * |
dudmuck | 336:1e18a06a987b | 6 | * Redistribution and use in source and binary forms, with or without |
dudmuck | 336:1e18a06a987b | 7 | * modification, are permitted provided that the following conditions are met: |
dudmuck | 336:1e18a06a987b | 8 | * |
dudmuck | 336:1e18a06a987b | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
dudmuck | 336:1e18a06a987b | 10 | * this list of conditions and the following disclaimer. |
dudmuck | 336:1e18a06a987b | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
dudmuck | 336:1e18a06a987b | 12 | * this list of conditions and the following disclaimer in the documentation |
dudmuck | 336:1e18a06a987b | 13 | * and/or other materials provided with the distribution. |
dudmuck | 336:1e18a06a987b | 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
dudmuck | 336:1e18a06a987b | 15 | * may be used to endorse or promote products derived from this software |
dudmuck | 336:1e18a06a987b | 16 | * without specific prior written permission. |
dudmuck | 336:1e18a06a987b | 17 | * |
dudmuck | 336:1e18a06a987b | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
dudmuck | 336:1e18a06a987b | 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
dudmuck | 336:1e18a06a987b | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
dudmuck | 336:1e18a06a987b | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
dudmuck | 336:1e18a06a987b | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
dudmuck | 336:1e18a06a987b | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
dudmuck | 336:1e18a06a987b | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
dudmuck | 336:1e18a06a987b | 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
dudmuck | 336:1e18a06a987b | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
dudmuck | 336:1e18a06a987b | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
dudmuck | 336:1e18a06a987b | 28 | ******************************************************************************* |
dudmuck | 336:1e18a06a987b | 29 | */ |
dudmuck | 336:1e18a06a987b | 30 | #ifndef MBED_GPIO_OBJECT_H |
dudmuck | 336:1e18a06a987b | 31 | #define MBED_GPIO_OBJECT_H |
dudmuck | 336:1e18a06a987b | 32 | |
dudmuck | 336:1e18a06a987b | 33 | #include "mbed_assert.h" |
dudmuck | 336:1e18a06a987b | 34 | #include "cmsis.h" |
dudmuck | 336:1e18a06a987b | 35 | #include "PortNames.h" |
dudmuck | 336:1e18a06a987b | 36 | #include "PeripheralNames.h" |
dudmuck | 336:1e18a06a987b | 37 | #include "PinNames.h" |
dudmuck | 336:1e18a06a987b | 38 | |
dudmuck | 336:1e18a06a987b | 39 | #ifdef __cplusplus |
dudmuck | 336:1e18a06a987b | 40 | extern "C" { |
dudmuck | 336:1e18a06a987b | 41 | #endif |
dudmuck | 336:1e18a06a987b | 42 | |
dudmuck | 336:1e18a06a987b | 43 | typedef struct { |
dudmuck | 336:1e18a06a987b | 44 | PinName pin; |
dudmuck | 336:1e18a06a987b | 45 | uint32_t mask; |
dudmuck | 336:1e18a06a987b | 46 | __IO uint32_t *reg_in; |
dudmuck | 336:1e18a06a987b | 47 | __IO uint32_t *reg_set; |
dudmuck | 336:1e18a06a987b | 48 | __IO uint32_t *reg_clr; |
dudmuck | 336:1e18a06a987b | 49 | } gpio_t; |
dudmuck | 336:1e18a06a987b | 50 | |
dudmuck | 336:1e18a06a987b | 51 | static inline void gpio_write(gpio_t *obj, int value) |
dudmuck | 336:1e18a06a987b | 52 | { |
dudmuck | 336:1e18a06a987b | 53 | MBED_ASSERT(obj->pin != (PinName)NC); |
dudmuck | 336:1e18a06a987b | 54 | #ifdef STM32L152xC |
dudmuck | 336:1e18a06a987b | 55 | /* FIXME: is GPIOx->BRR working in STM32L152RC ? */ |
dudmuck | 336:1e18a06a987b | 56 | /* using upper half of BSRR to clear for now */ |
dudmuck | 336:1e18a06a987b | 57 | if (value) { |
dudmuck | 336:1e18a06a987b | 58 | *obj->reg_set = obj->mask; |
dudmuck | 336:1e18a06a987b | 59 | } else { |
dudmuck | 336:1e18a06a987b | 60 | *obj->reg_set = obj->mask << 16; |
dudmuck | 336:1e18a06a987b | 61 | } |
dudmuck | 336:1e18a06a987b | 62 | #else |
dudmuck | 336:1e18a06a987b | 63 | if (value) { |
dudmuck | 336:1e18a06a987b | 64 | *obj->reg_set = obj->mask; |
dudmuck | 336:1e18a06a987b | 65 | } else { |
dudmuck | 336:1e18a06a987b | 66 | *obj->reg_clr = obj->mask; |
dudmuck | 336:1e18a06a987b | 67 | } |
dudmuck | 336:1e18a06a987b | 68 | #endif |
dudmuck | 336:1e18a06a987b | 69 | } |
dudmuck | 336:1e18a06a987b | 70 | |
dudmuck | 336:1e18a06a987b | 71 | static inline int gpio_read(gpio_t *obj) |
dudmuck | 336:1e18a06a987b | 72 | { |
dudmuck | 336:1e18a06a987b | 73 | MBED_ASSERT(obj->pin != (PinName)NC); |
dudmuck | 336:1e18a06a987b | 74 | return ((*obj->reg_in & obj->mask) ? 1 : 0); |
dudmuck | 336:1e18a06a987b | 75 | } |
dudmuck | 336:1e18a06a987b | 76 | |
dudmuck | 336:1e18a06a987b | 77 | #ifdef __cplusplus |
dudmuck | 336:1e18a06a987b | 78 | } |
dudmuck | 336:1e18a06a987b | 79 | #endif |
dudmuck | 336:1e18a06a987b | 80 | |
dudmuck | 336:1e18a06a987b | 81 | #endif |