# spi_master_sw

SPI Master Software

Author | Matthew Schinkel - borntechi.com, copyright © 2009, all rights reserved.
Adapted-by |
Compiler | 2.4o

Description

    SPI Master software control.
    Routines for sending and receiving through SPI software in master mode

Sources

    Jallib spi_master_hw library - Written by William Welch
    http://www.justanotherlanguage.org/content/jallib/tutorials/tutorial_spi_introduction
    http://ww1.microchip.com/downloads/en/devicedoc/spi.pdf

Notes

    alias spi_master_sw_sdi              is pin_sdi
    alias spi_master_sw_sdi_direction    is pin_sdi_direction
    alias spi_master_sw_sdo              is pin_sdo
    alias spi_master_sw_sdo_direction    is pin_sdo_direction
    alias spi_master_sw_sck              is pin_sck
    alias spi_master_sw_sck_direction    is pin_sck_direction

     define spi inputs/outputs
    spi_master_sw_sdi_direction = input    -- spi input
    spi_master_sw_sdo_direction = output   -- spi output
    spi_master_sw_sck_direction = output   -- spi clock

    include spi_master_sw
    spi_init(SPI_MODE_11) -- init spi, choose mode

Dependencies

- spi_common

## Summary

### Global variables/contants

- `var byte _spi_mode`
- `var byte _spi_rate`

### Procedures

- `spi_master_sw_init(byte in spi_mode)`
- `spi_master_sw_set_speed(byte in spi_rate)`
- `spi_master_sw_set_mode_11()`
- `spi_master_sw_set_mode_00()`
- `spi_master_sw_set_mode(byte in spi_mode)`
- `spi_master_sw'put(byte in data)`
- `spi_master_sw_set_mode_10()`
- `spi_master_sw_set_mode_01()`

### Functions

- `spi_master_sw_exchange(byte in data) return byte`
- `spi_master_sw'get() return byte`

## API details

### Global variables/contants

- `var byte _spi_mode`

  No documentation found

- `var byte _spi_rate`

  No documentation found

### Procedures

- `spi_master_sw_init(byte in spi_mode)`

      init spi

- `spi_master_sw_set_speed(byte in spi_rate)`

      set spi speed (not actually implemented yet, just here for compatibility)

- `spi_master_sw_set_mode_11()`

  No documentation found

- `spi_master_sw_set_mode_00()`

  No documentation found

- `spi_master_sw_set_mode(byte in spi_mode)`

      set spi mode

- `spi_master_sw'put(byte in data)`

      put one byte of data onto the spi bus (pseudo variable)

- `spi_master_sw_set_mode_10()`

  No documentation found

- `spi_master_sw_set_mode_01()`

  No documentation found

### Functions

- `spi_master_sw_exchange(byte in data) return byte`

      exchange data on the spi bus.

- `spi_master_sw'get() return byte`

      read one byte of data from the spi bus (pseudo variable)

## Related samples

Here are the list of samples which use this library:

18f27j53 | 18f27j53_mcp4922.jal
18f4550 | 18f4550_dtmf_encoder_ht9200.jal