//read telemetry from Flash Memory and send radio packets back void telemFlashReadback(unsigned int count) { unsigned char status = 0; unsigned int sampLen = sizeof(telemStruct_t); unsigned long sampNum = 0; telemU data; DisableIntT5; // prevent MPU access to SPI2 for(sampNum = 0; sampNum < count; sampNum++) { dfmemReadSample(sampNum, sampLen, (unsigned char *) &data); if ((sampNum+1) != data.telemStruct.sampleIndex) while(1) // hang here if bad read { blink_leds(1,200); } radioConfirmationPacket(RADIO_DEST_ADDR, CMD_SPECIAL_TELEMETRY, status, sampLen, (unsigned char *) &data); // delay_ms(25); // slow down for XBee 57.6 K blink_leds(1,20); // wait 40 ms to give plenty of time to send packets } // wait for DMA to finish and release SPI2 while(port_status[1] == STAT_SPI_BUSY) { blink_leds(1,300); // waste some time } EnableIntT5; }
void main() { auto int done; WrPortI(PGCR, &PGCRShadow, 0x00); WrPortI(PGFR, &PGFRShadow, 0x00); WrPortI(PGDCR, &PGDCRShadow, 0x00); WrPortI(PGDDR, &PGDDRShadow, 0xC0); done = FALSE; while (!done) { costate { // full processor clock useMainOsc(); waitfor(DelaySec(STEPDELAY)); // 1/2 processor clock useClockDivider3000(CLKDIV_2); waitfor(DelaySec(STEPDELAY)); // 1/4 processor clock useClockDivider3000(CLKDIV_4); waitfor(DelaySec(STEPDELAY)); // 1/6 processor clock useClockDivider3000(CLKDIV_6); waitfor(DelaySec(STEPDELAY)); // 1/8 processor clock useClockDivider3000(CLKDIV_8); waitfor(DelaySec(STEPDELAY)); // run processor clock off 32kHz oscillator use32kHzOsc(); // waitfor() will not work when running off the // 32kHz oscillator (the periodic interrupt is // disabled). Instead we'll just call the // LED-blinking code once, which should be enough // (note that it will take one the order of // half a minute to finish). blink_leds(); // full processor clock useMainOsc(); waitfor(DelaySec(STEPDELAY)); done = TRUE; } costate { blink_leds(); } } }
void main() { auto int i; BLINKYLEDS_INIT; // full processor clock useMainOsc(); for (i=0; i<10000; i++) blink_leds(); // disable watchdog time-outs for when running off the 32 KHz oscillator Disable_HW_WDT(); // switch to 32kHz oscillator use32kHzOsc(); // run processor clock off 32kHz oscillator set32kHzDivider(OSC32DIV_1); for (i=0; i<16; i++) blink_leds(); // 32kHz oscillator divided by two set32kHzDivider(OSC32DIV_2); for (i=0; i<8; i++) blink_leds(); // 32kHz oscillator divided by four set32kHzDivider(OSC32DIV_4); for (i=0; i<4; i++) blink_leds(); // 32kHz oscillator divided by eight set32kHzDivider(OSC32DIV_8); for (i=0; i<2; i++) blink_leds(); // 32kHz oscillator divided by sixteen set32kHzDivider(OSC32DIV_16); for (i=0; i<1; i++) blink_leds(); // full processor clock useMainOsc(); // re-enable watchdog time-outs Enable_HW_WDT(); for (i=0; i<10000; i++) blink_leds(); printf("Done.\n"); }
int main (void) { verify_gpio_map(); int ret = gpio_init(); if (ret) { fprintf(stderr, "Failed to initialize GPIO\n"); return ret; } init_leds(); signal(SIGINT, sigint_handler); while (running) blink_leds(); leds_off(); gpio_munmap(); return 0; }
/******************************************************************************* * Function name: main * Description : main function for Can API demo program. Initializes the LCD, * flashes some LEDs, then calls the Can API demo program. * Arguments : none * Return value : none *******************************************************************************/ void main(void) { /* Setup LCD. */ lcd_initialize(); /* Display splash screen. */ // lcd_display(LCD_LINE1, "Lab 2 "); //lcd_display(LCD_LINE4, "Sean"); //lcd_display(LCD_LINE5, "Tanmay"); //lcd_display(LCD_LINE4, "CAN Demo"); /* Blink board LEDs. */ blink_leds(20); switches_initialize(); /* Run the CAN API Demo. */ can_api_demo(); } /* End function main(). */
/*! Contains the code execution loop */ int main() { float temp; // setup temperature_setup(); display_setup(); SysTick_Config(SystemCoreClock / 50); // super loop while(1) { while (!ticks); ticks = 0; temp = get_temperature(); printf("%f\n", temp); show_temperature(temp); blink_leds(); } }
int main(int argc, char **argv) { int sock, port, ret; struct sockaddr_in addr; struct action_data data; struct hostent *h; in_addr_t host_addr, tmp_addr; if (argc < 2) { fprintf(stderr, "U¿ycie: %s <host> [port]\n", *argv); exit(1); } if ((tmp_addr = inet_addr(argv[1])) == INADDR_NONE) { if ((h = gethostbyname(argv[1])) == NULL) { fprintf(stderr, "Host %s nie znaleziony.\n", argv[1]); exit(1); } bcopy(*h->h_addr_list, &host_addr, sizeof(in_addr_t)); host_addr = ntohl(host_addr); } else host_addr = ntohl(tmp_addr); if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { fprintf(stderr, "Nie mogê utworzyæ gniazda: %s\n", strerror(errno)); exit(1); } if (argv[2]) port = atoi(argv[2]); else port = IOCTLDNET_PORT; addr.sin_addr.s_addr = htonl(host_addr); addr.sin_port = htons(port); addr.sin_family = AF_INET; if (connect(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) == -1) { fprintf(stderr, "Nie mogê po³±czyæ siê z %s:%d (%s)\n", argv[1], port, strerror(errno)); close(sock); exit(1); } fprintf(stderr, "Po³±czono.\n"); while (1) { if ((ret = read(sock, &data, sizeof(struct action_data))) == 0 || ret == -1) { if (ret == -1) perror("read()"); close(sock); exit(1); } if (data.act == ACT_BLINK_LEDS) blink_leds(data.value, data.delay); else if (data.act == ACT_BEEPS_SPK) beeps_spk(data.value, data.delay); } close(sock); exit(0); }