Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stm32_libraries
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
humanoides
tools
stm32_libraries
Commits
b12fc911
Commit
b12fc911
authored
5 months ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added the clock frequency to the scheduler initialization.
parent
91c6a65c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scheduler/include/scheduler.h
+2
-1
2 additions, 1 deletion
scheduler/include/scheduler.h
scheduler/src/scheduler.c
+4
-3
4 additions, 3 deletions
scheduler/src/scheduler.c
with
6 additions
and
4 deletions
scheduler/include/scheduler.h
+
2
−
1
View file @
b12fc911
...
...
@@ -40,6 +40,7 @@ typedef struct{
TSchedulerChannel
channels
[
SCHEDULER_MAX_CHANNELS
];
unsigned
char
num_channels
;
unsigned
short
int
prescaler
;
unsigned
int
clk_freq
;
void
(
*
start
)(
unsigned
short
int
);
void
(
*
stop
)(
unsigned
short
int
);
void
(
*
set_pulse
)(
unsigned
short
int
,
unsigned
short
int
,
unsigned
char
);
...
...
@@ -47,7 +48,7 @@ typedef struct{
unsigned
int
scheduler_get_channel
(
sched_channel_t
channel_id
);
sched_channel_t
scheduler_get_id
(
unsigned
int
id
);
void
scheduler_init
(
TScheduler
*
scheduler
,
unsigned
char
num_channels
,
unsigned
short
int
prescaler
);
void
scheduler_init
(
TScheduler
*
scheduler
,
unsigned
char
num_channels
,
unsigned
short
int
prescaler
,
unsigned
int
clk_freq
);
void
scheduler_interrupt
(
TScheduler
*
scheduler
,
sched_channel_t
channel_id
);
unsigned
short
int
scheduler_get_pulse
(
TScheduler
*
scheduler
,
sched_channel_t
channel_id
);
void
scheduler_set_channel
(
TScheduler
*
scheduler
,
sched_channel_t
channel_id
,
void
(
*
function
)(
void
*
data
),
unsigned
char
period_ms
,
void
*
data
);
...
...
This diff is collapsed.
Click to expand it.
scheduler/src/scheduler.c
+
4
−
3
View file @
b12fc911
#include
"scheduler.h"
extern
unsigned
int
SystemCoreClock
;
#include
<iostream>
/* private functions */
unsigned
short
int
scheduler_ms_to_pulse
(
TScheduler
*
scheduler
,
unsigned
char
period_ms
)
{
return
(
SystemCoreClock
/
(
scheduler
->
prescaler
*
1000
))
*
period_ms
;
return
(
scheduler
->
clk_freq
/
(
scheduler
->
prescaler
*
1000
))
*
period_ms
;
}
unsigned
int
scheduler_get_channel
(
sched_channel_t
channel_id
)
...
...
@@ -32,7 +32,7 @@ sched_channel_t scheduler_get_id(unsigned int id)
}
}
void
scheduler_init
(
TScheduler
*
scheduler
,
unsigned
char
num_channels
,
unsigned
short
int
prescaler
)
void
scheduler_init
(
TScheduler
*
scheduler
,
unsigned
char
num_channels
,
unsigned
short
int
prescaler
,
unsigned
int
clk_freq
)
{
unsigned
char
i
=
0
;
...
...
@@ -45,6 +45,7 @@ void scheduler_init(TScheduler *scheduler,unsigned char num_channels, unsigned s
}
scheduler
->
num_channels
=
num_channels
;
scheduler
->
prescaler
=
prescaler
;
scheduler
->
clk_freq
=
clk_freq
;
scheduler
->
stop
=
0x00000000
;
scheduler
->
start
=
0x00000000
;
scheduler
->
set_pulse
=
0x00000000
;
...
...
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