Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_spi

Driver for SPI bus. More...

Enumerations

enum  bc_spi_speed_t {
  BC_SPI_SPEED_125_KHZ = 0,
  BC_SPI_SPEED_250_KHZ = 1,
  BC_SPI_SPEED_500_KHZ = 2,
  BC_SPI_SPEED_1_MHZ = 3,
  BC_SPI_SPEED_2_MHZ = 4,
  BC_SPI_SPEED_4_MHZ = 5,
  BC_SPI_SPEED_8_MHZ = 6,
  BC_SPI_SPEED_16_MHZ = 7
}
 SPI communication speed. More...
 
enum  bc_spi_mode_t {
  BC_SPI_MODE_0 = 0,
  BC_SPI_MODE_1 = 1,
  BC_SPI_MODE_2 = 2,
  BC_SPI_MODE_3 = 3
}
 SPI mode of operation. More...
 
enum  bc_spi_event_t { BC_SPI_EVENT_DONE = 1 }
 SPI event. More...
 

Functions

void bc_spi_init (bc_spi_speed_t speed, bc_spi_mode_t mode)
 Initialize SPI channel. More...
 
void bc_spi_set_speed (bc_spi_speed_t speed)
 Set SPI communication speed. More...
 
void bc_spi_set_timing (uint16_t cs_delay, uint16_t delay, uint16_t cs_quit)
 Set SPI timing. More...
 
bc_spi_speed_t bc_spi_get_speed (void)
 Get SPI communication speed. More...
 
void bc_spi_set_mode (bc_spi_mode_t mode)
 Set SPI mode of operation. More...
 
void bc_spi_set_manual_cs_control (bool manual_cs_control)
 Enable manual control of CS pin. More...
 
bc_spi_mode_t bc_spi_get_mode (void)
 Get SPI mode of operation. More...
 
bool bc_spi_is_ready (void)
 Check if is ready for transfer. More...
 
bool bc_spi_transfer (const void *source, void *destination, size_t length)
 Execute SPI transfer. More...
 
bool bc_spi_async_transfer (const void *source, void *destination, size_t length, void(*event_handler)(bc_spi_event_t event, void *event_param), void(*event_param))
 Execute async SPI transfer. More...
 

Detailed Description

Driver for SPI bus.

Enumeration Type Documentation

SPI event.

Enumerator
BC_SPI_EVENT_DONE 

SPI event is completed.

Definition at line 60 of file bc_spi.h.

SPI mode of operation.

Enumerator
BC_SPI_MODE_0 

SPI mode of operation is 0 (CPOL = 0, CPHA = 0)

BC_SPI_MODE_1 

SPI mode of operation is 1 (CPOL = 0, CPHA = 1)

BC_SPI_MODE_2 

SPI mode of operation is 2 (CPOL = 1, CPHA = 0)

BC_SPI_MODE_3 

SPI mode of operation is 3 (CPOL = 1, CPHA = 1)

Definition at line 42 of file bc_spi.h.

SPI communication speed.

Enumerator
BC_SPI_SPEED_125_KHZ 

SPI communication speed is 125 kHz.

BC_SPI_SPEED_250_KHZ 

SPI communication speed is 250 kHz.

BC_SPI_SPEED_500_KHZ 

SPI communication speed is 500 kHz.

BC_SPI_SPEED_1_MHZ 

SPI communication speed is 1 MHz.

BC_SPI_SPEED_2_MHZ 

SPI communication speed is 2 MHz.

BC_SPI_SPEED_4_MHZ 

SPI communication speed is 4 MHz.

BC_SPI_SPEED_8_MHZ 

SPI communication speed is 8 MHz.

BC_SPI_SPEED_16_MHZ 

SPI communication speed is 16 MHz.

Definition at line 12 of file bc_spi.h.

Function Documentation

bool bc_spi_async_transfer ( const void *  source,
void *  destination,
size_t  length,
void(*)(bc_spi_event_t event, void *event_param)  event_handler,
void *  event_param 
)

Execute async SPI transfer.

Parameters
[in]sourcePointer to source buffer
[out]destinationPointer to destination buffer
[in]lengthNumber of bytes to be transferred
[in]event_handlerFunction address (can be NULL)
[in]event_paramOptional event parameter (can be NULL)

Definition at line 267 of file bc_spi.c.

Referenced by bc_ls013b7dh03_update().

Here is the call graph for this function:

Here is the caller graph for this function:

bc_spi_mode_t bc_spi_get_mode ( void  )

Get SPI mode of operation.

Returns
SPI mode of operation

Definition at line 177 of file bc_spi.c.

bc_spi_speed_t bc_spi_get_speed ( void  )

Get SPI communication speed.

Returns
SPI communication speed

Definition at line 150 of file bc_spi.c.

void bc_spi_init ( bc_spi_speed_t  speed,
bc_spi_mode_t  mode 
)

Initialize SPI channel.

Parameters
[in]speedSPI communication speed
[in]modeSPI mode of operation

Definition at line 64 of file bc_spi.c.

Referenced by bc_ls013b7dh03_init().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_spi_is_ready ( void  )

Check if is ready for transfer.

Returns
true If ready
false If not ready

Definition at line 187 of file bc_spi.c.

Referenced by bc_ls013b7dh03_is_ready(), and bc_ls013b7dh03_update().

Here is the caller graph for this function:

void bc_spi_set_manual_cs_control ( bool  manual_cs_control)

Enable manual control of CS pin.

Parameters
[in]manual_cs_controlenable manual control

Definition at line 182 of file bc_spi.c.

void bc_spi_set_mode ( bc_spi_mode_t  mode)

Set SPI mode of operation.

Parameters
[in]modeSPI mode of operation

Definition at line 155 of file bc_spi.c.

Referenced by bc_spi_init().

Here is the caller graph for this function:

void bc_spi_set_speed ( bc_spi_speed_t  speed)

Set SPI communication speed.

Parameters
[in]speedSPI communication speed

Definition at line 119 of file bc_spi.c.

Referenced by bc_spi_init().

Here is the caller graph for this function:

void bc_spi_set_timing ( uint16_t  cs_delay,
uint16_t  delay,
uint16_t  cs_quit 
)

Set SPI timing.

Parameters
[in]cs_delayin us
[in]delayin us
[in]cs_quitin us

Definition at line 141 of file bc_spi.c.

bool bc_spi_transfer ( const void *  source,
void *  destination,
size_t  length 
)

Execute SPI transfer.

Parameters
[in]sourcePointer to source buffer
[out]destinationPointer to destination buffer
[in]lengthNumber of bytes to be transferred

Definition at line 192 of file bc_spi.c.

Here is the call graph for this function: