int main(void) { initializeHardware(); initializeVariables(); uint8 ledTiming = 0; for (;;) { mainTask(); buttonTask(); if (ledTiming == 200) // led have to be changed only every 1000ms { ledTask(); ledTiming = 0; } ledTiming++; Timer_delayMs(5); } return 0 ; }
/* initialize and start the device */ static void ethernetInit(void *arg) { struct bfin_ethernetSoftc *sc; struct ifnet *ifp; void *ethBase; void *rxdmaBase; void *txdmaBase; sc = arg; ifp = &sc->arpcom.ac_if; ethBase = sc->ethBase; rxdmaBase = sc->rxdmaBase; txdmaBase = sc->txdmaBase; if (sc->txDaemonTid == 0) { initializeHardware(sc); /* start driver tasks */ sc->rxDaemonTid = rtems_bsdnet_newproc("BFrx", 4096, rxDaemon, sc); sc->txDaemonTid = rtems_bsdnet_newproc("BFtx", 4096, txDaemon, sc); } if (ifp->if_flags & IFF_PROMISC) BFIN_REG32(ethBase, EMAC_OPMODE_OFFSET) |= EMAC_OPMODE_PR; else BFIN_REG32(ethBase, EMAC_OPMODE_OFFSET) &= ~EMAC_OPMODE_PR; /* * Tell the world that we're running. */ ifp->if_flags |= IFF_RUNNING; }
int main(void) { trace_printf("Hello, ARM!\n"); printf("Hello, printf\n"); puts("Hello, puts\n"); initializeHardware(); /* Create IPC variables */ buttonPushesQueue = xQueueCreate(10, sizeof(int)); if (buttonPushesQueue == 0) { while (1) ; /* fatal error */ } /* Create tasks */ createTask(toggleLedWithTimer, "Task1"); createTask(detectButtonPress, "Task2"); createTask(toggleLedWithIpc, "Task3"); createTask(drawSmlLogo, "Logo"); /* Start the RTOS Scheduler */ vTaskStartScheduler(); /* HALT */ while (1) ; }
int main(void){ WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer PM5CTL0 &= ~LOCKLPM5; initializeHardware(); reboots++; DINO_RESTORE_CHECK(); DINO_TASK_BOUNDARY(START_TASK,NULL); if( finished == 0xBEEE ){ #if defined(WISP5) PJOUT |= BIT6; #elif defined(BREADBOARD) P4OUT |= BIT4; #endif while( 1 ){ } } if( inErrorState == 0xBEEE ){ abortWithError(); } initializeNVData(); while( numSamples < (NUM_ITERS * SAMPLES_PER_ITER) ){ int r; for(r = 0; r < SAMPLES_PER_ITER; r++){ DINO_TASK_BOUNDARY(SAMPLE_TASK,NULL); unsigned samp = getOneSample(); DINO_TASK_BOUNDARY(BIN_TASK,NULL); addToBin(samp); numSamples++; } DINO_TASK_BOUNDARY(SORT_TASK,NULL); sortBinsByFrequency(); DINO_TASK_BOUNDARY(CHECK_TASK,NULL); checkInvariants(); } finished = 0xBEEE; #if defined(WISP5) PJOUT |= BIT6; #elif defined(BREADBOARD) P4OUT |= BIT4; #endif while( 1 ){ } }
void main (void) { initializeHardware (); pwm [0].ccpr = &CCPR1L; pwm [0].ccpcon = &CCP1CON; pwm [1].ccpr = &CCPR2L; pwm [1].ccpcon = &CCP2CON; pwm [2].ccpr = &CCPR3L; pwm [2].ccpcon = &CCP3CON; pwm [3].ccpr = &CCPR4L; pwm [3].ccpcon = &CCP4CON; int i; for (i = 0; i < 4; ++i) { uint8_t type = eeprom_read (i); //type 255 is PWM output so close relay to bypass filter if (type == 255) PORTB |= 1 << (i + 1); } //AquaPic Bus initialization //AquaPic Bus initialization apb_init (apbInst, &apbMessageHandler, APB_ADDRESS, 1); //enable UART TX_nRX = 0; TXSTAbits.TXEN = 1; //Transmit Enable, Transmit enabled RCSTAbits.CREN = 1; //Continuous Receive Enable, Enables receiver /*Global Interrupts*/ PEIE = 1; //Enable peripheral interrupts GIE = 1; //Enable Global interrupts yLedOff; gLedOn; while (1) { //RCIF is set regardless of the global interrupts //apb_run might take a while so putting it in the main "loop" makes more sense if (RCIF) { uint8_t data = RCREG; apb_run (apbInst, data); } } }
void setup() { packet_length[KEYDOWN] = 2; packet_length[KEYUP] = 2; packet_length[LEDON] = 2; packet_length[LEDOFF] = 2; packet_length[LEDROW] = 2; packet_length[CLEAR] = 1; packet_length[MODE] = 1; packet_length[COLOR] = 5; rx_count = rx_type = rx_timeout = 0; rx_length = 1; initializeHardware(); }
int main(int argc, char *argv[]) { HEX_LINE *hexFile; initializeHardware(); deactivateReset(); enableAVRProgramming(); hexFile = parseHexFile(argv[1]); printHexfile(hexFile); eraseAVRFlash(); writeSinglePage(hexFile); readSinglePage(); deactivateReset(); deleteHexfile(hexFile); freeHardwareResources(); return 0; } // end main()
/** * Function implementations */ void init_hardware(void) { initializeHardware(); // Initialise the USB serial usb_init(); }