/*! \brief Initialize the SPI in slave mode and enable the spi interrupt. */ static void spi_slave_init(volatile void *spi, uint8_t mode) { /* Enable Clock for SPI module */ sysclk_enable_module(POWER_RED_REG0, PRSPI_bm); /* Configure SPI pins for slave */ /* Set MISO as output high, and set MOSI, SS , SCK as input */ gpio_configure_pin(SPI_SCK, IOPORT_DIR_INPUT); gpio_configure_pin(SPI_MOSI, IOPORT_DIR_INPUT); gpio_configure_pin(SPI_SS, IOPORT_DIR_INPUT); gpio_configure_pin(SPI_MISO, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT); /* Set the clock mode */ spi_set_clock_mode(spi, mode); /* Enable SPI as slave */ spi_enable_slave_mode(spi); /* Set the interrupt call back */ spi_set_interrupt_callback(spi_interrupt_callback); /* Enable SPI interrupt */ spi_enable_interrupt(spi); }
static int spi_set_params(struct s3c2410_spi *device) { spi_set_def_prescale(device); spi_set_master_mode(device); spi_set_clock_mode(device); spi_enable_sck(device); sppin_set_keep(0x1); /* stay in master mode after tx */ sppin_set_resv1(0x1); /* according to spec this should be 1 */ dprintf("%s: done\n", __func__); return 0; }