lol

Dependencies:   MMA8451Q

Fork of Application by Mateusz Kowalik

Committer:
Zaitsev
Date:
Tue Jan 10 20:42:26 2017 +0000
Revision:
10:41552d038a69
USB Serial bi-directional bridge

Who changed what in which revision?

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