SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #if 1
  2.     float volts;
  3.     float adcresult;
  4.     void blink();
  5.     void adc();
  6.     int zmain (void)
  7.     {
  8.     adc();
  9.        
  10.      while(true)
  11.     {
  12.      if(volts <=4)
  13.     {
  14.         blink();
  15.         if(SW1_Read() == 1)
  16.         {
  17.         adc();
  18.         break;
  19.         }
  20.         else
  21.         adc();
  22.     }
  23.     }
  24.     return 0;
  25.     }
  26.    
  27. #endif
  28. void adc()
  29. {
  30.      float volts=0.0;
  31.      ADC_Battery_Start();
  32.      int16 adcresult =0;
  33.      ADC_Battery_StartConvert(); // start sampling
  34.      if(ADC_Battery_IsEndConversion(ADC_Battery_WAIT_FOR_RESULT))   // wait for ADC converted value
  35.      volts = adcresult/4095*6.75;
  36.     }
  37. void blink()
  38. {
  39.     BatteryLed_Write(1);
  40.     vTaskDelay(500);
  41.     BatteryLed_Write(0);
  42.     vTaskDelay(500);
  43. }
  44.  
  45.    
  46.  
  47. /* [] END OF FILE */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top