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


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:19