SONIX 单片机DEMO源代码
单片机源程序如下:
- //---------------------------------------------------
- //---------------------------------------------------
- // Copyright 2015 SONiX Technology Corp. All rights reserved.
- // AUTHOR: SONiX
- // The system clock frequency is IHRC 32MHz
- // Device: SN8F5708
- // Tool chain: KEIL C51 V9.50a
- //---------------------------------------------------
- // Includes
- //---------------------------------------------------
- #include "Define.h"
- //#include "RFM75.h"
- User_RAM r;
- void F_Data16Byte_To_TXbuf(void);
- void F_RXbuf_To_Data16Byte(void);
- /***********************************************************/
- void main(void)
- {
- WDTR = 0x5a; // clear watchdog if watchdog enable
- //Set clk
- CLKSEL = 0x05; //03:fcpu=fosc/16=2M; 04:fcpu=fosc/8=4M; 05:fcpu=fosc/4=8M;
- CLKCMD = 0x69; //Apply CLKSELs setting
- CKCON = 0x10;
- // F_ClrAllRam();
- F_Init_System();
- I2C_Init();
- I2C_Slave_Address(0x64); // set i2c addr
-
- while(true)
- {
- if(b_T0ms5 == true)
- {
- b_T0ms5 = false;
- WDTR = 0x5a; // clear watchdog if watchdog enable
- if(b_irSend16data == true)
- {
- EI2C = 0; //off I2C interrupt enable
- F_Send_IR_TX();
- }
- else
- {
- EI2C = 1; // I2C interrupt enable
- }
- }
- }
- }
- /****************************************************
- *****************************************************/
- void F_Data16Byte_To_TXbuf(void)
- {
- uchar i,j;
- r.IRdataStep = 0;
- for(i=0;i<16;i++)
- {
- j = r.Data16ByteRX[i];
- r.TXbuf[i] = j;
- r.Data16ByteTX[i] = j;
- // r.Data16ByteRX[i] = 0;
- }
-
- j = 0;
- for(i=0;i<16;i++)
- {
- j = j + r.TXbuf[i];
- }
- r.TXbuf[16] = j;
- }
- /****************************************************
- *****************************************************/
- void F_RXbuf_To_Data16Byte(void)
- {
- uchar i,j;
-
- j = 0;
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
57_i2c.rar
(232.22 KB, 下载次数: 22)
|