1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * This document contains proprietary information belonging to Czech
7 * Technical University in Prague. Passing on and copying of this
8 * document, and communication of its contents is not permitted
9 * without prior written authorization.
13 * Analog Input RPP API implementation file.
17 * RPP API documentation.
23 #if rppCONFIG_DRV == 1
26 // RPP has 12 ADC channels
27 // See s_adcSelect and s_adcFiFoSize in ti_drv_adc.c for hardware configuration.
28 #define ADC_CHANNELS 12
29 static adcData_t in_cache[ADC_CHANNELS];
32 static boolean_t initialized = FALSE;
41 #if rppCONFIG_DRV == 1
49 int16_t rpp_adc_get(uint8_t pin)
51 if((pin < 1) || (pin > 12)) {
57 #if rppCONFIG_DRV == 1
58 // This conversion uint16_t -> int16_t is safe because we know values
59 // are 12bits. Here we are masking those 12bits just in case.
60 result = (int16_t) (in_cache[pin - 1].value & 0xFFF);
67 int8_t rpp_adc_update()
69 #if rppCONFIG_DRV == 1
70 // in_cache is thread safe because it's only write operation is mutexed
71 drv_adc_read_adc((adcData_t*)&in_cache);