/* The handler for the GPIOPortB Pin4, Pin5 & Pin6 state change interrupt. */ void portBIntHandler(void) { //clear the interrupt GPIOPinIntClear (GPIO_PORTB_BASE, (GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6)); int button; //Read the state of the pins //Select icon clicked to start/stop heli if (!GPIOPinRead( GPIO_PORTB_BASE, GPIO_PIN_4 )) { xSemaphoreGiveFromISR( xBinarySelectSemaphore, pdFALSE ); } //Up icon clicked if (!GPIOPinRead( GPIO_PORTB_BASE, GPIO_PIN_5 )) { button = UP; xQueueSendFromISR( xButtonQueue, &button, NULL ); } //Down icon clicked if (!GPIOPinRead( GPIO_PORTB_BASE, GPIO_PIN_6 )) { button = DOWN; xQueueSendFromISR( xButtonQueue, &button, NULL ); } //Reset icon clicked if (!GPIOPinRead( GPIO_PORTB_BASE, GPIO_PIN_1 )) { SysCtlReset(); } }
void USBDFUTriggerDevice::beginUpdate() { vTaskSuspendAll(); //USBDDFUUpdateBegin(); uint32_t *x = (uint32_t*)0x20017FFC; *x = 0x23422342; SysCtlReset(); }
void ButtPressIntHandler (void) { unsigned long ulSelect; //SELECT unsigned long ulUp; //UP unsigned long ulDown; //DOWN unsigned long ulCCw; //CCW/RIGHT unsigned long ulCw; //CW/LEFT unsigned long ulReset; //RESET //int power = 0; // Clear the interrupt (documentation recommends doing this early) GPIOPinIntClear (GPIO_PORTB_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6); // Read the pins simultaneously to ensure the right states are read ulReset = GPIOPinRead (GPIO_PORTB_BASE, GPIO_PIN_1); ulCw = GPIOPinRead (GPIO_PORTB_BASE, GPIO_PIN_2); ulCCw = GPIOPinRead (GPIO_PORTB_BASE, GPIO_PIN_3); ulSelect = GPIOPinRead (GPIO_PORTB_BASE, GPIO_PIN_4); ulUp = GPIOPinRead (GPIO_PORTB_BASE, GPIO_PIN_5); ulDown = GPIOPinRead (GPIO_PORTB_BASE, GPIO_PIN_6); // Compute the PWM period in terms of the PWM clock period = SysCtlClockGet () / PWM_DIVIDER / MOTOR_RATE_HZ; if(ulUp == 0){// && main_duty < 98){ //main_duty += 10; //if (main_duty >= 98) main_duty = 98; //PWMPulseWidthSet (PWM_BASE, PWM_OUT_1, period * main_duty /100); desiredHeight += 10; } //Might have to change the duty cycle down here if(ulDown == 0){// && main_duty > 10){ //main_duty -= 10; //if (main_duty <= 10) main_duty = 10; //PWMPulseWidthSet (PWM_BASE, PWM_OUT_1, period * main_duty /100); desiredHeight -= 10; } if(ulCw == 0){// && tail_duty < 98){ //tail_duty += 15; //if (tail_duty >= 98) tail_duty = 98; //PWMPulseWidthSet (PWM_BASE, PWM_OUT_4, period * tail_duty /100); desiredYaw += 15; } if(ulCCw == 0){// && tail_duty > 10){ //tail_duty -= 15; //if (tail_duty <= 10) tail_duty = 10; //PWMPulseWidthSet (PWM_BASE, PWM_OUT_4, period * tail_duty /100); desiredYaw -= 15; } if(ulSelect == 0 && state == 0){ main_duty = MOTOR_DUTY_MAIN; tail_duty = MOTOR_DUTY_TAIL; PWMOutputState (PWM_BASE, PWM_OUT_1_BIT, true); PWMOutputState (PWM_BASE, PWM_OUT_4_BIT, true); PWMPulseWidthSet (PWM_BASE, PWM_OUT_1, period * main_duty /100); PWMPulseWidthSet (PWM_BASE, PWM_OUT_4, period * tail_duty /100); state = 1; } /*if(ulSelect == 0 && state == 1){ PWMOutputState (PWM_BASE, PWM_OUT_1_BIT, false); PWMOutputState (PWM_BASE, PWM_OUT_4_BIT, false); state = 0; }*/ if(ulReset == 0){ if (!ulReset) SysCtlReset(); } }
main() { SysCtlClockSet(SYSCTL_SYSDIV_2_5| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ); IntMasterEnable(); Uart0Init(19200); Uart1Init(19200); DPRINTF(("Bat=%d ,cha=%x ,Temp=%f \n",1,20,3.0)); // ADCBAT_init(); // Ssi0Init(); //AD7367 //spi_ad7705Init(); //AD7705 IoPortInit(); //IO口初始化 // I2CM_Init(); //Fm31256 //TimerInit(); PIN_JR_relay(ERelay_off); PIN_JRTG_relay(ERelay_off); PIN_JUNX_relay(ERelay_off); PIN_JUN_relay(ERelay_off); PIN_JUX_relay(ERelay_off); FlashUsecSet(49); AD7367_init(); AD7705_init(); // PIN_JR_relay(ERsample_1M); /* { uint32 i; set.Debug=EDebug_sub; set.Fre=EFre_500; gainchange(); Vac_read(); for(i=0;i<500;i++) { Fourier_Samplestart(); ; delay(0xf000*200); } } */ /* { uint32 i; set.Debug=EDebug_sub; set.Fre=EFre_000; V_read(); for(i=0;i<50;i++) { DPRINTF(("I=%x \n",Read_ad7705_I(0x07,1))); } for(i=0;i<50;i++) { DPRINTF(("U=%x \n",Read_ad7705_U(0x07,1))); } for(i=0;i<500;i++) { R_test(); delay(0xf000*200); } } */ modifyK_js(); rx_flag=0; while(1) { // uint8 option=0; if((rx_flag==rx_succeed)) { Sendstc_ask(); set.Work=0x0f&rx_data.mune.workcommand; set.Debug=0x0f&(rx_data.mune.workcommand>>4); set.Fre=rx_data.mune.Fre; set.Voltage=rx_data.mune.Voltage; rx_flag=0x00; switch(set.Work) { case EstartV_main: V_read(); break; case EstartTg_main://AC Fourier_Samplestart(); PIN_JRTG_relay(ERelay_off); PIN_JUNX_relay(ERelay_off); PIN_JUN_relay(ERelay_off); PIN_JUX_relay(ERelay_off); break; case EstartR_main://DC R_test(); PIN_JRTG_relay(ERelay_off); break; case Emodifyin_main: modify_save(); modifyK_js(); //DPRINTF(("In \n")); break; case Emodifyout_main : delay(0x80000); modify_ToView(); modifyK_js(); //DPRINTF(("out \n")); break; case EstartX_main : Vacx_read(); break; case ERelay_main: PIN_JRTG_relay(ERelay_on); PIN_JR_relay(ERsample_50); break; default : SysCtlReset(); break; } if((rx_flag==rx_succeed)) { if(set.Work==0x0f&rx_data.mune.workcommand) { rx_flag=0; } } } }
void bsp_reboot(void) { SysCtlReset(); }
void Restart(void) { SysCtlReset(); }