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 <stdbool.h>
38 #include <stdint.h>
39 #include <ctype.h>
40 #include <string.h>
41 #include <stdarg.h>
42 
43 #pragma GCC system_header
44 
45 #include "stm32f4xx.h"
46 #include "stm32f4xx_rcc.h"
47 #include "stm32f4xx_exti.h"
48 #include "stm32f4xx_gpio.h"
49 #include "stm32f4xx_spi.h"
50 #include "stm32f4xx_i2c.h"
51 #include "stm32f4xx_tim.h"
52 #include "stm32f4xx_dma.h"
53 #include "stm32f4xx_usart.h"
54 #include "stm32f4xx_adc.h"
55 #include "misc.h"
56 
57 typedef struct {
60  uint8_t SCK_PinSource;
61  uint16_t SCK_Pin;
62  uint8_t MOSI_PinSource;
63  uint16_t MOSI_Pin;
64  uint8_t MISO_PinSource;
65  uint16_t MISO_Pin;
66  uint8_t GPIO_AF;
70  uint32_t DMA_Channel;
71  uint32_t Tx_DMA_TCIF;
72  uint32_t Rx_DMA_TCIF;
74 
75 typedef struct {
77  uint32_t I2C_ClockSpeed;
81  uint8_t GPIO_AF;
82  uint8_t SCL_PinSource;
83  uint16_t SCL_Pin;
84  uint8_t SDA_PinSource;
85  uint16_t SDA_Pin;
87  uint32_t DMA_Channel;
89  uint32_t DMA_TCIF;
91 
92 typedef struct {
94  uint16_t GPIO_Pin;
95  uint8_t GPIO_PinSource;
97  uint8_t TIM_Channel;
98  uint8_t GIPO_AF_TIM;
100  uint16_t TIM_IT_CC;
102 
103 typedef struct {
106  uint16_t Rx_Pin;
107  uint16_t Tx_Pin;
108  uint8_t Rx_PinSource;
109  uint8_t Tx_PinSource;
110  uint8_t GPIO_AF;
116  uint32_t DMA_Channel;
117  uint32_t DMA_Rx_IT_Bit;
118  uint32_t DMA_Tx_IT_Bit;
120 
122 {
125  uint32_t DMA_channel;
126 };
127 
129 {
131  uint16_t voltage_pin;
134  uint16_t current_pin;
136  const struct ADCHardwareStruct *adc;
137 };
138 
139 #ifdef __cplusplus
140 extern "C" {
141 #endif
142 
143 void systemInit(void);
144 void delayMicroseconds(uint32_t us);
145 void delay(uint32_t ms);
146 
147 volatile uint64_t micros(void);
148 volatile uint32_t millis(void);
149 
150 // bootloader/IAP
151 void systemReset(void);
152 void systemResetToBootloader(void);
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif //SYSTEM_H
void systemInit(void)
Definition: system.c:55
IRQn_Type DMA_IRQn
Definition: system.h:88
uint32_t I2C_ClockSpeed
Definition: system.h:77
uint16_t TIM_IT_CC
Definition: system.h:100
uint16_t MISO_Pin
Definition: system.h:65
GPIO_TypeDef * current_gpio
Definition: system.h:133
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:112
void delayMicroseconds(uint32_t us)
Definition: system.c:94
IRQn_Type USART_IRQn
Definition: system.h:111
This file contains all the functions prototypes for the TIM firmware library.
uint16_t SCK_Pin
Definition: system.h:61
ADC_TypeDef * adc
Definition: system.h:123
DMA Controller.
Definition: stm32f4xx.h:907
DMA_Stream_TypeDef * Rx_DMA_Stream
Definition: system.h:69
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
const struct ADCHardwareStruct * adc
Definition: system.h:136
Serial Peripheral Interface.
Definition: stm32f4xx.h:1580
IRQn_Type TIM_IRQn
Definition: system.h:99
volatile uint64_t micros(void)
Definition: system.c:44
uint16_t SCL_Pin
Definition: system.h:83
This file contains all the functions prototypes for the ADC firmware library.
uint32_t DMA_Channel
Definition: system.h:70
uint8_t MOSI_PinSource
Definition: system.h:62
I2C_TypeDef * dev
Definition: system.h:76
void systemReset(void)
IRQn_Type DMA_IRQn
Definition: system.h:67
GPIO_TypeDef * GPIO
Definition: system.h:105
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:94
uint8_t SCK_PinSource
Definition: system.h:60
This file contains all the functions prototypes for the DMA firmware library.
uint8_t Rx_PinSource
Definition: system.h:108
uint16_t MOSI_Pin
Definition: system.h:63
SPI_TypeDef * dev
Definition: system.h:58
IRQn_Type I2C_EV_IRQn
Definition: system.h:78
This file contains all the functions prototypes for the USART firmware library.
uint32_t Rx_DMA_TCIF
Definition: system.h:72
TIM_TypeDef * TIM
Definition: system.h:96
DMA_Stream_TypeDef * DMA_Stream
Definition: system.h:124
GPIO_TypeDef * GPIO
Definition: system.h:59
GPIO_TypeDef * voltage_gpio
Definition: system.h:130
uint16_t SDA_Pin
Definition: system.h:85
IRQn_Type I2C_ER_IRQn
Definition: system.h:79
uint32_t DMA_channel
Definition: system.h:125
uint32_t DMA_Channel
Definition: system.h:87
void systemResetToBootloader(void)
USART_TypeDef * dev
Definition: system.h:104
IRQn_Type Tx_DMA_IRQn
Definition: system.h:113
uint32_t Tx_DMA_TCIF
Definition: system.h:71
uint8_t GPIO_PinSource
Definition: system.h:95
uint32_t DMA_Rx_IT_Bit
Definition: system.h:117
DMA_Stream_TypeDef * DMA_Stream
Definition: system.h:86
GPIO_TypeDef * GPIO
Definition: system.h:80
Inter-integrated Circuit Interface.
Definition: stm32f4xx.h:1320
uint32_t DMA_Tx_IT_Bit
Definition: system.h:118
uint8_t TIM_Channel
Definition: system.h:97
DMA_Stream_TypeDef * Rx_DMA_Stream
Definition: system.h:114
uint8_t MISO_PinSource
Definition: system.h:64
uint32_t DMA_Channel
Definition: system.h:116
DMA_Stream_TypeDef * Tx_DMA_Stream
Definition: system.h:68
uint8_t Tx_PinSource
Definition: system.h:109
uint8_t SCL_PinSource
Definition: system.h:82
uint8_t SDA_PinSource
Definition: system.h:84
This file contains all the functions prototypes for the EXTI firmware library.
uint32_t DMA_TCIF
Definition: system.h:89
void delay(uint32_t ms)
Definition: system.c:101
uint8_t GIPO_AF_TIM
Definition: system.h:98
DMA_Stream_TypeDef * Tx_DMA_Stream
Definition: system.h:115
GPIO_TypeDef * GPIO
Definition: system.h:93


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Fri Apr 3 2020 03:19:25