DHT11

Committer:
jhon309
Date:
Thu Aug 13 00:21:57 2015 +0000
Revision:
0:c52df770855b
DHT11

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhon309 0:c52df770855b 1 /* mbed Microcontroller Library
jhon309 0:c52df770855b 2 *******************************************************************************
jhon309 0:c52df770855b 3 * Copyright (c) 2014, STMicroelectronics
jhon309 0:c52df770855b 4 * All rights reserved.
jhon309 0:c52df770855b 5 *
jhon309 0:c52df770855b 6 * Redistribution and use in source and binary forms, with or without
jhon309 0:c52df770855b 7 * modification, are permitted provided that the following conditions are met:
jhon309 0:c52df770855b 8 *
jhon309 0:c52df770855b 9 * 1. Redistributions of source code must retain the above copyright notice,
jhon309 0:c52df770855b 10 * this list of conditions and the following disclaimer.
jhon309 0:c52df770855b 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
jhon309 0:c52df770855b 12 * this list of conditions and the following disclaimer in the documentation
jhon309 0:c52df770855b 13 * and/or other materials provided with the distribution.
jhon309 0:c52df770855b 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
jhon309 0:c52df770855b 15 * may be used to endorse or promote products derived from this software
jhon309 0:c52df770855b 16 * without specific prior written permission.
jhon309 0:c52df770855b 17 *
jhon309 0:c52df770855b 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
jhon309 0:c52df770855b 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
jhon309 0:c52df770855b 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jhon309 0:c52df770855b 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
jhon309 0:c52df770855b 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
jhon309 0:c52df770855b 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
jhon309 0:c52df770855b 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
jhon309 0:c52df770855b 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jhon309 0:c52df770855b 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
jhon309 0:c52df770855b 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jhon309 0:c52df770855b 28 *******************************************************************************
jhon309 0:c52df770855b 29 */
jhon309 0:c52df770855b 30 #ifndef MBED_PINNAMES_H
jhon309 0:c52df770855b 31 #define MBED_PINNAMES_H
jhon309 0:c52df770855b 32
jhon309 0:c52df770855b 33 #include "cmsis.h"
jhon309 0:c52df770855b 34
jhon309 0:c52df770855b 35 #ifdef __cplusplus
jhon309 0:c52df770855b 36 extern "C" {
jhon309 0:c52df770855b 37 #endif
jhon309 0:c52df770855b 38
jhon309 0:c52df770855b 39 // See stm32f0xx_hal_gpio.h and stm32f0xx_hal_gpio_ex.h for values of MODE, PUPD and AFNUM
jhon309 0:c52df770855b 40 #define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
jhon309 0:c52df770855b 41 #define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
jhon309 0:c52df770855b 42 #define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
jhon309 0:c52df770855b 43 #define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
jhon309 0:c52df770855b 44 #define STM_MODE_INPUT (0)
jhon309 0:c52df770855b 45 #define STM_MODE_OUTPUT_PP (1)
jhon309 0:c52df770855b 46 #define STM_MODE_OUTPUT_OD (2)
jhon309 0:c52df770855b 47 #define STM_MODE_AF_PP (3)
jhon309 0:c52df770855b 48 #define STM_MODE_AF_OD (4)
jhon309 0:c52df770855b 49 #define STM_MODE_ANALOG (5)
jhon309 0:c52df770855b 50 #define STM_MODE_IT_RISING (6)
jhon309 0:c52df770855b 51 #define STM_MODE_IT_FALLING (7)
jhon309 0:c52df770855b 52 #define STM_MODE_IT_RISING_FALLING (8)
jhon309 0:c52df770855b 53 #define STM_MODE_EVT_RISING (9)
jhon309 0:c52df770855b 54 #define STM_MODE_EVT_FALLING (10)
jhon309 0:c52df770855b 55 #define STM_MODE_EVT_RISING_FALLING (11)
jhon309 0:c52df770855b 56 #define STM_MODE_IT_EVT_RESET (12)
jhon309 0:c52df770855b 57
jhon309 0:c52df770855b 58 // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
jhon309 0:c52df770855b 59 // Low nibble = pin number
jhon309 0:c52df770855b 60 #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
jhon309 0:c52df770855b 61 #define STM_PIN(X) ((uint32_t)(X) & 0xF)
jhon309 0:c52df770855b 62
jhon309 0:c52df770855b 63 typedef enum {
jhon309 0:c52df770855b 64 PIN_INPUT,
jhon309 0:c52df770855b 65 PIN_OUTPUT
jhon309 0:c52df770855b 66 } PinDirection;
jhon309 0:c52df770855b 67
jhon309 0:c52df770855b 68 typedef enum {
jhon309 0:c52df770855b 69 PA_0 = 0x00,
jhon309 0:c52df770855b 70 PA_1 = 0x01,
jhon309 0:c52df770855b 71 PA_2 = 0x02,
jhon309 0:c52df770855b 72 PA_3 = 0x03,
jhon309 0:c52df770855b 73 PA_4 = 0x04,
jhon309 0:c52df770855b 74 PA_5 = 0x05,
jhon309 0:c52df770855b 75 PA_6 = 0x06,
jhon309 0:c52df770855b 76 PA_7 = 0x07,
jhon309 0:c52df770855b 77 PA_8 = 0x08,
jhon309 0:c52df770855b 78 PA_9 = 0x09,
jhon309 0:c52df770855b 79 PA_10 = 0x0A,
jhon309 0:c52df770855b 80 PA_11 = 0x0B,
jhon309 0:c52df770855b 81 PA_12 = 0x0C,
jhon309 0:c52df770855b 82 PA_13 = 0x0D,
jhon309 0:c52df770855b 83 PA_14 = 0x0E,
jhon309 0:c52df770855b 84 PA_15 = 0x0F,
jhon309 0:c52df770855b 85
jhon309 0:c52df770855b 86 PB_0 = 0x10,
jhon309 0:c52df770855b 87 PB_1 = 0x11,
jhon309 0:c52df770855b 88 PB_2 = 0x12,
jhon309 0:c52df770855b 89 PB_3 = 0x13,
jhon309 0:c52df770855b 90 PB_4 = 0x14,
jhon309 0:c52df770855b 91 PB_5 = 0x15,
jhon309 0:c52df770855b 92 PB_6 = 0x16,
jhon309 0:c52df770855b 93 PB_7 = 0x17,
jhon309 0:c52df770855b 94 PB_8 = 0x18,
jhon309 0:c52df770855b 95 PB_9 = 0x19,
jhon309 0:c52df770855b 96 PB_10 = 0x1A,
jhon309 0:c52df770855b 97 PB_11 = 0x1B,
jhon309 0:c52df770855b 98 PB_12 = 0x1C,
jhon309 0:c52df770855b 99 PB_13 = 0x1D,
jhon309 0:c52df770855b 100 PB_14 = 0x1E,
jhon309 0:c52df770855b 101 PB_15 = 0x1F,
jhon309 0:c52df770855b 102
jhon309 0:c52df770855b 103 PC_0 = 0x20,
jhon309 0:c52df770855b 104 PC_1 = 0x21,
jhon309 0:c52df770855b 105 PC_2 = 0x22,
jhon309 0:c52df770855b 106 PC_3 = 0x23,
jhon309 0:c52df770855b 107 PC_4 = 0x24,
jhon309 0:c52df770855b 108 PC_5 = 0x25,
jhon309 0:c52df770855b 109 PC_6 = 0x26,
jhon309 0:c52df770855b 110 PC_7 = 0x27,
jhon309 0:c52df770855b 111 PC_8 = 0x28,
jhon309 0:c52df770855b 112 PC_9 = 0x29,
jhon309 0:c52df770855b 113 PC_10 = 0x2A,
jhon309 0:c52df770855b 114 PC_11 = 0x2B,
jhon309 0:c52df770855b 115 PC_12 = 0x2C,
jhon309 0:c52df770855b 116 PC_13 = 0x2D,
jhon309 0:c52df770855b 117 PC_14 = 0x2E,
jhon309 0:c52df770855b 118 PC_15 = 0x2F,
jhon309 0:c52df770855b 119
jhon309 0:c52df770855b 120 PD_2 = 0x32,
jhon309 0:c52df770855b 121
jhon309 0:c52df770855b 122 PF_0 = 0x50,
jhon309 0:c52df770855b 123 PF_1 = 0x51,
jhon309 0:c52df770855b 124
jhon309 0:c52df770855b 125 // Arduino connector namings
jhon309 0:c52df770855b 126 A0 = PA_0,
jhon309 0:c52df770855b 127 A1 = PA_1,
jhon309 0:c52df770855b 128 A2 = PA_4,
jhon309 0:c52df770855b 129 A3 = PB_0,
jhon309 0:c52df770855b 130 A4 = PC_1,
jhon309 0:c52df770855b 131 A5 = PC_0,
jhon309 0:c52df770855b 132 D0 = PA_3,
jhon309 0:c52df770855b 133 D1 = PA_2,
jhon309 0:c52df770855b 134 D2 = PA_10,
jhon309 0:c52df770855b 135 D3 = PB_3,
jhon309 0:c52df770855b 136 D4 = PB_5,
jhon309 0:c52df770855b 137 D5 = PB_4,
jhon309 0:c52df770855b 138 D6 = PB_10,
jhon309 0:c52df770855b 139 D7 = PA_8,
jhon309 0:c52df770855b 140 D8 = PA_9,
jhon309 0:c52df770855b 141 D9 = PC_7,
jhon309 0:c52df770855b 142 D10 = PB_6,
jhon309 0:c52df770855b 143 D11 = PA_7,
jhon309 0:c52df770855b 144 D12 = PA_6,
jhon309 0:c52df770855b 145 D13 = PA_5,
jhon309 0:c52df770855b 146 D14 = PB_9,
jhon309 0:c52df770855b 147 D15 = PB_8,
jhon309 0:c52df770855b 148
jhon309 0:c52df770855b 149 // Generic signals namings
jhon309 0:c52df770855b 150 LED1 = PA_5,
jhon309 0:c52df770855b 151 LED2 = PA_5,
jhon309 0:c52df770855b 152 LED3 = PA_5,
jhon309 0:c52df770855b 153 LED4 = PA_5,
jhon309 0:c52df770855b 154 USER_BUTTON = PC_13,
jhon309 0:c52df770855b 155 SERIAL_TX = PA_2,
jhon309 0:c52df770855b 156 SERIAL_RX = PA_3,
jhon309 0:c52df770855b 157 USBTX = PA_2,
jhon309 0:c52df770855b 158 USBRX = PA_3,
jhon309 0:c52df770855b 159 I2C_SCL = PB_8,
jhon309 0:c52df770855b 160 I2C_SDA = PB_9,
jhon309 0:c52df770855b 161 SPI_MOSI = PA_7,
jhon309 0:c52df770855b 162 SPI_MISO = PA_6,
jhon309 0:c52df770855b 163 SPI_SCK = PA_5,
jhon309 0:c52df770855b 164 SPI_CS = PB_6,
jhon309 0:c52df770855b 165 PWM_OUT = PB_3,
jhon309 0:c52df770855b 166
jhon309 0:c52df770855b 167 // Not connected
jhon309 0:c52df770855b 168 NC = (int)0xFFFFFFFF
jhon309 0:c52df770855b 169 } PinName;
jhon309 0:c52df770855b 170
jhon309 0:c52df770855b 171 typedef enum {
jhon309 0:c52df770855b 172 PullNone = 0,
jhon309 0:c52df770855b 173 PullUp = 1,
jhon309 0:c52df770855b 174 PullDown = 2,
jhon309 0:c52df770855b 175 OpenDrain = 3,
jhon309 0:c52df770855b 176 PullDefault = PullNone
jhon309 0:c52df770855b 177 } PinMode;
jhon309 0:c52df770855b 178
jhon309 0:c52df770855b 179 #ifdef __cplusplus
jhon309 0:c52df770855b 180 }
jhon309 0:c52df770855b 181 #endif
jhon309 0:c52df770855b 182
jhon309 0:c52df770855b 183 #endif