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