Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
5e756c98
Commit
5e756c98
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Rename servo_TIM2_Handle -> TIM2_Handle.
parent
e2548095
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
stmhal/servo.c
+11
-11
11 additions, 11 deletions
stmhal/servo.c
stmhal/servo.h
+1
-1
1 addition, 1 deletion
stmhal/servo.h
stmhal/stm32f4xx_hal_msp.c
+1
-1
1 addition, 1 deletion
stmhal/stm32f4xx_hal_msp.c
stmhal/stm32f4xx_it.c
+1
-2
1 addition, 2 deletions
stmhal/stm32f4xx_it.c
with
14 additions
and
15 deletions
stmhal/servo.c
+
11
−
11
View file @
5e756c98
...
@@ -29,7 +29,7 @@ STATIC const mp_obj_type_t servo_obj_type;
...
@@ -29,7 +29,7 @@ STATIC const mp_obj_type_t servo_obj_type;
STATIC
pyb_servo_obj_t
pyb_servo_obj
[
PYB_SERVO_NUM
];
STATIC
pyb_servo_obj_t
pyb_servo_obj
[
PYB_SERVO_NUM
];
TIM_HandleTypeDef
servo_
TIM2_Handle
;
TIM_HandleTypeDef
TIM2_Handle
;
void
servo_init
(
void
)
{
void
servo_init
(
void
)
{
// TIM2 clock enable
// TIM2 clock enable
...
@@ -40,12 +40,12 @@ void servo_init(void) {
...
@@ -40,12 +40,12 @@ void servo_init(void) {
HAL_NVIC_EnableIRQ
(
TIM2_IRQn
);
HAL_NVIC_EnableIRQ
(
TIM2_IRQn
);
// PWM clock configuration
// PWM clock configuration
servo_
TIM2_Handle
.
Instance
=
TIM2
;
TIM2_Handle
.
Instance
=
TIM2
;
servo_
TIM2_Handle
.
Init
.
Period
=
2000
;
// timer cycles at 50Hz
TIM2_Handle
.
Init
.
Period
=
2000
;
// timer cycles at 50Hz
servo_
TIM2_Handle
.
Init
.
Prescaler
=
((
SystemCoreClock
/
2
)
/
100000
)
-
1
;
// timer runs at 100kHz
TIM2_Handle
.
Init
.
Prescaler
=
((
SystemCoreClock
/
2
)
/
100000
)
-
1
;
// timer runs at 100kHz
servo_
TIM2_Handle
.
Init
.
ClockDivision
=
0
;
TIM2_Handle
.
Init
.
ClockDivision
=
0
;
servo_
TIM2_Handle
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
TIM2_Handle
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
HAL_TIM_PWM_Init
(
&
servo_
TIM2_Handle
);
HAL_TIM_PWM_Init
(
&
TIM2_Handle
);
// reset servo objects
// reset servo objects
for
(
int
i
=
0
;
i
<
PYB_SERVO_NUM
;
i
++
)
{
for
(
int
i
=
0
;
i
<
PYB_SERVO_NUM
;
i
++
)
{
...
@@ -83,9 +83,9 @@ void servo_timer_irq_callback(void) {
...
@@ -83,9 +83,9 @@ void servo_timer_irq_callback(void) {
}
}
}
}
if
(
need_it
)
{
if
(
need_it
)
{
__HAL_TIM_ENABLE_IT
(
&
servo_
TIM2_Handle
,
TIM_IT_UPDATE
);
__HAL_TIM_ENABLE_IT
(
&
TIM2_Handle
,
TIM_IT_UPDATE
);
}
else
{
}
else
{
__HAL_TIM_DISABLE_IT
(
&
servo_
TIM2_Handle
,
TIM_IT_UPDATE
);
__HAL_TIM_DISABLE_IT
(
&
TIM2_Handle
,
TIM_IT_UPDATE
);
}
}
}
}
...
@@ -115,10 +115,10 @@ STATIC void servo_init_channel(pyb_servo_obj_t *s) {
...
@@ -115,10 +115,10 @@ STATIC void servo_init_channel(pyb_servo_obj_t *s) {
oc_init
.
Pulse
=
s
->
pulse_cur
;
// units of 10us
oc_init
.
Pulse
=
s
->
pulse_cur
;
// units of 10us
oc_init
.
OCPolarity
=
TIM_OCPOLARITY_HIGH
;
oc_init
.
OCPolarity
=
TIM_OCPOLARITY_HIGH
;
oc_init
.
OCFastMode
=
TIM_OCFAST_DISABLE
;
oc_init
.
OCFastMode
=
TIM_OCFAST_DISABLE
;
HAL_TIM_PWM_ConfigChannel
(
&
servo_
TIM2_Handle
,
&
oc_init
,
channel
);
HAL_TIM_PWM_ConfigChannel
(
&
TIM2_Handle
,
&
oc_init
,
channel
);
// start PWM
// start PWM
HAL_TIM_PWM_Start
(
&
servo_
TIM2_Handle
,
channel
);
HAL_TIM_PWM_Start
(
&
TIM2_Handle
,
channel
);
}
}
/******************************************************************************/
/******************************************************************************/
...
...
This diff is collapsed.
Click to expand it.
stmhal/servo.h
+
1
−
1
View file @
5e756c98
extern
TIM_HandleTypeDef
servo_
TIM2_Handle
;
extern
TIM_HandleTypeDef
TIM2_Handle
;
void
servo_init
(
void
);
void
servo_init
(
void
);
void
servo_timer_irq_callback
(
void
);
void
servo_timer_irq_callback
(
void
);
...
...
This diff is collapsed.
Click to expand it.
stmhal/stm32f4xx_hal_msp.c
+
1
−
1
View file @
5e756c98
...
@@ -149,7 +149,7 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
...
@@ -149,7 +149,7 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
void
HAL_TIM_PeriodElapsedCallback
(
TIM_HandleTypeDef
*
htim
)
{
void
HAL_TIM_PeriodElapsedCallback
(
TIM_HandleTypeDef
*
htim
)
{
if
(
htim
==
&
TIM3_Handle
)
{
if
(
htim
==
&
TIM3_Handle
)
{
USBD_CDC_HAL_TIM_PeriodElapsedCallback
();
USBD_CDC_HAL_TIM_PeriodElapsedCallback
();
}
else
if
(
htim
==
&
servo_
TIM2_Handle
)
{
}
else
if
(
htim
==
&
TIM2_Handle
)
{
servo_timer_irq_callback
();
servo_timer_irq_callback
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
stmhal/stm32f4xx_it.c
+
1
−
2
View file @
5e756c98
...
@@ -352,8 +352,7 @@ void RTC_WKUP_IRQHandler(void) {
...
@@ -352,8 +352,7 @@ void RTC_WKUP_IRQHandler(void) {
}
}
void
TIM2_IRQHandler
(
void
)
{
void
TIM2_IRQHandler
(
void
)
{
// servo timer is TIM2
HAL_TIM_IRQHandler
(
&
TIM2_Handle
);
HAL_TIM_IRQHandler
(
&
servo_TIM2_Handle
);
}
}
void
TIM3_IRQHandler
(
void
)
{
void
TIM3_IRQHandler
(
void
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment