Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ch32v003fun
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Andreas Horn
ch32v003fun
Commits
a1748b9c
Commit
a1748b9c
authored
1 year ago
by
cnlohr
Browse files
Options
Downloads
Patches
Plain Diff
Update with more cap sense pins
parent
442d6fb3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/cap_touch_exti/cap_touch_exti.c
+13
-3
13 additions, 3 deletions
examples/cap_touch_exti/cap_touch_exti.c
with
13 additions
and
3 deletions
examples/cap_touch_exti/cap_touch_exti.c
+
13
−
3
View file @
a1748b9c
...
...
@@ -68,13 +68,17 @@ int MeasureTouch( int portno, int pin, int pu_mode )
endtime
=
starttime
-
1
;
port
->
BSHR
=
1
<<
(
pin
);
// Allow up to
256
cycles for the pin to change.
// Allow up to
384
cycles for the pin to change.
#define DELAY8 \
asm volatile( "c.nop;c.nop;c.nop;c.nop;c.nop;c.nop;c.nop;c.nop;" );
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
DELAY8
// Optimization: If you did the nop sled in assembly, the interrupt could scoot to the end
// Disable EXTI
EXTI
->
INTENR
=
0
;
...
...
@@ -98,10 +102,16 @@ int main()
while
(
1
)
{
printf
(
"%
4
d %
4
d %
4
d
\n
"
,
printf
(
"%
d %d %
d %d %
d %d %d %
d
\n
"
,
MeasureTouch
(
2
,
4
,
GPIO_CFGLR_IN_PUPD
),
// Port C4
MeasureTouch
(
2
,
5
,
GPIO_CFGLR_IN_FLOAT
),
// Port C5, with external pull-up.
MeasureTouch
(
2
,
7
,
GPIO_CFGLR_IN_PUPD
),
// Port C7
MeasureTouch
(
3
,
2
,
GPIO_CFGLR_IN_PUPD
),
// Port D2
MeasureTouch
(
3
,
3
,
GPIO_CFGLR_IN_PUPD
),
// Port D3
MeasureTouch
(
3
,
4
,
GPIO_CFGLR_IN_PUPD
),
// Port D4
MeasureTouch
(
3
,
5
,
GPIO_CFGLR_IN_PUPD
),
// Port D5
MeasureTouch
(
2
,
5
,
GPIO_CFGLR_IN_FLOAT
)
);
// Port C5, with external pull-up.
MeasureTouch
(
3
,
6
,
GPIO_CFGLR_IN_PUPD
)
// Port D6
);
}
}
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