The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
mbed_official
Date:
Thu Dec 21 18:20:02 2017 +0000
Revision:
159:7130f322cb7e
mbed library version 157

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 159:7130f322cb7e 1 /* mbed Microcontroller Library
mbed_official 159:7130f322cb7e 2 *******************************************************************************
mbed_official 159:7130f322cb7e 3 * Copyright (c) 2016, STMicroelectronics
mbed_official 159:7130f322cb7e 4 * All rights reserved.
mbed_official 159:7130f322cb7e 5 *
mbed_official 159:7130f322cb7e 6 * Redistribution and use in source and binary forms, with or without
mbed_official 159:7130f322cb7e 7 * modification, are permitted provided that the following conditions are met:
mbed_official 159:7130f322cb7e 8 *
mbed_official 159:7130f322cb7e 9 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 159:7130f322cb7e 10 * this list of conditions and the following disclaimer.
mbed_official 159:7130f322cb7e 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 159:7130f322cb7e 12 * this list of conditions and the following disclaimer in the documentation
mbed_official 159:7130f322cb7e 13 * and/or other materials provided with the distribution.
mbed_official 159:7130f322cb7e 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 159:7130f322cb7e 15 * may be used to endorse or promote products derived from this software
mbed_official 159:7130f322cb7e 16 * without specific prior written permission.
mbed_official 159:7130f322cb7e 17 *
mbed_official 159:7130f322cb7e 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 159:7130f322cb7e 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 159:7130f322cb7e 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 159:7130f322cb7e 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 159:7130f322cb7e 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 159:7130f322cb7e 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 159:7130f322cb7e 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 159:7130f322cb7e 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 159:7130f322cb7e 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 159:7130f322cb7e 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 159:7130f322cb7e 28 *******************************************************************************
mbed_official 159:7130f322cb7e 29 */
mbed_official 159:7130f322cb7e 30 #ifndef MBED_COMMON_OBJECTS_H
mbed_official 159:7130f322cb7e 31 #define MBED_COMMON_OBJECTS_H
mbed_official 159:7130f322cb7e 32
mbed_official 159:7130f322cb7e 33 #include "cmsis.h"
mbed_official 159:7130f322cb7e 34 #include "PortNames.h"
mbed_official 159:7130f322cb7e 35 #include "PeripheralNames.h"
mbed_official 159:7130f322cb7e 36 #include "PinNames.h"
mbed_official 159:7130f322cb7e 37
mbed_official 159:7130f322cb7e 38 #ifdef __cplusplus
mbed_official 159:7130f322cb7e 39 extern "C" {
mbed_official 159:7130f322cb7e 40 #endif
mbed_official 159:7130f322cb7e 41
mbed_official 159:7130f322cb7e 42 struct pwmout_s {
mbed_official 159:7130f322cb7e 43 PWMName pwm;
mbed_official 159:7130f322cb7e 44 PinName pin;
mbed_official 159:7130f322cb7e 45 uint32_t prescaler;
mbed_official 159:7130f322cb7e 46 uint32_t period;
mbed_official 159:7130f322cb7e 47 uint32_t pulse;
mbed_official 159:7130f322cb7e 48 uint8_t channel;
mbed_official 159:7130f322cb7e 49 uint8_t inverted;
mbed_official 159:7130f322cb7e 50 };
mbed_official 159:7130f322cb7e 51
mbed_official 159:7130f322cb7e 52 struct serial_s {
mbed_official 159:7130f322cb7e 53 UARTName uart;
mbed_official 159:7130f322cb7e 54 int index;
mbed_official 159:7130f322cb7e 55 uint32_t baudrate;
mbed_official 159:7130f322cb7e 56 uint32_t databits;
mbed_official 159:7130f322cb7e 57 uint32_t stopbits;
mbed_official 159:7130f322cb7e 58 uint32_t parity;
mbed_official 159:7130f322cb7e 59 PinName pin_tx;
mbed_official 159:7130f322cb7e 60 PinName pin_rx;
mbed_official 159:7130f322cb7e 61 #if DEVICE_SERIAL_ASYNCH
mbed_official 159:7130f322cb7e 62 uint32_t events;
mbed_official 159:7130f322cb7e 63 #endif
mbed_official 159:7130f322cb7e 64 #if DEVICE_SERIAL_FC
mbed_official 159:7130f322cb7e 65 uint32_t hw_flow_ctl;
mbed_official 159:7130f322cb7e 66 PinName pin_rts;
mbed_official 159:7130f322cb7e 67 PinName pin_cts;
mbed_official 159:7130f322cb7e 68 #endif
mbed_official 159:7130f322cb7e 69 };
mbed_official 159:7130f322cb7e 70
mbed_official 159:7130f322cb7e 71 struct spi_s {
mbed_official 159:7130f322cb7e 72 SPI_HandleTypeDef handle;
mbed_official 159:7130f322cb7e 73 IRQn_Type spiIRQ;
mbed_official 159:7130f322cb7e 74 SPIName spi;
mbed_official 159:7130f322cb7e 75 PinName pin_miso;
mbed_official 159:7130f322cb7e 76 PinName pin_mosi;
mbed_official 159:7130f322cb7e 77 PinName pin_sclk;
mbed_official 159:7130f322cb7e 78 PinName pin_ssel;
mbed_official 159:7130f322cb7e 79 #ifdef DEVICE_SPI_ASYNCH
mbed_official 159:7130f322cb7e 80 uint32_t event;
mbed_official 159:7130f322cb7e 81 uint8_t transfer_type;
mbed_official 159:7130f322cb7e 82 #endif
mbed_official 159:7130f322cb7e 83 };
mbed_official 159:7130f322cb7e 84
mbed_official 159:7130f322cb7e 85 struct i2c_s {
mbed_official 159:7130f322cb7e 86 /* The 1st 2 members I2CName i2c
mbed_official 159:7130f322cb7e 87 * and I2C_HandleTypeDef handle should
mbed_official 159:7130f322cb7e 88 * be kept as the first members of this struct
mbed_official 159:7130f322cb7e 89 * to have get_i2c_obj() function work as expected
mbed_official 159:7130f322cb7e 90 */
mbed_official 159:7130f322cb7e 91 I2CName i2c;
mbed_official 159:7130f322cb7e 92 I2C_HandleTypeDef handle;
mbed_official 159:7130f322cb7e 93 uint8_t index;
mbed_official 159:7130f322cb7e 94 int hz;
mbed_official 159:7130f322cb7e 95 PinName sda;
mbed_official 159:7130f322cb7e 96 PinName scl;
mbed_official 159:7130f322cb7e 97 IRQn_Type event_i2cIRQ;
mbed_official 159:7130f322cb7e 98 IRQn_Type error_i2cIRQ;
mbed_official 159:7130f322cb7e 99 uint8_t XferOperation;
mbed_official 159:7130f322cb7e 100 volatile uint8_t event;
mbed_official 159:7130f322cb7e 101 #if DEVICE_I2CSLAVE
mbed_official 159:7130f322cb7e 102 uint8_t slave;
mbed_official 159:7130f322cb7e 103 volatile uint8_t pending_slave_tx_master_rx;
mbed_official 159:7130f322cb7e 104 volatile uint8_t pending_slave_rx_maxter_tx;
mbed_official 159:7130f322cb7e 105 #endif
mbed_official 159:7130f322cb7e 106 #if DEVICE_I2C_ASYNCH
mbed_official 159:7130f322cb7e 107 uint32_t address;
mbed_official 159:7130f322cb7e 108 uint8_t stop;
mbed_official 159:7130f322cb7e 109 uint8_t available_events;
mbed_official 159:7130f322cb7e 110 #endif
mbed_official 159:7130f322cb7e 111 };
mbed_official 159:7130f322cb7e 112
mbed_official 159:7130f322cb7e 113 #if DEVICE_FLASH
mbed_official 159:7130f322cb7e 114 struct flash_s {
mbed_official 159:7130f322cb7e 115 uint32_t dummy;
mbed_official 159:7130f322cb7e 116 };
mbed_official 159:7130f322cb7e 117 #endif
mbed_official 159:7130f322cb7e 118
mbed_official 159:7130f322cb7e 119 struct analogin_s {
mbed_official 159:7130f322cb7e 120 ADC_HandleTypeDef handle;
mbed_official 159:7130f322cb7e 121 PinName pin;
mbed_official 159:7130f322cb7e 122 uint8_t channel;
mbed_official 159:7130f322cb7e 123 };
mbed_official 159:7130f322cb7e 124
mbed_official 159:7130f322cb7e 125 #define GPIO_IP_WITHOUT_BRR
mbed_official 159:7130f322cb7e 126 #include "gpio_object.h"
mbed_official 159:7130f322cb7e 127
mbed_official 159:7130f322cb7e 128 #if DEVICE_ANALOGOUT
mbed_official 159:7130f322cb7e 129 struct dac_s {
mbed_official 159:7130f322cb7e 130 DACName dac;
mbed_official 159:7130f322cb7e 131 uint32_t channel;
mbed_official 159:7130f322cb7e 132 DAC_HandleTypeDef handle;
mbed_official 159:7130f322cb7e 133 };
mbed_official 159:7130f322cb7e 134 #endif
mbed_official 159:7130f322cb7e 135
mbed_official 159:7130f322cb7e 136 #if DEVICE_CAN
mbed_official 159:7130f322cb7e 137 struct can_s {
mbed_official 159:7130f322cb7e 138 CAN_HandleTypeDef CanHandle;
mbed_official 159:7130f322cb7e 139 int index;
mbed_official 159:7130f322cb7e 140 int hz;
mbed_official 159:7130f322cb7e 141 };
mbed_official 159:7130f322cb7e 142 #endif
mbed_official 159:7130f322cb7e 143
mbed_official 159:7130f322cb7e 144 #ifdef __cplusplus
mbed_official 159:7130f322cb7e 145 }
mbed_official 159:7130f322cb7e 146 #endif
mbed_official 159:7130f322cb7e 147
mbed_official 159:7130f322cb7e 148 #endif
mbed_official 159:7130f322cb7e 149