//********************************************************************** /*  『拡張ポートのテストデータ送信用(マスター)』 */ //********************************************************************** #define SW GPIO.F3 #define LED GPIO.F2 #define ON 1 #define OFF 0 #define ACK 1 #define NO_ACK 0 //********************************************************************** void SwitchONcheck() { while (Button(&GPIO, 3, 1, 0) == 0) ; while (Button(&GPIO, 3, 1, 1) == 0) ; } //********************************************************************** void main() { unsigned short cnt, dat; // CMCON0 = 0b00000111; ANSEL.ANS0 = 0; ANSEL.ANS1 = 0; ANSEL.ANS2 = 0; ANSEL.ANS3 = 0; ADCON0.VCFG = 0; TRISIO = 0b00001011; OSCCON = 0b01110000; // for (cnt = 0; cnt < 10; cnt++) { LED = ON; Delay_ms(50); LED = OFF; Delay_ms(50); } // Soft_I2C_Config(&GPIO, 4, 5); // SDA, SCL // while (1) { SwitchONcheck(); //TRIS_EX = 0b00001111 Soft_I2C_Start(); Soft_I2C_Write(0xC0); Soft_I2C_Write(0x00); Soft_I2C_Write(0b00001111); Soft_I2C_Stop(); // SwitchONcheck(); //PORT_EX = 0x10100000 Soft_I2C_Start(); Soft_I2C_Write(0xC0); Soft_I2C_Write(0x01); Soft_I2C_Write(0b10100000); Soft_I2C_Stop(); // SwitchONcheck(); //PORT_EX = 0x01010000 Soft_I2C_Start(); Soft_I2C_Write(0xC0); Soft_I2C_Write(0x01); Soft_I2C_Write(0b01010000); Soft_I2C_Stop(); // SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0xC0); Soft_I2C_Write(0x01); Soft_I2C_Start(); Soft_I2C_Write(0xC1); dat = Soft_I2C_Read(NO_ACK); Soft_I2C_Stop(); // SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0xC0); Soft_I2C_Write(0x01); Soft_I2C_Write(dat << 4); Soft_I2C_Stop(); // for (cnt = 0; cnt < 10; cnt++) { LED = ON; Delay_ms(50); LED = OFF; Delay_ms(50); } } } //**********************************************************************