Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years ago.
query regarding function definition
can I get the definition of the function "analogin_read_u16(&_adc)"?
2 Answers
12 years ago.
Hello prasanna hegde,
for what platform do you need a definition? Here's a code from KLxx platforms (KL25Z for example):
uint16_t analogin_read_u16(analogin_t *obj) {
// start conversion
ADC0->SC1[0] = ADC_SC1_ADCH(obj->adc & ~(1 << CHANNELS_A_SHIFT));
// Wait Conversion Complete
while ((ADC0->SC1[0] & ADC_SC1_COCO_MASK) != ADC_SC1_COCO_MASK);
// Return value
return (uint16_t)ADC0->R[0];
}
Thsi code is available in the online compiler (mbed-src) or on github https://github.com/mbedmicro/mbed.
Regards,
0xc0170
12 years ago.
It returns an unsigned 16 bit value for the analog input specified, exactly how it does that will depend on the platform you are using. The whole point of the mbed API is that you shouldn't need to worry about what's going on after that point, if you need more control than the API gives you then you may need to fall back to accessing the platform specific CPU registers.