int main(void){ //int x=0; init_IO(); init_Uart(); startup_flashes_text(); init_Timer2and3(); init_OC2(); while(1){ PORTBbits.RB3=1; if(PORTBbits.RB0==1 && dutyCycle<1065){ PORTBbits.RB3=0; sendString("increased duty cycle to "); dutyCycle+=5; OC2RS=dutyCycle; sendNum(dutyCycle); sendString(" \t(counterclockwise)\n\r"); delay(10); } if(PORTBbits.RB1==1 && dutyCycle>110){ PORTBbits.RB3=0; sendString(" decreased duty cycle to "); dutyCycle-=5; OC2RS=dutyCycle; sendNum(dutyCycle); sendString("\t(clockwise)\n\r"); delay(10); } } }
/* Functions */ int main(void) { u32 OutputEnableTimeout; init_SystemClock(); //RCC config init_Discovery(); //leds & user button init_TimeBase(); //timebase & clock init_LCD(); //HD44780 based display init_UART(&urt2,2); init_IO(); /* program loop */ //******************************************* main loop time.fast = actualTime() + FASTINTERVAL; time.slow = actualTime() + SLOWINTERVAL; while (1) { //realtick: if(gValues.filter.output){ //output enable, timeout restart OutputEnableTimeout = actualTime() + OUTPUT_TIMEOUT; GPIO_WriteBit(GPIOC, GPIO_Pin_9, (BitAction)1); }else if (timeElapsed(OutputEnableTimeout)){ //output disable after timeout GPIO_WriteBit(GPIOC, GPIO_Pin_9, (BitAction)0); } if(timeElapsed(time.fast)){ time.fast += FASTINTERVAL; //fasttick fast_Tick(); } if(timeElapsed(time.slow)){ time.slow += SLOWINTERVAL; //slowtick LCD_periodic_update(); slow_Tick(); } //COMM_DESC * PC_com = &urt2.parent; /*Ticks*/ //PC_com->Tick(PC_com); //urt2.Tick(&urt2.parent); } //end while } //end main()
void hardware_init (void){ init_IO(); /** * @brief set watchdog timer * we use hardware fuse bit to enforce watchdog is always on * and ask timer to reset watchdog * Set up the longest watchdog here */ //! Ram - From the AVR datasheet, the typical watchdog reset interval is 1.9 seconds at 3V Vcc for the max. prescalar value // __asm__ __volatile__ ("wdr"); // WDTCR = (1 << WDCE) | (1 << WDE); //! Ram - Start the timed sequence required to change the watchdog pre-scaler values // WDTCR = (1 << WDE) | (1 << WDP2) | (1 << WDP1) | (1 << WDP0); //! Ram - Set the pre-scalar values (Must be done within 4 clock cycles) (compiler must pre-compute const ?) //! component level init //! we do led initialization in sos_watchdog_processing systime_init(); // SYSTEM TIMER timer_hardware_init(DEFAULT_INTERVAL, DEFAULT_SCALE); #ifdef USE_UART1 SET_FLASH_SELECT_DD_OUT(); SET_FLASH_OUT_DD_OUT(); SET_FLASH_CLK_DD_OUT(); SET_FLASH_SELECT(); #endif // UART uart_system_init(); #ifndef NO_SOS_UART //! Initalize uart comm channel sos_uart_init(); #endif // I2C i2c_system_init(); #ifndef NO_SOS_I2C //! Initalize i2c comm channel sos_i2c_init(); //! Initialize the I2C Comm Manager // Ram - Assuming that it is turned on // by default with the SOS_I2C component sos_i2c_mgr_init(); #endif // ADC adc_proc_init(); #ifndef SOS_EMU // radio_init(NON_BEACONED_PAN); //hubert: use mac_init for vmac mac_init(); #endif }
int main(void) { init_IO(); sei(); _delay_ms(10); #if DEBUG uart_init(); uart_sendSTR("Iniciou Temperatura\n"); #endif while (1); return 0; }
int main(void) { init_IO(); sei(); _delay_ms(10); #if DEBUG uart_init(); uart_sendSTR("Iniciando Agente\n"); #endif while (1); return 0; }
int main(void) { init_IO(); init_interrupts(); oledInit(); _delay_ms(200); oledSetCursor(cursX, cursY); putChar(66,1); advanceCursor(6); compose(); initMenu(); while(1) { static uint16_t butCounter = 0; if (butCounter++ > 65000) { //FIXME: Proper button debounce and handling butCounter = 0; uint8_t readButtons = BUT_PIN; if (~readButtons & BUT_LEFT) { ++goLeft; } if (~readButtons & BUT_SEL) { ++goSel; } } if (knobChange) { if (knobChange > 0) { //menuUp(); knobLeft(); } else { //menuDn(); knobRight(); } knobChange = 0; } if (goSel) { //Lookup and execute action doSelect[optionIndex](); goSel = 0; } else if (goLeft) { doBack(); goLeft = 0; } } }
void main(void) { //Initialize IOs init_IO(); //Initialize the RTC init_rtc(); //Initialize the UART uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) ); //set the Global Interrupt Enable Bit sei(); while(1) { //Blink sekonds LED if (led_state == 1) { PORTB |= (1<<led_pin); // Turn on LED } else { PORTB &= ~(1<<led_pin); // Turn off LED } if (new_tick) { //Convert and display hours char buf [2]; itoa (t.hour,buf,10); uart_puts(buf); uart_puts(":"); //Convert and display minutes itoa (t.minute,buf,10); uart_puts(buf); uart_puts(":"); //Convert and display seconds itoa (t.second,buf,10); uart_puts(buf); uart_puts("\r\n"); new_tick = 0; } } }
void main(void) { CPUCS = bmCLKSPD1; init_IO(); EA = 0; // disable interrupts setup_autovectors(); usb_install_handlers(); EA = 1; fx2_renumerate(); while(1) { if(usb_setup_packet_avail()) usb_handle_setup_packet(); } }
int main(void){ //declare main() variables //initialize comms init_IO(); init_Uart(UART_ENABLED); startup_flashes_text(); //initialize variables clearData(); dutyCycle1 = 710; dutyCycle2 = 710; count=0; filtered1=0; filtered2=0; filtered3=0; //initialize controller init_Timer2and3(); init_OutputCompare(); ADC_Init(); while(1){} //interupt driven from here on out }
int main(void) { init_IO(); init_RTC(); while(1) { if (~PIND & BUTSHOW) { showTime(); } if (showTimeFlag) { showTimeFlag = 0; showTime(); } if (~PIND & BUTHOUR) { incHours(); showHours(); } if (~PIND & BUTMIN) { incMinutes(); showMinutes(); } } while(1) { // twiddle(); //readInput(); findZero(); findZero(); findZero(); _delay_ms(1000); showTime(); /* PORTC |= 1<<PC4; _delay_ms(200); PORTC &= ~(1<<PC4); _delay_ms(200); */ } }
//------------------------------------------------------------------------- // FUNCTION DECLARATION //------------------------------------------------------------------------- void hardware_init(void) { init_IO(); // WATCHDOG SETUP FOR AVR #ifndef DISABLE_WDT /* * Hardware Fuse Bit ensures WDT is always ON * The following timed sequence sets up a WDT * with the longest timeout period. */ __asm__ __volatile__ ("wdr"); WDTCR = (1 << WDCE) | (1 << WDE); WDTCR = (1 << WDE) | (1 << WDP2) | (1 << WDP1) | (1 << WDP0); #else /* * WDT may need to be disabled during debugging etc. * You must also unset the WDT fuse. If it is set it * is not possible to disable the WDT in software. * Setting the fuses to ff9fff will allow it to be disabled. */ __asm__ __volatile__ ("wdr"); WDTCR = (1 << WDCE) | (1 << WDE); WDTCR = 0; #endif //DISABLE_MICA2_WDT // LEDS // We do led initialization in sos_watchdog_processing // LOCAL TIME systime_init(); // SYSTEM TIMER timer_hardware_init(DEFAULT_INTERVAL, DEFAULT_SCALE); // UART #ifdef USE_UART1 SET_FLASH_SELECT_DD_OUT(); SET_FLASH_SELECT(); #endif uart_system_init(); #ifndef NO_SOS_UART //! Initalize uart comm channel sos_uart_init(); #endif // I2C // always initalize the i2c system i2c_system_init(); #ifndef NO_SOS_I2C //! Initalize i2c comm channel sos_i2c_init(); //! Initialize the I2C Comm Manager // Ram - Assuming that it is turned on // by default with the SOS_I2C component sos_i2c_mgr_init(); #endif // ADC adc_proc_init(); // RADIO #ifndef SOS_EMU cc1k_radio_init(); #ifndef DISABLE_RADIO cc1k_radio_start(); #ifdef RADIO_XMIT_POWER cc1k_cnt_SetRFPower(RADIO_XMIT_POWER); #endif//RADIO_XMIT_POWER #else cc1k_radio_stop(); #endif//DISABLE_RADIO #endif//SOS_EMU // EXTERNAL FLASH #ifndef USE_UART1 exflash_init(); #endif // MICA2 PERIPHERALS (Optional) #ifdef SOS_MICA2_PERIPHERAL mica2_peripheral_init(); #endif //TODO: We may want to move this out of the mica2 hardware (Roy) one_wire_init(); }
//------------------------------------------------------------------------- // FUNCTION DECLARATION //------------------------------------------------------------------------- void hardware_init(void){ init_IO(); // WATCHDOG SETUP FOR MSP430 // After PUC, watchdog is enabled by default // with a timeout of 32 ms. Till we support // watchdog, we will simply disable it DISABLE_WDT(); // CLOCK SUBSYSTEM clock_hal_init(); // LEDS led_init(); // HARDWARE TIMERS timerb_hal_init(); // SYSTEM TIMER timer_hardware_init(DEFAULT_INTERVAL); // UART uart_hardware_init(); uart_system_init(); #ifndef NO_SOS_UART //! Initialize uart comm channel sos_uart_init(); #endif // I2C //! Limited I2C support for the ARL deployment #ifdef NEW_SENSING_API #ifdef TMOTE_INVENT_SENSOR_BOARD invent_sensor_init(); #endif #endif // SPI spi_hardware_init(); // RADIO //#ifndef NO_SOS_RADIO // cc2420_hardware_init(); mac_init(); //#endif // ADC #ifdef NEW_SENSING_API adc_driver_init(); #else adc_proc_init(); #endif // Interrupt controller interrupt_init(); // SHT1x chip communication controller #ifdef NEW_SENSING_API #ifdef TMOTE_SENSOR_BOARD sht1x_comm_init(); #endif #endif // Ram - I dont know which flash this is ? // init_flash(); // EXTERNAL FLASH // Currently there is no support // MSP430 PERIPHERALS (Optional) }