Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
dd25366b
Commit
dd25366b
authored
8 years ago
by
Mark Whitehorn
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
clean up timer_set_rate and add advice on hacking counter frequency
parent
2d5588ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/drivers/stm32/drv_io_timer.c
+5
-15
5 additions, 15 deletions
src/drivers/stm32/drv_io_timer.c
with
5 additions
and
15 deletions
src/drivers/stm32/drv_io_timer.c
+
5
−
15
View file @
dd25366b
...
...
@@ -378,7 +378,10 @@ static int allocate_channel(unsigned channel, io_timer_channel_mode_t mode)
static
int
timer_set_rate
(
unsigned
timer
,
unsigned
rate
)
{
/* configure the timer to update at the desired rate */
/* Configure the timer to run at 1MHz (other system code _assumes_ that timers run at 1MHz).
* If you want to hack this to achieve a different frequency, alter the value of
* .clock_freq in the relevant driver/boards/xxxx/xxx_timer_config.c file.
*/
timer_freq
[
timer
]
=
1
;
rPSC
(
timer
)
=
(
io_timers
[
timer
].
clock_freq
/
1000000
)
-
1
;
rARR
(
timer
)
=
timer_freq
[
timer
]
*
1000000
/
rate
;
...
...
@@ -391,6 +394,7 @@ static int timer_set_rate(unsigned timer, unsigned rate)
void
io_timer_set_oneshot_mode
(
unsigned
timer
)
{
/* This timer MUST run at 8MHz */
timer_freq
[
timer
]
=
8
;
rPSC
(
timer
)
=
(
io_timers
[
timer
].
clock_freq
/
8000000
)
-
1
;
...
...
@@ -452,20 +456,6 @@ int io_timer_init_timer(unsigned timer)
rBDTR
(
timer
)
=
ATIM_BDTR_MOE
;
}
/* If in oneshot mode, configure the prescaler for 8MHz output.
* else set prescaler for 1MHz.
*/
if
(
timer_freq
[
timer
]
==
8
)
{
rPSC
(
timer
)
=
(
io_timers
[
timer
].
clock_freq
/
8000000
)
-
1
;
// can't find a way to trigger in this mode
// /* set one pulse mode */
// rCR1(timer) |= 1 << 3;
}
else
{
rPSC
(
timer
)
=
(
io_timers
[
timer
].
clock_freq
/
1000000
)
-
1
;
}
/*
* Note we do the Standard PWM Out init here
* default to updating at 50Hz
...
...
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