int main(void) { WDTCTL = WDTPW + WDTHOLD; // Watchdog timer disabled /* Set up the system clock */ BCSCTL1 = CALBC1_1MHZ; // can replace 8 with 1, 12 or 16 DCOCTL = CALDCO_1MHZ; /* Initialise Timer */ TACTL = 0x0212; // Use SMCLK, Up mode (count to TACCR0), Interrupts Enabled TACCTL0 = 0x0010; // Interrupts Enabled, Compare Mode TACCR0 = 1000; // 1MHz/1000Hz = 1000 gives the number of system clocks required for a 1ms timer /* Initialisation of P1.0 (LED) */ LEDSEL &= ~LEDBIT; // Digital I/O mode LEDDIR |= LEDBIT; // Output Mode LEDOUT |= LEDBIT; // LED on __eint(); WatchdogEnable(WDT_8000); while(1) { if (tick>=500) // 1s period (500ms) { LEDOUT ^= LEDBIT; // Toggle Led tick = 0; } } }
//***************************************************************************** // // This example demonstrates the use of the watchdog timer. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Initialize the OLED display and write status. // RIT128x96x4Init(1000000); RIT128x96x4StringDraw("Watchdog example", 12, 24, 15); // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // // Enable processor interrupts. // IntMasterEnable(); // // Set GPIO G2 as an output. This drives an LED on the board that will // toggle when a watchdog interrupt is processed. // GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2); GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0); // // Enable the watchdog interrupt. // IntEnable(INT_WATCHDOG); // // Set the period of the watchdog timer. // WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()); // // Enable reset generation from the watchdog timer. // WatchdogResetEnable(WATCHDOG0_BASE); // // Enable the watchdog timer. // WatchdogEnable(WATCHDOG0_BASE); // // Loop forever while the LED winks as watchdog interrupts are handled. // while(1) { } }
//***************************************************************************** // // This example demonstrates the use of the watchdog timer. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ); // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); // // Enable processor interrupts. // IntMasterEnable(); // // Set GPIO C5 as an output. This drives an LED on the board that will // toggle when a watchdog interrupt is processed. // GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5); // // Enable the watchdog interrupt. // IntEnable(INT_WATCHDOG); // // Set the period of the watchdog timer. // WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()); // // Enable reset generation from the watchdog timer. // WatchdogResetEnable(WATCHDOG0_BASE); // // Enable the watchdog timer. // WatchdogEnable(WATCHDOG0_BASE); // // Loop forever while the LED winks as watchdog interrupts are handled. // while(1) { } }
/* * ======== WatchdogCC26XX_hwInit ======== * This functions initializes the Watchdog hardware module. * * @pre Function assumes that the Watchdog handle is pointing to a hardware * module which has already been opened. */ static void WatchdogCC26XX_initHw(Watchdog_Handle handle) { WatchdogCC26XX_Object *object; /* get the pointer to the object and hwAttrs */ object = handle->object; /* unlock the Watchdog configuration registers */ WatchdogUnlock(); /* make sure the Watchdog is unlocked before continuing */ while(WatchdogLockState() == WATCHDOG_LOCK_LOCKED) { } WatchdogReloadSet(object->reloadValue); #ifndef CCWARE /* set reset mode */ if (object->resetMode == Watchdog_RESET_ON) { WatchdogResetEnable(); } else { WatchdogResetDisable(); } #endif /* set debug stall mode */ if (object->debugStallMode == Watchdog_DEBUG_STALL_ON) { WatchdogStallEnable(); } else { WatchdogStallDisable(); } /* enable the Watchdog interrupt as a non-maskable interrupt */ WatchdogIntTypeSet(WATCHDOG_INT_TYPE_NMI); /* enable interrupts */ WatchdogIntEnable(); /* enable the Watchdog */ WatchdogEnable(); /* lock the Watchdog configuration registers */ WatchdogLock(); }
//***************************************************************************** // // Configure the SysTick and SysTick interrupt with a period of 1 second. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the external crystal/oscillator. // (no ext 32k osc, no internal osc) // SysCtrlClockSet(false, false, SYS_CTRL_SYSDIV_32MHZ); // // Set IO clock to the same as system clock // SysCtrlIOClockSet(SYS_CTRL_SYSDIV_32MHZ); // // Set up the serial console to use for displaying messages. This is // just for this example program and is not needed for Systick operation. // InitConsole(); // // Display a reset message // UARTprintf("Watchdog Reset!\n"); // // Enable watchdog // WatchdogEnable(WATCHDOG_INTERVAL_32768); while(1) { // // Delay // WdDelay(100); // // Clear WD such that we do not get a reset! // WatchdogClear(); } }
void hwInitWatchdog(long intervalMilliseconds) { if (SysCtlPeripheralPresent(SYSCTL_PERIPH_WDOG)){ SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG); WatchdogUnlock(WATCHDOG_BASE); // unlock WD register WatchdogResetEnable(WATCHDOG_BASE); // enable reset capability on second timeout /* watchdog resets the system on the second timeout! * -> so we have to divide the time by 2 * -> on the first time-out only an interrupt is generated */ glWDLoad = (SysCtlClockGet()/1000) * (intervalMilliseconds/2); WatchdogReloadSet(WATCHDOG_BASE, glWDLoad); WatchdogStallEnable(WATCHDOG_BASE); // stops the watchdog during debug break WatchdogIntUnregister(WATCHDOG_BASE); // mask interrupt -> interrupts are not seen and handled by processor WatchdogEnable(WATCHDOG_BASE); WatchdogLock(WATCHDOG_BASE); // lock WD register } }
/********************************************************************************************** * Main *********************************************************************************************/ void main(void) { //After tomorrow's test flight. FOR THE LOVE OF GOD MOVE THESE INITALIZATIONS TO FUNCTIONS /********************************************************************************************** * Local Variables *********************************************************************************************/ unsigned long ultrasonic = 0; // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. FPULazyStackingEnable(); //Set the clock speed to 80MHz aka max speed SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); /*unsigned long test[2]; test[0] = 180; test[1] = 10; short bob[1]; bob[0] = ((char)test[0]<<8)|(char)test[1]; float jimmy = (short)(((char)test[0]<<8)|(char)test[1]); jimmy /= 26;*/ /********************************************************************************************** * Peripheral Initialization Awake *********************************************************************************************/ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //Turn on GPIO communication on F pins for switches SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //Turn on GPIO for ADC SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //Turn on GPIO for the PWM comms SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //Turn on GPIO for LED test SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); //Turn on GPIO for UART SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); //Turn on Timer for PWM SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); //Turn on Timer for PWM SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); //Turn on Timer for PWM SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3); //Turn on Timer for PWM SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); //Turn on I2C communication I2C slot 0 SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2); //Turn on the UART com SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG); //Turn on the watchdog timer. This is a risky idea but I think it's for the best. /********************************************************************************************** * Peripheral Initialization Sleep *********************************************************************************************/ /*SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF); //This sets what peripherals are still enabled in sleep mode while UART would be nice, it would require the clock operate at full speed which is :P SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_TIMER0); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_TIMER1); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_TIMER2); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_TIMER3); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_SSI0); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_I2C1); SysCtlPeripheralSleepDisable(SYSCTL_PERIPH_ADC); SysCtlPeripheralClockGating(true); //I'm not sure about this one maybe remove it */ /********************************************************************************************** * PWM Initialization *********************************************************************************************/ SysCtlDelay((SysCtlClockGet() / (1000 * 3))*100); //This shouldn't be needed will test to remove //PWM pin Setup //PWM 0 on GPIO PB6, PWM 1 on pin 4... etc GPIOPinConfigure(GPIO_PB6_T0CCP0); //Pitch - yaw + GPIOPinConfigure(GPIO_PB4_T1CCP0); //Pitch + yaw + GPIOPinConfigure(GPIO_PB0_T2CCP0); //Roll - yaw - GPIOPinConfigure(GPIO_PB2_T3CCP0); //Roll + yaw - GPIOPinTypeTimer(GPIO_PORTB_BASE, (GPIO_PIN_6|GPIO_PIN_4|GPIO_PIN_0|GPIO_PIN_2)); //Prescale the timers so they are slow enough to work with the ESC TimerPrescaleSet(TIMER0_BASE,TIMER_A,2); TimerPrescaleSet(TIMER1_BASE,TIMER_A,2); TimerPrescaleSet(TIMER2_BASE,TIMER_A,2); TimerPrescaleSet(TIMER3_BASE,TIMER_A,2); //Basic LED Out Test Not sure why this is here look into This just turns on an LED that I don't have plugged in. should remove later GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3,0xFF); //GPIOPinTypeGPIOOutputOD(GPIO_PORTB_BASE,GPIO_PIN_0); //Timers Setup for PWM and the load for the countdown TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM); TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod -1); TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM); TimerLoadSet(TIMER1_BASE, TIMER_A, ulPeriod -1); TimerConfigure(TIMER2_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM); TimerLoadSet(TIMER2_BASE, TIMER_A, (ulPeriod -1)); TimerConfigure(TIMER3_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM); TimerLoadSet(TIMER3_BASE, TIMER_A, ulPeriod -1); //TimerPrescaleSet(TIMER2_BASE, TIMER_A, extender1); //TimerLoadSet(TIMER2_BASE, TIMER_A, period1); //Set the match which is when the thing will pull high TimerMatchSet(TIMER0_BASE, TIMER_A, 254); //Duty cycle = (1-%desired)*1000 note this means this number is percent low not percent high TimerMatchSet(TIMER1_BASE, TIMER_A, 254); TimerMatchSet(TIMER2_BASE, TIMER_A, 254); TimerMatchSet(TIMER3_BASE, TIMER_A, 254); //TimerPrescaleMatchSet(TIMER2_BASE, TIMER_A, extender2); //TimerMatchSet(TIMER2_BASE, TIMER_A, period2); //Enable the timers TimerEnable(TIMER0_BASE, TIMER_A); TimerEnable(TIMER1_BASE, TIMER_A); TimerEnable(TIMER2_BASE, TIMER_A); TimerEnable(TIMER3_BASE, TIMER_A); /********************************************************************************************** * onboard Chip interrupt Initialization *********************************************************************************************/ //These two buttons are used to reset the bluetooth module in case of disconnection GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); //RGB LED's GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x00); HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD; //Sw1 (PF4) is unaviable unless you make it only a GPIOF input via these commands HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x1; GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_0|GPIO_PIN_4); //Onboard buttons (PF0=Sw2,PF4=Sw1 GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_4, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); //This will make the buttons falling edge (a press pulls them low) //void (*functionPtr)(void) = &onBoardInteruptHandle; GPIOPortIntRegister(GPIO_PORTF_BASE, onBoardInteruptHandle); //set function to handle interupt GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_0|GPIO_PIN_4,GPIO_FALLING_EDGE); //Set the interrupt as falling edge GPIOPinIntEnable(GPIO_PORTF_BASE,GPIO_PIN_0|GPIO_PIN_4); //Enable the interrupt //IntMasterEnable(); IntEnable(INT_GPIOF); /********************************************************************************************** * UART Initialization *********************************************************************************************/ //Unlock PD7 HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD; HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0x80; GPIOPinConfigure(GPIO_PD7_U2TX); //Set PD7 as TX GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_7); GPIOPinConfigure(GPIO_PD6_U2RX); //Set PD6 as RX GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6); UARTConfigSetExpClk(UART2_BASE,SysCtlClockGet(),115200,UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE); //I believe the Xbee defaults to no parity I do know it's 9600 baud though, changed to 115200 for bluetooth reasons UARTFIFOLevelSet(UART2_BASE,UART_FIFO_TX1_8,UART_FIFO_RX1_8); //Set's how big the fifo needs to be in order to call the interrupt handler, 2byte UARTIntRegister(UART2_BASE,Uart2IntHandler); //Regiester the interrupt handler UARTIntClear(UART2_BASE, UART_INT_TX | UART_INT_RX); //Clear the interrupt UARTIntEnable(UART2_BASE, UART_INT_TX | UART_INT_RX); //Enable the interrupt to trigger on both TX and RX event's. Could possibly remove TX UARTEnable(UART2_BASE); //Enable UART IntEnable(INT_UART2); //Second way to enable handler not sure if needed using anyway /********************************************************************************************** * I2C Initialization *********************************************************************************************/ //Serious credit to the man who made the Arduino version of this. he gave me addresses and equations. Sadly Arduino obfuscates what really is happening //Link posted on blog page //gyro address = 0x68 not 0x69 GPIOPinConfigure(GPIO_PA7_I2C1SDA); GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7); //Set GPA7 as SDA GPIOPinConfigure(GPIO_PA6_I2C1SCL); GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6); //Set GPA6 as SCL I2CMasterInitExpClk(I2C1_MASTER_BASE,SysCtlClockGet(),false); //I think it operates at 100kbps I2CMasterEnable(I2C1_MASTER_BASE); //Initalize the accelerometer Address = 0x53 GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x02); UARTSend(0xAB); I2CTransmit(0x53,0x2D,0x00); I2CTransmit(0x53,0x2D,0x10); I2CTransmit(0x53,0x2D,0x08); //Initalize the gyroscope Address = 0x68 I2CTransmit(0x68,0x3E,0x00); I2CTransmit(0x68,0x15,0x07); I2CTransmit(0x68,0x16,0x1E); I2CTransmit(0x68,0x17,0x00); UARTSend(0xAC); /********************************************************************************************** * SysTick Initialization *********************************************************************************************/ SysTickIntRegister(SysTickIntHandler); SysTickIntEnable(); SysTickPeriodSet((SysCtlClockGet() / (1000 * 3))*timeBetweenCalculations); //This sets the period for the delay. the last num is the num of milliseconds SysTickEnable(); /********************************************************************************************** * Watchdog Initialization *********************************************************************************************/ WatchdogReloadSet(WATCHDOG_BASE, 0xFEEFEEFF); //Set the timer for a reset WatchdogIntRegister(WATCHDOG_BASE,WatchdogIntHandler); //Enable interrupt WatchdogIntClear(WATCHDOG_BASE); WatchdogIntEnable(WATCHDOG_BASE); WatchdogEnable(WATCHDOG_BASE); //Enable the actual timer IntEnable(INT_WATCHDOG); /********************************************************************************************** * Preflight motor inialization maybe not necessary not going to test *********************************************************************************************/ PWMSet(TIMER0_BASE,998); PWMSet(TIMER1_BASE,998); PWMSet(TIMER2_BASE,998); PWMSet(TIMER3_BASE,998); recievedCommands[0]=253; SysCtlDelay((SysCtlClockGet() / (1000 * 3))*100); //Very important to ensure motor see's a start high (998 makes 0 sense but it works so shhhh don't tell anyone) GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x06); while(1){ WatchdogReloadSet(WATCHDOG_BASE, 0xFEEFEEFF); //Feed the dog a new time //UARTSend(recievedCommands[0]); //SysCtlDelay(50000); //Set 4 PWM Outputs //Get Acc data I2CRead(0x53,0x32,6,quadAcc); //Address blah blah 2 for each axis rawAccToG(quadAcc,RwAcc); /*GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x04); //Blue //Get Gyro data /************************************** Gyro ITG-3200 I2C registers: temp MSB = 1B, temp LSB = 1C x axis MSB = 1D, x axis LSB = 1E y axis MSB = 1F, y axis LSB = 20 z axis MSB = 21, z axis LSB = 22 *************************************/ I2CRead(0x68,0x1B,8,quadGyro); //Address blah blah 2 for each axis + 2 for temperature. why. because why not rawGyroToDegsec(quadGyro,Gyro_ds); //GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x02); //Red //Get the actual angles in XYZ. Store them in RwEst //getInclination(RwAcc, RwEst, RwGyro, Gyro_ds, Awz); //After this function is called RwEst will hold the roll pitch and yaw //RwEst will be returned in PITCH, ROLL, YAW 0, 1, 2 remember this order very important. Little obvious but yaw is worthless /*if(RwEst[1]>0.5){ GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x06); //Red Blue, Correct data read in }else{ GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x0A); //Red Green, The correct data is not there }*/ /*GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x06); //Red Blue, Correct data read in float test=RwAcc[0]*100; //These two commands work char temp = (char)test; //UARTSend((char)(RwAcc[0])*100); //This one does not UARTSend(temp); //UARTSend((char)(RwAcc[1])*100); UARTSend(0xAA); SysCtlDelay((SysCtlClockGet() / (1000 * 3))*1); */ } }
void prvSetupHardware( void ){ tBoolean found; long lEEPROMRetStatus; unsigned short data,data2; unsigned long uart_speed; /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. This is a workaround to allow the PLL to operate reliably. */ if( DEVICE_IS_REVA2 ) { SysCtlLDOSet( SYSCTL_LDO_2_75V ); } /* Set the clocking to run from the PLL at 50 MHz */ SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ ); /* Enable Port F for Ethernet LEDs LED0 Bit 3 Output LED1 Bit 2 Output */ SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOF ); GPIODirModeSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3), GPIO_DIR_MODE_HW ); GPIOPadConfigSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD ); // // Enable the GPIO pin for the LED (PF0). Set the direction as output, and // enable the GPIO pin for digital function. // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); // // Enable processor interrupts. // IntMasterEnable(); if(SoftEEPROMInit(0x1F000, 0x20000, 0x800) != 0) { LWIPDebug("SoftEEPROM initialisation failed."); } lEEPROMRetStatus = SoftEEPROMRead(UART0_SPEED_HIGH_ID, &data, &found); if(lEEPROMRetStatus == 0 && found) { SoftEEPROMRead(UART0_SPEED_LOW_ID, &data2, &found); uart_speed = (data << 16 & 0xFFFF0000) | (data2 & 0x0000FFFF); SoftEEPROMRead(UART0_CONFIG_ID, &data, &found); } else { uart_speed=115200; data = (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); } uart_init(0, uart_speed, data); SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); IntPriorityGroupingSet(4); IntPrioritySet(INT_WATCHDOG,SET_SYSCALL_INTERRUPT_PRIORITY(5)); IntEnable(INT_WATCHDOG); // Enable the watchdog interrupt. WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()); WatchdogResetEnable(WATCHDOG0_BASE); WatchdogEnable(WATCHDOG0_BASE); rtc_init(); modules_init(); }
int main() { KernelInit(); SchedulerStartup(); SetupPipe(MessageBuffer1, &Pipe1, &ProducerContext1, &ConsumerContext1, 1, 2); SetupPipe(MessageBuffer2, &Pipe2, &ProducerContext2, &ConsumerContext2, 3, 4); SetupPipe(MessageBuffer3, &Pipe3, &ProducerContext3, &ConsumerContext3, 5, 6); SchedulerCreateThread( &Producer1, QUANTUM, ProducerStack1, STACK_SIZE, ProducerMain, & ProducerContext1, TRUE ); SchedulerCreateThread( &Producer2, QUANTUM, ProducerStack2, STACK_SIZE, ProducerMain, & ProducerContext2, TRUE ); SchedulerCreateThread( &Producer3, QUANTUM, ProducerStack3, STACK_SIZE, ProducerMain, & ProducerContext3, TRUE ); SchedulerCreateThread( &Consumer1, QUANTUM, ConsumerStack1, STACK_SIZE, ConsumerMain, & ConsumerContext1, TRUE ); SchedulerCreateThread( &Consumer2, QUANTUM, ConsumerStack2, STACK_SIZE, ConsumerMain, & ConsumerContext2, TRUE ); SchedulerCreateThread( &Consumer3, QUANTUM, ConsumerStack3, STACK_SIZE, ConsumerMain, & ConsumerContext3, TRUE ); WatchdogEnable( TIMEOUT ); KernelStart(); return 0; }
//***************************************************************************** // //! \brief xwdt001 test execute main body. //! //! \return None. // //***************************************************************************** static void xwdt001Execute(void) { unsigned long i = 0; unsigned long tmp = 0; unsigned long WdtBase = 0; // // Reset Enable/Disable Test // for(i = 0; i < WDT_NUM; i++) { WdtBase = WdtBaseTbl[i]; // // Reset Enable Test // if(WdtBase == WATCHDOG1_BASE) { Watchdog1WriteSync(); } WatchdogResetEnable(WdtBase); tmp = xHWREG(WdtBase + WDT_O_CTL) & WDT_CTL_RESEN; TestAssert((0 != tmp), "WDT Test 001: Res%set Enable Failed"); // // Reset Disable Test // if(WdtBase == WATCHDOG1_BASE) { Watchdog1WriteSync(); } WatchdogResetDisable(WdtBase); tmp = xHWREG(WdtBase + WDT_O_CTL) & WDT_CTL_RESEN; TestAssert((0 == tmp), "WDT Test 001: Reset Disable Failed"); } // // Lock/Unlock/GetState Test // for(i = 0; i < WDT_NUM; i++) { WdtBase = WdtBaseTbl[i]; // // Lock Test // if(WdtBase == WATCHDOG1_BASE) { Watchdog1WriteSync(); } WatchdogLock(WdtBase); tmp = xHWREG(WdtBase + WDT_O_LOCK); TestAssert((tmp == WDT_LOCK_LOCKED), "WDT Test 001: Lock Failed"); // // Get Lock State Test // tmp = WatchdogLockState(WdtBase); TestAssert((tmp == xtrue), "WDT Test 001: Get Lock State Failed"); // // Unlock Test // if(WdtBase == WATCHDOG1_BASE) { Watchdog1WriteSync(); } WatchdogUnlock(WdtBase); tmp = xHWREG(WdtBase + WDT_O_LOCK); TestAssert((tmp == WDT_LOCK_UNLOCKED), "WDT Test 001: Unlock Failed"); // // Get Lock State Test // tmp = WatchdogLockState(WdtBase); TestAssert((tmp == xfalse), "WDT Test 001: Get Lock State Failed"); } // // Reload Set/Get Test // for(i = 0; i < 1; i++) { unsigned long j = 0; unsigned long TblSize = 0; WdtBase = WdtBaseTbl[i]; TblSize = sizeof(ReloadValueTbl) / sizeof(ReloadValueTbl[0]); for(j = 0; j < TblSize; j++) { // // Reload Set Test // if(WdtBase == WATCHDOG1_BASE) { Watchdog1WriteSync(); } WatchdogReloadSet(WdtBase, ReloadValueTbl[j]); tmp = xHWREG(WdtBase + WDT_O_LOAD); TestAssert((ReloadValueTbl[j] == tmp), "WDT Test 001: Wdt Reload Set Failed"); // // Reload Get Test // tmp = WatchdogReloadGet(WdtBase); TestAssert((ReloadValueTbl[j] == tmp), "WDT Test 001: Wdt Reload Get Failed"); } } // // Stall Enable/Disable Test // for(i = 0; i < WDT_NUM; i++) { WdtBase = WdtBaseTbl[i]; // // Stall Enable Test // if(WdtBase == WATCHDOG1_BASE) { Watchdog1WriteSync(); } WatchdogStallEnable(WdtBase); tmp = xHWREG(WdtBase + WDT_O_TEST) & WDT_TEST_STALL; TestAssert((0 != tmp), "WDT Test 001: Stall Enable Failed"); // // Stall Disable Test // if(WdtBase == WATCHDOG1_BASE) { Watchdog1WriteSync(); } WatchdogStallDisable(WdtBase); tmp = xHWREG(WdtBase + WDT_O_TEST) & WDT_TEST_STALL; TestAssert((0 == tmp), "WDT Test 001: Stall Disable Failed"); } // // Enable/Running Test // for(i = 0; i < WDT_NUM; i++) { WdtBase = WdtBaseTbl[i]; // // Enable Test // WatchdogEnable(WdtBase); tmp = xHWREG(WdtBase + WDT_O_CTL) & WDT_CTL_INTEN; TestAssert((0 != tmp), "WDT Test 001: Enable Failed"); // // IsRunning Test // tmp = WatchdogRunning(WdtBase); TestAssert((0 != tmp), "WDT Test 001: IsRunning Failed"); } }