ACDC Senior Project v1.0.0
Senior Project for Textron Aviation
Loading...
Searching...
No Matches
ACDC_TIMER.c File Reference

Implementation of timer functions for system clock speed and delay. More...

#include "ACDC_TIMER.h"
#include "ACDC_GPIO.h"
#include "ACDC_INTERRUPT.h"
#include "stm32f1xx.h"

Macros

#define MS_PER_SECOND   1000
 
#define US_PER_MS   1000
 

Functions

void TIMER_Init (SystemClockSpeed SCS_x)
 (SHOULD NOT BE CALLED BY USER, CALLED IN ACDC_CLOCK.h) Initilizes the SysClock timer and sets the value of SysClock->LOAD
 
void TIMER_SetSystemClockSpeed (SystemClockSpeed SCS_x)
 (SHOULD NOT BE CALLED BY USER, CALLED IN ACDC_CLOCK.h) Sets the value for SysClock->LOAD
 
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. (Default duty cycle = 0)
 
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.
 
uint32_t TIMER_PWM_GetDuty (TIMx_CHx TIMx_CHx_Pxx)
 Retrieves the current duty cycle of the specified timer and channel.
 
uint32_t TIMER_PWM_GetPeriod (TIMx_CHx TIMx_CHx_Pxx)
 Retrieves the period of the PWM signal on the specified timer.
 
void SysTick_Handler (void)
 
uint64_t Millis ()
 Grabs and returns the total number of milliseconds since the MCU turned on.
 
uint64_t Micros ()
 Grabs and returns the total number of microseconds since the MCU turned on.
 
void Delay_MS (uint64_t delayVal)
 Pauses code execution for delayVal number of milliseconds.
 
void Delay_US (uint64_t delayVal)
 Pauses code execution for delayVal number of microseconds.
 

Detailed Description

Implementation of timer functions for system clock speed and delay.

Author
Devin Marx
Version
0.1
Date
2023-11-7

Macro Definition Documentation

◆ MS_PER_SECOND

#define MS_PER_SECOND   1000

◆ US_PER_MS

#define US_PER_MS   1000

Function Documentation

◆ Delay_MS()

void Delay_MS ( uint64_t delayVal)

Pauses code execution for delayVal number of milliseconds.

Parameters
delayValNumber of milliseconds to delay for

◆ Delay_US()

void Delay_US ( uint64_t delayVal)

Pauses code execution for delayVal number of microseconds.

Parameters
delayValNumber of microseconds to delay for

◆ Micros()

uint64_t Micros ( )

Grabs and returns the total number of microseconds since the MCU turned on.

Returns
Number of microseconds since startup

◆ Millis()

uint64_t Millis ( )

Grabs and returns the total number of milliseconds since the MCU turned on.

Returns
Number of milliseconds since startup

◆ SysTick_Handler()

void SysTick_Handler ( void )

◆ TIMER_Init()

void TIMER_Init ( SystemClockSpeed SCS_x)

(SHOULD NOT BE CALLED BY USER, CALLED IN ACDC_CLOCK.h) Initilizes the SysClock timer and sets the value of SysClock->LOAD

Parameters
SCS_xSystem Clock Speed (Ex. SCS_72Mhz, SCS_36Mhz, ...)

◆ TIMER_PWM_GetDuty()

uint32_t TIMER_PWM_GetDuty ( TIMx_CHx TIMx_CHx_Pxx)

Retrieves the current duty cycle of the specified timer and channel.

Parameters
TIMx_CHx_PxxStruct containing configuration data for the specific timer and channel
Returns
Current duty cycle

◆ TIMER_PWM_GetPeriod()

uint32_t TIMER_PWM_GetPeriod ( TIMx_CHx TIMx_CHx_Pxx)

Retrieves the period of the PWM signal on the specified timer.

Parameters
TIMx_CHx_PxxStruct containing configuration data for the specific timer and channel
Returns
Period of the PWM signal in timer ticks.

◆ TIMER_PWM_Init()

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. (Default duty cycle = 0)

Parameters
TIMx_CHx_PxxStruct containing configuration data for the specific timer and channel
PWM_MODE_xDesired PWM mode
frequencyDesired frequency (in Hz) for PWM to run at

◆ TIMER_PWM_SetDuty()

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.

Parameters
TIMx_CHx_PxxStruct containing configuration data for the specific timer and channel
dutyCycleDuty cycle value in timer ticks.

◆ TIMER_SetSystemClockSpeed()

void TIMER_SetSystemClockSpeed ( SystemClockSpeed SCS_x)

(SHOULD NOT BE CALLED BY USER, CALLED IN ACDC_CLOCK.h) Sets the value for SysClock->LOAD

Parameters
SCS_xSystem Clock Speed (Ex. SCS_72Mhz, SCS_36Mhz, ...)