dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_dmashot.h
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  *
25  * Additional note on redistribution: The copyright and license notices above
26  * must be maintained in each individual source file that is a derivative work
27  * of this source file; otherwise redistribution is prohibited.
28  */
29 
30 #ifndef PIOS_DMASHOT_H
31 #define PIOS_DMASHOT_H
32 
33 #include <stdint.h>
34 
35 #include <pios_stm32.h>
36 #include "stm32f4xx_tim.h"
37 
38 #include "pios_tim_priv.h"
39 
40 // Frequencies.
41 #define DMASHOT_150 150000
42 #define DMASHOT_300 300000
43 #define DMASHOT_600 600000
44 #define DMASHOT_1200 1200000
45 
52 
53  TIM_TypeDef *timer;
54  DMA_Stream_TypeDef *stream;
55  uint32_t channel;
56  uint32_t tcif;
57 
58  TIM_TypeDef *master_timer;
59  uint16_t master_config;
60 
61 };
62 
67 
69  uint8_t num_timers;
70 
71 };
72 
77 void PIOS_DMAShot_Init(const struct pios_dmashot_cfg *config);
78 
83 
89 
95 
104 bool PIOS_DMAShot_RegisterTimer(TIM_TypeDef *timer, uint32_t clockrate, uint32_t dshot_freq);
105 
112 bool PIOS_DMAShot_RegisterServo(const struct pios_tim_channel *servo_channel);
113 
118 
122 void PIOS_DMAShot_InitializeTimers(TIM_OCInitTypeDef *ocinit);
123 
128 
132 void PIOS_DMAShot_Validate();
133 
140 void PIOS_DMAShot_WriteValue(const struct pios_tim_channel *servo_channel, uint16_t throttle);
141 
146 
147 #endif // PIOS_DMASHOT_H
Types that are specific to the STM32 peripherals.
const struct pios_dmashot_timer_cfg * timer_cfg
Definition: pios_dmashot.h:68
void PIOS_DMAShot_Prepare()
Makes sure the DMAShot driver has allocated all internal structs.
Definition: pios_dmashot.c:104
struct usb_configuration_desc config
TIM_TypeDef * timer
Definition: pios_dmashot.h:53
void PIOS_DMAShot_InitializeTimers(TIM_OCInitTypeDef *ocinit)
Initializes and configures the registered timers for DMAShot operation.
Definition: pios_dmashot.c:367
void PIOS_DMAShot_Validate()
Validates any timer and servo registrations.
Definition: pios_dmashot.c:279
TIM_TypeDef * master_timer
Definition: pios_dmashot.h:58
bool PIOS_DMAShot_RegisterTimer(TIM_TypeDef *timer, uint32_t clockrate, uint32_t dshot_freq)
Tells the DMAShot driver about a timer that needs to be set up.
Definition: pios_dmashot.c:190
bool PIOS_DMAShot_RegisterServo(const struct pios_tim_channel *servo_channel)
Tells the DMAShot driver about a servo that needs to be set up.
Definition: pios_dmashot.c:250
DMA_Stream_TypeDef * stream
Definition: pios_dmashot.h:54
bool PIOS_DMAShot_IsConfigured()
Checks whether DMAShot has been configured.
Definition: pios_dmashot.c:565
Configuration struct holding all timer configurations.
Definition: pios_dmashot.h:66
Configuration struct to assign a DMA channel and stream to a timer, and optionally specify a master t...
Definition: pios_dmashot.h:51
void PIOS_DMAShot_InitializeGPIOs()
Initializes the GPIO on the registered servos for DMAShot operation.
Definition: pios_dmashot.c:297
void PIOS_DMAShot_InitializeDMAs()
Initializes and configures the known DMA channels for DMAShot operation.
Definition: pios_dmashot.c:467
uint8_t num_timers
Definition: pios_dmashot.h:69
void PIOS_DMAShot_WriteValue(const struct pios_tim_channel *servo_channel, uint16_t throttle)
Sets the throttle value of a specific servo.
Definition: pios_dmashot.c:143
bool PIOS_DMAShot_IsReady()
Checks whether DMAShot is ready for use (i.e. at least one DMA configured timer). ...
Definition: pios_dmashot.c:552
void PIOS_DMAShot_Init(const struct pios_dmashot_cfg *config)
Initializes the DMAShot driver by loading the configuration.
Definition: pios_dmashot.c:96
void PIOS_DMAShot_TriggerUpdate()
Triggers the configured DMA channels to fire and send throttle values to the timer DMAR and optional ...
Definition: pios_dmashot.c:489