mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 189:f392fc9709a3 1 /* mbed Microcontroller Library
AnnaBridge 189:f392fc9709a3 2 * Copyright (c) 2018 GigaDevice Semiconductor Inc.
AnnaBridge 189:f392fc9709a3 3 *
AnnaBridge 189:f392fc9709a3 4 * SPDX-License-Identifier: Apache-2.0
AnnaBridge 189:f392fc9709a3 5 *
AnnaBridge 189:f392fc9709a3 6 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 189:f392fc9709a3 7 * you may not use this file except in compliance with the License.
AnnaBridge 189:f392fc9709a3 8 * You may obtain a copy of the License at
AnnaBridge 189:f392fc9709a3 9 *
AnnaBridge 189:f392fc9709a3 10 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 189:f392fc9709a3 11 *
AnnaBridge 189:f392fc9709a3 12 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 189:f392fc9709a3 13 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 189:f392fc9709a3 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 189:f392fc9709a3 15 * See the License for the specific language governing permissions and
AnnaBridge 189:f392fc9709a3 16 * limitations under the License.
AnnaBridge 189:f392fc9709a3 17 */
AnnaBridge 189:f392fc9709a3 18 #ifndef MBED_OBJECTS_H
AnnaBridge 189:f392fc9709a3 19 #define MBED_OBJECTS_H
AnnaBridge 189:f392fc9709a3 20
AnnaBridge 189:f392fc9709a3 21 #include "cmsis.h"
AnnaBridge 189:f392fc9709a3 22 #include "PortNames.h"
AnnaBridge 189:f392fc9709a3 23 #include "PeripheralNames.h"
AnnaBridge 189:f392fc9709a3 24 #include "PinNames.h"
AnnaBridge 189:f392fc9709a3 25 #include "mbed_assert.h"
AnnaBridge 189:f392fc9709a3 26
AnnaBridge 189:f392fc9709a3 27 #ifdef __cplusplus
AnnaBridge 189:f392fc9709a3 28 extern "C" {
AnnaBridge 189:f392fc9709a3 29 #endif
AnnaBridge 189:f392fc9709a3 30
AnnaBridge 189:f392fc9709a3 31 typedef struct gpio_s gpio_t;
AnnaBridge 189:f392fc9709a3 32
AnnaBridge 189:f392fc9709a3 33 struct gpio_s {
AnnaBridge 189:f392fc9709a3 34 uint32_t mask;
AnnaBridge 189:f392fc9709a3 35 PinName pin;
AnnaBridge 189:f392fc9709a3 36 __IO uint32_t gpio_periph;
AnnaBridge 189:f392fc9709a3 37 };
AnnaBridge 189:f392fc9709a3 38
AnnaBridge 189:f392fc9709a3 39 struct gpio_irq_s {
AnnaBridge 189:f392fc9709a3 40 IRQn_Type irq_n;
AnnaBridge 189:f392fc9709a3 41 uint32_t irq_index;
AnnaBridge 189:f392fc9709a3 42 uint32_t event;
AnnaBridge 189:f392fc9709a3 43 PinName pin;
AnnaBridge 189:f392fc9709a3 44 };
AnnaBridge 189:f392fc9709a3 45
AnnaBridge 189:f392fc9709a3 46 struct port_s {
AnnaBridge 189:f392fc9709a3 47 PortName port;
AnnaBridge 189:f392fc9709a3 48 uint32_t mask;
AnnaBridge 189:f392fc9709a3 49 PinDirection direction;
AnnaBridge 189:f392fc9709a3 50 __IO uint32_t *reg_in;
AnnaBridge 189:f392fc9709a3 51 __IO uint32_t *reg_out;
AnnaBridge 189:f392fc9709a3 52 };
AnnaBridge 189:f392fc9709a3 53
AnnaBridge 189:f392fc9709a3 54 /* common objects */
AnnaBridge 189:f392fc9709a3 55 struct analogin_s {
AnnaBridge 189:f392fc9709a3 56 ADCName adc;
AnnaBridge 189:f392fc9709a3 57 PinName pin;
AnnaBridge 189:f392fc9709a3 58 uint8_t channel;
AnnaBridge 189:f392fc9709a3 59 };
AnnaBridge 189:f392fc9709a3 60
AnnaBridge 189:f392fc9709a3 61 #if DEVICE_ANALOGOUT
AnnaBridge 189:f392fc9709a3 62 struct dac_s {
AnnaBridge 189:f392fc9709a3 63 DACName dac;
AnnaBridge 189:f392fc9709a3 64 PinName pin;
AnnaBridge 189:f392fc9709a3 65 uint32_t channel;
AnnaBridge 189:f392fc9709a3 66 };
AnnaBridge 189:f392fc9709a3 67 #endif
AnnaBridge 189:f392fc9709a3 68
AnnaBridge 189:f392fc9709a3 69 struct can_s {
AnnaBridge 189:f392fc9709a3 70 CANName can;
AnnaBridge 189:f392fc9709a3 71 int index;
AnnaBridge 189:f392fc9709a3 72 };
AnnaBridge 189:f392fc9709a3 73
AnnaBridge 189:f392fc9709a3 74 struct pwmout_s {
AnnaBridge 189:f392fc9709a3 75 PWMName pwm;
AnnaBridge 189:f392fc9709a3 76 uint32_t cnt_unit;
AnnaBridge 189:f392fc9709a3 77 uint8_t ch;
AnnaBridge 189:f392fc9709a3 78 };
AnnaBridge 189:f392fc9709a3 79
AnnaBridge 189:f392fc9709a3 80 struct serial_s {
AnnaBridge 189:f392fc9709a3 81 /* basic information */
AnnaBridge 189:f392fc9709a3 82 UARTName uart;
AnnaBridge 189:f392fc9709a3 83 int index;
AnnaBridge 189:f392fc9709a3 84 PinName pin_tx;
AnnaBridge 189:f392fc9709a3 85 PinName pin_rx;
AnnaBridge 189:f392fc9709a3 86
AnnaBridge 189:f392fc9709a3 87 /* configure information */
AnnaBridge 189:f392fc9709a3 88 uint32_t baudrate;
AnnaBridge 189:f392fc9709a3 89 uint32_t databits;
AnnaBridge 189:f392fc9709a3 90 uint32_t stopbits;
AnnaBridge 189:f392fc9709a3 91 uint32_t parity;
AnnaBridge 189:f392fc9709a3 92
AnnaBridge 189:f392fc9709a3 93 /* operating parameters */
AnnaBridge 189:f392fc9709a3 94 uint16_t rx_size;
AnnaBridge 189:f392fc9709a3 95 uint8_t *tx_buffer_ptr;
AnnaBridge 189:f392fc9709a3 96 uint8_t *rx_buffer_ptr;
AnnaBridge 189:f392fc9709a3 97 __IO uint16_t tx_count;
AnnaBridge 189:f392fc9709a3 98 __IO uint16_t rx_count;
AnnaBridge 189:f392fc9709a3 99
AnnaBridge 189:f392fc9709a3 100 __IO uint32_t error_code;
AnnaBridge 189:f392fc9709a3 101 __IO operation_state_enum tx_state;
AnnaBridge 189:f392fc9709a3 102 __IO operation_state_enum rx_state;
AnnaBridge 189:f392fc9709a3 103
AnnaBridge 189:f392fc9709a3 104 #if DEVICE_SERIAL_ASYNCH
AnnaBridge 189:f392fc9709a3 105 uint32_t events;
AnnaBridge 189:f392fc9709a3 106 #endif
AnnaBridge 189:f392fc9709a3 107 #if DEVICE_SERIAL_FC
AnnaBridge 189:f392fc9709a3 108 uint32_t hw_flow_ctl;
AnnaBridge 189:f392fc9709a3 109 PinName pin_rts;
AnnaBridge 189:f392fc9709a3 110 PinName pin_cts;
AnnaBridge 189:f392fc9709a3 111 #endif
AnnaBridge 189:f392fc9709a3 112 };
AnnaBridge 189:f392fc9709a3 113
AnnaBridge 189:f392fc9709a3 114 struct spi_s {
AnnaBridge 189:f392fc9709a3 115 spi_parameter_struct spi_struct;
AnnaBridge 189:f392fc9709a3 116 IRQn_Type spi_irq;
AnnaBridge 189:f392fc9709a3 117 SPIName spi;
AnnaBridge 189:f392fc9709a3 118 PinName pin_miso;
AnnaBridge 189:f392fc9709a3 119 PinName pin_mosi;
AnnaBridge 189:f392fc9709a3 120 PinName pin_sclk;
AnnaBridge 189:f392fc9709a3 121 PinName pin_ssel;
AnnaBridge 189:f392fc9709a3 122 };
AnnaBridge 189:f392fc9709a3 123
AnnaBridge 189:f392fc9709a3 124 struct i2c_s {
AnnaBridge 189:f392fc9709a3 125 /* basic information */
AnnaBridge 189:f392fc9709a3 126 I2CName i2c;
AnnaBridge 189:f392fc9709a3 127 uint8_t index;
AnnaBridge 189:f392fc9709a3 128 PinName sda;
AnnaBridge 189:f392fc9709a3 129 PinName scl;
AnnaBridge 189:f392fc9709a3 130 int i2c_inited; /* flag used to indicate whether the i2c has been initialized */
AnnaBridge 189:f392fc9709a3 131
AnnaBridge 189:f392fc9709a3 132 /* configure information */
AnnaBridge 189:f392fc9709a3 133 int freq; /* i2c frequence */
AnnaBridge 189:f392fc9709a3 134 uint32_t addr_bit_mode; /* 7 bits or 10 bits */
AnnaBridge 189:f392fc9709a3 135 uint32_t slave_addr0;
AnnaBridge 189:f392fc9709a3 136 uint32_t slave_addr1;
AnnaBridge 189:f392fc9709a3 137 uint16_t transfer_size;
AnnaBridge 189:f392fc9709a3 138 uint8_t *buffer_pointer;
AnnaBridge 189:f392fc9709a3 139
AnnaBridge 189:f392fc9709a3 140 /* operating parameters */
AnnaBridge 189:f392fc9709a3 141 __IO operation_state_enum state;
AnnaBridge 189:f392fc9709a3 142 __IO i2c_mode_enum mode;
AnnaBridge 189:f392fc9709a3 143 __IO uint32_t previous_state_mode;
AnnaBridge 189:f392fc9709a3 144 __IO uint32_t i2c_target_dev_addr;
AnnaBridge 189:f392fc9709a3 145 __IO uint32_t event_count;
AnnaBridge 189:f392fc9709a3 146 __IO uint32_t transfer_count;
AnnaBridge 189:f392fc9709a3 147 __IO uint32_t transfer_option;
AnnaBridge 189:f392fc9709a3 148 __IO uint32_t error_code;
AnnaBridge 189:f392fc9709a3 149
AnnaBridge 189:f392fc9709a3 150 /* I2C DMA information */
AnnaBridge 189:f392fc9709a3 151 uint32_t tx_dma_periph;
AnnaBridge 189:f392fc9709a3 152 dma_channel_enum tx_dma_channel;
AnnaBridge 189:f392fc9709a3 153 uint32_t rx_dma_periph;
AnnaBridge 189:f392fc9709a3 154 dma_channel_enum rx_dma_channel;
AnnaBridge 189:f392fc9709a3 155
AnnaBridge 189:f392fc9709a3 156 IRQn_Type event_i2cIRQ;
AnnaBridge 189:f392fc9709a3 157 IRQn_Type error_i2cIRQ;
AnnaBridge 189:f392fc9709a3 158 uint32_t global_trans_option;
AnnaBridge 189:f392fc9709a3 159 volatile uint8_t event;
AnnaBridge 189:f392fc9709a3 160
AnnaBridge 189:f392fc9709a3 161 #if DEVICE_I2CSLAVE
AnnaBridge 189:f392fc9709a3 162 uint8_t slave;
AnnaBridge 189:f392fc9709a3 163 volatile uint8_t pending_slave_tx_master_rx;
AnnaBridge 189:f392fc9709a3 164 volatile uint8_t pending_slave_rx_maxter_tx;
AnnaBridge 189:f392fc9709a3 165 #endif
AnnaBridge 189:f392fc9709a3 166
AnnaBridge 189:f392fc9709a3 167 #if DEVICE_I2C_ASYNCH
AnnaBridge 189:f392fc9709a3 168 uint32_t address;
AnnaBridge 189:f392fc9709a3 169 uint8_t stop;
AnnaBridge 189:f392fc9709a3 170 uint8_t available_events;
AnnaBridge 189:f392fc9709a3 171 #endif
AnnaBridge 189:f392fc9709a3 172
AnnaBridge 189:f392fc9709a3 173 };
AnnaBridge 189:f392fc9709a3 174 #if DEVICE_FLASH
AnnaBridge 189:f392fc9709a3 175 struct flash_s {
AnnaBridge 189:f392fc9709a3 176 /* nothing to be stored for now */
AnnaBridge 189:f392fc9709a3 177 uint32_t dummy;
AnnaBridge 189:f392fc9709a3 178 };
AnnaBridge 189:f392fc9709a3 179 #endif
AnnaBridge 189:f392fc9709a3 180
AnnaBridge 189:f392fc9709a3 181 #if DEVICE_TRNG
AnnaBridge 189:f392fc9709a3 182 struct trng_s {
AnnaBridge 189:f392fc9709a3 183 /* nothing to be stored for now */
AnnaBridge 189:f392fc9709a3 184 uint32_t dummy;
AnnaBridge 189:f392fc9709a3 185 };
AnnaBridge 189:f392fc9709a3 186 #endif
AnnaBridge 189:f392fc9709a3 187
AnnaBridge 189:f392fc9709a3 188 #ifdef __cplusplus
AnnaBridge 189:f392fc9709a3 189 }
AnnaBridge 189:f392fc9709a3 190 #endif
AnnaBridge 189:f392fc9709a3 191
AnnaBridge 189:f392fc9709a3 192 #endif