Revision: 1289 Author: bvwelch Date: Fri Sep 4 11:28:49 2009 Log: move constants to top of file, add SPI sources/references
http://code.google.com/p/jallib/source/detail?r=1289 Modified: /trunk/include/peripheral/spi/spi_master_hw.jal ======================================= --- /trunk/include/peripheral/spi/spi_master_hw.jal Wed Sep 2 20:18:09 2009 +++ /trunk/include/peripheral/spi/spi_master_hw.jal Fri Sep 4 11:28:49 2009 @@ -1,6 +1,6 @@ -- Title: SPI Master (spi_master_hw.jal) -- Author: William Welch Copyright (c) 2009, all rights reserved. --- Compiler: 2.4 +-- Compiler: 2.4l -- -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the ZLIB license (http://www.opensource.org/licenses/zlib-license.html) @@ -8,8 +8,11 @@ -- Description: SPI Master hardware control. -- Routines for sending and receiving through the SPI in master mode -- --- TODO: only tested in Master mode 00 +-- Sources: good overview of SPI at http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus +-- also at: http://elm-chan.org/docs/spi_e.html -- +-- TODO: only tested in Master mode 00, and 11 +-- -- FIXME. This probably should be handled in the device files themselves. -- But until then, we will attempt to provide a 'legacy' mode such that this @@ -17,6 +20,19 @@ -- -- Credits: This 'aliasing' approach has been 'borrowed' from i2c_hardware_aliases.jal -- + +-- Use these when calling the spi_init() routine below ( SPI master mode, see sources above ) +const SPI_MODE_00 = 0 +const SPI_MODE_01 = 1 +const SPI_MODE_10 = 2 +const SPI_MODE_11 = 3 + +-- Use these when calling the spi_init() routine below ( SPI clock frequency ) +const SPI_RATE_FOSC_4 = 0 +const SPI_RATE_FOSC_16 = 1 +const SPI_RATE_FOSC_64 = 2 +const SPI_RATE_TMR = 3 + if ( target_cpu == PIC_16 ) then if defined( SSPCON ) == false then @@ -77,16 +93,6 @@ return data end function -const SPI_MODE_00 = 0 -const SPI_MODE_01 = 1 -const SPI_MODE_10 = 2 -const SPI_MODE_11 = 3 - -const SPI_RATE_FOSC_4 = 0 -const SPI_RATE_FOSC_16 = 1 -const SPI_RATE_FOSC_64 = 2 -const SPI_RATE_TMR = 3 - -- Initialize the SPI registers. -- Note: check your datasheet -- TRIS settings, any SPI errata? procedure spi_init(byte in spi_mode, byte in spi_rate) is --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
