Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
BSP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PolySTAR
RoboMaster
Controle-et-Systeme
BSP
Compare revisions
68a7d8b22c3022796d16f20e9faea4f83c390090 to 10054d4e3aa303af17af6b973611e02d0e24e3b8
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
polystar/robomaster/controle/bsp
Select target project
No results found
10054d4e3aa303af17af6b973611e02d0e24e3b8
Select Git revision
Branches
CS_CV
feature/test
master
motor
position_M3508_BSP
remote-tourelle
Swap
Target
polystar/robomaster/controle/bsp
Select target project
polystar/robomaster/controle/bsp
1 result
68a7d8b22c3022796d16f20e9faea4f83c390090
Select Git revision
Branches
CS_CV
feature/test
master
motor
position_M3508_BSP
remote-tourelle
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
· 10054d4e
Nathan Girard
authored
5 years ago
Ajout PWM
10054d4e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Driver/bsp_pwm.c
+28
-0
28 additions, 0 deletions
Driver/bsp_pwm.c
Driver/bsp_pwm.h
+8
-0
8 additions, 0 deletions
Driver/bsp_pwm.h
with
36 additions
and
0 deletions
Driver/bsp_pwm.c
0 → 100644
View file @
10054d4e
#include
"tim.h"
#include
"bsp_pwm.h"
void
PWM_init
(
void
){
/* Open 4 sets of PWM waves respectively */
/**TIM2 GPIO Configuration
PA8 ------> TIM2_CH1
PA9 ------> TIM2_CH2
PA10 ------> TIM2_CH3
PA11 ------> TIM2_CH4
*/
HAL_TIM_PWM_Start
(
&
htim1
,
TIM_CHANNEL_1
);
HAL_TIM_PWM_Start
(
&
htim1
,
TIM_CHANNEL_2
);
HAL_TIM_PWM_Start
(
&
htim1
,
TIM_CHANNEL_3
);
HAL_TIM_PWM_Start
(
&
htim1
,
TIM_CHANNEL_4
);
}
void
PWM_SetDuty
(
TIM_HandleTypeDef
*
tim
,
uint32_t
tim_channel
,
float
duty
){
switch
(
tim_channel
){
case
TIM_CHANNEL_1
:
tim
->
Instance
->
CCR1
=
(
PWM_RESOLUTION
*
duty
)
-
1
;
break
;
case
TIM_CHANNEL_2
:
tim
->
Instance
->
CCR2
=
(
PWM_RESOLUTION
*
duty
)
-
1
;
break
;
case
TIM_CHANNEL_3
:
tim
->
Instance
->
CCR3
=
(
PWM_RESOLUTION
*
duty
)
-
1
;
break
;
case
TIM_CHANNEL_4
:
tim
->
Instance
->
CCR4
=
(
PWM_RESOLUTION
*
duty
)
-
1
;
break
;
}
}
This diff is collapsed.
Click to expand it.
Driver/bsp_pwm.h
0 → 100644
View file @
10054d4e
#ifndef __BSP_PWM
#define __BSP_PWM
#include
"main.h"
void
PWM_SetDuty
(
TIM_HandleTypeDef
*
tim
,
uint32_t
tim_channel
,
float
duty
);
void
PWM_init
(
void
);
#endif
This diff is collapsed.
Click to expand it.