Skip to content

Commit a469023

Browse files
authored
Merge pull request #7 from WestfW/master
Remove unnecessary Atomicity code and extra sanity check.
2 parents 746de7f + 295f988 commit a469023

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

cores/arduino/wiring_digital.c

-16
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,9 @@ void pinMode(uint8_t pin, PinMode mode)
4141

4242
if(mode == OUTPUT){
4343

44-
/* Save state */
45-
uint8_t status = SREG;
46-
cli();
47-
4844
/* Configure direction as output */
4945
port->DIRSET = bit_mask;
5046

51-
/* Restore state */
52-
SREG = status;
53-
5447
} else { /* mode == INPUT or INPUT_PULLUP */
5548

5649
uint8_t bit_pos = digitalPinToBitPosition(pin);
@@ -151,15 +144,10 @@ void digitalWrite(uint8_t pin, PinStatus val)
151144

152145
/* Get port */
153146
PORT_t *port = digitalPinToPortStruct(pin);
154-
if(port == NULL) return;
155147

156148
/* Output direction */
157149
if(port->DIR & bit_mask){
158150

159-
/* Save system status and disable interrupts */
160-
uint8_t status = SREG;
161-
cli();
162-
163151
/* Set output to value */
164152
if (val == LOW) { /* If LOW */
165153
port->OUTCLR = bit_mask;
@@ -171,9 +159,6 @@ void digitalWrite(uint8_t pin, PinStatus val)
171159
port->OUTSET = bit_mask;
172160
}
173161

174-
/* Restore system status */
175-
SREG = status;
176-
177162
/* Input direction */
178163
} else {
179164
/* Old implementation has side effect when pin set as input -
@@ -218,7 +203,6 @@ PinStatus digitalRead(uint8_t pin)
218203

219204
/* Get port and check valid port */
220205
PORT_t *port = digitalPinToPortStruct(pin);
221-
if(port == NULL) return LOW;
222206

223207
/* Read pin value from PORTx.IN register */
224208
if(port->IN & bit_mask){

0 commit comments

Comments
 (0)