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