system.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, James Jackson
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef SYSTEM_H
33 #define SYSTEM_H
34 
35 #define ARM_MATH_CM4
36 
37 #include <ctype.h>
38 #include <stdarg.h>
39 #include <stdbool.h>
40 #include <stdint.h>
41 #include <string.h>
42 
43 #pragma GCC system_header
44 
45 #include "misc.h"
46 #include "stm32f4xx.h"
47 #include "stm32f4xx_adc.h"
48 #include "stm32f4xx_dma.h"
49 #include "stm32f4xx_exti.h"
50 #include "stm32f4xx_gpio.h"
51 #include "stm32f4xx_i2c.h"
52 #include "stm32f4xx_rcc.h"
53 #include "stm32f4xx_spi.h"
54 #include "stm32f4xx_tim.h"
55 #include "stm32f4xx_usart.h"
56 
57 typedef struct
58 {
61  uint8_t SCK_PinSource;
62  uint16_t SCK_Pin;
63  uint8_t MOSI_PinSource;
64  uint16_t MOSI_Pin;
65  uint8_t MISO_PinSource;
66  uint16_t MISO_Pin;
67  uint8_t GPIO_AF;
71  uint32_t DMA_Channel;
72  uint32_t Tx_DMA_TCIF;
73  uint32_t Rx_DMA_TCIF;
75 
76 typedef struct
77 {
79  uint32_t I2C_ClockSpeed;
83  uint8_t GPIO_AF;
84  uint8_t SCL_PinSource;
85  uint16_t SCL_Pin;
86  uint8_t SDA_PinSource;
87  uint16_t SDA_Pin;
89  uint32_t DMA_Channel;
91  uint32_t DMA_TCIF;
93 
94 typedef struct
95 {
97  uint16_t GPIO_Pin;
98  uint8_t GPIO_PinSource;
100  uint8_t TIM_Channel;
101  uint8_t GIPO_AF_TIM;
103  uint16_t TIM_IT_CC;
105 
106 typedef struct
107 {
110  uint16_t Rx_Pin;
111  uint16_t Tx_Pin;
112  uint8_t Rx_PinSource;
113  uint8_t Tx_PinSource;
114  uint8_t GPIO_AF;
120  uint32_t DMA_Channel;
121  uint32_t DMA_Rx_IT_Bit;
122  uint32_t DMA_Tx_IT_Bit;
124 
126 {
129  uint32_t DMA_channel;
130 };
131 
133 {
135  uint16_t voltage_pin;
138  uint16_t current_pin;
140  const struct ADCHardwareStruct* adc;
141 };
142 
143 #ifdef __cplusplus
144 extern "C"
145 {
146 #endif
147 
148  void systemInit(void);
149  void delayMicroseconds(uint32_t us);
150  void delay(uint32_t ms);
151 
152  volatile uint64_t micros(void);
153  volatile uint32_t millis(void);
154 
155  // bootloader/IAP
156  void systemReset(void);
157  void systemResetToBootloader(void);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif // SYSTEM_H
void systemInit(void)
Definition: system.c:55
IRQn_Type DMA_IRQn
Definition: system.h:90
uint32_t I2C_ClockSpeed
Definition: system.h:79
uint16_t TIM_IT_CC
Definition: system.h:103
uint16_t MISO_Pin
Definition: system.h:66
GPIO_TypeDef * current_gpio
Definition: system.h:137
Universal Synchronous Asynchronous Receiver Transmitter.
Definition: stm32f4xx.h:1710
volatile uint32_t millis(void)
Definition: system.c:50
Analog to Digital Converter.
Definition: stm32f4xx.h:725
enum IRQn IRQn_Type
STM32F4XX Interrupt Number Definition, according to the selected device in Library_configuration_sect...
This file contains all the functions prototypes for the SPI firmware library.
IRQn_Type Rx_DMA_IRQn
Definition: system.h:116
void delayMicroseconds(uint32_t us)
Definition: system.c:94
IRQn_Type USART_IRQn
Definition: system.h:115
This file contains all the functions prototypes for the TIM firmware library.
uint16_t SCK_Pin
Definition: system.h:62
ADC_TypeDef * adc
Definition: system.h:127
DMA Controller.
Definition: stm32f4xx.h:907
DMA_Stream_TypeDef * Rx_DMA_Stream
Definition: system.h:70
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
const struct ADCHardwareStruct * adc
Definition: system.h:140
Serial Peripheral Interface.
Definition: stm32f4xx.h:1580
IRQn_Type TIM_IRQn
Definition: system.h:102
volatile uint64_t micros(void)
Definition: system.c:44
uint16_t SCL_Pin
Definition: system.h:85
This file contains all the functions prototypes for the ADC firmware library.
uint32_t DMA_Channel
Definition: system.h:71
uint8_t MOSI_PinSource
Definition: system.h:63
I2C_TypeDef * dev
Definition: system.h:78
void systemReset(void)
IRQn_Type DMA_IRQn
Definition: system.h:68
GPIO_TypeDef * GPIO
Definition: system.h:109
This file contains all the functions prototypes for the I2C firmware library.
General Purpose I/O.
Definition: stm32f4xx.h:1281
uint16_t GPIO_Pin
Definition: system.h:97
uint8_t SCK_PinSource
Definition: system.h:61
This file contains all the functions prototypes for the DMA firmware library.
uint8_t Rx_PinSource
Definition: system.h:112
uint16_t MOSI_Pin
Definition: system.h:64
SPI_TypeDef * dev
Definition: system.h:59
IRQn_Type I2C_EV_IRQn
Definition: system.h:80
This file contains all the functions prototypes for the USART firmware library.
uint32_t Rx_DMA_TCIF
Definition: system.h:73
TIM_TypeDef * TIM
Definition: system.h:99
DMA_Stream_TypeDef * DMA_Stream
Definition: system.h:128
GPIO_TypeDef * GPIO
Definition: system.h:60
GPIO_TypeDef * voltage_gpio
Definition: system.h:134
uint16_t SDA_Pin
Definition: system.h:87
IRQn_Type I2C_ER_IRQn
Definition: system.h:81
uint32_t DMA_channel
Definition: system.h:129
uint32_t DMA_Channel
Definition: system.h:89
void systemResetToBootloader(void)
USART_TypeDef * dev
Definition: system.h:108
IRQn_Type Tx_DMA_IRQn
Definition: system.h:117
uint32_t Tx_DMA_TCIF
Definition: system.h:72
uint8_t GPIO_PinSource
Definition: system.h:98
uint32_t DMA_Rx_IT_Bit
Definition: system.h:121
DMA_Stream_TypeDef * DMA_Stream
Definition: system.h:88
GPIO_TypeDef * GPIO
Definition: system.h:82
Inter-integrated Circuit Interface.
Definition: stm32f4xx.h:1320
uint32_t DMA_Tx_IT_Bit
Definition: system.h:122
uint8_t TIM_Channel
Definition: system.h:100
DMA_Stream_TypeDef * Rx_DMA_Stream
Definition: system.h:118
uint8_t MISO_PinSource
Definition: system.h:65
uint32_t DMA_Channel
Definition: system.h:120
DMA_Stream_TypeDef * Tx_DMA_Stream
Definition: system.h:69
uint8_t Tx_PinSource
Definition: system.h:113
uint8_t SCL_PinSource
Definition: system.h:84
uint8_t SDA_PinSource
Definition: system.h:86
This file contains all the functions prototypes for the EXTI firmware library.
uint32_t DMA_TCIF
Definition: system.h:91
void delay(uint32_t ms)
Definition: system.c:101
uint8_t GIPO_AF_TIM
Definition: system.h:101
DMA_Stream_TypeDef * Tx_DMA_Stream
Definition: system.h:119
GPIO_TypeDef * GPIO
Definition: system.h:96


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:49