int main(void) { volatile float filteredTemp = readTemperature(); uint32_t lastTemperatureUpdate = 0; temperature = filteredTemp*10; ClockInit(); ModuloInit(); while(1) { ModuloUpdateStatusLED(); // Constantly read the temperature (every 1ms) and apply a low pass IIR filter. float filterRate = .01; float newTemperature = readTemperature(); filteredTemp = filterRate*newTemperature + (1.0-filterRate)*filteredTemp; _delay_ms(1); // Every 100ms, update the temperature from the current filtered value if ((millis()-lastTemperatureUpdate) > 100) { lastTemperatureUpdate = millis(); // Disable interrupts and atomically update the state noInterrupts(); temperature = filteredTemp*10; // tenths of degrees interrupts(); } } }
int main(void) { ClockInit(30e6); while (1) {} return 0; }
/** Initialize controllers that must setup at the early stage Some peripherals must be initialized in Secure World. For example, some L2x0 requires to be initialized in Secure World **/ RETURN_STATUS ArmPlatformInitialize ( IN UINTN MpId ) { BEAGLEBOARD_REVISION Revision; Revision = BeagleBoardGetRevision(); // Set up Pin muxing. PadConfiguration (Revision); // Set up system clocking ClockInit (); // Turn off the functional clock for Timer 3 MmioAnd32 (CM_FCLKEN_PER, 0xFFFFFFFF ^ CM_ICLKEN_PER_EN_GPT3_ENABLE ); ArmDataSynchronizationBarrier (); // Clear IRQs MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR); ArmDataSynchronizationBarrier (); return RETURN_SUCCESS; }
int main(void) { //Code geoptimaliseerd voor bordje 3 //###1### //Initialize subsystems ClockInit(); //Initialize system clock (16 MHz) USARTInit(); //Initialize USART and bind to stdout,stdin AnalogInit(); //Initialize ADC AccInit(); //Initialize accelerometer system LEDInit(); //Initialize LEDs SwitchInit(); //Initialize switches EncoderInit(); //Initialize encoder SpeakerInit(); //Initialize speaker system //Enable interrupts PMIC.CTRL|=0b00000111; //Enable low, medium, high priority interrupts SREG|=0b10000000; //Globale interrupt enable //###2### //Print the digits 0 to 9 5x on terminal device //Reason this section didn't work: de variabelen 'a' is globaal gedefinieerd. In het subprogramma 'SimpleFunction()' wordt //de variabelen 'a' gebruikt. Na dit subprogramma is de waarde van 'a' gelijk aan 10 en zal de lus (a<5) onderbroken worden. for (a=0; a<5; a++) { SimpleFunction(); printf ("\r\n"); } //###3### //Main program loop a=0; ledOn=0b00001000; //Beeps(); //Genereer 3 beeps van 500hz, 1000hz, 1500hz (500 ms) setNotes(); //Stel een reeks van noten in playNextNote(); //Speel de eerste noot uit de reeks while(1) { LoopLicht(); //LoopLicht sequentie AccLezen(); //Accelerometer lezen printf("$SWITCH %d\r\n", SwitchGet()); //Switchwaarde over USARTD: 1: center, 2: rechts, 4: beneden, 8: links, 16: boven printf("$ACCRAW %d %d %d\r\n", RawAccX, RawAccY, RawAccZ); //Ongecalibreerde waardes accelerometer x, y, z over USARTD printf("$ACC__ %d %d %d\r\n", AccGetXAxis(RawAccX), AccGetYAxis(RawAccY), AccGetZAxis(RawAccZ)); //Gecalibreerde waardes accelerometer x, y, z over USARTD printf("$ENC__ %d\r\n", EncoderGetPos()); //printf ("Counter:%d\r\n",a); //printf("%c", 0x55); //Stuur de waarde 0x55 uit (0b01010101) //a++; _delay_ms(20); } }
void main(void) { ClockInit(); TimersInit(); I2C_Init(57600); //Default register value is equal to 0b1110000 ADx isn't set I2C_WriteToReg(0x70, 0x20, 0b00100001); I2C_WriteToReg(0x70, 0xA0, 0b10100000); I2C_WriteToReg(0x70, 0x80, 0b10000001); //This is the command for 8/16 Duty Setup 0xEx where x is 0 - F for 1/16 to 16/16 duty. I2C_WriteToReg(0x70, 0xEF, 0xE7); }
int main(void) { ClockInit(); SerialInit(); TimerInit(); //ADMUX = POWER_IN;//A7 power DIDR0 |= _BV(0);//1 ADCSRA = _BV(ADEN) | _BV(ADPS0) | _BV(ADPS1) | _BV(ADPS2);// | _BV(ADIE) | _BV(ADATE) _BV(ADSC) | ADCSRB = _BV(ADLAR); loop(); }
void MasterInitialize()//called on startup, will call the port setup etc. as well as find the appropriate setting for the pot { cli();//disable interrupts ADCInit(); PortInit();//these init values (clock and port) are taken directly from our old code ClockInit(); SerialInit(); sei();//enable interrupts return; }
int notmain ( void ) { volatile unsigned int ra; unsigned int rx; ClockInit(); ra=GET32(RCCBASE+0x30); ra|=1<<3; //enable port D PUT32(RCCBASE+0x30,ra); ra=GET32(RCCBASE+0x40); ra|=1<<3; //enable TIM5 PUT32(RCCBASE+0x40,ra); //d12 = d15 output ra=GET32(GPIODBASE+0x00); ra&=0x00FFFFFF; ra|=0x55000000; PUT32(GPIODBASE+0x00,ra); //push pull ra=GET32(GPIODBASE+0x04); ra&=0xFFFF0FFF; PUT32(GPIODBASE+0x04,ra); PUT32(TIM5BASE+0x00,0x00000000); PUT32(TIM5BASE+0x2C,168000000); //auto reload PUT32(TIM5BASE+0x00,0x00000001); while(1) { PUT32(GPIODBASE+0x18,0xE0001000); while(1) { if(GET32(TIM5BASE+0x10)&1) break; } PUT32(TIM5BASE+0x10,0); PUT32(GPIODBASE+0x18,0xF0000000); while(1) { if(GET32(TIM5BASE+0x10)&1) break; } PUT32(TIM5BASE+0x10,0); } return(0); }
int GeneratorInit(Generator *g, unsigned int seed) { g->rng = RNGNew(RNG_ISAAC, seed); if (!g->rng) { X(RNGNew); } if (!ClockInit(&g->clock)) { X(ClockInit); } g->mask_sampler = SampleDefault; g->mask_sampler_rsc = NULL; g->grapher = NULL; return 1; err_ClockInit: RNGFree(g->rng); err_RNGNew: return 0; }
int main(int argc, char** argv) { PowerOn(); ClockInit(); ANSELA = 0; ANSELB = 0; SPLIM = 0xFFFF; // TODO: implement proper handling of SPLIM. ModuleInit(); I2cInit(); ShellTaskInit(); App * first = MainMenuAppInit(&main_menu_app); // Comment out the next line to skip splash. first = SplashAppInit(&splash_app, first); AppTaskInit(first); vTaskStartScheduler(); }
void BoardInit (void) { /* Set HSION bit */ RCC->CR |= (uint32_t) 0x00000001; /* Reset CFGR register */ RCC->CFGR = 0x00000000; /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t) 0xFEF6FFFF; /* Reset PLLCFGR register */ RCC->PLLCFGR = 0x24003010; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t) 0xFFFBFFFF; /* System Clock Setup */ ClockInit (); }
VOID CEntryPoint ( IN VOID *MemoryBase, IN UINTN MemorySize, IN VOID *StackBase, IN UINTN StackSize ) { VOID *HobBase; // Build a basic HOB list HobBase = (VOID *)(UINTN)(FixedPcdGet32(PcdEmbeddedFdBaseAddress) + FixedPcdGet32(PcdEmbeddedFdSize)); CreateHobList (MemoryBase, MemorySize, HobBase, StackBase); //Set up Pin muxing. PadConfiguration (); // Set up system clocking ClockInit (); // Enable program flow prediction, if supported. ArmEnableBranchPrediction (); // Initialize CPU cache InitCache ((UINT32)MemoryBase, (UINT32)MemorySize); // Add memory allocation hob for relocated FD BuildMemoryAllocationHob (FixedPcdGet32(PcdEmbeddedFdBaseAddress), FixedPcdGet32(PcdEmbeddedFdSize), EfiBootServicesData); // Add the FVs to the hob list BuildFvHob (PcdGet32(PcdFlashFvMainBase), PcdGet32(PcdFlashFvMainSize)); // Start talking UartInit (); InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL, NULL); SaveAndSetDebugTimerInterrupt (TRUE); DEBUG ((EFI_D_ERROR, "UART Enabled\n")); // Start up a free running timer so that the timer lib will work TimerInit (); // SEC phase needs to run library constructors by hand. ExtractGuidedSectionLibConstructor (); LzmaDecompressLibConstructor (); // Build HOBs to pass up our version of stuff the DXE Core needs to save space BuildPeCoffLoaderHob (); BuildExtractSectionHob ( &gLzmaCustomDecompressGuid, LzmaGuidedSectionGetInfo, LzmaGuidedSectionExtraction ); // Assume the FV that contains the SEC (our code) also contains a compressed FV. DecompressFirstFv (); // Load the DXE Core and transfer control to it LoadDxeCoreFromFv (NULL, 0); // DXE Core should always load and never return ASSERT (FALSE); }
void my_task_Startup() { DebugManager(1, 0x1F, 0x180000, 0x40000, 0x1C0000); dmstart(); dmProcInit(); #ifdef ENABLE_MASSIVE_DEBUG // the 2nd level is 32 flags for debug classes // the 3rd arg is log level, 0 == full debug, >0 == less debug dmSetStoreLevel(hDbgMgr, 0xFF, 0); dmSetPrintLevel(hDbgMgr, 0xFF, 0); #endif initialize(); sub_FFAFE5BC(); SetAssert(); EventProcedureServiceInit(); ShutDownProcInit(); Install3VMemory(0xF8000000); RomManagerInit(); CreateParamPubInstance(); PropertyServiceInit(); ErrorNumberListInit(); FatalErrorsProcInit(); RegisterISRs_OCH(); BlockUntilAfterTimeoutProcInit(50); sub_FFB07740(0x10, 8, 0x1BBC); ResourceNameServiceInit(); MemorySuite(0); sysClockRateSet_100(3); sub_FFB2BD6C(); InitializeSerialIO(); RtcInit(0x386D4380); AdjDefectsInit(); CameraAdjsInit(); SetAssertProc(AssertPrepare, 0); my_InitializeIntercom(); // InitializeIntercom(); AfeGainCmosParamInit(); EngineInit(); EDmacPriorityManager(); EngineResourceInit(); PowerMgrInit(0); ClockInit(1); RegisterISR_CAPREADY(); FaceSensorInit(); RemDrvInit(); ActSweepInit(); LcdInit(); DisplayInit1(); DisplayInit2(); PowerSaveProcInit(); sub_FFA03B0C(); sub_FFA05114(); InitializeImagePlayDriver(); LensNameTblInit(); LensPOTblInit(); FlyingInit(); CaptureInit(); BathtubSaturateInit(); Module_CaptureImagePass(); ClearSomeCapMem(); ColorAdjustmentsInit(); Module_PreDarkPassInit(); LoadSystemInfo(); SharedBufferInit(0x10800000, 0x18000000, 0xEE0000, 0xEE0000); FileCacheInit(); PackMemInit(); ImagePropInit(); DigPropInit(); ShootMainInit(); OlcInfoInit(); RegisterISR_EMERGENCY_CARDDOOR(); my_MainCtrlInit(); CaptureSemaphoreInit(); VShadingInit(); Module_CaptureDarkPassInit(); Module_DarkSubtractionPassInit(); BathtubInit(); Module_BathtubCorrectPassInit(); Module_VObIntegPassInit(); SetProjectionInit(); Module_DefectsDetectPassInit(); DefsInit(); WbDetectionInit(); ObInit(); Module_WbDetectionPassInit(); DefsProcInit(); Module_ObAreaCopyPassInit(); Module_AdditionVTwoLinePassInit(); VShadingProcInit(); Module_VShadingCorrectPassInit(); sub_FFA24838(); HuffmanInit(); RawToJpegPass_L_Init(); RawToJpegPass_M2_Init(); RawToJpegPass_S_Init(); YcToJpegLargeFastInit(); YcToJpegM2FastInit(); YcToJpegSFastInit(); RawToLosslessInit(); Module_YcToTwainInit(); RawToYcPass_S_Init(); RawToYPackPass_S_Init(); DvlpInit(); DecodeJpegPassInit(); HistPassInit(); RectangleColorPassInit(); RectangleCopyPassInit(); ResizeYuvPassInit(); sub_FFA35354(); LpfPassInit(); EncodeJpegPassInit(); AdjRgbGainInit(); LuckyInit(); SysInfoProcInit(); TablesInit(); ColorInit(); CtrlManRecursiveLock(); CtrlSrvInit(0x19); LangConInit(); sub_FF926E40(); CreateDispSwControlPubInstance(); CreateMemoryManagerPubInstance(); my_GUIInit(); //GUIInit(); GUIApiCalls(); InitializeImagePlayer(); ColorBarProcsInit(); LcdAdjustProcsInit(); sub_FFB29348(); CMOSParamInit(); CameraSettingsInit(); BootDiskProcsInit(); DDDInit(); TFTInit(); RegisterResourceName(hResourceName, "USR ROOT DEVICE HANDLE", 0x7B); RegisterResource_env(0xC02200B8, "U2VBUS"); RegisterResource_env(1, "USBC20 VBUS SUPPORT"); RegisterResource_env(0x14, "DEVICESPEED"); USBC20_Init(); USBC20_USBIF_Init(); USBC20_BUFCON_Init(); USBC20_CLK_Init(); USBC20_HDMAC_Init(); DCPClassFunctionsInit(); USBDriverInit(); RapiSwitcherInit(); DCPClassInit(); RAPITransportUSBInit(); PTPRespondInit(); PTPFrameworkInit(); StartupPtpResponder(); RapiTransportManagerInit(); DCPClassInit(); EventProcServerInit(); sub_FFA5D8A0(); DCPInit(); SesnMngrInit(); MemMngrInit(); InitializeRapiTransportManager(); PrintInit(); sub_FF95EC54(); SomePrintInit(); sub_FF9EB94C(); InitializeUSBDriver(); TransMemoryInit(); InitializeComCtrl(); FactoryModeInit(); DP_Init(0, 0x1B, 0, 0); return_0(); sub_FF98CF4C(); EdLedProcsInit(); CallBacksInit(); RegistNotifyConnectDT(); DPOF_Initialize(); MpuMonInit(); StartConsole(); }
static void ClockInit(void) { uint32_t status; /* Enable all source clocks */ status = Cy_SysClk_WcoEnable(500000u); if (CY_RET_SUCCESS != status) { CyClockStartupError(CYCLOCKSTART_WCO_ERROR); } Cy_SysClk_ClkLfSetSource(CY_SYSCLK_CLKLF_IN_WCO); #if FEATURE_BLE { cy_stc_ble_bless_eco_cfg_params_t bleCfg = { .ecoXtalStartUpTime = (785 / 31.25), .loadCap = ((9.9 - 7.5) / 0.075), .ecoFreq = CY_BLE_BLESS_ECO_FREQ_32MHZ, .ecoSysDiv = CY_BLE_SYS_ECO_CLK_DIV_4 }; Cy_BLE_EcoStart(&bleCfg); } #endif // FEATURE_BLE /* Configure CPU clock dividers */ Cy_SysClk_ClkFastSetDivider(0u); Cy_SysClk_ClkPeriSetDivider((CY_CLK_HFCLK0_FREQ_HZ / CY_CLK_PERICLK_FREQ_HZ) - 1); Cy_SysClk_ClkSlowSetDivider((CY_CLK_PERICLK_FREQ_HZ / CY_CLK_SYSTEM_FREQ_HZ) - 1); /* Configure LF & HF clocks */ Cy_SysClk_ClkHfSetSource(0u, CY_SYSCLK_CLKHF_IN_CLKPATH1); Cy_SysClk_ClkHfSetDivider(0u, CY_SYSCLK_CLKHF_NO_DIVIDE); Cy_SysClk_ClkHfEnable(0u); /* Configure Path Clocks */ /* PLL path is used to clock HF domain from BLE ECO */ Cy_SysClk_ClkPathSetSource(2, CY_SYSCLK_CLKPATH_IN_IMO); Cy_SysClk_ClkPathSetSource(3, CY_SYSCLK_CLKPATH_IN_IMO); Cy_SysClk_ClkPathSetSource(4, CY_SYSCLK_CLKPATH_IN_IMO); #if FEATURE_BLE Cy_SysClk_ClkPathSetSource(0, CY_SYSCLK_CLKPATH_IN_ALTHF); Cy_SysClk_ClkPathSetSource(1, CY_SYSCLK_CLKPATH_IN_ALTHF); { const cy_stc_pll_config_t pllConfig = { .inputFreq = CY_CLK_ALTHF_FREQ_HZ, .outputFreq = CY_CLK_HFCLK0_FREQ_HZ, .lfMode = false, .outputMode = CY_SYSCLK_FLLPLL_OUTPUT_AUTO }; #else Cy_SysClk_ClkPathSetSource(0, CY_SYSCLK_CLKPATH_IN_IMO); Cy_SysClk_ClkPathSetSource(1, CY_SYSCLK_CLKPATH_IN_IMO); { const cy_stc_pll_config_t pllConfig = { .inputFreq = CY_CLK_IMO_FREQ_HZ, .outputFreq = CY_CLK_HFCLK0_FREQ_HZ, .lfMode = false, .outputMode = CY_SYSCLK_FLLPLL_OUTPUT_AUTO }; #endif // FEATURE_BLE status = Cy_SysClk_PllConfigure(1u, &pllConfig); if (CY_SYSCLK_SUCCESS != status) { CyClockStartupError(CYCLOCKSTART_PLL_ERROR); } } status = Cy_SysClk_PllEnable(1u, 10000u); if (CY_SYSCLK_SUCCESS != status) { CyClockStartupError(CYCLOCKSTART_PLL_ERROR); } /* Configure miscellaneous clocks */ Cy_SysClk_ClkTimerSetSource(CY_SYSCLK_CLKTIMER_IN_HF0_NODIV); Cy_SysClk_ClkTimerSetDivider(0); Cy_SysClk_ClkTimerEnable(); Cy_SysClk_ClkPumpSetSource(CY_SYSCLK_PUMP_IN_CLKPATH0); Cy_SysClk_ClkPumpSetDivider(CY_SYSCLK_PUMP_DIV_4); Cy_SysClk_ClkPumpEnable(); Cy_SysClk_ClkBakSetSource(CY_SYSCLK_BAK_IN_WCO); /* Disable unused clocks started by default */ Cy_SysClk_IloDisable(); /* Set memory wait states based on HFClk[0] */ Cy_SysLib_SetWaitStates(false, (CY_CLK_HFCLK0_FREQ_HZ + 990000) / 1000000UL); } /* Analog API Functions */ /******************************************************************************* * Function Name: AnalogSetDefault ******************************************************************************** * * Summary: * Sets up the analog portions of the chip to default values based on chip * configuration options from the project. * * Parameters: * void * * Return: * void * *******************************************************************************/ static void AnalogSetDefault(void) { const cy_stc_sysanalog_config_t config = { .startup = CY_SYSANALOG_STARTUP_NORMAL, .iztat = CY_SYSANALOG_IZTAT_SOURCE_LOCAL, .vref = CY_SYSANALOG_VREF_SOURCE_LOCAL_1_2V, .deepSleep = CY_SYSANALOG_DEEPSLEEP_IPTAT_1 }; Cy_SysAnalog_Init(&config); Cy_SysAnalog_Enable(); } /******************************************************************************* * Function Name: Cy_SystemInit ******************************************************************************** * Summary: * This function is called by the start-up code for the selected device. It * performs all of the necessary device configuration based on the design * settings. This includes settings from the Design Wide Resources (DWR) such * as Clocks and Pins as well as any component configuration that is necessary. * * Parameters: * void * * Return: * void * *******************************************************************************/ void Cy_SystemInit(void) { /* Set worst case memory wait states (150 MHz), ClockInit() will update */ Cy_SysLib_SetWaitStates(false, 150); if(0u == Cy_SysLib_GetResetReason()) { /* POR, XRES, or BOD */ Cy_SysLib_ResetBackupDomain(); } /* Power Mode */ Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_1_1V); /* PMIC Control */ Cy_SysPm_UnlockPmic(); Cy_SysPm_DisablePmicOutput(); /* Pin0_0 and Pin0_1 drive WCO, configure as analog before configuring clock */ cy_reserve_io_pin(P0_0); cy_reserve_io_pin(P0_1); Cy_GPIO_Pin_FastInit(GPIO_PRT0, 0, CY_GPIO_DM_ANALOG, 0, P0_0_GPIO); Cy_GPIO_Pin_FastInit(GPIO_PRT0, 1, CY_GPIO_DM_ANALOG, 0, P0_1_GPIO); /* Clock */ ClockInit(); /******* Pre-defined port configuration section ********/ { /* RGB LED is P_0_3 (R), P_1_1 (G) and P_11_1 (B) */ const uint32_t led_off = 1; Cy_GPIO_Pin_FastInit(GPIO_PRT0, 3, CY_GPIO_DM_STRONG_IN_OFF, led_off, P0_3_GPIO); Cy_GPIO_Pin_FastInit(GPIO_PRT1, 1, CY_GPIO_DM_STRONG_IN_OFF, led_off, P1_1_GPIO); Cy_GPIO_Pin_FastInit(GPIO_PRT11, 1, CY_GPIO_DM_STRONG_IN_OFF, led_off, P11_1_GPIO); /* USER BUTTON is P_0_4 */ Cy_GPIO_Pin_FastInit(GPIO_PRT0, 4, CY_GPIO_DM_PULLUP, 1, P0_4_GPIO); /* Configure hw debug interface on port 6 */ cy_reserve_io_pin(P6_6); cy_reserve_io_pin(P6_7); Cy_GPIO_Pin_FastInit(GPIO_PRT6, 6, CY_GPIO_DM_PULLUP, 0, P6_6_CPUSS_SWJ_SWDIO_TMS); Cy_GPIO_Pin_FastInit(GPIO_PRT6, 7, CY_GPIO_DM_PULLDOWN, 0, P6_7_CPUSS_SWJ_SWCLK_TCLK); } /* Perform basic analog initialization to defaults */ AnalogSetDefault(); }
int main(void) { ClockInit(); SerialInit(); TimerInit(); loop(); }
unsigned char _sdcc_external_startup(void) { IE=0; // disable ALL interrupts // use A19..16 and !CE3..0, no CAN TIMED_ACCESS(P4CNT,0x3f); // use !PCE3..0, serial 1 at P5.2/3 TIMED_ACCESS(P5CNT,0x27); // disable watchdog EWT=0; // watchdog set to 9.1 seconds // CKCON|=0xc0; // default stretch cycles for MOVX //CKCON = (CKCON&0xf8)|(CPU_MOVX_STRETCH&0x07); CKCON=0xf9; // use internal 4k RAM as data(stack) memory at 0x400000 and // move CANx memory access to 0x401000 and upwards // use !CE* for program and/or data memory access TIMED_ACCESS(MCON,0xaf); __asm ; save the 24-bit return address ; pop ar2; msb mov r2, #0x00 pop ar1 pop ar0; lsb mov _TA,#0xaa; timed access mov _TA,#0x55 mov _ACON,#0x06; 24 bit addresses, 10 bit stack at 0x400000 mov _ESP,#0x00; reinitialize the stack mov _SP,#0x00 ; restore the 24-bit return address push ar0; lsb push ar1 push ar2; msb __endasm; // select default cpu speed CpuSpeed(CPU_SPEED); // Copy the Interrupt Vector Table (128 bytes) from 0x10000 to 0x100000 // This isn't needed for older bootloaders than the 0515, but it won't harm __asm push dpx push dph push dpl push dps push b push acc mov dps,#0x00 ; make sure no autoincrement in progress mov dptr,#0x10000 ; from inc dps ; switch to alternate dptr mov dptr,#0x100000 ; to mov b,#0x80 ; count _Startup390CopyIVT: inc dps movx a,@dptr inc dptr inc dps movx @dptr,a inc dptr djnz b,_Startup390CopyIVT pop acc pop b pop dps pop dpl pop dph pop dpx __endasm; // global interrupt enable, all masks cleared // let the Gods be with us :) IE = 0x80; Serial0Init(SERIAL_0_BAUD,1); //Serial1Init(SERIAL_1_BAUD,1); ClockInit(); //RtcInit(); //WatchDogInit(); // signal _sdcc_gsinit_startup to initialize data (call _sdcc_init_data) return 0; }
int main(void) { ClockInit(); Init(); loop(); }
// This runs once during program startup void Controller::setup() { // Setup code here LGSerial::init(); LGSerial::put("Hello World!"); DDRC |= 1 << DDC2;//trigger DDRC |= 1 << DDC3;//pc3 pin 26 for output DDRC |= 1 << DDC4; DDRC |= 1 << DDC5; DDRD |= 1 << DDD0; PORTD &= ~(1 << PD0); PORTC &= ~(1 << PC2); PORTC &= ~(1 << PC3); _delay_ms(500); ClockInit(); SetSecond(1); SetMinute(33); SetHour(8); SetAmPm(1);///0 for AM, 1 for PM SetDay(3); SetDate(23); SetMonth(4); SetYear(13); char Time[12]; //hh:mm:ss AM/PM while(0) { //Get the Current Time as a String if(!GetTimeString(Time))//modifies time { /* If return value is false then some error has occured Check ->DS1307 Installed Properly ->DIP Switch 1,2 are in on position */ while(1);//halt } _delay_ms(500); } uint8_t second = GetSecond(); uint8_t minute = GetMinute(); uint8_t hour = GetHour(); uint8_t AmPm = GetAmPm(); uint8_t day = GetDate(); uint8_t date = GetDate(); uint8_t month = GetMonth(); uint8_t year = GetYear(); LGSerial::print(second); LGSerial::print(minute); LGSerial::print(hour); LGSerial::print(AmPm); LGSerial::print(day); LGSerial::print(date); LGSerial::print(month); LGSerial::print(year); _delay_ms(20000); second = GetSecond(); minute = GetMinute(); LGSerial::print(second); LGSerial::print(minute); _delay_ms(20000); second = GetSecond(); minute = GetMinute(); LGSerial::print(second); LGSerial::print(minute); //uint8_t minute = GetMinute(); //uint8_t minute = 0xAA; // bool min[8]; /* min[0] = minute & 0x01; min[1] = minute & 0x02; min[2] = minute & 0x04; min[3] = minute & 0x08; min[4] = minute & 0x10; min[5] = minute & 0x20; min[6] = minute & 0x40; min[7] = minute & 0x80; */ /* min[0] = 0; min[1] = 1; min[2] = 0; min[3] = 1; min[4] = 0; min[5] = 1; min[6] = 0; min[7] = 1; */ /* int i = 0; while(1){ //make pc2 trigger PORTC |= 1 << PC2; PORTC &= ~(1 << PC2); PORTC |= 1 << PC3; PORTC &= ~(1 << PC3); PORTC |= 1 << PC3; PORTC &= ~(1 << PC3); PORTC |= 1 << PC3; PORTC &= ~(1 << PC3); for (i=0;i<8;i++){ if (min[i] == 1){ //if that bit of min is 1 PORTD |= 1 << PD0; PORTD &= ~(1 << PD0); PORTD |= 1 << PD0; PORTD &= ~(1 << PD0); PORTC &= ~(1 << PC3); PORTC |= 1 << PC3; PORTC &= ~(1 << PC3); } else {//if (min[i] == 0){ //if that bit of min is 0 PORTD |= 1 << PD0; PORTD &= ~(1 << PD0); PORTC |= 1 << PC3; PORTC &= ~(1 << PC3); PORTC |= 1 << PC3; } } } */ }