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 "misc.h"
55 
56 typedef struct
57 {
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
76 {
78  uint32_t I2C_ClockSpeed;
82  uint8_t GPIO_AF;
83  uint8_t SCL_PinSource;
84  uint16_t SCL_Pin;
85  uint8_t SDA_PinSource;
86  uint16_t SDA_Pin;
88  uint32_t DMA_Channel;
90  uint32_t DMA_TCIF;
92 
93 typedef struct
94 {
96  uint16_t GPIO_Pin;
97  uint8_t GPIO_PinSource;
99  uint8_t TIM_Channel;
100  uint8_t GIPO_AF_TIM;
102  uint16_t TIM_IT_CC;
104 
105 typedef struct
106 {
109  uint16_t Rx_Pin;
110  uint16_t Tx_Pin;
111  uint8_t Rx_PinSource;
112  uint8_t Tx_PinSource;
113  uint8_t GPIO_AF;
119  uint32_t DMA_Channel;
120  uint32_t DMA_Rx_IT_Bit;
121  uint32_t DMA_Tx_IT_Bit;
123 
124 #ifdef __cplusplus
125 extern "C" {
126 #endif
127 
128 void systemInit(void);
129 void delayMicroseconds(uint32_t us);
130 void delay(uint32_t ms);
131 
132 volatile uint64_t micros(void);
133 volatile uint32_t millis(void);
134 
135 // bootloader/IAP
136 void systemReset(void);
137 void systemResetToBootloader(void);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif //SYSTEM_H
void systemInit(void)
Definition: system.c:55
IRQn_Type DMA_IRQn
Definition: system.h:89
uint32_t I2C_ClockSpeed
Definition: system.h:78
uint16_t TIM_IT_CC
Definition: system.h:102
uint16_t MISO_Pin
Definition: system.h:65
Universal Synchronous Asynchronous Receiver Transmitter.
Definition: stm32f4xx.h:1710
volatile uint32_t millis(void)
Definition: system.c:50
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:115
void delayMicroseconds(uint32_t us)
Definition: system.c:91
IRQn_Type USART_IRQn
Definition: system.h:114
This file contains all the functions prototypes for the TIM firmware library.
uint16_t SCK_Pin
Definition: system.h:61
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...
Serial Peripheral Interface.
Definition: stm32f4xx.h:1580
IRQn_Type TIM_IRQn
Definition: system.h:101
volatile uint64_t micros(void)
Definition: system.c:44
uint16_t SCL_Pin
Definition: system.h:84
uint32_t DMA_Channel
Definition: system.h:70
uint8_t MOSI_PinSource
Definition: system.h:62
I2C_TypeDef * dev
Definition: system.h:77
void systemReset(void)
IRQn_Type DMA_IRQn
Definition: system.h:67
GPIO_TypeDef * GPIO
Definition: system.h:108
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:96
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:111
uint16_t MOSI_Pin
Definition: system.h:63
SPI_TypeDef * dev
Definition: system.h:58
IRQn_Type I2C_EV_IRQn
Definition: system.h:79
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:98
GPIO_TypeDef * GPIO
Definition: system.h:59
uint16_t SDA_Pin
Definition: system.h:86
IRQn_Type I2C_ER_IRQn
Definition: system.h:80
uint32_t DMA_Channel
Definition: system.h:88
void systemResetToBootloader(void)
USART_TypeDef * dev
Definition: system.h:107
IRQn_Type Tx_DMA_IRQn
Definition: system.h:116
uint32_t Tx_DMA_TCIF
Definition: system.h:71
uint8_t GPIO_PinSource
Definition: system.h:97
uint32_t DMA_Rx_IT_Bit
Definition: system.h:120
DMA_Stream_TypeDef * DMA_Stream
Definition: system.h:87
GPIO_TypeDef * GPIO
Definition: system.h:81
Inter-integrated Circuit Interface.
Definition: stm32f4xx.h:1320
uint32_t DMA_Tx_IT_Bit
Definition: system.h:121
uint8_t TIM_Channel
Definition: system.h:99
DMA_Stream_TypeDef * Rx_DMA_Stream
Definition: system.h:117
uint8_t MISO_PinSource
Definition: system.h:64
uint32_t DMA_Channel
Definition: system.h:119
DMA_Stream_TypeDef * Tx_DMA_Stream
Definition: system.h:68
uint8_t Tx_PinSource
Definition: system.h:112
uint8_t SCL_PinSource
Definition: system.h:83
uint8_t SDA_PinSource
Definition: system.h:85
This file contains all the functions prototypes for the EXTI firmware library.
uint32_t DMA_TCIF
Definition: system.h:90
void delay(uint32_t ms)
Definition: system.c:98
uint8_t GIPO_AF_TIM
Definition: system.h:100
DMA_Stream_TypeDef * Tx_DMA_Stream
Definition: system.h:118
GPIO_TypeDef * GPIO
Definition: system.h:95


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:26