int getID(void) { int result; //REG_IME = 0; // disable interrupts (critical section) // Get ID while (SERIAL_CR & SPI_BUSY); SERIAL_CR = SPI_ENABLE | SPI_CONTINUOUS | SPI_DEVICE_FIRMWARE; SERIAL_DATA = FW_RDID; while (SERIAL_CR & SPI_BUSY); result = 0; for (int i = 0; i < 3; i++) { SERIAL_DATA = 0; while (SERIAL_CR & SPI_BUSY); result = (SERIAL_DATA & 0xFF) | (result<<8); } // Get status while (SERIAL_CR & SPI_BUSY); SERIAL_CR = SPI_ENABLE | SPI_CONTINUOUS | SPI_DEVICE_FIRMWARE; SERIAL_DATA = FW_RDSR; while (SERIAL_CR & SPI_BUSY); SERIAL_DATA = 0; while (SERIAL_CR & SPI_BUSY); result = ((SERIAL_DATA & 0xFF) << 24) | result; //REG_IME = 1; // enable interrupts return result; }