Jonathan Jones
/
Radios
Radio Structures in OOP
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "robot.h" 00002 00003 // Create a file system if needed for writing startup information to the boot log 00004 #if RJ_BOOT_LOG 00005 LocalFileSystem local("local"); // Create the local filesystem object 00006 #endif 00007 DigitalOut led1(LED1); 00008 DigitalOut led2(LED2); 00009 DigitalOut led3(LED3); 00010 DigitalOut led4(LED4); 00011 00012 Serial pc(USBTX, USBRX); 00013 00014 // Sets the mbed's baudrate for debugging purposes 00015 void baud(int baudrate) 00016 { 00017 Serial s(USBTX, USBRX); 00018 s.baud(baudrate); 00019 } 00020 00021 // Main program operations ======================= 00022 int main() 00023 { 00024 led4 = 0; 00025 // Set the baud rate 00026 baud(57600); 00027 00028 // Check the mbed's firmware if enabled 00029 #if RJ_CHECK_FIRMWARE 00030 std::string firmware; 00031 firmware_version(firmware); // this is from FirmwareHelper.h 00032 LOG("Firmware Version: %s\r\n", firmware.c_str()); 00033 00034 // Write any errors to a log file if enabled 00035 #if RJ_BOOT_LOG 00036 LOG("Begin logging\r\n"); 00037 #endif 00038 00039 #endif 00040 00041 DigitalOut temppp(RJ_PRIMARY_RADIO_INT, 1); 00042 00043 // Create a new physical hardware communication link 00044 CC1101 radio_900( 00045 RJ_SPI_BUS, 00046 RJ_PRIMARY_RADIO_CS, 00047 RJ_PRIMARY_RADIO_INT 00048 ); 00049 00050 // Create a Communication Module Object 00051 CommModule comm; 00052 00053 radio_900.setModule(comm); 00054 00055 comm.TxHandler((CommLink*)&radio_900, &CommLink::sendPacket, 8); 00056 comm.openSocket(8); 00057 00058 // Open a socket for the Communication Module. Give it a port number and a function to call when a packet of that port number is received 00059 led3 = 1; 00060 00061 // Create a dummy packet that is set to send out from socket connection 8 00062 RTP_t dummy_packet; 00063 for (int i=0; i<20; i++) 00064 dummy_packet.data[i] = i; 00065 00066 dummy_packet.data_size = 20; 00067 dummy_packet.port = 8; 00068 dummy_packet.subclass = 1; 00069 00070 00071 // Enable watchdog timer 00072 //Watchdog watchdog; 00073 //watchdog.set(RJ_WATCHDOG_TIMER_VALUE); 00074 00075 led1 = 0; 00076 00077 while(1) { 00078 led1 = !led1; 00079 //radio_900.status(); 00080 //comm.send(dummy_packet); 00081 osDelay(500); 00082 00083 } 00084 }
Generated on Mon Jul 18 2022 20:09:01 by 1.7.2