//********************************************************************** /*  『ステッピングモータのテストデータ送信用(マスター)』 */ //********************************************************************** #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(); // Soft_I2C_Start(); Soft_I2C_Write(0x9E); Soft_I2C_Write(0x00); Soft_I2C_Write(1); Soft_I2C_Write(0); Soft_I2C_Write(0); Soft_I2C_Write(200); Soft_I2C_Write(100); Soft_I2C_Stop(); // SwitchONcheck(); // while (1) { Soft_I2C_Start(); Soft_I2C_Write(0x9E); Soft_I2C_Write(0x00); Soft_I2C_Start(); Soft_I2C_Write(0x9F); dat = Soft_I2C_Read(NO_ACK); Soft_I2C_Stop(); // if (dat == 0) break; } // SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0x9E); Soft_I2C_Write(0x00); Soft_I2C_Write(1); Soft_I2C_Write(1); Soft_I2C_Write(0); Soft_I2C_Write(200); Soft_I2C_Write(100); Soft_I2C_Stop(); // SwitchONcheck(); // while (1) { Soft_I2C_Start(); Soft_I2C_Write(0x9E); Soft_I2C_Write(0x00); Soft_I2C_Start(); Soft_I2C_Write(0x9F); dat = Soft_I2C_Read(NO_ACK); Soft_I2C_Stop(); // if (dat == 0) break; } // for (cnt = 0; cnt < 10; cnt++) { LED = ON; Delay_ms(50); LED = OFF; Delay_ms(50); } } } //**********************************************************************