-
-
Notifications
You must be signed in to change notification settings - Fork 65
Closed
Description
The Mega-0 OUTSET and OUTCLR registers are atomic by nature, so interrupts do not need to be disabled in the digitalWrite() code that manipulates them. (code that does &= or |= still needs such wrappers, since all the IOREGes are now outside the SBI/CBI range and will result in non-atomic access.)
/* Output direction */
if(port->DIR & bit_mask){
//OMIT /* Save system status and disable interrupts */
//OMIT uint8_t status = SREG;
//OMIT cli();
/* Set output to value */
if (val == LOW) { /* If LOW */
port->OUTCLR = bit_mask;
} else if (val == TOGGLE) { /* If TOGGLE */
port->OUTTGL = bit_mask;
/* If HIGH OR > TOGGLE */
} else {
port->OUTSET = bit_mask;
}
//OMIT /* Restore system status */
//OMIT SREG = status;
/* Input direction */
} else {
Metadata
Metadata
Assignees
Labels
No labels