/******************* initialiseren van de constanten uit lader.h *******************/ void init(){ gpio_map(); printf("We zijn in de lader.c\n"); gpio_output(DISCHARGE_BANK, DISCHARGE_PIN); printf("lader1\n"); gpio_output(ON_OFF_BANK, ON_OFF_PIN); printf("lader2\n"); turnOff(); printf("lader3\n"); charge(); printf("lader4\n"); currentCharger=0; //uitgedrukt in mA printf("lader5\n"); //On: 1, off: 0 on=0; //Charging: 1, discharging: 0 charging=1; // Variabelen voor State of Charge integratedCurrent=0; // Accumulatie van vorige stromen printf("lader6\n"); timeOfMeasurement=0; //Lipo: 0, NiMH: 1 batterij_type = LiPo; // Toestanden voor relay-standen status = USE; printf("lader7\n"); }
/*************************************** Main ***************************************/ int main(){ int i; gpio_map(); initLCD10(); initLCD11(); initLCD12(); initLCD13(); initLCD14(); initLCD15(); initPIN1(); initPIN2(); initPIN3(); initPIN30(); initPIN31(); initPIN4(); initPIN5(); initPIN6(); initPIN7(); initPIN8(); initPIN9(); for(i=0; i<100; i++){ setLCD10(); setLCD11(); setLCD12(); setLCD13(); setLCD14(); setLCD15(); setPIN1(); setPIN2(); setPIN3(); setPIN30(); setPIN31(); setPIN4(); setPIN5(); setPIN6(); setPIN7(); setPIN8(); setPIN9(); usleep(20000); clrLCD10(); clrLCD11(); clrLCD12(); clrLCD13(); clrLCD14(); clrLCD15(); clrPIN1(); clrPIN2(); clrPIN3(); clrPIN30(); clrPIN31(); clrPIN4(); clrPIN5(); clrPIN6(); clrPIN7(); clrPIN8(); clrPIN9(); usleep(20000); } }
int init(){ gpio_map(); gpio_output(DISCHARGE_BANK, DISCHARGE_PIN); gpio_output(ON_OFF_BANK, ON_OFF_PIN); turnOff(); charge(); return 0; }
int main(int argc, char* argv[]) { gpio_map (); CMainTask m_MainTask; printf ("main 1\n"); m_MainTask.Create (1); printf ("main 2\n"); return 0; }
void initialise_io() { gpio_map(); gpio_output(BBGPIO_01); gpio_output(BBGPIO_02); gpio_output(BBGPIO_04); gpio_output(BBGPIO_05); gpio_output(BBGPIO_06); gpio_output(BBGPIO_07); gpio_output(BBGPIO_16); gpio_output(BBGPIO_51); }
int main(int argc, char *argv[]) { int ret = 0; int fileDescriptor, ss, sp, j; int retuid; int doing; layoutloader("layout.conf.json"); int face, row, col; retuid = setuid(0); // root me! if (retuid == -1) { exit(-10); } since_start(); // initialize the count of when we started execution // Read the size of our LED string // Use the correct map for the string size string_size = ss = NUM_BULBS; sp = ss * 3; // Number of color units in string // Allocate space for the frame transmit buffer txbuf = malloc(sp + 1); txbuf[sp] = 0x00; // Last byte always null for end of sequence signalling #ifdef OLIMEX gpio_map(); gpio_output(2,1); //bank 2 bit 1 = GPIO65 the LED on board gpio_output(0,20); //bank 0 bit 20 = GPIO20 = SSP2_MOSI gpio_output(0,24); //bank 0 bit 24 = GPIO24 = SSP2_SCLK #else fileDescriptor = open(device, O_RDWR); if (fileDescriptor < 0) pabort("can't open device"); /* * spi mode */ ret = ioctl(fileDescriptor, SPI_IOC_WR_MODE, &mode); if (ret == -1) pabort("can't set spi mode"); ret = ioctl(fileDescriptor, SPI_IOC_RD_MODE, &mode); if (ret == -1) pabort("can't get spi mode"); /* * bits per word */ ret = ioctl(fileDescriptor, SPI_IOC_WR_BITS_PER_WORD, &bits); if (ret == -1) pabort("can't set bits per word"); ret = ioctl(fileDescriptor, SPI_IOC_RD_BITS_PER_WORD, &bits); if (ret == -1) pabort("can't get bits per word"); /* * max speed hz */ ret = ioctl(fileDescriptor, SPI_IOC_WR_MAX_SPEED_HZ, &speed); if (ret == -1) pabort("can't set max speed hz"); ret = ioctl(fileDescriptor, SPI_IOC_RD_MAX_SPEED_HZ, &speed); if (ret == -1) pabort("can't get max speed hz"); ////("spi mode: %d\n", mode); ////("bits per word: %d\n", bits); ////("max speed: %d Hz (%d KHz)\n", speed, speed/1000); #endif // Ok, we're ready to start, so call the setup //setup(argc,argv); synchronize(1); // And setup the sync function while (doing) { // Clear the whole string // Set a bulb // And move on for (face = 0; face < 4; face++) { for (row = 0; row < ROWS_PER_FACE; row++) { for (col = 0; col < COLS_PER_FACE; col++) { memset((void*) txbuf, (int) 0x80, (size_t) sp); // Clear the string quickly set_pixel(face, col, row, 0xFF, 0xFF, 0xFF); send_frame(fileDescriptor, txbuf, (sp + 3)); // Try to transmit the frame usleep(100000); } } } // Chase the inner LEDs for (face = 0; face < 4; face++) { for (row = 0; row < BULBS_INSIDE; row++) { memset((void*) txbuf, (int) 0x80, (size_t) sp); // Clear the string quickly set_inner_pixel(face, row, 0xFF, 0xFF, 0xFF); send_frame(fileDescriptor, txbuf, (sp + 3)); // Try to transmit the frame usleep(100000); } } /*if (loop(since_start())) { //doing = 0; }*/ //synchronize(20000000); // 50 fps or 20 msec/frame //send_frame(fileDescriptor, txbuf, (sp + 1)); // Try to transmit the frame } free(txbuf); // Always clean up after yourself! #ifdef OLIMEX #else close(fileDescriptor); #endif return 0; }