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