StepperII
Dual Axis Stepper Controller

CSpi.h

00001 
00002 #pragma once
00003 
00004 //#include <avr/io.h>
00005 
00006 
00007 /*
00008         SPI support (master and slave)
00009 
00010         Currently set up to send 6-digit BCD data (3 bytes)
00011         Uses pin change interrupt to detect SS going active - initializes xfer
00012         Uses SPI transfer complete to load data bytes
00013         Note: Should freeze multi-byte data while doing SPI transfer,
00014         otherwise bytes could be out of sync.
00015 
00016         I/O that needs to be programmed:
00017         (For ATmega48,88,168)
00018 
00019         Pin  Port Master Slave
00020         ==== ==== ====== =====
00021         MOSI PB3  User   Input
00022         MISO PB4  Input  User
00023         SCK  PB5  User   Input
00024         /SS  PB2  User   Input
00025 
00026         Interrupts
00027 
00028         Master - SIGNAL (SPI_STC_vect), SPCR.SPIE, SPI Transfere Complete
00029         Slave  - SIGNAL (SPI_STC_vect)
00030                  SIGNAL (SIG_PIN_CHANGE0), PCMSK0.PCINT2 PCICR.PCIE0
00031 
00032 */
00033 
00034 
00035 class CSpi
00036 {
00037 private:
00038         // Don't declare ss because we won't ever be slave
00039         // CBit(B, 2, RO_AL) ss;        //!< Declare slave select
00040         //CBit(C, 7, WO_AL) cs ;        //!< Declare active-low chip select
00041         //CBit(B, 1, WO) static sclk;           //!< Make SCLK an output
00042         //CBit(B, 2, WO) static mosi;           //!< Make MOSI an output
00043         //CBit(B, 3, RO) static miso;           //!< Make MISO an input
00044 public:
00045 
00046 public:
00047         static void init(void);
00048         static int writeWord(unsigned int x);
00049 };
 All Classes Files Functions Variables Defines