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
a654914d
Commit
a654914d
authored
9 years ago
by
danicampora
Browse files
Options
Downloads
Patches
Plain Diff
cc3200: Allow to read pin value when in OPEN_DRAIN mode.
parent
359a8aa7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cc3200/mods/pybpin.c
+26
-2
26 additions, 2 deletions
cc3200/mods/pybpin.c
with
26 additions
and
2 deletions
cc3200/mods/pybpin.c
+
26
−
2
View file @
a654914d
...
@@ -73,6 +73,7 @@ STATIC void pin_validate_mode (uint mode);
...
@@ -73,6 +73,7 @@ STATIC void pin_validate_mode (uint mode);
STATIC
void
pin_validate_pull
(
uint
pull
);
STATIC
void
pin_validate_pull
(
uint
pull
);
STATIC
void
pin_validate_drive
(
uint
strength
);
STATIC
void
pin_validate_drive
(
uint
strength
);
STATIC
void
pin_validate_af
(
const
pin_obj_t
*
pin
,
int8_t
idx
,
uint8_t
*
fn
,
uint8_t
*
unit
,
uint8_t
*
type
);
STATIC
void
pin_validate_af
(
const
pin_obj_t
*
pin
,
int8_t
idx
,
uint8_t
*
fn
,
uint8_t
*
unit
,
uint8_t
*
type
);
STATIC
uint8_t
pin_get_value
(
const
pin_obj_t
*
self
);
STATIC
void
GPIOA0IntHandler
(
void
);
STATIC
void
GPIOA0IntHandler
(
void
);
STATIC
void
GPIOA1IntHandler
(
void
);
STATIC
void
GPIOA1IntHandler
(
void
);
STATIC
void
GPIOA2IntHandler
(
void
);
STATIC
void
GPIOA2IntHandler
(
void
);
...
@@ -456,6 +457,29 @@ STATIC void pin_validate_af(const pin_obj_t* pin, int8_t idx, uint8_t *fn, uint8
...
@@ -456,6 +457,29 @@ STATIC void pin_validate_af(const pin_obj_t* pin, int8_t idx, uint8_t *fn, uint8
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
}
}
STATIC
uint8_t
pin_get_value
(
const
pin_obj_t
*
self
)
{
uint32_t
value
;
bool
setdir
=
false
;
if
(
self
->
mode
==
PIN_TYPE_OD
||
self
->
mode
==
GPIO_DIR_MODE_ALT_OD
)
{
setdir
=
true
;
// configure the direction to IN for a moment in order to read the pin value
MAP_GPIODirModeSet
(
self
->
port
,
self
->
bit
,
GPIO_DIR_MODE_IN
);
}
// now get the value
value
=
MAP_GPIOPinRead
(
self
->
port
,
self
->
bit
);
if
(
setdir
)
{
// set the direction back to output
MAP_GPIODirModeSet
(
self
->
port
,
self
->
bit
,
GPIO_DIR_MODE_OUT
);
if
(
self
->
value
)
{
MAP_GPIOPinWrite
(
self
->
port
,
self
->
bit
,
self
->
bit
);
}
else
{
MAP_GPIOPinWrite
(
self
->
port
,
self
->
bit
,
0
);
}
}
// return it
return
value
?
1
:
0
;
}
STATIC
void
GPIOA0IntHandler
(
void
)
{
STATIC
void
GPIOA0IntHandler
(
void
)
{
EXTI_Handler
(
GPIOA0_BASE
);
EXTI_Handler
(
GPIOA0_BASE
);
}
}
...
@@ -648,8 +672,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
...
@@ -648,8 +672,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
STATIC
mp_obj_t
pin_value
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
pin_value
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
pin_obj_t
*
self
=
args
[
0
];
pin_obj_t
*
self
=
args
[
0
];
if
(
n_args
==
1
)
{
if
(
n_args
==
1
)
{
// get the
pin
value
// get the value
return
MP_OBJ_NEW_SMALL_INT
(
MAP_GPIOPinRead
(
self
->
port
,
self
->
bit
)
?
1
:
0
);
return
MP_OBJ_NEW_SMALL_INT
(
pin_get_value
(
self
)
);
}
else
{
}
else
{
// set the pin value
// set the pin value
if
(
mp_obj_is_true
(
args
[
1
]))
{
if
(
mp_obj_is_true
(
args
[
1
]))
{
...
...
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