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
cdfa11f5
Commit
cdfa11f5
authored
10 years ago
by
Daniel Campora
Browse files
Options
Downloads
Patches
Plain Diff
cc3200: In Timer.callback() only use value param if in edge count mode.
parent
e78a8c94
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cc3200/mods/pybtimer.c
+4
-14
4 additions, 14 deletions
cc3200/mods/pybtimer.c
with
4 additions
and
14 deletions
cc3200/mods/pybtimer.c
+
4
−
14
View file @
cdfa11f5
...
...
@@ -63,7 +63,7 @@
/// tim = pyb.Timer(4) # create a timer object using timer 4
/// tim.init(mode=Timer.PERIODIC) # initialize it in periodic mode
/// tim_ch = tim.channel(Timer.A, freq=2) # configure channel A at a frequency of 2Hz
/// tim_ch.callback(handler=lambda t:led.toggle()) # toggle a
led
on every cycle of the timer
/// tim_ch.callback(handler=lambda t:led.toggle()) # toggle a
LED
on every cycle of the timer
///
/// Further examples:
///
...
...
@@ -765,12 +765,14 @@ STATIC mp_obj_t pyb_timer_channel_callback (mp_uint_t n_args, const mp_obj_t *po
break
;
case
TIMER_CFG_A_CAP_COUNT
:
ch
->
timer
->
intflags
|=
TIMER_CAPA_MATCH
<<
shift
;
// set the match value and make 1 the minimum
MAP_TimerMatchSet
(
ch
->
timer
->
timer
,
ch
->
channel
,
MAX
(
1
,
args
[
3
].
u_int
));
break
;
case
TIMER_CFG_A_CAP_TIME
:
ch
->
timer
->
intflags
|=
TIMER_CAPA_EVENT
<<
shift
;
break
;
case
TIMER_CFG_A_PWM
:
// special case for the match interrupt
// special case for the
PWM
match interrupt
ch
->
timer
->
intflags
|=
((
ch
->
channel
&
TIMER_A
)
==
TIMER_A
)
?
TIMER_TIMA_MATCH
:
TIMER_TIMB_MATCH
;
break
;
default:
...
...
@@ -833,18 +835,6 @@ STATIC mp_obj_t pyb_timer_channel_callback (mp_uint_t n_args, const mp_obj_t *po
// create the callback
_callback
=
mpcallback_new
(
ch
,
args
[
1
].
u_obj
,
&
pyb_timer_channel_cb_methods
);
// get the value if given
uint32_t
c_value
=
MAX
(
0
,
args
[
3
].
u_int
);
ch
->
duty_cycle
=
MIN
(
100
,
c_value
);
// reload the timer
uint32_t
period_c
;
uint32_t
match
;
compute_prescaler_period_and_match_value
(
ch
,
&
period_c
,
&
match
);
MAP_TimerLoadSet
(
ch
->
timer
->
timer
,
ch
->
channel
,
period_c
);
// set the appropiate match value
MAP_TimerMatchSet
(
ch
->
timer
->
timer
,
ch
->
channel
,
(
_config
==
TIMER_CFG_A_PWM
)
?
match
:
c_value
);
// enable the callback before returning
pyb_timer_channel_callback_enable
(
ch
);
}
...
...
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