void spi_master_initialize(void) {
// Configure an SPI peripheral.
spi_enable_clock(SPI);
spi_disable(SPI);
spi_reset(SPI);
spi_set_lastxfer(SPI);
spi_set_master_mode(SPI);
spi_disable_mode_fault_detect(SPI);
spi_set_peripheral_chip_select_value(SPI, SPI_CHIP_SEL);
spi_set_clock_polarity(SPI, SPI_CHIP_SEL, SPI_CLK_POLARITY);
spi_set_clock_phase(SPI, SPI_CHIP_SEL, SPI_CLK_PHASE);
spi_set_bits_per_transfer(SPI, SPI_CHIP_SEL, SPI_CSR_BITS_12_BIT);
spi_set_baudrate_div(SPI, SPI_CHIP_SEL, 30);
spi_set_transfer_delay(SPI, SPI_CHIP_SEL, SPI_DLYBS, SPI_DLYBCT);
spi_set_clock_polarity(SPI, SPI_CHIP1_SEL, 0);
spi_set_clock_phase(SPI, SPI_CHIP1_SEL, 1);
spi_set_bits_per_transfer(SPI, SPI_CHIP1_SEL, SPI_CSR_BITS_8_BIT);
spi_set_baudrate_div(SPI, SPI_CHIP1_SEL, 120); //EEPROM工作在1MHz
spi_set_transfer_delay(SPI, SPI_CHIP1_SEL, SPI_DLYBS, SPI_DLYBCT);
spi_enable(SPI);
spi_set_peripheral_chip_select_value(SPI, SPI_CHIP_SEL);
}