LTlib LaurTec Library
4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
|
#include "LTlib.h"
Go to the source code of this file.
Macros | |
#define | SPI_SS_ENABLED 0b00000100 |
#define | SPI_SS_DISABLED 0b00000101 |
#define | SPI1_SS_PIN SPI_SS_DISABLED |
#define | SPI2_SS_PIN SPI_SS_DISABLED |
#define | SPI_MASTER_DEVICE 0x01 |
#define | SPI_SLAVE_DEVICE 0x02 |
#define | SPI_MODE_0 0x00 |
#define | SPI_MODE_1 0x01 |
#define | SPI_MODE_2 0x02 |
#define | SPI_MODE_3 0x03 |
#define | SPI_TIMER_OUT_CLK 0b00000011 |
#define | SPI_CLK_OSC_64 0b00000010 |
#define | SPI_CLK_OSC_16 0b00000001 |
#define | SPI_CLK_OSC_4 0b00000000 |
#define | SPI1_check_data_ready() (SSPSTATbits.BF) |
#define | SPI1_check_bus_collision() (SSPCON1bits.WCOL) |
#define | SPI1_check_buffer_overflow() (SSPCON1bits.SSPOV) |
#define | SPI1_is_TX_over() (PIR1bits.SSPIF) |
Functions | |
void | SPI1_open (unsigned char device_type) |
void | SPI1_close (void) |
void | SPI1_baudrate (unsigned char baudrate) |
void | SPI1_mode (unsigned char communication_mode) |
signed char | SPI1_write_byte (unsigned char byte_to_send) |
unsigned char | SPI1_read_byte (void) |
#define SPI1_check_buffer_overflow | ( | ) | (SSPCON1bits.SSPOV) |
This macro checks if any buffer overflow occured.
void |
Definition at line 225 of file module_SPI.h.
#define SPI1_check_bus_collision | ( | ) | (SSPCON1bits.WCOL) |
This macro checks if any communication .
void |
Definition at line 211 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.
void |
Definition at line 196 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.
void |
Definition at line 239 of file module_SPI.h.
#define SPI1_SS_PIN SPI_SS_DISABLED |
Definition at line 64 of file module_SPI.h.
#define SPI2_SS_PIN SPI_SS_DISABLED |
Definition at line 65 of file module_SPI.h.
#define SPI_CLK_OSC_16 0b00000001 |
Definition at line 82 of file module_SPI.h.
#define SPI_CLK_OSC_4 0b00000000 |
Definition at line 83 of file module_SPI.h.
#define SPI_CLK_OSC_64 0b00000010 |
Definition at line 81 of file module_SPI.h.
#define SPI_MASTER_DEVICE 0x01 |
Definition at line 72 of file module_SPI.h.
#define SPI_MODE_0 0x00 |
Definition at line 75 of file module_SPI.h.
#define SPI_MODE_1 0x01 |
Definition at line 76 of file module_SPI.h.
#define SPI_MODE_2 0x02 |
Definition at line 77 of file module_SPI.h.
#define SPI_MODE_3 0x03 |
Definition at line 78 of file module_SPI.h.
#define SPI_SLAVE_DEVICE 0x02 |
Definition at line 73 of file module_SPI.h.
#define SPI_SS_DISABLED 0b00000101 |
Definition at line 63 of file module_SPI.h.
#define SPI_SS_ENABLED 0b00000100 |
Definition at line 62 of file module_SPI.h.
#define SPI_TIMER_OUT_CLK 0b00000011 |
Definition at line 80 of file module_SPI.h.
void SPI1_baudrate | ( | unsigned char | baudrate | ) |
This function sets the communication baudrate. It should be called before SPI_open function.
baudrate | Baudrate [SPI_CLK_OSC_64, SPI_CLK_OSC_16, SPI_CLK_OSC_4, SPI_TIMER_OUT_CLK] |
Definition at line 151 of file module_SPI.c.
void SPI1_close | ( | void | ) |
This function close the SPI module.
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.
communication_mode | Operational mode [SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3] |
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.
device_type | Device Type [SPI_MASTER_DEVICE, SPI_SLAVE_DEVICE] |
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
void |
Definition at line 286 of file module_SPI.c.
References SPI1_is_TX_over.
signed char SPI1_write_byte | ( | unsigned char | byte_to_send | ) |
This function writes a single byte on the bus.
byte_to_send | Byte to send [0..255] |
Definition at line 228 of file module_SPI.c.
References SPI1_is_TX_over.