Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino Core for SAMD21 CPU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josc941e
Arduino Core for SAMD21 CPU
Commits
9affb8f6
Commit
9affb8f6
authored
10 years ago
by
Thibaut VIARD
Browse files
Options
Downloads
Patches
Plain Diff
fixing pullup mode and adding pulldown
Signed-off-by:
Thibaut VIARD
<
thibaut.viard@atmel.com
>
parent
cebfc3c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cores/arduino/wiring_digital.c
+17
-2
17 additions, 2 deletions
cores/arduino/wiring_digital.c
cores/arduino/wiring_digital.h
+2
-1
2 additions, 1 deletion
cores/arduino/wiring_digital.h
with
19 additions
and
3 deletions
cores/arduino/wiring_digital.c
+
17
−
2
View file @
9affb8f6
...
...
@@ -25,6 +25,7 @@
int
pinPeripheral
(
uint32_t
ulPin
,
EPioType
ulPeripheral
)
{
// Handle the case the pin isn't usable as PIO
if
(
g_APinDescription
[
ulPin
].
ulPinType
==
PIO_NOT_A_PIN
)
{
return
-
1
;
...
...
@@ -121,11 +122,13 @@ int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral )
void
pinMode
(
uint32_t
ulPin
,
uint32_t
ulMode
)
{
// Handle the case the pin isn't usable as PIO
if
(
g_APinDescription
[
ulPin
].
ulPinType
==
PIO_NOT_A_PIN
)
{
return
;
}
// Set pin mode according to chapter '22.6.3 I/O Pin Configuration'
switch
(
ulMode
)
{
case
INPUT
:
...
...
@@ -138,6 +141,18 @@ void pinMode( uint32_t ulPin, uint32_t ulMode )
// Set pin to input mode with pull-up resistor enabled
PORT
->
Group
[
g_APinDescription
[
ulPin
].
ulPort
].
PINCFG
[
g_APinDescription
[
ulPin
].
ulPin
].
reg
=
(
uint8_t
)(
PORT_PINCFG_INEN
|
PORT_PINCFG_PULLEN
)
;
PORT
->
Group
[
g_APinDescription
[
ulPin
].
ulPort
].
DIRCLR
.
reg
=
(
uint32_t
)(
1
<<
g_APinDescription
[
ulPin
].
ulPin
)
;
// Enable pull level (cf '22.6.3.2 Input Configuration' and '22.8.7 Data Output Value Set')
PORT
->
Group
[
g_APinDescription
[
ulPin
].
ulPort
].
OUTSET
.
reg
=
(
uint32_t
)(
1
<<
g_APinDescription
[
ulPin
].
ulPin
)
;
break
;
case
INPUT_PULLDOWN
:
// Set pin to input mode with pull-down resistor enabled
PORT
->
Group
[
g_APinDescription
[
ulPin
].
ulPort
].
PINCFG
[
g_APinDescription
[
ulPin
].
ulPin
].
reg
=
(
uint8_t
)(
PORT_PINCFG_INEN
|
PORT_PINCFG_PULLEN
)
;
PORT
->
Group
[
g_APinDescription
[
ulPin
].
ulPort
].
DIRCLR
.
reg
=
(
uint32_t
)(
1
<<
g_APinDescription
[
ulPin
].
ulPin
)
;
// Enable pull level (cf '22.6.3.2 Input Configuration' and '22.8.6 Data Output Value Clear')
PORT
->
Group
[
g_APinDescription
[
ulPin
].
ulPort
].
OUTCLR
.
reg
=
(
uint32_t
)(
1
<<
g_APinDescription
[
ulPin
].
ulPin
)
;
break
;
case
OUTPUT
:
...
...
@@ -154,7 +169,7 @@ void pinMode( uint32_t ulPin, uint32_t ulMode )
void
digitalWrite
(
uint32_t
ulPin
,
uint32_t
ulVal
)
{
/
*
Handle the case the pin isn't usable as PIO
*/
/
/
Handle the case the pin isn't usable as PIO
if
(
g_APinDescription
[
ulPin
].
ulPinType
==
PIO_NOT_A_PIN
)
{
return
;
...
...
@@ -182,7 +197,7 @@ void digitalWrite( uint32_t ulPin, uint32_t ulVal )
int
digitalRead
(
uint32_t
ulPin
)
{
/
*
Handle the case the pin isn't usable as PIO
*/
/
/
Handle the case the pin isn't usable as PIO
if
(
g_APinDescription
[
ulPin
].
ulPinType
==
PIO_NOT_A_PIN
)
{
return
LOW
;
...
...
This diff is collapsed.
Click to expand it.
cores/arduino/wiring_digital.h
+
2
−
1
View file @
9affb8f6
...
...
@@ -26,6 +26,7 @@
#define INPUT (0x0ul)
#define OUTPUT (0x1ul)
#define INPUT_PULLUP (0x2ul)
#define INPUT_PULLDOWN (0x4ul)
#define LOW (0x0ul)
#define HIGH (0x1ul)
...
...
@@ -44,7 +45,7 @@ extern int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral ) ;
* \brief Configures the specified pin to behave either as an input or an output. See the description of digital pins for details.
*
* \param ulPin The number of the pin whose mode you wish to set
* \param ulMode
Either INPUT
or
O
UTPU
T
* \param ulMode
Can be INPUT, OUTPUT, INPUT_PULLUP
or
INP
UT
_
PU
LLDOWN
*/
extern
void
pinMode
(
uint32_t
dwPin
,
uint32_t
dwMode
)
;
...
...
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