This file contains SPI lib header file. More...
#include "lib_mcu/spi/spi_drv.h"

Go to the source code of this file.
Functions | |
| bit | spi_init_master (U8 mode, U8 rate, Bool b_msb_first) |
| This function configures the SPI controller in master. | |
| bit | spi_init_slave (U8 mode, U8 rate, Bool b_msb_first) |
| This function configures the SPI controller in slave. | |
| char | spi_putchar (char uc_wr_byte) |
| This function sends a byte on the SPI. | |
| bit | spi_test_hit (void) |
| This function checks if a bytes has been received on the SPI. | |
| char | spi_getchar (void) |
| This function reads a byte on the SPI. | |
| void | spi_transmit_master (char cData) |
| SPI Make the transmission possible. | |
| char | spi_rw (char tx) |
| This function sends a byte on SPI interface. | |
This file contains SPI lib header file.
Definition in file spi_lib.h.
This function configures the SPI controller in master.
| mode | SPI_MODE_0 to SPI_MODE_3 |
| rate | SPI_RATE_0 to SPI_RATE_6 |
| b_msb_first | TRUE if the MSB of the data word is transmitted first |
Definition at line 62 of file spi_lib.c.
References Spi_enable, Spi_init_bus, Spi_select_master, Spi_set_lsbfirst, Spi_set_mode, Spi_set_msbfirst, Spi_set_rate, and TRUE.
{
Spi_select_master();
Spi_set_mode(mode);
Spi_set_rate(rate);
if( b_msb_first )
{
Spi_set_msbfirst();
}else{
Spi_set_lsbfirst();
}
Spi_init_bus();
Spi_enable();
return TRUE;
}
This function configures the SPI controller in slave.
| mode | SPI_MODE_0 to SPI_MODE_3 |
| rate | SPI_RATE_0 to SPI_RATE_6 |
| b_msb_first | TRUE if the MSB of the data word is transmitted first |
Definition at line 88 of file spi_lib.c.
References Spi_enable, Spi_init_bus, Spi_select_slave, Spi_set_lsbfirst, Spi_set_mode, Spi_set_msbfirst, Spi_set_rate, and TRUE.
{
Spi_select_slave();
Spi_set_mode(mode);
Spi_set_rate(rate);
if( b_msb_first )
{
Spi_set_msbfirst();
}else{
Spi_set_lsbfirst();
}
Spi_init_bus();
Spi_enable();
return TRUE;
}
| char spi_putchar | ( | char | ch ) |
This function sends a byte on the SPI.
| uc_wr_byte | character to send on the SPI |
Definition at line 111 of file spi_lib.c.
References Spi_tx_ready, and Spi_write_data.
{
Spi_write_data(ch);
while(!Spi_tx_ready());
return ch;
}
| bit spi_test_hit | ( | void | ) |
This function checks if a bytes has been received on the SPI.
Definition at line 123 of file spi_lib.c.
References Spi_rx_ready.
{
return Spi_rx_ready();
}
| char spi_getchar | ( | void | ) |
This function reads a byte on the SPI.
Definition at line 133 of file spi_lib.c.
References Spi_read_data, and Spi_rx_ready.
{
register char c;
while(!Spi_rx_ready());
c = Spi_read_data();
return c;
}
| void spi_transmit_master | ( | char | cData ) |
SPI Make the transmission possible.
| cData | the data byte to send |
Definition at line 146 of file spi_lib.c.
References Spi_wait_eot, and Spi_write_data.
{
// Wait for transmission complete
Spi_wait_eot();
// Start new transmission
Spi_write_data(cData);
}
| char spi_rw | ( | char | tx ) |
This function sends a byte on SPI interface.
| tx | the data byte to send |
Definition at line 161 of file spi_lib.c.
References Spi_read_data, and Spi_write_data.
{
Spi_write_data(tx);
return Spi_read_data();
}
1.7.2