ACDC Senior Project v1.0.0
Senior Project for Textron Aviation
Loading...
Searching...
No Matches
ACDC_TIMER.h
Go to the documentation of this file.
1
16#ifndef __ACDC_TIMER_H
17#define __ACDC_TIMER_H
18
19#include "ACDC_CLOCK.h"
20#include "ACDC_stdint.h"
21#include "ACDC_stdbool.h"
22
23typedef struct {
24 TIM_TypeDef *TIMx;
26 GPIO_TypeDef *GPIOx;
28 bool isRM;
29} TIMx_CHx;
30
31typedef enum {
32 PWM_MODE_1 = 0b01100000,
33 PWM_MODE_2 = 0b01110000
35
36// Does not include Alternate function
37#define TIM1_CH1_PB13 ((TIMx_CHx){TIM1, 1, GPIOB, GPIO_PIN_13, false}) // Timer 1 Channel 1 on GPIOB Pin 13
38#define TIM1_CH2_PB14 ((TIMx_CHx){TIM1, 2, GPIOB, GPIO_PIN_14, false}) // Timer 1 Channel 2 on GPIOB Pin 14
39#define TIM1_CH3_PA10 ((TIMx_CHx){TIM1, 3, GPIOA, GPIO_PIN_10, false}) // Timer 1 Channel 3 on GPIOA Pin 10
40#define TIM1_CH4_PA11 ((TIMx_CHx){TIM1, 4, GPIOA, GPIO_PIN_11, false}) // Timer 1 Channel 4 on GPIOA Pin 11
41
42#define TIM2_CH1_PA0 ((TIMx_CHx){TIM2, 1, GPIOA, GPIO_PIN_0, false}) // Timer 2 Channel 1 on GPIOA Pin 0
43#define TIM2_CH2_PA1 ((TIMx_CHx){TIM2, 2, GPIOA, GPIO_PIN_1, false}) // Timer 2 Channel 2 on GPIOA Pin 1
44#define TIM2_CH3_PA2 ((TIMx_CHx){TIM2, 3, GPIOA, GPIO_PIN_2, false}) // Timer 2 Channel 3 on GPIOA Pin 2
45#define TIM2_CH4_PA3 ((TIMx_CHx){TIM2, 4, GPIOA, GPIO_PIN_3, false}) // Timer 2 Channel 4 on GPIOA Pin 3
46
47#define TIM3_CH1_PA6 ((TIMx_CHx){TIM3, 1, GPIOA, GPIO_PIN_6, false}) // Timer 3 Channel 1 on GPIOA Pin 6
48#define TIM3_CH2_PA7 ((TIMx_CHx){TIM3, 2, GPIOA, GPIO_PIN_7, false}) // Timer 3 Channel 2 on GPIOA Pin 7
49#define TIM3_CH3_PB0 ((TIMx_CHx){TIM3, 3, GPIOB, GPIO_PIN_0, false}) // Timer 3 Channel 3 on GPIOB Pin 0
50#define TIM3_CH4_PB1 ((TIMx_CHx){TIM3, 4, GPIOB, GPIO_PIN_1, false}) // Timer 3 Channel 4 on GPIOB Pin 1
51
52#define TIM4_CH1_PB6 ((TIMx_CHx){TIM4, 1, GPIOB, GPIO_PIN_6, false}) // Timer 4 Channel 1 on GPIOB Pin 6
53#define TIM4_CH2_PB7 ((TIMx_CHx){TIM4, 2, GPIOB, GPIO_PIN_7, false}) // Timer 4 Channel 2 on GPIOB Pin 7
54#define TIM4_CH3_PB8 ((TIMx_CHx){TIM4, 3, GPIOB, GPIO_PIN_8, false}) // Timer 4 Channel 3 on GPIOB Pin 8
55#define TIM4_CH4_PB9 ((TIMx_CHx){TIM4, 4, GPIOB, GPIO_PIN_9, false}) // Timer 4 Channel 4 on GPIOB Pin 9
56
57
61
65
70void TIMER_PWM_Init(TIMx_CHx TIMx_CHx_Pxx, PWM_MODE PWM_MODE_x, uint32_t frequency);
71
75void TIMER_PWM_SetDuty(TIMx_CHx TIMx_CHx_Pxx, uint32_t dutyCycle);
76
81
86
90
94
97void Delay_MS(uint64_t delayVal);
98
101void Delay_US(uint64_t delayVal);
102
103#endif
Header file containing functions for configuring the system clock and clock-related peripherals.
SystemClockSpeed
Definition ACDC_CLOCK.h:21
uint64_t Millis()
Grabs and returns the total number of milliseconds since the MCU turned on.
Definition ACDC_TIMER.c:110
void TIMER_SetSystemClockSpeed(SystemClockSpeed SCS_x)
(SHOULD NOT BE CALLED BY USER, CALLED IN ACDC_CLOCK.h) Sets the value for SysClock->LOAD
Definition ACDC_TIMER.c:50
uint32_t TIMER_PWM_GetPeriod(TIMx_CHx TIMx_CHx_Pxx)
Retrieves the period of the PWM signal on the specified timer.
Definition ACDC_TIMER.c:102
void TIMER_PWM_Init(TIMx_CHx TIMx_CHx_Pxx, PWM_MODE PWM_MODE_x, uint32_t frequency)
Initializes PWM output on the specified timer and channel with the given parameters....
Definition ACDC_TIMER.c:55
void TIMER_Init(SystemClockSpeed SCS_x)
(SHOULD NOT BE CALLED BY USER, CALLED IN ACDC_CLOCK.h) Initilizes the SysClock timer and sets the val...
Definition ACDC_TIMER.c:44
uint32_t TIMER_PWM_GetDuty(TIMx_CHx TIMx_CHx_Pxx)
Retrieves the current duty cycle of the specified timer and channel.
Definition ACDC_TIMER.c:88
void TIMER_PWM_SetDuty(TIMx_CHx TIMx_CHx_Pxx, uint32_t dutyCycle)
Sets the duty cycle of the PWM signal on the specified timer and channel.
Definition ACDC_TIMER.c:73
PWM_MODE
Definition ACDC_TIMER.h:31
@ PWM_MODE_2
Definition ACDC_TIMER.h:33
@ PWM_MODE_1
Definition ACDC_TIMER.h:32
void Delay_MS(uint64_t delayVal)
Pauses code execution for delayVal number of milliseconds.
Definition ACDC_TIMER.c:119
uint64_t Micros()
Grabs and returns the total number of microseconds since the MCU turned on.
Definition ACDC_TIMER.c:114
void Delay_US(uint64_t delayVal)
Pauses code execution for delayVal number of microseconds.
Definition ACDC_TIMER.c:124
Header file for the type bool.
Header file for intx_t and uintx_t types.
unsigned short uint16_t
Definition ACDC_stdint.h:15
unsigned long int uint32_t
Definition ACDC_stdint.h:16
unsigned char uint8_t
Definition ACDC_stdint.h:14
unsigned long long int uint64_t
Definition ACDC_stdint.h:17
Definition ACDC_TIMER.h:23
bool isRM
Definition ACDC_TIMER.h:28
GPIO_TypeDef * GPIOx
Definition ACDC_TIMER.h:26
TIM_TypeDef * TIMx
Definition ACDC_TIMER.h:24
uint8_t TimerChannel
Definition ACDC_TIMER.h:25
uint16_t GPIO_PIN_x
Definition ACDC_TIMER.h:27