sub_spi_config |
Top Previous Next |
Got to SUB-20 page |
Synopsis int sub_spi_config( sub_handle hndl, int cfg_set, int* cfg_get )
Configure SUB-20 SPI module or read current configuration. If *cfg_get is NULL function will configure SPI according to the cfg_set parameter. Otherwise it will read current SPI configuration into *cfg_get Parameters •cfg_set - Desired SPI configuration. This parameter is effective only if *cfg_get is NULL. cfg_set should be assembled as a combination of below flags
Beginning from FW version 0.3.3 and library version 0.1.12.25 lower SPI frequencies (down to 4KHz) are supported for SPI Master transfer with sub_spi_transfer function. Special SPI_CLK_HZ(FHZ) macro defined in libsub.h, where FHZ parameter denotes SPI frequency in Hz. Supported frequencies range is 100.000Hz .. 4000Hz. Exact frequency may differ from requested due to integer rounding in division.
•*cfg_get - Pointer to store current configuration read from SUB-20 device or NULL Return value On success function returns 0. Otherwise error code. Example /* Read current SPI configuration */ sub_spi_config( hndl, 0, &spi_config );
/* Configure SPI */ sub_spi_config( hndl, SPI_ENABLE|SPI_CPOL_RISE|SPI_SMPL_SETUP|SPI_MSB_FIRST|SPI_CLK_4MHZ, 0 );
/* Disable SPI */ sub_spi_config( hndl, 0, 0 );
Compatibility
|