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

📄 ssc0.c

📁 英飞凌C166之XC164CS的eeprom数据读写程序
💻 C
字号:
//****************************************************************************
// @Module        High-Speed Synchronous Serial Interface 0 (SSC0)
// @Filename      SSC0.C
// @Project       X5043.dav
//----------------------------------------------------------------------------
// @Controller    Infineon XC164CS-8R40
//
// @Compiler      Keil
//
// @Codegenerator 2.8
//
// @Description   This file contains functions that use the SSC0 module.
//
//----------------------------------------------------------------------------
// @Date          2007-5-25 17:16:29
//
//****************************************************************************

// USER CODE BEGIN (SSC0_General,1)

// USER CODE END



//****************************************************************************
// @Project Includes
//****************************************************************************

#include "MAIN.H"

// USER CODE BEGIN (SSC0_General,2)

// USER CODE END


//****************************************************************************
// @Macros
//****************************************************************************

// USER CODE BEGIN (SSC0_General,3)

// USER CODE END


//****************************************************************************
// @Defines
//****************************************************************************

// USER CODE BEGIN (SSC0_General,4)

// USER CODE END


//****************************************************************************
// @Typedefs
//****************************************************************************

// USER CODE BEGIN (SSC0_General,5)

// USER CODE END


//****************************************************************************
// @Imported Global Variables
//****************************************************************************

// USER CODE BEGIN (SSC0_General,6)

// USER CODE END


//****************************************************************************
// @Global Variables
//****************************************************************************

// USER CODE BEGIN (SSC0_General,7)

// USER CODE END


//****************************************************************************
// @External Prototypes
//****************************************************************************

// USER CODE BEGIN (SSC0_General,8)

// USER CODE END


//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************

// USER CODE BEGIN (SSC0_General,9)

// USER CODE END


//****************************************************************************
// @Function      void SSC0_vInit(void) 
//
//----------------------------------------------------------------------------
// @Description   This is the initialization function of the SSC0 function 
//                library. It is assumed that the SFRs used by this library 
//                are in its reset state. 
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    None
//
//----------------------------------------------------------------------------
// @Date          2007-5-25
//
//****************************************************************************

// USER CODE BEGIN (Init,1)

// USER CODE END

void SSC0_vInit(void)
{
  // USER CODE BEGIN (Init,2)

  // USER CODE END

  SSC0_CON_EN = 0;           //  enable access to control bits

  ///  -----------------------------------------------------------------------
  ///  Configuration of the SSC0 Baud Rate Generator:
  ///  -----------------------------------------------------------------------
  ///  - required baud rate = 100.000 kbaud
  ///  - real baud rate     = 100.000 kbaud
  ///  - deviation          = 0.000 %

  SSC0_BR        =  0x0063;      // load SSC0 baud rate time reload register

  ///  -----------------------------------------------------------------------
  ///  Configuration of the SSC0 Operation Mode:
  ///  -----------------------------------------------------------------------
  ///  - this device is configured as SSC0 master
  ///  - transfer data width is 8 bit
  ///  - transfer/receive MSB first
  ///  - latch receive data on leading clock edge, shift on trailing edge
  ///  - idle clock line is low, leading clock edge is low-to-high transition
  ///  - ignore receive error
  ///  - ignore phase error

  P3        &= 0xDFFF;      //  load P3.13 output latch (SCLK) with the
                            //  desired clock idle level(low)
  ALTSEL0P3 |= 0x2000;      /// set ALtSEL0P3.P13
  DP3       |= 0x2000;      /// set P3.13 direction control (SCLK output)


  SSC0_CON       =  0xC037;      // load SSC0 control register

  ///  -----------------------------------------------------------------------
  ///  Configuration of the used SSC0 Port Pins:
  ///  -----------------------------------------------------------------------
  P3        |= 0x2000;      //  set P3.13 output latch (SCLK)

  DP3       &= 0xFEFF;      /// reset P3.8 direction control (MRST input)
  P3        |= 0x0200;      //  set P3.9 output latch (MTSR)
  ALTSEL0P3 |= 0x0200;      /// set ALtSEL0P3.P9
  DP3       |= 0x0200;      /// set P3.9 direction control (MTSR output)


  ///  -----------------------------------------------------------------------
  ///  Configuration of the used SSC0 Interrupts:
  ///  -----------------------------------------------------------------------

  // USER CODE BEGIN (Init,3)
  SSC0_TIC_IR = 0;			//reset transmit interrupt request 
  CS_X5043    = 1;			//片选信号无效(‘1’无效)			
  DP3_P6 	  = 1;			//把X5043的片选信号对应的引脚设置为输出口

  // USER CODE END

} //  End of function SSC0_vInit


//****************************************************************************
// @Function      void SSC0_vSendData(uword uwData) 
//
//----------------------------------------------------------------------------
// @Description   The master device can initiate the first data transfer by 
//                writing the transmit data into transmit buffer. This value 
//                is copied into the shift register (which is assumed to be 
//                empty at this time), and the selected first bit of the 
//                transmit data is placed onto the MTSR line on the next 
//                clock from the baud rate generator. 
//                A slave device immediately outputs the selected first bit 
//                (MSB or LSB of the transfer data) at pin MRST, when the 
//                contents of the transmit buffer are copied into the slave's 
//                shift register. 
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    uwData: 
//                Data to be send
//
//----------------------------------------------------------------------------
// @Date          2007-5-25
//
//****************************************************************************

// USER CODE BEGIN (SendData,1)

// USER CODE END

void SSC0_vSendData(uword uwData)
{
  SSC0_TIC_IR = 0;        //  reset transmit interrupt request 
  SSC0_TB  = uwData;   //  load transmit buffer register

} //  End of function SSC0_vSendData


//****************************************************************************
// @Function      uword SSC0_uwGetData(void) 
//
//----------------------------------------------------------------------------
// @Description   This function returns the contents of the receive buffer. 
//                When the receive interrupt request flag is set this implies 
//                that data is available for reading in the receive buffer. 
//
//----------------------------------------------------------------------------
// @Returnvalue   Received data
//
//----------------------------------------------------------------------------
// @Parameters    None
//
//----------------------------------------------------------------------------
// @Date          2007-5-25
//
//****************************************************************************

// USER CODE BEGIN (GetData,1)

// USER CODE END

uword SSC0_uwGetData(void)
{
  SSC0_RIC_IR = 0;        // reset receive interrupt request
  return(SSC0_RB);     // return receive buffer register

} //  End of function SSC0_uwGetData




// USER CODE BEGIN (SSC_General,10)

// USER CODE END

⌨️ 快捷键说明

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