Go to the source code of this file.
#define SPI1_check_buffer_overflow |
( |
| ) |
(SSPCON1bits.SSPOV) |
This macro checks if any buffer overflow occured.
- Parameters
-
- Returns
- Bit WCOL 0: No overflow. 1: Buffer Overflow dedected.
Definition at line 215 of file module_SPI.h.
#define SPI1_check_bus_collision |
( |
| ) |
(SSPCON1bits.WCOL) |
This macro checks if any communication .
- Parameters
-
- Returns
- Bit WCOL 0: No communication collision. 1: Communication collision dedected.
Definition at line 202 of file module_SPI.h.
#define SPI1_check_data_ready |
( |
| ) |
(SSPSTATbits.BF) |
This macro checks if the data is ready. It can be used for TX mode only.
- Parameters
-
- Returns
- Bit BF 0: Trasmission in progress 0: Trasmission completed (buffer full)
Definition at line 189 of file module_SPI.h.
#define SPI1_is_TX_over |
( |
| ) |
(PIR1bits.SSPIF) |
This macro checks TX transition is over. It check the interrupt flag as reference.
- Parameters
-
- Returns
- Bit Interrupt Flag 0: Communication in progress 1: Communication completed
Definition at line 228 of file module_SPI.h.
#define SPI2_check_buffer_overflow |
( |
| ) |
(SSP2CON1bits.SSPOV) |
#define SPI2_check_bus_collision |
( |
| ) |
(SSP2CON1bits.WCOL) |
#define SPI2_check_data_ready |
( |
| ) |
(SSP2STATbits.BF) |
#define SPI2_is_TX_over |
( |
| ) |
(PIR3bits.SSP2IF) |
#define SPI_CLK_OSC_16 0b00000001 |
#define SPI_CLK_OSC_4 0b00000000 |
#define SPI_CLK_OSC_64 0b00000010 |
#define SPI_MASTER_DEVICE 0x01 |
#define SPI_SLAVE_DEVICE 0x02 |
#define SPI_SS_DISABLED 0b00000101 |
#define SPI_SS_ENABLED 0b00000100 |
#define SPI_TIMER_OUT_CLK 0b00000011 |
void SPI1_baudrate |
( |
unsigned char |
baudrate | ) |
|
This function sets the communication baudrate. It should be called before SPI_open function.
- Parameters
-
baudrate | Baudrate [SPI_CLK_OSC_64, SPI_CLK_OSC_16, SPI_CLK_OSC_4, SPI_TIMER_OUT_CLK] |
- Returns
- void
- Warning
- This function should be called before SPI_open and for Master device Only.
Definition at line 151 of file module_SPI.c.
This function close the SPI module.
- Parameters
-
- Returns
- void
Definition at line 134 of file module_SPI.c.
void SPI1_mode |
( |
unsigned char |
communication_mode | ) |
|
This function sets the communication mode. It should be called before SPI_open function.
- Parameters
-
communication_mode | Operational mode [SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3] |
- Returns
- void
- Warning
- This function should be called before SPI_open for both MAster and Slave devices.
Definition at line 168 of file module_SPI.c.
References SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, and SPI_MODE_3.
void SPI1_open |
( |
unsigned char |
device_type | ) |
|
This function opens the SPI module for communication. In particular it sets the device type either to Master or Slave.
- Parameters
-
device_type | Device Type [SPI_MASTER_DEVICE, SPI_SLAVE_DEVICE] |
- Returns
- void
- Warning
- This function should be called only after having set the module with the right baudrate and mode.
Definition at line 52 of file module_SPI.c.
References PIN_AS_INPUT, PIN_AS_OUTPUT, SPI1_SS_PIN, SPI_MASTER_DEVICE, and SPI_SLAVE_DEVICE.
unsigned char SPI1_read_byte |
( |
void |
| ) |
|
This function reads a single byte from the bus
- Parameters
-
- Returns
- byte Value read from the input buffer.
- Warning
- The function is a bloching one. It waits for 8 bits to be sent out.
Definition at line 286 of file module_SPI.c.
References SPI1_is_TX_over.
unsigned char SPI1_write_byte |
( |
unsigned char |
byte_to_send | ) |
|
This function writes a single byte on the bus.
- Parameters
-
byte_to_send | Byte to send [0..255] |
- Returns
- error Communication error 0: The byte has been properly written -1: Communication error
Definition at line 228 of file module_SPI.c.
References SPI1_is_TX_over.
void SPI2_baudrate |
( |
unsigned char |
baudrate | ) |
|
void SPI2_mode |
( |
unsigned char |
communication_mode | ) |
|
void SPI2_open |
( |
unsigned char |
device_type | ) |
|
unsigned char SPI2_read_byte |
( |
void |
| ) |
|
unsigned char SPI2_write_byte |
( |
unsigned char |
byte_to_send | ) |
|