Skip to content

Commit

Permalink
[Core] Fix Read Pin configured as output
Browse files Browse the repository at this point in the history
  • Loading branch information
fasol committed Nov 27, 2017
1 parent 370468d commit ae95c12
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions module/cores/arduino/port_sam/core_digital.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,22 @@ int digitalRead( uint32_t ulPin )
return LOW ;
}

if ( (Ports[g_aPinMap[ulPin].iPort].pGPIO->PIO_PDSR & g_aPinMap[ulPin].ulPin) != 0 )
/* Test if pin is under control of GPIO */
if ( (Ports[g_aPinMap[ulPin].iPort].pGPIO->PIO_PSR & g_aPinMap[ulPin].ulPin) != 0 )
{
return HIGH ;
/* Read Output Status */
if ( (Ports[g_aPinMap[ulPin].iPort].pGPIO->PIO_ODSR & g_aPinMap[ulPin].ulPin) != 0)
{
return HIGH;
}
}
else // Pin is configured as input
{
/* Read Pin Status */
if ( (Ports[g_aPinMap[ulPin].iPort].pGPIO->PIO_PDSR & g_aPinMap[ulPin].ulPin) != 0 )
{
return HIGH ;
}
}

return LOW ;
Expand All @@ -180,4 +193,3 @@ int digitalRead( uint32_t ulPin )
#ifdef __cplusplus
}
#endif

0 comments on commit ae95c12

Please sign in to comment.