Functions | Variables

# spi_if.c File Reference

this file contains the SPI functions and the CRC calculation More...

`#include "msp430.h"`
`#include "main.h"`
`#include "spi_if.h"`

Go to the source code of this file.

## Functions
unsigned char | calculate_crc (unsigned char *buffer, unsigned char buffer_lenght)
| Local functions .
void | init_spi (void)
| Global functions .
short | spi_write_reg (unsigned char dev_addr, unsigned char reg_addr, unsigned char data)
| Function Name: spi_write_reg .
short | spi_read_reg (unsigned char dev_addr, unsigned char reg_addr, short elem_num, unsigned char discard_crc, unsigned char *pData)
| Function Name: spi_read_reg.
## Variables
const unsigned char | spi_regs_rw_mask []
| constants .
const unsigned char | CrcTable []

## Detailed Description

this file contains the SPI functions and the CRC calculation

Author:
  Texas Instruments, Inc

Date:
  November 2010

Version:
  1.0 Initial version

Note:
  Built with IAR for MSP430 Version: 5.10

Definition in file spi_if.c.

## Function Documentation

unsigned char calculate_crc | ( | unsigned char * | buffer,
|  | unsigned char | buffer_lenght |
| ) |  |  |

Local functions .

Function Name: calculate_crc . Description : calculates CRC coming/going to the 'PL536 device.

Parameters:

  | parameters | : buffer, buffer size

Returns:
  Value : crc

Definition at line 327 of file spi_if.c.

void init_spi | ( | void |  | ) |

Global functions .

Function Name: init_spi . Description : Initializes the SPI module and the SPI pins .

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 134 of file spi_if.c.

short spi_read_reg | ( | unsigned char | dev_addr,
|  | unsigned char | reg_addr,
|  | short | elem_num,
|  | unsigned char | discard_crc,
|  | unsigned char * | pData |
| ) |  |  |

Function Name: spi_read_reg.

External functions declaration .

Description : Read elem_num bytes from SPI reg of the attached device, read data is returned in pData, returns number of received bytes (including CRC as last pData byte if required) .

Parameters:

  | parameters | : device address, register address, num of bytes, CRC enable/disable, receiver buffer .

Returns:
  Value : number of bytes received

Definition at line 224 of file spi_if.c.

short spi_write_reg | ( | unsigned char | dev_addr,
|  | unsigned char | reg_addr,
|  | unsigned char | data |
| ) |  |  |

Function Name: spi_write_reg .

Description : Writes just 1 byte into the specified bq pack register.

Parameters:

  | parameters | : device address, register address, data

Returns:
  Value : return the number of bytes sent

Definition at line 163 of file spi_if.c.

## Variable Documentation

const unsigned char spi_regs_rw_mask[]

Initial value:

    {
      0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,
      0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
      0x3,0x3,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
      0x3,0x3,0x3,0x3,0x3,0x0,0x0,0x0,0x0,0x0,0x3,0x3,0x2,0x3,0x0,0x3,
      0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0
    }

constants .

Definition at line 79 of file spi_if.c.