FITkit
Fakulta informačních technologií

fspi.h

Zobrazit dokumentaci tohoto souboru.
00001 /*******************************************************************************
00002    fspi.h: second SPI interface
00003    Copyright (C) 2009 Brno University of Technology,
00004                       Faculty of Information Technology
00005    Author(s): Karel Slany <slany AT fit.vutbr.cz>
00006 
00007    LICENSE TERMS
00008 
00009    Redistribution and use in source and binary forms, with or without
00010    modification, are permitted provided that the following conditions
00011    are met:
00012    1. Redistributions of source code must retain the above copyright
00013       notice, this list of conditions and the following disclaimer.
00014    2. Redistributions in binary form must reproduce the above copyright
00015       notice, this list of conditions and the following disclaimer in
00016       the documentation and/or other materials provided with the
00017       distribution.
00018    3. All advertising materials mentioning features or use of this software
00019       or firmware must display the following acknowledgement:
00020 
00021         This product includes software developed by the University of
00022         Technology, Faculty of Information Technology, Brno and its
00023         contributors.
00024 
00025    4. Neither the name of the Company nor the names of its contributors
00026       may be used to endorse or promote products derived from this
00027       software without specific prior written permission.
00028 
00029    This software or firmware is provided ``as is'', and any express or implied
00030    warranties, including, but not limited to, the implied warranties of
00031    merchantability and fitness for a particular purpose are disclaimed.
00032    In no event shall the company or contributors be liable for any
00033    direct, indirect, incidental, special, exemplary, or consequential
00034    damages (including, but not limited to, procurement of substitute
00035    goods or services; loss of use, data, or profits; or business
00036    interruption) however caused and on any theory of liability, whether
00037    in contract, strict liability, or tort (including negligence or
00038    otherwise) arising in any way out of the use of this software, even
00039    if advised of the possibility of such damage.
00040 
00041    $Id$
00042 
00043 
00044 *******************************************************************************/
00045 
00046 #ifndef _FSPI_H_
00047 #define _FSPI_H_
00048 
00049 #include <fitkitlib.h>
00050 
00051 // fast SPI interface connected to FPGA
00052 #define FSPI_DO  BIT1       
00053 #define FSPI_DI  BIT2       
00054 #define FSPI_CLK BIT3       
00055 #define FSPI_CS  BIT6
00056 
00057 #define FSPI_PORT_DIR P3DIR 
00058 #define FSPI_PORT_IN  P3IN  
00059 #define FSPI_PORT_OUT P3OUT 
00060 #define FSPI_PORT_SEL P3SEL 
00061 
00062 #if defined MSP_16X
00063  #define FSPI_RX_BUF U0RXBUF
00064  #define FSPI_TX_BUF U0TXBUF
00065  #define FSPI_BUSY ((TXEPT & U0TCTL) == 0)
00066 #elif defined MSP_261X
00067  #define FSPI_RX_BUF UCB0RXBUF
00068  #define FSPI_TX_BUF UCB0TXBUF
00069  #define FSPI_BUSY ((UCBUSY & UCB0STAT) != 0)
00070 #else 
00071  #error "FSPI define"
00072 #endif
00073 
00074 
00078 void FSPI_Init(char smclkdiv);
00079 
00083 void FSPI_Close(void);
00084 
00085 inline unsigned char FSPI_write_wait_read(unsigned char data);
00086 inline void FSPI_write_wait(unsigned char data);
00087 
00088 #define FSPI_set_CS(val) FSPI_PORT_OUT = (val) ? (FSPI_PORT_OUT | FSPI_CS) : (FSPI_PORT_OUT & (~FSPI_CS))
00089 
00090 #endif /* _FSPI_H_ */