/* * These configuration parameters specify how to clock the * bits that are sent and received on the Cheetah SPI * interface. * * The polarity option specifies which transition * constitutes the leading edge and which transition is the * falling edge. For example, CH_SPI_POL_RISING_FALLING * would configure the SPI to idle the SCK clock line low. * The clock would then transition low-to-high on the * leading edge and high-to-low on the trailing edge. * * The phase option determines whether to sample or setup on * the leading edge. For example, CH_SPI_PHASE_SAMPLE_SETUP * would configure the SPI to sample on the leading edge and * setup on the trailing edge. * * The bitorder option is used to indicate whether LSB or * MSB is shifted first. * * The SS polarity option is to indicate the polarity of the * slave select pin (active high or active low). Each of * the lower three bits of ss_polarity corresponds to each * of the SS lines. Set the bit value for a given SS line * to 0 for active low or 1 for active high. */ // enum CheetahSpiPolarity (from declaration above) // CH_SPI_POL_RISING_FALLING = 0 // CH_SPI_POL_FALLING_RISING = 1 // enum CheetahSpiPhase (from declaration above) // CH_SPI_PHASE_SAMPLE_SETUP = 0 // CH_SPI_PHASE_SETUP_SAMPLE = 1 // enum CheetahSpiBitorder (from declaration above) // CH_SPI_BITORDER_MSB = 0 // CH_SPI_BITORDER_LSB = 1 /* Configure the SPI master interface */ public static int ch_spi_configure( int cheetah, CheetahSpiPolarity polarity, CheetahSpiPhase phase, CheetahSpiBitorder bitorder, byte ss_polarity ) { if (!CH_LIBRARY_LOADED) { return((int)CheetahStatus.CH_INCOMPATIBLE_LIBRARY); } return(net_ch_spi_configure(cheetah, polarity, phase, bitorder, ss_polarity)); }
private static extern int net_ch_spi_configure(int cheetah, CheetahSpiPolarity polarity, CheetahSpiPhase phase, CheetahSpiBitorder bitorder, byte ss_polarity);