Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Babyseat_NewFirmware_copy_sean by
src/gpio_nucleo.cpp@2:625a45555a85, 2017-08-25 (annotated)
- Committer:
- kevin1990
- Date:
- Fri Aug 25 11:17:37 2017 +0000
- Revision:
- 2:625a45555a85
Sensor Channel 0 Type K example
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kevin1990 | 2:625a45555a85 | 1 | /*! |
| kevin1990 | 2:625a45555a85 | 2 | ****************************************************************************** |
| kevin1990 | 2:625a45555a85 | 3 | * @file: gpio_nucleo.c |
| kevin1990 | 2:625a45555a85 | 4 | * @brief: ADISense1000 OS Dependant wrapper layer for gpio |
| kevin1990 | 2:625a45555a85 | 5 | *----------------------------------------------------------------------------- |
| kevin1990 | 2:625a45555a85 | 6 | * |
| kevin1990 | 2:625a45555a85 | 7 | Copyright (c) 2017 Emutex Ltd. / Analog Devices, Inc. |
| kevin1990 | 2:625a45555a85 | 8 | |
| kevin1990 | 2:625a45555a85 | 9 | All rights reserved. |
| kevin1990 | 2:625a45555a85 | 10 | |
| kevin1990 | 2:625a45555a85 | 11 | Redistribution and use in source and binary forms, with or without modification, |
| kevin1990 | 2:625a45555a85 | 12 | are permitted provided that the following conditions are met: |
| kevin1990 | 2:625a45555a85 | 13 | - Redistributions of source code must retain the above copyright notice, |
| kevin1990 | 2:625a45555a85 | 14 | this list of conditions and the following disclaimer. |
| kevin1990 | 2:625a45555a85 | 15 | - Redistributions in binary form must reproduce the above copyright notice, |
| kevin1990 | 2:625a45555a85 | 16 | this list of conditions and the following disclaimer in the documentation |
| kevin1990 | 2:625a45555a85 | 17 | and/or other materials provided with the distribution. |
| kevin1990 | 2:625a45555a85 | 18 | - Modified versions of the software must be conspicuously marked as such. |
| kevin1990 | 2:625a45555a85 | 19 | - This software is licensed solely and exclusively for use with processors |
| kevin1990 | 2:625a45555a85 | 20 | manufactured by or for Analog Devices, Inc. |
| kevin1990 | 2:625a45555a85 | 21 | - This software may not be combined or merged with other code in any manner |
| kevin1990 | 2:625a45555a85 | 22 | that would cause the software to become subject to terms and conditions |
| kevin1990 | 2:625a45555a85 | 23 | which differ from those listed here. |
| kevin1990 | 2:625a45555a85 | 24 | - Neither the name of Analog Devices, Inc. nor the names of its |
| kevin1990 | 2:625a45555a85 | 25 | contributors may be used to endorse or promote products derived |
| kevin1990 | 2:625a45555a85 | 26 | from this software without specific prior written permission. |
| kevin1990 | 2:625a45555a85 | 27 | - The use of this software may or may not infringe the patent rights of one |
| kevin1990 | 2:625a45555a85 | 28 | or more patent holders. This license does not release you from the |
| kevin1990 | 2:625a45555a85 | 29 | requirement that you obtain separate licenses from these patent holders |
| kevin1990 | 2:625a45555a85 | 30 | to use this software. |
| kevin1990 | 2:625a45555a85 | 31 | |
| kevin1990 | 2:625a45555a85 | 32 | THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY |
| kevin1990 | 2:625a45555a85 | 33 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
| kevin1990 | 2:625a45555a85 | 34 | TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| kevin1990 | 2:625a45555a85 | 35 | NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| kevin1990 | 2:625a45555a85 | 36 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES |
| kevin1990 | 2:625a45555a85 | 37 | (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL |
| kevin1990 | 2:625a45555a85 | 38 | PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| kevin1990 | 2:625a45555a85 | 39 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| kevin1990 | 2:625a45555a85 | 40 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| kevin1990 | 2:625a45555a85 | 41 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| kevin1990 | 2:625a45555a85 | 42 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| kevin1990 | 2:625a45555a85 | 43 | * |
| kevin1990 | 2:625a45555a85 | 44 | *****************************************************************************/ |
| kevin1990 | 2:625a45555a85 | 45 | /******************************************************************************/ |
| kevin1990 | 2:625a45555a85 | 46 | /* Include Files */ |
| kevin1990 | 2:625a45555a85 | 47 | /******************************************************************************/ |
| kevin1990 | 2:625a45555a85 | 48 | |
| kevin1990 | 2:625a45555a85 | 49 | #include "inc/gpio_nucleo.h" |
| kevin1990 | 2:625a45555a85 | 50 | |
| kevin1990 | 2:625a45555a85 | 51 | DigitalOut resetPin(D2, 1); |
| kevin1990 | 2:625a45555a85 | 52 | DigitalIn errorPin(D3); |
| kevin1990 | 2:625a45555a85 | 53 | DigitalIn alertPin(D4); |
| kevin1990 | 2:625a45555a85 | 54 | DigitalIn readyPin(D5); |
| kevin1990 | 2:625a45555a85 | 55 | |
| kevin1990 | 2:625a45555a85 | 56 | /*! |
| kevin1990 | 2:625a45555a85 | 57 | * @brief Register a new gpio pin |
| kevin1990 | 2:625a45555a85 | 58 | * |
| kevin1990 | 2:625a45555a85 | 59 | * @param[in] config gpio connections to configure |
| kevin1990 | 2:625a45555a85 | 60 | * |
| kevin1990 | 2:625a45555a85 | 61 | * @return Status |
| kevin1990 | 2:625a45555a85 | 62 | * - #ADI_SENSE_SUCCESS Call completed successfully. |
| kevin1990 | 2:625a45555a85 | 63 | * - todo |
| kevin1990 | 2:625a45555a85 | 64 | * |
| kevin1990 | 2:625a45555a85 | 65 | */ |
| kevin1990 | 2:625a45555a85 | 66 | ADI_SENSE_RESULT ADISense1000_HostGpioOpen(gpioSettings *config) |
| kevin1990 | 2:625a45555a85 | 67 | { |
| kevin1990 | 2:625a45555a85 | 68 | /* |
| kevin1990 | 2:625a45555a85 | 69 | For v0.1 we are using the mbed api so this function is |
| kevin1990 | 2:625a45555a85 | 70 | not required. The digital classes are declared globally. |
| kevin1990 | 2:625a45555a85 | 71 | Parameters are placeholders for future revisions |
| kevin1990 | 2:625a45555a85 | 72 | */ |
| kevin1990 | 2:625a45555a85 | 73 | resetPin = 1; |
| kevin1990 | 2:625a45555a85 | 74 | |
| kevin1990 | 2:625a45555a85 | 75 | return ADI_SENSE_SUCCESS; |
| kevin1990 | 2:625a45555a85 | 76 | } |
| kevin1990 | 2:625a45555a85 | 77 | |
| kevin1990 | 2:625a45555a85 | 78 | /*! |
| kevin1990 | 2:625a45555a85 | 79 | * @brief Get input status of gpio |
| kevin1990 | 2:625a45555a85 | 80 | * |
| kevin1990 | 2:625a45555a85 | 81 | * @param[in] pinID Gpio to be read |
| kevin1990 | 2:625a45555a85 | 82 | * @param[out] bState State of gpio pin |
| kevin1990 | 2:625a45555a85 | 83 | * |
| kevin1990 | 2:625a45555a85 | 84 | * @return Status |
| kevin1990 | 2:625a45555a85 | 85 | * - #ADI_SENSE_SUCCESS Call completed successfully. |
| kevin1990 | 2:625a45555a85 | 86 | * - todo |
| kevin1990 | 2:625a45555a85 | 87 | * |
| kevin1990 | 2:625a45555a85 | 88 | */ |
| kevin1990 | 2:625a45555a85 | 89 | ADI_SENSE_RESULT ADISense1000_HostGpioGet(gpioPins pinID, bool *bState) |
| kevin1990 | 2:625a45555a85 | 90 | { |
| kevin1990 | 2:625a45555a85 | 91 | switch(pinID) |
| kevin1990 | 2:625a45555a85 | 92 | { |
| kevin1990 | 2:625a45555a85 | 93 | case HOST_RESET: |
| kevin1990 | 2:625a45555a85 | 94 | // Digital Output only |
| kevin1990 | 2:625a45555a85 | 95 | break; |
| kevin1990 | 2:625a45555a85 | 96 | case HOST_ERROR: |
| kevin1990 | 2:625a45555a85 | 97 | *bState = !errorPin ? false : true; |
| kevin1990 | 2:625a45555a85 | 98 | break; |
| kevin1990 | 2:625a45555a85 | 99 | case HOST_ALERT: |
| kevin1990 | 2:625a45555a85 | 100 | *bState = !alertPin ? false : true; |
| kevin1990 | 2:625a45555a85 | 101 | break; |
| kevin1990 | 2:625a45555a85 | 102 | case HOST_READY: |
| kevin1990 | 2:625a45555a85 | 103 | *bState = !readyPin ? false : true; |
| kevin1990 | 2:625a45555a85 | 104 | break; |
| kevin1990 | 2:625a45555a85 | 105 | default: |
| kevin1990 | 2:625a45555a85 | 106 | return ADI_SENSE_FAILURE; |
| kevin1990 | 2:625a45555a85 | 107 | } |
| kevin1990 | 2:625a45555a85 | 108 | |
| kevin1990 | 2:625a45555a85 | 109 | return ADI_SENSE_SUCCESS; |
| kevin1990 | 2:625a45555a85 | 110 | } |
| kevin1990 | 2:625a45555a85 | 111 | |
| kevin1990 | 2:625a45555a85 | 112 | /*! |
| kevin1990 | 2:625a45555a85 | 113 | * @brief Set output status of gpio |
| kevin1990 | 2:625a45555a85 | 114 | * |
| kevin1990 | 2:625a45555a85 | 115 | * @param[in] pinID Gpio to be set |
| kevin1990 | 2:625a45555a85 | 116 | * @param[out] bState New state of pin |
| kevin1990 | 2:625a45555a85 | 117 | * |
| kevin1990 | 2:625a45555a85 | 118 | * @return Status |
| kevin1990 | 2:625a45555a85 | 119 | * - #ADI_SENSE_SUCCESS Call completed successfully. |
| kevin1990 | 2:625a45555a85 | 120 | * - todo |
| kevin1990 | 2:625a45555a85 | 121 | * |
| kevin1990 | 2:625a45555a85 | 122 | */ |
| kevin1990 | 2:625a45555a85 | 123 | ADI_SENSE_RESULT ADISense1000_HostGpioSet(gpioPins pinID, bool bState) |
| kevin1990 | 2:625a45555a85 | 124 | { |
| kevin1990 | 2:625a45555a85 | 125 | switch(pinID) |
| kevin1990 | 2:625a45555a85 | 126 | { |
| kevin1990 | 2:625a45555a85 | 127 | case HOST_RESET: |
| kevin1990 | 2:625a45555a85 | 128 | resetPin = bState; |
| kevin1990 | 2:625a45555a85 | 129 | break; |
| kevin1990 | 2:625a45555a85 | 130 | case HOST_ERROR: |
| kevin1990 | 2:625a45555a85 | 131 | // Digital Input only |
| kevin1990 | 2:625a45555a85 | 132 | break; |
| kevin1990 | 2:625a45555a85 | 133 | case HOST_ALERT: |
| kevin1990 | 2:625a45555a85 | 134 | // Digital Input only |
| kevin1990 | 2:625a45555a85 | 135 | break; |
| kevin1990 | 2:625a45555a85 | 136 | case HOST_READY: |
| kevin1990 | 2:625a45555a85 | 137 | // Digital Input only |
| kevin1990 | 2:625a45555a85 | 138 | break; |
| kevin1990 | 2:625a45555a85 | 139 | default: |
| kevin1990 | 2:625a45555a85 | 140 | return ADI_SENSE_FAILURE; |
| kevin1990 | 2:625a45555a85 | 141 | } |
| kevin1990 | 2:625a45555a85 | 142 | return ADI_SENSE_SUCCESS; |
| kevin1990 | 2:625a45555a85 | 143 | } |
| kevin1990 | 2:625a45555a85 | 144 | |
| kevin1990 | 2:625a45555a85 | 145 | /*! |
| kevin1990 | 2:625a45555a85 | 146 | * @brief |
| kevin1990 | 2:625a45555a85 | 147 | * |
| kevin1990 | 2:625a45555a85 | 148 | * @param[in] |
| kevin1990 | 2:625a45555a85 | 149 | * @param[out] |
| kevin1990 | 2:625a45555a85 | 150 | * |
| kevin1990 | 2:625a45555a85 | 151 | * @return Status |
| kevin1990 | 2:625a45555a85 | 152 | * - #ADI_SENSE_SUCCESS Call completed successfully. |
| kevin1990 | 2:625a45555a85 | 153 | * - todo |
| kevin1990 | 2:625a45555a85 | 154 | * |
| kevin1990 | 2:625a45555a85 | 155 | */ |
| kevin1990 | 2:625a45555a85 | 156 | ADI_SENSE_RESULT ADISense1000_HostGpioIrqEnable() |
| kevin1990 | 2:625a45555a85 | 157 | { |
| kevin1990 | 2:625a45555a85 | 158 | // TODO: Not required for v0.1 |
| kevin1990 | 2:625a45555a85 | 159 | return ADI_SENSE_SUCCESS; |
| kevin1990 | 2:625a45555a85 | 160 | } |
| kevin1990 | 2:625a45555a85 | 161 | |
| kevin1990 | 2:625a45555a85 | 162 | /*! |
| kevin1990 | 2:625a45555a85 | 163 | * @brief |
| kevin1990 | 2:625a45555a85 | 164 | * |
| kevin1990 | 2:625a45555a85 | 165 | * @param[in] |
| kevin1990 | 2:625a45555a85 | 166 | * @param[out] |
| kevin1990 | 2:625a45555a85 | 167 | * |
| kevin1990 | 2:625a45555a85 | 168 | * @return Status |
| kevin1990 | 2:625a45555a85 | 169 | * - #ADI_SENSE_SUCCESS Call completed successfully. |
| kevin1990 | 2:625a45555a85 | 170 | * - todo |
| kevin1990 | 2:625a45555a85 | 171 | * |
| kevin1990 | 2:625a45555a85 | 172 | */ |
| kevin1990 | 2:625a45555a85 | 173 | ADI_SENSE_RESULT ADISense1000_HostGpioIrqDisable() |
| kevin1990 | 2:625a45555a85 | 174 | { |
| kevin1990 | 2:625a45555a85 | 175 | // TODO: Not required for v0.1 |
| kevin1990 | 2:625a45555a85 | 176 | return ADI_SENSE_SUCCESS; |
| kevin1990 | 2:625a45555a85 | 177 | } |
| kevin1990 | 2:625a45555a85 | 178 | |
| kevin1990 | 2:625a45555a85 | 179 | /*! |
| kevin1990 | 2:625a45555a85 | 180 | * @brief |
| kevin1990 | 2:625a45555a85 | 181 | * |
| kevin1990 | 2:625a45555a85 | 182 | * @param[in] |
| kevin1990 | 2:625a45555a85 | 183 | * @param[out] |
| kevin1990 | 2:625a45555a85 | 184 | * |
| kevin1990 | 2:625a45555a85 | 185 | * @return Status |
| kevin1990 | 2:625a45555a85 | 186 | * - #ADI_SENSE_SUCCESS Call completed successfully. |
| kevin1990 | 2:625a45555a85 | 187 | * - todo |
| kevin1990 | 2:625a45555a85 | 188 | * |
| kevin1990 | 2:625a45555a85 | 189 | */ |
| kevin1990 | 2:625a45555a85 | 190 | ADI_SENSE_RESULT ADISense1000_HostGpioClose() |
| kevin1990 | 2:625a45555a85 | 191 | { |
| kevin1990 | 2:625a45555a85 | 192 | return ADI_SENSE_SUCCESS; |
| kevin1990 | 2:625a45555a85 | 193 | } |
| kevin1990 | 2:625a45555a85 | 194 | /** |
| kevin1990 | 2:625a45555a85 | 195 | * @} |
| kevin1990 | 2:625a45555a85 | 196 | */ |
| kevin1990 | 2:625a45555a85 | 197 |
