XMega: Add threading protection to prevent race conditions