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
e84673c0
Verified
Commit
e84673c0
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
Add buzzer
parent
3ca07eb5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ports/card10/Makefile
+4
-0
4 additions, 0 deletions
ports/card10/Makefile
ports/card10/buzzer.c
+44
-0
44 additions, 0 deletions
ports/card10/buzzer.c
ports/card10/mpconfigport.h
+1
-0
1 addition, 0 deletions
ports/card10/mpconfigport.h
with
49 additions
and
0 deletions
ports/card10/Makefile
+
4
−
0
View file @
e84673c0
...
@@ -44,6 +44,7 @@ LIBS =
...
@@ -44,6 +44,7 @@ LIBS =
SRC_C
=
\
SRC_C
=
\
main.c
\
main.c
\
uart_core.c
\
uart_core.c
\
buzzer.c
\
lib/utils/printf.c
\
lib/utils/printf.c
\
lib/utils/stdout_helpers.c
\
lib/utils/stdout_helpers.c
\
lib/utils/pyexec.c
\
lib/utils/pyexec.c
\
...
@@ -52,6 +53,9 @@ SRC_C = \
...
@@ -52,6 +53,9 @@ SRC_C = \
OBJ
=
$(
PY_O
)
$(
addprefix
$(
BUILD
)
/,
$(
SRC_C:.c
=
.o
))
OBJ
=
$(
PY_O
)
$(
addprefix
$(
BUILD
)
/,
$(
SRC_C:.c
=
.o
))
SRC_QSTR
+=
buzzer.c
USER_C_MODULES
+=
buzzer.c
# SDK compilation hack
# SDK compilation hack
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
ports/card10/buzzer.c
0 → 100644
+
44
−
0
View file @
e84673c0
#include
"py/obj.h"
#include
"py/runtime.h"
#include
"py/builtin.h"
#include
<stdio.h>
#include
"gpio.h"
static
const
gpio_cfg_t
motor_pin
=
{
PORT_0
,
PIN_8
,
GPIO_FUNC_OUT
,
GPIO_PAD_NONE
};
STATIC
mp_obj_t
buzzer_set
(
mp_obj_t
state_obj
)
{
if
(
state_obj
==
mp_const_true
)
{
printf
(
"Buzzer ON!
\n
"
);
GPIO_OutSet
(
&
motor_pin
);
}
else
if
(
state_obj
==
mp_const_false
){
printf
(
"Buzzer OFF!
\n
"
);
GPIO_OutClr
(
&
motor_pin
);
}
else
{
mp_raise_TypeError
(
"expected bool"
);
}
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
buzzer_set_obj
,
buzzer_set
);
// Define all properties of the example module.
// Table entries are key/value pairs of the attribute name (a string)
// and the MicroPython object reference.
// All identifiers and strings are written as MP_QSTR_xxx and will be
// optimized to word-sized integers by the build system (interned strings).
STATIC
const
mp_rom_map_elem_t
buzzer_module_globals_table
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_buzzer
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set
),
MP_ROM_PTR
(
&
buzzer_set_obj
)
},
};
STATIC
MP_DEFINE_CONST_DICT
(
buzzer_module_globals
,
buzzer_module_globals_table
);
// Define module object.
const
mp_obj_module_t
buzzer_module
=
{
.
base
=
{
&
mp_type_module
},
.
globals
=
(
mp_obj_dict_t
*
)
&
buzzer_module_globals
,
};
// Register the module to make it available in Python
MP_REGISTER_MODULE
(
MP_QSTR_buzzer
,
buzzer_module
,
MODULE_BUZZER_ENABLED
);
This diff is collapsed.
Click to expand it.
ports/card10/mpconfigport.h
+
1
−
0
View file @
e84673c0
...
@@ -59,6 +59,7 @@
...
@@ -59,6 +59,7 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_PY_UTIME_MP_HAL (1)
#define MICROPY_PY_UTIME_MP_HAL (1)
#define MODULE_BUZZER_ENABLED (1)
// type definitions for the specific machine
// type definitions for the specific machine
...
...
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