⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lpc_lib_spi.h

📁 使用embest IDE开发工具开发的基于LPC2294 的触摸屏开发
💻 H
字号:

/*
***********************************************************************

       Embest Info&Tech Co., Ltd.  All rights reserved.
                     www.embedinfo.com

***********************************************************************

---------------- file information -------------------------------------

file name: lpc_lib_spi.h
version  : v0
author   : peter pan / panqan@hotmail.com
begin    : 2006-02-10
finish   : 2006-02-10
define   : lpc spi controll functions head file

notes    :

---------------- modify information -----------------------------------
version  :
modify   :
begin    :
finish   :
define   :
-----------------------------------------------------------------------
*/


// (--------------------- compiler condition --------------------------
#ifndef  lpc_lib_spi_h
         #define  lpc_lib_spi_h



// --------------------- compiler condition --------------------------)



/*-------------------------------------------------------------------*/
/*                       include files                               */
/*---------------------------------------------------------------- --*/
#include	"..\..\com\type_redefine.h"
#include	"..\..\com\lpc22xx_register.h"


/*-------------------------------------------------------------------*/
/*                       variable define                             */
/*-------------------------------------------------------------------*/


// SPI driver



// SPI Port define
// P0 to spi0 controll value
#define		P0_4__SPI_SCK0       (0x01 <<8)  //01
#define		P0_5__SPI_MISO0      (0x01 <<10) //01
#define		P0_6__SPI_MOSI0      (0x01 <<12) //01
#define		P0_7__SPI_SSEL0      (0x01 <<14) //01
#define     SPI0_EN              (P0_4__SPI_SCK0 + P0_5__SPI_MISO0 + P0_6__SPI_MOSI0 + P0_7__SPI_SSEL0)
// P0 to spi0 controll value MASK
// use to clear the control bit
#define		P0_4__SPI_SCK0_MASK  (0x03 <<8)  //11
#define		P0_5__SPI_MISO0_MASK (0x03 <<10) //11
#define		P0_6__SPI_MOSI0_MASK (0x03 <<12) //11
#define		P0_7__SPI_SSEL0_MASK (0x03 <<14) //11
#define     SPI0_EN_MASK         (P0_4__SPI_SCK0_MASK + P0_5__SPI_MISO0_MASK + P0_6__SPI_MOSI0_MASK + P0_7__SPI_SSEL0_MASK)
// spio master control in PINSEL1
#define     P0_24__GPIO_024      (0x00<<16)
#define     P0_24__GPIO_024_MASK (0x03<<16)  //11


//define the spi0 control
#define     SPCR_CPHA_B1         (0x0<<3)
#define     SPCR_CPHA_B2         (0x1<<3)
#define     SPCR_CPOL_CH         (0x0<<4)
#define     SPCR_CPOL_CL         (0x1<<4)
#define     SPCR_MSTR_MASTER     (0x1<<5)
#define     SPCR_MSTR_SLAVE      (0x0<<5)
#define     SPCR_LSBR_B0F        (0x1<<6)
#define     SPCR_LSBR_B7F        (0x0<<6)
#define     SPCR_SPIE_EE         (0x1<<7)
#define     SPCR_SPIE_ED         (0x0<<7)

//spi0 value for 595
#define     SPCR_SPI_595         (SPCR_CPHA_B1+SPCR_CPOL_CL+SPCR_MSTR_MASTER+SPCR_LSBR_B7F+SPCR_SPIE_ED)


/*
	#define		SPCR_MSTR_SLAVE			(0 << 5)
	#define		SPCR_MSTR_MASTER		(1 << 5)
	#define		SPCR_CPOL_SET			(1 << 4)


    SPI0_SPCCR = SPCCR_SET(S0SPCCR_DATA);						// Set the SPI Frequence
    SPI0_SPCR  = (SPCR_MSTR_MASTER | SPCR_CPOL_SET);	
	SPI0_SPCR  = 0x30;

*/

// P0 to spi1 controll value
#define		P0_17__SPI_SCK1      (0x10<<2)
#define		P0_18__SPI_MISO1     (0x10<<4)
#define		P0_19__SPI_MOSI1     (0x10<<6)
#define		P0_20__SPI_SSEL1     (0x10<<8)
#define     SPI1_EN              (P0_4__SPI_SCK1 + P0_5__SPI_MISO1 + P0_6__SPI_MOSI1 + P0_7__SPI_SSEL1)

// P0 to spi1 controll value MASK
// use to clear the control bit
#define		P0_17__SPI_SCK1_MASK  (0x03<<2)
#define		P0_18__SPI_MISO1_MASK (0x03<<4)
#define		P0_19__SPI_MOSI1_MASK (0x03<<6)
#define		P0_20__SPI_SSEL1_MASK (0x03<<8)
#define     SPI1_EN_MASK          (P0_4__SPI_SCK1_MASK + P0_5__SPI_MISO1_MASK + P0_6__SPI_MOSI1_MASK + P0_7__SPI_SSEL1_MASK)


// define the spix_spccr value
#define     SPI_SPCCR_value_max   10








/*-------------------------------------------------------------------*/
/*                       local function declare                      */
/*-------------------------------------------------------------------*/

// spi_extend controll LIB
void spi_init(INT8U channel, INT8U mode, INT8U onoff);
void spi_send(INT8U channel, INT8U data_send);

void spi_data_send(INT8U channel, INT8U data_send);








/*-------------------------------------------------------------------*/
/*                       extern function declare                     */
/*-------------------------------------------------------------------*/

/*--- define in XXX.c ---
extern  void    XXX();
*/


/*-------------------------------------------------------------------*/
/*                       extern variable declare                     */
/*-------------------------------------------------------------------*/

/*--- USED in XXX() ---
XXX SSS; // used inXXX()
*/



/*-------------------------------------------------------------------*/
/*                       function code                               */
/*-------------------------------------------------------------------*/


/**********************************************************************
* name  :    xxxxx
* func  :    xxxxx
* para  :    xxxx
* ret   :    xxxx

* glob  :    xxxx
* inc   :

* author:
* date  :

* modify:
* comment:
**********************************************************************/
/*void  xxx(xxx xxx)
      {
      }
*/




#endif  //lpc_lib_spi_h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -