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
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
641300dc
Commit
641300dc
authored
8 years ago
by
Peter Hinch
Committed by
Paul Sokolovsky
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
stmhal/dac: DAC deinit() method added.
parent
ee009d71
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
docs/library/pyb.DAC.rst
+4
-0
4 additions, 0 deletions
docs/library/pyb.DAC.rst
stmhal/dac.c
+16
-0
16 additions, 0 deletions
stmhal/dac.c
with
20 additions
and
0 deletions
docs/library/pyb.DAC.rst
+
4
−
0
View file @
641300dc
...
...
@@ -66,6 +66,10 @@ Methods
Reinitialise the DAC. ``bits`` can be 8 or 12.
.. method:: dac.deinit()
De-initialise the DAC making its pin available for other uses.
.. method:: dac.noise(freq)
Generate a pseudo-random noise signal. A new random sample is written
...
...
This diff is collapsed.
Click to expand it.
stmhal/dac.c
+
16
−
0
View file @
641300dc
...
...
@@ -246,6 +246,21 @@ STATIC mp_obj_t pyb_dac_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *k
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
pyb_dac_init_obj
,
1
,
pyb_dac_init
);
/// \method deinit()
/// Turn off the DAC, enable other use of pin.
STATIC
mp_obj_t
pyb_dac_deinit
(
mp_obj_t
self_in
)
{
pyb_dac_obj_t
*
self
=
self_in
;
if
(
self
->
dac_channel
==
DAC_CHANNEL_1
)
{
DAC_Handle
.
Instance
->
CR
&=
~
DAC_CR_EN1
;
DAC_Handle
.
Instance
->
CR
|=
DAC_CR_BOFF1
;
}
else
{
DAC_Handle
.
Instance
->
CR
&=
~
DAC_CR_EN2
;
DAC_Handle
.
Instance
->
CR
|=
DAC_CR_BOFF2
;
}
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_dac_deinit_obj
,
pyb_dac_deinit
);
#if defined(TIM6)
/// \method noise(freq)
/// Generate a pseudo-random noise signal. A new random sample is written
...
...
@@ -461,6 +476,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_dac_write_timed_obj, 1, pyb_dac_write_time
STATIC
const
mp_map_elem_t
pyb_dac_locals_dict_table
[]
=
{
// instance methods
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_init
),
(
mp_obj_t
)
&
pyb_dac_init_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_deinit
),
(
mp_obj_t
)
&
pyb_dac_deinit_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_write
),
(
mp_obj_t
)
&
pyb_dac_write_obj
},
#if defined(TIM6)
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_noise
),
(
mp_obj_t
)
&
pyb_dac_noise_obj
},
...
...
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