int main(void) { for (u32 i = 0; i < 600000; i++) __asm__("nop"); led_setup(); rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3); debug_setup(); printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n"); printf("--- DEBUG TEST ---\n"); debug_register_callback(0x22, &foo_callback, &foo_callback_node); debug_register_callback(0x42, &led_callback, &led_callback_node); while(1) { debug_process_messages(); for (u32 i = 0; i < 600000; i++) __asm__("nop"); } while (1); return 0; }
int main(void) { for (u32 i = 0; i < 600000; i++) __asm__("nop"); led_setup(); rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3); debug_setup(); timer_setup(); // Debug pins (CC1111 TX/RX) RCC_AHB1ENR |= RCC_AHB1ENR_IOPCEN; gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO10|GPIO11); gpio_clear(GPIOC, GPIO10|GPIO11); printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n"); printf("--- DEBUG TEST ---\n"); u32 len; for (u8 i=0; i<30; i++) { guard_below[i] = 0; guard_above[i] = 0; } for (u32 i=0; i<256; i++) buff_out[i] = (u8)i; while(1) { /* Random transmit length. */ len = (u32)rand() % 256; while(debug_send_msg(0x22, len, buff_out)); /* Check the guards for buffer over/underrun. */ for (u8 i=0; i<30; i++) { if (guard_below[i] != 0) screaming_death(); if (guard_above[i] != 0) screaming_death(); } /* Introduce some timing jitter. */ u32 jitter_delay = ((u32)rand() % 20000); for (u32 i = 0; i < jitter_delay; i++) /*for (u32 i = 0; i < 1000; i++)*/ __asm__("nop"); } while (1); return 0; }
int main(void) { for (u32 i = 0; i < 600000; i++) __asm__("nop"); led_setup(); rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3); debug_setup(); timer_setup(); // Debug pins (CC1111 TX/RX) RCC_AHB1ENR |= RCC_AHB1ENR_IOPCEN; gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO10|GPIO11); gpio_clear(GPIOC, GPIO10|GPIO11); printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n"); printf("--- DEBUG RX STRESS TEST ---\n"); static msg_callbacks_node_t callback_node; debug_register_callback(0x22, &callback, &callback_node); for (u8 i=0; i<30; i++) { guard_below[i] = 0; guard_above[i] = 0; } while(1) { /* Check the guards for buffer over/underrun. */ for (u8 i=0; i<30; i++) { if (guard_below[i] != 0) screaming_death(); if (guard_above[i] != 0) screaming_death(); } debug_process_messages(); //for (u32 i = 0; i < 1000; i++) // __asm__("nop"); } while (1); return 0; }
void setup() { // Configure the NVIC Preemption Priority Bits // 2 bit for pre-emption priority, 2 bits for subpriority NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); debug_setup(); debug_led_set(1); debug_write_line("?BEGIN setup"); ring_buffer_u8_init(&g_usartInputRingBuffer, g_usartInputBuffer, INPUT_BUFFER_SIZE); ir_code_setup(); time_setup(); ir_tx_setup(); ir_rx_setup(); //cc3000_setup(0, 0); //wifi_connect(); debug_led_set(0); debug_write_line("?END setup"); }
void setup() { NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); WWDG_DeInit(); time_setup(); debug_setup(); rtc_setup(); spi_setup(); sdcard_setupGpio(); cc3000_setupGpio(); button_setup(); if (!sdcard_setup()) { printf("Failed to setup SDCard\n"); } else { if (!sdcard_fat_setup()) { printf("Failed to setup SDCard Fat\n"); } } if (config_read()) { printf("read config success\n"); } else { printf("read config FAILED\n"); while (1); } network_setup(); uint32_t ntpTime = ntp_getTime(); printf("ntp time %lu\n", ntpTime); if (ntpTime > 0) { rtc_setTime(ntpTime); } }
int main( void ) { uint8_t d = 0x34,rxbuf = 0X23; mInit(); // I2C_config(); SPI_config(); debug_setup(); ADC_A_config(); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //M4 DIRECTION GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //M3 DIRECTION GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, &GPIO_InitStructure); TIMA_config(100, 20,10); // timer1 channel 1 PA8 TIMB_config(100, 20,10); // timer2 channel 3 PA9 TIMC_config(100, 20,10); // timer15 channel 1 PB14 TIMD_config(100, 20,10); // timer2 channel 2 PA1 // first 2 numbers // // in this function are not doing anything while(1) { GPIO_ResetBits(GPIOA, GPIO_Pin_0); GPIO_ResetBits(GPIOB, GPIO_Pin_15); // debug_write_ch(0XAB); mBlueTOGGLE; mGreenTOGGLE; mRedTOGGLE; mWaitms(300); GPIO_SetBits(GPIOA, GPIO_Pin_0); GPIO_SetBits(GPIOB, GPIO_Pin_15); /* Test EOC flag */ while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); /* Get ADC1 converted data */ ADC1ConvertedValue =ADC_GetConversionValue(ADC1); debug_write_u16(ADC1ConvertedValue,10); debug_write_line(" "); // mWaitms(300); // I2C_write_1byte(SLAVE_ADDR2,254,22); // rxbuf = I2C_read_1byte(SLAVE_ADDR,254); // debug_write_ch(rxbuf); // rxbuf = I2C_read_1byte(SLAVE_ADDR1,254); // debug_write_ch(rxbuf); // rxbuf = I2C_read_1byte(SLAVE_ADDR2,254); // debug_write_ch(rxbuf); // TIM_SetCompare2 ( TIM2,1); // mWaitms(300); // TIM_SetCompare2 ( TIM2,0); // mWaitms(1000); // SPI_SendData8(SPI1, d); // while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); // while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); // rxbuf = SPI_ReceiveData8(SPI1); } }
static void setup(void) { char *fname = NULL; uint64_t intvl; if (atexit(teardown) != 0) { log_stderr("cannot register teardown procedure with atexit()"); exit(EX_OSERR); /* only failure comes from NOMEM */ } /* Setup logging first */ log_setup(&stats.log); if (debug_setup(&setting.debug) != CC_OK) { log_stderr("debug log setup failed"); exit(EX_CONFIG); } /* setup top-level application options */ if (option_bool(&setting.ds.daemonize)) { daemonize(); } fname = option_str(&setting.ds.pid_filename); if (fname != NULL) { /* to get the correct pid, call create_pidfile after daemonize */ create_pidfile(fname); } /* setup library modules */ buf_setup(&setting.buf, &stats.buf); dbuf_setup(&setting.dbuf, &stats.dbuf); event_setup(&stats.event); sockio_setup(&setting.sockio, &stats.sockio); tcp_setup(&setting.tcp, &stats.tcp); timing_wheel_setup(&stats.timing_wheel); /* setup pelikan modules */ time_setup(&setting.time); procinfo_setup(&stats.procinfo); request_setup(&setting.request, &stats.request); response_setup(&setting.response, &stats.response); parse_setup(&stats.parse_req, NULL); compose_setup(NULL, &stats.compose_rsp); slab_setup(&setting.slab, &stats.slab); process_setup(&setting.process, &stats.process); admin_process_setup(); core_admin_setup(&setting.admin); core_server_setup(&setting.server, &stats.server); core_worker_setup(&setting.worker, &stats.worker); /* adding recurring events to maintenance/admin thread */ intvl = option_uint(&setting.ds.dlog_intvl); if (core_admin_register(intvl, debug_log_flush, NULL) == NULL) { log_stderr("Could not register timed event to flush debug log"); goto error; } return; error: if (fname != NULL) { remove_pidfile(fname); } /* since we registered teardown with atexit, it'll be called upon exit */ exit(EX_CONFIG); }
int main(void) { for (u32 i = 0; i < 600000; i++) __asm__("nop"); led_setup(); // Debug pins (CC1111 TX/RX) RCC_AHB1ENR |= RCC_AHB1ENR_IOPCEN; gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO10|GPIO11); gpio_clear(GPIOC, GPIO10|GPIO11); rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_130_944MHz_out_3v3); debug_setup(); printf("\n\n# Firmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n"); swift_nap_setup(); swift_nap_reset(); led_toggle(LED_GREEN); led_toggle(LED_RED); u64 cw_power; float cw_freq; while(1) { printf("#PLOT_DATA_START\n"); // Load CW ram cw_schedule_load(timing_count() + 1000); while (!(cw_get_load_done())); printf("# Finished loading cw ram\n"); // Do CW detection // cw_start(-4e6,4e6,8e6/(SPECTRUM_LEN-1)); // cw_start(0.5e6,0.7e6,0.2e6/(SPECTRUM_LEN-1)); float cf = (1.575542*1e9-1.575420*1e9); float span = 200e3; cw_start(cf-span/2,cf+span/2,span/(SPECTRUM_LEN-1)); while (!(cw_get_running_done())); printf("# Finished doing cw detection\n"); for (u16 si=0;si<SPECTRUM_LEN;si++) { for (u32 dly = 0; dly < 50000; dly++) __asm__("nop"); cw_get_spectrum_point(&cw_freq,&cw_power,si); if (~((cw_power == 0) && (cw_freq == 0))) { // printf("%+7.2f %lu # %d\n",cw_freq,(long unsigned int)cw_power,(unsigned int)si); printf("%+7.1f %lu\n",cw_freq,(long unsigned int)cw_power); // printf("%+4.2f %lu\n",cw_freq,(long unsigned int)cw_power); } u32 err = swift_nap_read_error_blocking(); if (err) { printf("Error: 0x%08X\n", (unsigned int)err); while(1); } } printf("#PLOT_DATA_END\n"); } while (1); return 0; }
/* Main function starts here*/ int main(void) { //Functions to set up the neccessary registers for GPIO, UART and SPI peripherals and motors // mInit(); InitPeripherals(); mYellowON; mRedON; mGreenON; mWhiteON; mBlueON; DelayMilliseconds(10000); mYellowOFF;mRedOFF;mGreenOFF; mWhiteOFF; mBlueOFF; debug_setup(); //Enter Module number to give it corresponding static IP //ie 192.168.10.(110+num) cc3000_initialize_ip(10); cc3000_startup_check(); //Initialization for motors // motor_dir_init(); // TIMA_config(100, 20,10); // timer1 channel 1 PA8 // TIMB_config(100, 20,10); // timer2 channel 3 PA9 // TIMC_config(100, 20,10); // timer15 channel 1 PB14 // TIMD_config(100, 20,10); // timer2 channel 2 PA1 // first 2 numbers // in this function are not doing anything // Motormsg testmsg; mGreenOFF; MsgDof *testmsg2; // testmsg.motor_0_vel = 34; // testmsg.motor_1_vel = 34; // testmsg.motor_0_direction = 34; // testmsg.motor_1_direction = 3489; uint8_t testarray[3] = {1,0,7}; testmsg2 = (MsgDof*)testarray; /* Uncomment the function to use the desired socket for communication * ONLY ONE of the following functions should be uncommented */ udp_socket_communication(); //UDP socket communication // tcp_socket_server(); //TCP socket communication as a server // tcp_socket_client(); //TCP socket communication as a client //Transmit and Receive in an infinite loop while(1){ //Transmit data sendto(desSocket, testmsg2, sizeof(*testmsg2), 0, (sockaddr*) &des_addr, sizeof(des_addr)); //mWaitms(2); //Delay is needed between send and receive functions //Receive data revLen = recvfrom(revSocket, rev_buf, 10, 0, (sockaddr*) &source_addr, &revPacketLen); if(revLen>0){ //debug_write_u32(source_addr.sin_addr.s_addr, 16); debug_write_bytes(rev_buf, revLen); if(rev_buf[0] = 5) { mBlueON; DelayMilliseconds(100); } //motor_test(rev_buf[0]); // mPurpleTOGGLE; mRedON; } //Available function seems to cause lots of overhead, avoid using it if speed is desired /* if(available(revSocket)==1){ revLen = recvfrom(revSocket, rev_buf, 10, 0, (sockaddr*) &source_addr, &revPacketLen); //debug_write_bytes(rev_buf, revLen); motor_test(rev_buf[0]); mRedTOGGLE; } */ //Heartbeat mGreenTOGGLE; //mWaitms(2); //Delay is needed between send and receive functions } }
void dc_electronic_load_setup() { setCurrentMilliamps = 0; readCurrentMilliamps = 0; readMilliVolts = 0; setRateIndex = 0; readCurrentMilliampsDisplay = DISPLAY_MILLI; gfxState = GFX_STATE_MEASURE; dma_ring_buffer_init(&g_debugUsartDmaInputRingBuffer, DEBUG_USART_RX_DMA_CH, g_debugUsartRxBuffer, DEBUG_USART_RX_BUFFER_SIZE); debug_setup(); debug_write_line("?BEGIN setup"); process_init(); process_start(&etimer_process, NULL); process_start(&debug_process, NULL); #ifdef DISP6800_ENABLE process_start(&gfx_update_process, NULL); process_poll(&gfx_update_process); #endif spi_setup(); #ifdef DISP6800_ENABLE disp6800_setup(); gfx_setup(); #endif #ifdef ENCODER_ENABLE encoder_setup(); #endif #ifdef FLASH_ENABLE flashsst25_setup(); #endif #ifdef MAC_ENABLE mac25aa02e48_setup(); mac25aa02e48_read_eui48(); #endif #ifdef ADC_ENABLE adc_setup(); #endif #ifdef DAC_ENABLE dac_setup(); dac_set(0); #endif #ifdef NETWORK_ENABLE network_setup(EUI48); #endif #ifdef FAN_ENABLE fan_setup(); #endif #ifdef BUTTONS_ENABLE buttons_setup(); #endif time_setup(); recorder_setup(); debug_write_line("?END setup"); }