telecommand master
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 #define interrupt D9 00004 00005 const int addr = 0x20; //slave address 00006 I2C master (D14,D15); //configure pins p27,p28 as I2C master 00007 Serial pc(USBTX,USBRX); 00008 DigitalOut m2s_interrupt(interrupt); 00009 00010 00011 int main() 00012 { 00013 while(1) 00014 { 00015 char* command= new char; 00016 printf("\ncommand from com \n\r"); 00017 m2s_interrupt=0; 00018 *command=pc.getc(); //characters 0 to 4 are assumed to be commands 00019 printf("\n command detected\n\r"); 00020 m2s_interrupt =1; 00021 bool master_status_write = true; 00022 master.frequency(100000); 00023 while(master_status_write) 00024 { 00025 master.start(); 00026 master_status_write = (bool) master.write(addr|0x00,command,1); 00027 printf("\n master trying to write \n\r"); 00028 } 00029 printf("command %c sent to slave\n\r",*command); 00030 delete command; 00031 } 00032 }
Generated on Sat Jul 30 2022 08:28:18 by
1.7.2