Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. inline uint16_t my_adc_start(uint32_t adc, uint32_t flags)
  2. {
  3. ADC_CR(adc)=flags | ADC_CR_CLKDIV((uint8_t)(208/4.5))|ADC_CR_10BITS|ADC_CR_POWER|ADC_CR_START;
  4. }
  5.  
  6. /* from libopencm3, we copy it here to have it inlined */
  7. inline uint16_t my_adc_get_single(uint32_t adc, uint32_t flags)
  8. {
  9. uint32_t result;
  10.  
  11. do {
  12. result=ADC_GDR(adc);
  13. } while( (!ADC_DR_DONE(result)) );
  14.  
  15. uint16_t adc_value = ADC_DR_VREF(result);
  16.  
  17. my_adc_start(adc, flags);
  18.  
  19. return adc_value;
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement