-/* Copyright (C) 2013 Czech Technical University in Prague
+/* Copyright (C) 2013, 2015 Czech Technical University in Prague
*
* Authors:
* - Carlos Jenkins <carlos@jenkins.co.cr>
#ifndef FREERTOS_POSIX
#include "drv/drv.h"
+#include "drv/port.h"
-// RPP has 12 ADC channels
-// See s_adcSelect and s_adcFiFoSize in ti_drv_adc.c for hardware configuration.
-#define ADC_CHANNELS 16
-static adcData_t in_cache[ADC_CHANNELS];
+static uint16_t in_cache[PORT_ADC_CHANNELS];
#endif
static boolean_t initialized = FALSE;
int16_t rpp_adc_get(uint8_t pin)
{
- if ((pin < 1) || (pin > 16))
+ if ((pin < 1) || (pin > PORT_ADC_CHANNELS))
return -1;
int16_t result = 0;
#ifndef FREERTOS_POSIX
// This conversion uint16_t -> int16_t is safe because we know values
// are 12bits. Here we are masking those 12bits just in case.
- result = (int16_t)(in_cache[pin - 1].value & 0xFFF);
+ result = in_cache[pin - 1] & 0xFFF;
#endif
return result;
int8_t rpp_adc_update()
{
#ifndef FREERTOS_POSIX
- // in_cache is thread safe because it's only write operation is mutexed
- drv_adc_read_adc((adcData_t *)&in_cache);
+ const struct port_desc *port = &port_desc[PORT_ID_ADC];
+ port->get(port, in_cache, sizeof(in_cache));
#endif
return SUCCESS;