亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? example280x_i2c_master.c

?? tms320f2812 iic配置,包括pdf文件和原碼.來源于TI公司.
?? C
字號:
//###########################################################################
//
// FILE:    Example_i2c_master.c
//
// TITLE:   DSP280x I2C MASTER EXAMPLE
//
// ASSUMPTIONS:
//
//          This program requires the DSP280x header files.  
//          As supplied, this project is configured for "boot to SARAM" operation.
//
//			This program will allow the I2C to act as a master. External
//          connections must be made to the I2C Clock and Data pins.
//      
//          Signal         2808 Pin         eZdsp Pin
//          I2C Clock      GPIO33 (pin 5)    P8-38
//          I2C Data       GPIO32 (pin 100)  P8-36
//          Ground         Vss (pin 2)       P8-40
//
// DESCRIPTION:
//
// This program will communicate to 6 read/write locations in the Slave 2808 RAM. 
// It will allow communications with those registers by the following I2C commands:
//
//  I2C Write (from host)
//
//  S  ADDR  W  A  DATA  A  DATA  A  DATA  A  P
//
//     S = Start bit
//  ADDR = Device Address (7 bits - to this 2808)
//     W = Write
//     A = Acknowledge (from 2808 to host)
//  DATA = location number (0 - 5)
//     A = Acknowledge (from 2808)
//  DATA = High byte of word to be stored
//     A = Ack
//  DATA = Low byte of word to be stored
//     A = Ack
//     P = Stop bit 
//
//
//  I2C Read (from host)
//
//  S   ADDR  W  A  DATA  A  S   ADDR R A  DATA  A  DATA  A  P
//
//     S = Start bit
//  ADDR = Device Address (7 bits - to this 2808)
//     W = Write
//     A = Acknowledge (from 2808 to host)
//  DATA = location number (0 - 5)
//     A = Acknowledge (from 2808)
//
//     S = Repeated Start Bit
//  ADDR = Device Address (7 bits - to this 2808)
//     R = Read
//     A = Acknowlege (from 2808)
//  DATA = High byte of word to be read
//     A = Ack (from host)
//  DATA = Low byte of word to be read
//     A = (N)Ack (from host)
//     P = Stop bit   
//
//###########################################################################
// Author: Todd Anderson
//
// October, 2006
//###########################################################################
// Change Log
//---------------------------------------------------------------------------
//   Date               Change
//---------------------------------------------------------------------------
//
//---------------------------------------------------------------------------

#include "DSP280x_Device.h"     // DSP280x Headerfile Include File
#include "DSP280x_Examples.h"   // DSP280x Examples Include File
#include "DSP280x_I2C_defines.h"

// Note: I2C Macros used in this example can be found in the 
// DSP280x_I2C_defines.h file

// Prototype statements for functions found within this file.
void I2CA_Init(void);
void I2CA_Write(int);
void I2CA_Read(int);
void I2CA_Wait(void);
 
interrupt void i2c_int1a_isr(void);


struct FLAGREG_BITS
{
	volatile unsigned int Rsvd:16;		//bits 0-14
};
union FLAG_REG
{
	volatile unsigned int all;
	struct FLAGREG_BITS   bit;
}Flags;


Uint16 Register;
Uint16 Reg[6];
Uint16 ReadReg[6] = {0,0,0,0,0,0};

Uint16 InData[3];
Uint16 OutData[3];
Uint16 I2cIndex;

#define I2C_SLAVE_ADDR        0x2c

void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP280x_SysCtrl.c file.
	InitSysCtrl();
	

// Step 2. Initalize GPIO: 
// This example function is found in the DSP280x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();    
// Setup only the GP I/O only for I2C functionality
	InitI2CGpio();

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts 
	DINT;   

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.  
// This function is found in the DSP280x_PieCtrl.c file.
	InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
	IER = 0x0000;
	IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt 
// Service Routines (ISR).  
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP280x_DefaultIsr.c.
// This function is found in DSP280x_PieVect.c.
	InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.  
	EALLOW;	// This is needed to write to EALLOW protected registers
	PieVectTable.I2CINT1A = &i2c_int1a_isr;
	EDIS;   // This is needed to disable write to EALLOW protected registers 

	I2cIndex = 0;

// Step 4. Initialize all the Device Peripherals:
	I2CA_Init();

// Step 5, Master I2C register initialization
//
    Reg[0] = 0x0055;
    Reg[1] = 0x01AA;
    Reg[2] = 0x0234;
    Reg[3] = 0x0321;
    Reg[4] = 0x0468;
    Reg[5] = 0x0531;

// Enable interrupts required for this example
// Enable I2C interrupt 1 in the PIE: Group 8 interrupt 1
	PieCtrlRegs.PIEIER8.bit.INTx1 = 1;

// Enable CPU INT8 which is connected to PIE group 8
	IER |= M_INT8;
	EINT;

   // Application loop
	while(1)
	{
      //////////////////////////////////
      // Write data to slave section  //
      //////////////////////////////////
//     Register        Value
//        0            x0055
//        1            x01AA
//        2            x0234
//        3            x0321
//        4            x0468
//        5            x0531
// 	
//   I2caRegs.I2CSAR = I2C_SLAVE_ADDR;// Set up address written to.

   I2CA_Write(0);                   // Transfer Register 0 contents to slave.
   I2CA_Wait();						// Wait for I2C bus to clear

   I2CA_Write(1);
   I2CA_Wait();						// Wait for I2C bus to clear

   I2CA_Write(2);
   I2CA_Wait();						// Wait for I2C bus to clear

   I2CA_Write(3);
   I2CA_Wait();						// Wait for I2C bus to clear

   I2CA_Write(4);
   I2CA_Wait();						// Wait for I2C bus to clear

   I2CA_Write(5);
   I2CA_Wait();						// Wait for I2C bus to clear

      ///////////////////////////////////
      // Read data from slave section  //
      ///////////////////////////////////
//
//  This needs to be changed to (1) Send out the Register as a write, 
//   followed by (2) Receiving the response.
//
	I2CA_Read(0);
	I2CA_Wait();
    ReadReg[0] = (InData[0]<<8) + InData[1];

	I2CA_Read(1);
	I2CA_Wait();
    ReadReg[1] = (InData[0]<<8) + InData[1];

	I2CA_Read(2);
	I2CA_Wait();
    ReadReg[2] = (InData[0]<<8) + InData[1];

	I2CA_Read(3);
	I2CA_Wait();
    ReadReg[3] = (InData[0]<<8) + InData[1];

	I2CA_Read(4);
	I2CA_Wait();
    ReadReg[4] = (InData[0]<<8) + InData[1];

	I2CA_Read(5);
	I2CA_Wait();
    ReadReg[5] = (InData[0]<<8) + InData[1];

	}
}   // end of main


void I2CA_Init(void)
{
   // Initialize I2C
	I2caRegs.I2CSAR = 0x002C;		// Slave Address.
	I2caRegs.I2COAR = 0x002D;       //  address as Master.
	I2caRegs.I2CPSC.all = 9;		// Prescaler - need 7-12 Mhz on module clk
	I2caRegs.I2CCLKL = 10;			// NOTE: must be non zero
	I2caRegs.I2CCLKH = 5;			// NOTE: must be non zero
    I2caRegs.I2CIER.all = 0x2C;		// Enable SCD & ARDY interrupts

    I2caRegs.I2CMDR.bit.IRS = 1;	// Take I2C out of reset
   									// Stop I2C when suspended

    I2caRegs.I2CFFTX.all = 0x6000;	// Enable FIFO mode and TXFIFO
//    I2caRegs.I2CFFRX.all = 0x2040;	// Enable RXFIFO, clear RXFFINT,
	return;   
}

void I2CA_Write(Register)
{
	int Byte0;
	int Byte1;

    Byte0 = Reg[Register]&0x0FF;    // Get low byte of selected register.
	Byte1 = Reg[Register]>>8;       // Get high byte of selected register.

// Slave Address info gets passed with Start Condition
//    I2caRegs.I2CFFTX.all = 0x6000;	// Enable FIFO mode and TXFIFO
	I2caRegs.I2CCNT = 3; 			// 3 Additional Bytes being tranferred.
	I2caRegs.I2CDXR = Register;     // Send Register to be updated.
	I2caRegs.I2CDXR = Byte1;        // Next is high byte of register.
	I2caRegs.I2CDXR = Byte0;        // Next is low byte of register.

    I2caRegs.I2CMDR.all = 0x6E20;   // Set up the control register:
	                                // bit 14 FREE = 1
									// bit 13 STT = 1  (Start condition)
									
									// bit 11 STP = 1  (Stop condition after 
									//                transfer of bytes.)
									// bit 10 MST = 1  Master
									// bit  9 TRX = 1  Transmit
									
									// bit  5 IRS = 1 to Reset I2C bus.
}

void I2CA_Read(Register)
{
    I2cIndex = 0;                   // Reset value for ISR.
// Slave Address info gets passed with Start Condition
	I2caRegs.I2CCNT = 1; 			// 1 Additional Byte being tranferred.
	I2caRegs.I2CDXR = Register;     // Send Register to be updated.
    I2caRegs.I2CMDR.all = 0x6620;   // Set up the control register:
	                                // bit 14 FREE = 1
									// bit 13 STT = 1  (Start condition)
									
									// bit 11 STP = 0  (Stop condition after 
									//                transfer of bytes.)
									// bit 10 MST = 1  Master
									// bit  9 TRX = 1  Transmit
									
									// bit  5 IRS = 1 to Reset I2C bus.

    DELAY_US(50);                   // Delay 50 usec 

	I2caRegs.I2CCNT = 2;            // Set up receive of 2 bytes.
	I2caRegs.I2CMDR.all = 0x6C20;	// Send "repeated" Start with Read (TRX off)
	                                // and Stop.
//    while (I2caRegs.I2CMDR.bit.STP == 1); // Wait for Stop condition bit to be zero.

//	while (I2caRegs.I2CSTR.bit.BB == 1);  // Wait for Bus Busy to be zero.

}

void I2CA_Wait(void)
{
   // Wait until the STP bit is cleared from any previous master communication.
   // Clearing of this bit by the module is delayed until after the SCD bit is
   // set. If this bit is not checked prior to initiating a new message, the
   // I2C could get confused.

    while (I2caRegs.I2CMDR.bit.STP == 1); // Wait for Stop condition bit to be zero.

	while (I2caRegs.I2CSTR.bit.BB == 1);  // Wait for Bus Busy to be zero.
 
}
interrupt void i2c_int1a_isr(void)     // I2C-A
{
	Uint16 IntSource;

   // Read interrupt source
	IntSource = I2caRegs.I2CISRC.bit.INTCODE & 0x7;
	
	switch(IntSource)
	{
		case I2C_NO_ISRC:   // =0
			break;

		case I2C_ARB_ISRC:  // =1
			break;

		case I2C_NACK_ISRC: // =2
			break;

		case I2C_ARDY_ISRC: // =3
			break;

		case I2C_RX_ISRC:   // =4
			InData[I2cIndex++] = I2caRegs.I2CDRR;
			break;

		case I2C_TX_ISRC:   // =5
			break;

		case I2C_SCD_ISRC:  // =6
			break;

		case I2C_AAS_ISRC:  // =7
			break;
	
		default:
			asm("   ESTOP0"); // Halt on invalid number.
	}

   // Enable future I2C (PIE Group 8) interrupts
	PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}

//===========================================================================
// No more.
//===========================================================================

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜成人免费电影| 成人avav在线| 91麻豆免费看| 日韩欧美国产午夜精品| 亚洲欧美一区二区不卡| 国内成+人亚洲+欧美+综合在线| 99久久伊人精品| 久久综合视频网| 天堂影院一区二区| 成人黄色一级视频| 欧美不卡一区二区三区| 午夜av一区二区三区| 91视频国产资源| 国产欧美日韩精品a在线观看| 男人的j进女人的j一区| 欧美在线观看禁18| 亚洲三级在线播放| 波多野结衣91| 国产三级欧美三级| 国产一区二区中文字幕| 91精品国产手机| 青青草视频一区| 色狠狠一区二区三区香蕉| 欧美精彩视频一区二区三区| 精品无人区卡一卡二卡三乱码免费卡| 欧美性猛片aaaaaaa做受| 亚洲欧美激情小说另类| 91天堂素人约啪| 亚洲欧美国产77777| 99久久夜色精品国产网站| 国产精品毛片久久久久久| 福利视频网站一区二区三区| 久久久久久久av麻豆果冻| 日韩成人午夜电影| 日韩欧美国产一区二区三区| 免费成人美女在线观看| 精品日韩在线一区| 国产精品一品视频| 国产精品丝袜一区| 日本乱码高清不卡字幕| 一区二区在线看| 在线观看免费视频综合| 亚洲日本免费电影| 欧美色手机在线观看| 肉色丝袜一区二区| 欧美成人r级一区二区三区| 秋霞影院一区二区| 久久久久久久免费视频了| 国产乱码精品一区二区三区忘忧草 | 久久99久久精品欧美| 日韩欧美卡一卡二| 国产乱对白刺激视频不卡| 国产欧美综合在线观看第十页| 国产成人精品免费网站| 亚洲视频一区二区在线| 欧美日韩国产一级片| 极品少妇xxxx精品少妇| 自拍偷拍欧美激情| 欧美日本韩国一区| 国产91精品欧美| 亚洲精品国产无天堂网2021| 欧美精品日韩一区| 国产成人免费在线观看不卡| 亚洲黄色尤物视频| 日韩一级免费观看| gogogo免费视频观看亚洲一| 午夜精品久久久久久久| 国产网红主播福利一区二区| 欧美在线观看一二区| 国内精品在线播放| 玉米视频成人免费看| 精品国精品国产| 色天使色偷偷av一区二区| 韩国女主播成人在线| 一区二区三区波多野结衣在线观看| 日韩午夜激情视频| 91美女福利视频| 国产一区二区三区免费观看| 一区二区欧美国产| 欧美韩国日本一区| 日韩欧美黄色影院| 欧美日韩精品一区二区天天拍小说| 国产成人亚洲精品狼色在线| 亚洲www啪成人一区二区麻豆| 国产人成亚洲第一网站在线播放| 欧美日韩黄视频| 不卡av免费在线观看| 韩日av一区二区| 午夜精品123| 亚洲另类中文字| 国产亚洲美州欧州综合国| 欧美日韩五月天| 色狠狠av一区二区三区| 国产成人精品免费| 国产主播一区二区| 另类专区欧美蜜桃臀第一页| 亚洲一二三区不卡| 亚洲人精品一区| 成人欧美一区二区三区小说| 26uuu久久天堂性欧美| 6080午夜不卡| 欧美精品高清视频| 欧美日韩一区小说| 精品视频在线免费| 欧美日韩在线亚洲一区蜜芽| 91久久精品一区二区三区| 成人网在线免费视频| 国产精品亚洲专一区二区三区 | 色欧美88888久久久久久影院| 福利视频网站一区二区三区| 精品一区二区三区免费视频| 免费人成黄页网站在线一区二区 | 免费观看91视频大全| 五月激情六月综合| 性感美女极品91精品| 亚洲成人激情综合网| 亚洲午夜免费视频| 一区二区三区四区不卡在线| 一区二区三区免费在线观看| 中文字幕综合网| 中文字幕一区二区三区在线观看| 成人免费在线观看入口| 综合久久久久综合| 亚洲久草在线视频| 午夜精彩视频在线观看不卡| 欧美96一区二区免费视频| 国产主播一区二区三区| 丰满放荡岳乱妇91ww| 99re这里只有精品视频首页| 在线亚洲一区二区| 欧美麻豆精品久久久久久| 欧美一级二级在线观看| 久久综合国产精品| 亚洲色图制服诱惑 | 国产亚洲欧美中文| 中文字幕人成不卡一区| 夜夜嗨av一区二区三区网页| 日韩高清一区二区| 国内外精品视频| 91蝌蚪porny九色| 91精品婷婷国产综合久久竹菊| 久久综合久久综合九色| 国产精品短视频| 日韩国产在线观看| 国产高清无密码一区二区三区| 97se亚洲国产综合在线| 欧美喷潮久久久xxxxx| 国产性做久久久久久| 亚洲一区电影777| 国产美女精品在线| 欧美在线播放高清精品| 日韩一区二区三区精品视频| 国产精品丝袜黑色高跟| 亚洲成年人网站在线观看| 国产精品中文有码| 欧美日韩国产另类一区| 国产精品久久久久久久久免费相片| 亚洲综合精品久久| 国产一区二区三区免费看 | 国产69精品久久久久毛片| 在线日韩一区二区| 久久视频一区二区| 婷婷综合在线观看| 成人国产精品视频| 日韩欧美一二三四区| 日韩一区在线看| 国产一二三精品| 欧美区在线观看| 亚洲乱码国产乱码精品精98午夜| 精品综合久久久久久8888| 欧美亚洲丝袜传媒另类| 国产精品美日韩| 国产在线一区观看| 欧美日韩1234| 一区二区三区欧美在线观看| 成人av资源站| 久久综合一区二区| 久久av资源站| 日韩一级完整毛片| 亚洲在线免费播放| 一本大道久久a久久综合婷婷| 国产日韩欧美综合在线| 精一区二区三区| 欧美成人一区二区三区片免费| 亚洲国产精品久久久男人的天堂| 成人精品国产福利| 久久精品一区四区| 国产原创一区二区| 欧美成人a∨高清免费观看| 日韩va亚洲va欧美va久久| 欧美三级蜜桃2在线观看| 亚洲欧美日韩国产综合在线| www.色精品| 亚洲日本在线a| 99久久精品费精品国产一区二区| 国产日韩欧美高清| 成人手机在线视频| 国产精品国产自产拍在线| 懂色av一区二区三区蜜臀| 国产亚洲va综合人人澡精品|