LTlib LaurTec Library  4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
module_SPI.c File Reference
#include "module_SPI.h"

Go to the source code of this file.

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)
 

Function Documentation

void SPI1_baudrate ( unsigned char  baudrate)

This function sets the communication baudrate. It should be called before SPI_open function.

Parameters
baudrateBaudrate [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.

void SPI1_close ( void  )

This function close the SPI module.

Parameters
void
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_modeOperational 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_typeDevice 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
void
Returns
byte Value read from the input buffer.
Warning
The function is a blocking one. It waits for 8 bits to be sent out.

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.

Parameters
byte_to_sendByte 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.