target_or_common = $(if $(wildcard ../../../$(dir $(1))/_$(TARGET)/$(notdir $(1))),$(dir $(1))/_$(TARGET)/$(notdir $(1)),$(1))
rpp_lib_SOURCES += \
- rpp/src/rpp/_$(TARGET)/adc.c \
+ rpp/src/rpp/adc.c \
rpp/src/rpp/can.c \
rpp/src/rpp/gio.c \
rpp/src/rpp/sci.c \
- rpp/src/drv/_$(TARGET)/adc.c \
+ rpp/src/drv/adc.c \
rpp/src/drv/_$(TARGET)/port_def.c \
rpp/src/drv/gio.c \
rpp/src/drv/gio_tab.c \
#ifndef DRV_TGT_PORT_DEF_H
#define DRV_TGT_PORT_DEF_H
+#include <stdint.h>
+
/* Port names */
enum port_id {
PORT_ID_GIOA,
_PORT_COUNT,
};
+#define PORT_ADC_CHANNELS 16
+
+static double port_adc_lsb2volts(uint16_t lsb)
+{
+ return ((double)lsb + 0.0)*2.5/4095*2;
+}
+
#endif
#ifndef DRV_TGT_PORT_DEF_H
#define DRV_TGT_PORT_DEF_H
+#include <stdint.h>
+
/* Port names */
enum port_id {
PORT_ID_GIOA,
_PORT_COUNT,
};
+#define PORT_ADC_CHANNELS 16
+
+static double port_adc_lsb2volts(uint16_t lsb)
+{
+ return ((double)lsb + 0.0)*2.5/4095*2;
+}
+
#endif
#ifndef DRV_TGT_PORT_DEF_H
#define DRV_TGT_PORT_DEF_H
+#include <stdint.h>
+
/* Port names */
enum port_id {
PORT_ID_GIOA,
_PORT_COUNT,
};
+#define PORT_ADC_CHANNELS 16
+
+static double port_adc_lsb2volts(uint16_t lsb)
+{
+ return ((double)lsb + 0.0)*2.5/4095*2;
+}
+
#endif
#ifndef _TMS570_RPP_PORT_DEF_H
#define _TMS570_RPP_PORT_DEF_H
+#include <stdint.h>
+
/* Port names */
enum port_id {
PORT_ID_DINMCU,
_PORT_COUNT,
};
+#define PORT_ADC_CHANNELS 12
+
+static double port_adc_lsb2volts(uint16_t lsb)
+{
+ return ((double)lsb + 0.0)*2.5/4095*10;
+}
+
#endif
#define ADC_MAX_CHANNELS 24
void drv_adc_init();
-uint32_t drv_adc_read_adc(adcData_t *data);
-#ifdef TARGET_TMS570_RPP
-uint32_t drv_adc_read_houtifbk(adcData_t *data);
-#endif
-
-uint32_t adc_get_port_val(uint32_t *config, uint32_t num_channels,
- uint32_t *values);
int8_t port_adc_get(const struct port_desc *port, void *values, size_t size);
#endif /* __DRV_ADC_H */
struct {
adcBASE_t *reg;
uint32_t group;
- uint32_t sem; /* TODO: Remove this. This is the same information as group. */
} adc;
gioPORT_t *gio_reg;
} cfg;
+++ /dev/null
-/* Copyright (C) 2012-2013 Czech Technical University in Prague
- *
- * Authors:
- * - Michal Horn
- * - Carlos Jenkins <carlos@jenkins.co.cr>
- *
- * This document contains proprietary information belonging to Czech
- * Technical University in Prague. Passing on and copying of this
- * document, and communication of its contents is not permitted
- * without prior written authorization.
- *
- * File : adc.c
- * Abstract:
- * RPP driver implementation for ADC.
- *
- * References:
- * ti_drv_adc.c
- */
-
-
-#include "drv/drv.h"
-
-// Binary semaphore for ADC1 GRP1 conversion (AIN)
-xSemaphoreHandle adcSemaphore_ADC1GRP1;
-// Binary semaphore for ADC2 GRP1 conversion (HOUT-IFBK)
-xSemaphoreHandle adcSemaphore_ADC2GRP1;
-
-// Mutex for AIN read control
-xSemaphoreHandle adcMutex_ADC;
-
-void drv_adc_init()
-{
- // Create semaphores
- vSemaphoreCreateBinary(adcSemaphore_ADC1GRP1);
- xSemaphoreTake(adcSemaphore_ADC1GRP1, 0);
- vSemaphoreCreateBinary(adcSemaphore_ADC2GRP1);
- xSemaphoreTake(adcSemaphore_ADC2GRP1, 0);
-
- adcMutex_ADC = xSemaphoreCreateMutex();
-
- // Low level init
- adcInit();
-}
-
-
-/**
- * ADC notification called by ADC conversion finished ISR.
- *
- * This procedure will just give semaphore.
- *
- * @param[in] adc Pointer to ADC module:
- * - adcREG1: ADC1 module pointer
- * - adcREG2: ADC2 module pointer
- * @param[in] group Hardware group of ADC module:
- * - adcGROUP0: ADC event group
- * - adcGROUP1: ADC group 1
- * - adcGROUP2: ADC group 2
- */
-void adcNotification(adcBASE_t *adc, uint32_t group)
-{
- if (adcIsConversionComplete(adc, group) == ADC_CONVERSION_IS_FINISHED) {
-
- // ADC1
- if (adc == adcREG1) {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- // According to FreeRTOS documentation second parameter is
- // optional (and can be set to NULL) from FreeRTOS
- // V7.3.0. We are using 7.0.2. I confirmed this in the
- // source code: src/os/queue.c line 821. - Carlos
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC1GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- // ADC2
- }
- else {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC2GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- }
- }
-}
-
-
-uint32_t drv_adc_generic_read(adcBASE_t *adc, uint32_t group,
- xSemaphoreHandle adcSemaphore, adcData_t *data)
-{
- // Calibrate
- adcCalibration(adc);
- adcMidPointCalibration(adc);
-
- // Start conversion
- adcEnableNotification(adc, group);
- adcStartConversion(adc, group);
-
- // Wait for conversion to complete
- xSemaphoreTake(adcSemaphore, portMAX_DELAY);
- adcDisableNotification(adc, group);
-
- // Get data
- uint32_t channels = adcGetData(adc, group, data);
-
- // Check if memory overrun
- if (adcIsFifoFull(adc, group) == ADC_FIFO_OVERFLOW)
- // FIXME Should report somehow.
- adcResetFiFo(adc, group);
-
- return channels;
-}
-
-
-uint32_t drv_adc_read_adc(adcData_t *data)
-{
- xSemaphoreTake(adcMutex_ADC, portMAX_DELAY);
- uint32_t result = drv_adc_generic_read(
- adcREG1,
- adcGROUP1,
- adcSemaphore_ADC1GRP1,
- data
- );
- xSemaphoreGive(adcMutex_ADC);
- return result;
-}
-
-uint32_t adc_get_port_val(uint32_t *config, uint32_t num_channels,
- uint32_t *values)
-{
- uint32_t i;
- adcBASE_t *adcReg = (adcBASE_t *)config[0];
- uint32_t adcGroup = config[1];
- uint32_t adcSemaphore = config[2];
- adcData_t data[ADC_MAX_CHANNELS];
-
- drv_adc_generic_read(
- adcReg,
- adcGroup,
- (adcSemaphore == 1) ? adcSemaphore_ADC1GRP1 : adcSemaphore_ADC2GRP1,
- data
- );
-
- for (i = 0; i < num_channels; i++) {
- values[i] = data[i].value;
- values[i+num_channels] = data[i].id;
- }
-
- return 0;
-}
},
[PORT_ID_ADC] = {
.name = "ADC",
- .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1, .sem = 1 } },
- .numchn = 16,
+ .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1 } },
+ .numchn = PORT_ADC_CHANNELS,
.bpch = 16,
.get = port_adc_get,
.set = NULL,
+++ /dev/null
-/* Copyright (C) 2012-2013 Czech Technical University in Prague
- *
- * Authors:
- * - Michal Horn
- * - Carlos Jenkins <carlos@jenkins.co.cr>
- *
- * This document contains proprietary information belonging to Czech
- * Technical University in Prague. Passing on and copying of this
- * document, and communication of its contents is not permitted
- * without prior written authorization.
- *
- * File : adc.c
- * Abstract:
- * RPP driver implementation for ADC.
- *
- * References:
- * ti_drv_adc.c
- */
-
-
-#include "drv/drv.h"
-
-// Binary semaphore for ADC1 GRP1 conversion (AIN)
-xSemaphoreHandle adcSemaphore_ADC1GRP1;
-// Binary semaphore for ADC2 GRP1 conversion (HOUT-IFBK)
-xSemaphoreHandle adcSemaphore_ADC2GRP1;
-
-// Mutex for AIN read control
-xSemaphoreHandle adcMutex_ADC;
-
-void drv_adc_init()
-{
- // Create semaphores
- vSemaphoreCreateBinary(adcSemaphore_ADC1GRP1);
- xSemaphoreTake(adcSemaphore_ADC1GRP1, 0);
- vSemaphoreCreateBinary(adcSemaphore_ADC2GRP1);
- xSemaphoreTake(adcSemaphore_ADC2GRP1, 0);
-
- adcMutex_ADC = xSemaphoreCreateMutex();
-
- // Low level init
- adcInit();
-}
-
-
-/**
- * ADC notification called by ADC conversion finished ISR.
- *
- * This procedure will just give semaphore.
- *
- * @param[in] adc Pointer to ADC module:
- * - adcREG1: ADC1 module pointer
- * - adcREG2: ADC2 module pointer
- * @param[in] group Hardware group of ADC module:
- * - adcGROUP0: ADC event group
- * - adcGROUP1: ADC group 1
- * - adcGROUP2: ADC group 2
- */
-void adcNotification(adcBASE_t *adc, uint32_t group)
-{
- if (adcIsConversionComplete(adc, group) == ADC_CONVERSION_IS_FINISHED) {
-
- // ADC1
- if (adc == adcREG1) {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- // According to FreeRTOS documentation second parameter is
- // optional (and can be set to NULL) from FreeRTOS
- // V7.3.0. We are using 7.0.2. I confirmed this in the
- // source code: src/os/queue.c line 821. - Carlos
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC1GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- // ADC2
- }
- else {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC2GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- }
- }
-}
-
-
-uint32_t drv_adc_generic_read(adcBASE_t *adc, uint32_t group,
- xSemaphoreHandle adcSemaphore, adcData_t *data)
-{
- // Calibrate
- adcCalibration(adc);
- adcMidPointCalibration(adc);
-
- // Start conversion
- adcEnableNotification(adc, group);
- adcStartConversion(adc, group);
-
- // Wait for conversion to complete
- xSemaphoreTake(adcSemaphore, portMAX_DELAY);
- adcDisableNotification(adc, group);
-
- // Get data
- uint32_t channels = adcGetData(adc, group, data);
-
- // Check if memory overrun
- if (adcIsFifoFull(adc, group) == ADC_FIFO_OVERFLOW)
- // FIXME Should report somehow.
- adcResetFiFo(adc, group);
-
- return channels;
-}
-
-
-uint32_t drv_adc_read_adc(adcData_t *data)
-{
- xSemaphoreTake(adcMutex_ADC, portMAX_DELAY);
- uint32_t result = drv_adc_generic_read(
- adcREG1,
- adcGROUP1,
- adcSemaphore_ADC1GRP1,
- data
- );
- xSemaphoreGive(adcMutex_ADC);
- return result;
-}
-
-uint32_t adc_get_port_val(uint32_t *config, uint32_t num_channels,
- uint32_t *values)
-{
- uint32_t i;
- adcBASE_t *adcReg = (adcBASE_t *)config[0];
- uint32_t adcGroup = config[1];
- uint32_t adcSemaphore = config[2];
- adcData_t data[ADC_MAX_CHANNELS];
-
- drv_adc_generic_read(
- adcReg,
- adcGroup,
- (adcSemaphore == 1) ? adcSemaphore_ADC1GRP1 : adcSemaphore_ADC2GRP1,
- data
- );
-
- for (i = 0; i < num_channels; i++) {
- values[i] = data[i].value;
- values[i+num_channels] = data[i].id;
- }
-
- return 0;
-}
},
[PORT_ID_ADC] = {
.name = "ADC",
- .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1, .sem = 1 } },
- .numchn = 16,
+ .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1 } },
+ .numchn = PORT_ADC_CHANNELS,
.bpch = 16,
.get = port_adc_get,
.set = NULL,
+++ /dev/null
-/* Copyright (C) 2012-2013 Czech Technical University in Prague
- *
- * Authors:
- * - Michal Horn
- * - Carlos Jenkins <carlos@jenkins.co.cr>
- *
- * This document contains proprietary information belonging to Czech
- * Technical University in Prague. Passing on and copying of this
- * document, and communication of its contents is not permitted
- * without prior written authorization.
- *
- * File : adc.c
- * Abstract:
- * RPP driver implementation for ADC.
- *
- * References:
- * ti_drv_adc.c
- */
-
-
-#include "drv/drv.h"
-
-// Binary semaphore for ADC1 GRP1 conversion (AIN)
-xSemaphoreHandle adcSemaphore_ADC1GRP1;
-// Binary semaphore for ADC2 GRP1 conversion (HOUT-IFBK)
-xSemaphoreHandle adcSemaphore_ADC2GRP1;
-
-// Mutex for AIN read control
-xSemaphoreHandle adcMutex_ADC;
-
-void drv_adc_init()
-{
- // Create semaphores
- vSemaphoreCreateBinary(adcSemaphore_ADC1GRP1);
- xSemaphoreTake(adcSemaphore_ADC1GRP1, 0);
- vSemaphoreCreateBinary(adcSemaphore_ADC2GRP1);
- xSemaphoreTake(adcSemaphore_ADC2GRP1, 0);
-
- adcMutex_ADC = xSemaphoreCreateMutex();
-
- // Low level init
- adcInit();
-}
-
-
-/**
- * ADC notification called by ADC conversion finished ISR.
- *
- * This procedure will just give semaphore.
- *
- * @param[in] adc Pointer to ADC module:
- * - adcREG1: ADC1 module pointer
- * - adcREG2: ADC2 module pointer
- * @param[in] group Hardware group of ADC module:
- * - adcGROUP0: ADC event group
- * - adcGROUP1: ADC group 1
- * - adcGROUP2: ADC group 2
- */
-void adcNotification(adcBASE_t *adc, uint32_t group)
-{
- if (adcIsConversionComplete(adc, group) == ADC_CONVERSION_IS_FINISHED) {
-
- // ADC1
- if (adc == adcREG1) {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- // According to FreeRTOS documentation second parameter is
- // optional (and can be set to NULL) from FreeRTOS
- // V7.3.0. We are using 7.0.2. I confirmed this in the
- // source code: src/os/queue.c line 821. - Carlos
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC1GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- // ADC2
- }
- else {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC2GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- }
- }
-}
-
-
-uint32_t drv_adc_generic_read(adcBASE_t *adc, uint32_t group,
- xSemaphoreHandle adcSemaphore, adcData_t *data)
-{
- // Calibrate
- adcCalibration(adc);
- adcMidPointCalibration(adc);
-
- // Start conversion
- adcEnableNotification(adc, group);
- adcStartConversion(adc, group);
-
- // Wait for conversion to complete
- xSemaphoreTake(adcSemaphore, portMAX_DELAY);
- adcDisableNotification(adc, group);
-
- // Get data
- uint32_t channels = adcGetData(adc, group, data);
-
- // Check if memory overrun
- if (adcIsFifoFull(adc, group) == ADC_FIFO_OVERFLOW)
- // FIXME Should report somehow.
- adcResetFiFo(adc, group);
-
- return channels;
-}
-
-
-uint32_t drv_adc_read_adc(adcData_t *data)
-{
- xSemaphoreTake(adcMutex_ADC, portMAX_DELAY);
- uint32_t result = drv_adc_generic_read(
- adcREG1,
- adcGROUP1,
- adcSemaphore_ADC1GRP1,
- data
- );
- xSemaphoreGive(adcMutex_ADC);
- return result;
-}
-
-uint32_t adc_get_port_val(uint32_t *config, uint32_t num_channels,
- uint32_t *values)
-{
- uint32_t i;
- adcBASE_t *adcReg = (adcBASE_t *)config[0];
- uint32_t adcGroup = config[1];
- uint32_t adcSemaphore = config[2];
- adcData_t data[ADC_MAX_CHANNELS];
-
- drv_adc_generic_read(
- adcReg,
- adcGroup,
- (adcSemaphore == 1) ? adcSemaphore_ADC1GRP1 : adcSemaphore_ADC2GRP1,
- data
- );
-
- for (i = 0; i < num_channels; i++) {
- values[i] = data[i].value;
- values[i+num_channels] = data[i].id;
- }
-
- return 0;
-}
},
[PORT_ID_ADC] = {
.name = "ADC",
- .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1, .sem = 1 } },
- .numchn = 16,
+ .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1 } },
+ .numchn = PORT_ADC_CHANNELS,
.bpch = 16,
.get = port_adc_get,
.set = NULL,
.bpch = 16,
.get = port_adc_get,
.set = NULL,
- .cfg = { .adc = { .reg = adcREG2, .group = adcGROUP1, .sem = 0 } },
+ .cfg = { .adc = { .reg = adcREG2, .group = adcGROUP1 } },
},
[PORT_ID_ADC] = {
.name = "ADC",
- .numchn = 12,
+ .numchn = PORT_ADC_CHANNELS,
.bpch = 16,
.get = port_adc_get,
.set = NULL,
- .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1, .sem = 1 } },
+ .cfg = { .adc = { .reg = adcREG1, .group = adcGROUP1 } },
},
[PORT_ID_LOUT] = {
.name = "LOUT",
#include "drv/drv.h"
#include "drv/port.h"
-// Binary semaphore for ADC1 GRP1 conversion (AIN)
-xSemaphoreHandle adcSemaphore_ADC1GRP1;
-// Binary semaphore for ADC2 GRP1 conversion (HOUT-IFBK)
-xSemaphoreHandle adcSemaphore_ADC2GRP1;
+// Binary semaphores for finish notifications
+static xSemaphoreHandle sem[2][2];
-// Mutex for AIN read control
-xSemaphoreHandle adcMutex_ADC;
-// Mutex for HOUTIFBK control
-xSemaphoreHandle adcMutex_HOUTIFBK;
+// Mutex for two ADCs
+xSemaphoreHandle mutex[2];
void drv_adc_init()
{
- // Create semaphores
- vSemaphoreCreateBinary(adcSemaphore_ADC1GRP1);
- xSemaphoreTake(adcSemaphore_ADC1GRP1, 0);
- vSemaphoreCreateBinary(adcSemaphore_ADC2GRP1);
- xSemaphoreTake(adcSemaphore_ADC2GRP1, 0);
-
- adcMutex_ADC = xSemaphoreCreateMutex();
- adcMutex_HOUTIFBK = xSemaphoreCreateMutex();
+ int adc, grp;
+ for (adc = 0; adc < 2; adc++) {
+ for (grp = 0; grp < 2; grp++) {
+ vSemaphoreCreateBinary(sem[adc][grp]);
+ xSemaphoreTake(sem[adc][grp], 0);
+ }
+ mutex[adc] = xSemaphoreCreateMutex();
+ }
// Low level init
adcInit();
}
void adcNotification(adcBASE_t *adc, uint32_t group)
{
if (adcIsConversionComplete(adc, group) == ADC_CONVERSION_IS_FINISHED) {
-
- // ADC1
- if (adc == adcREG1) {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- // According to FreeRTOS documentation second parameter is
- // optional (and can be set to NULL) from FreeRTOS
- // V7.3.0. We are using 7.0.2. I confirmed this in the
- // source code: src/os/queue.c line 821. - Carlos
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC1GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- // ADC2
- }
- else {
- switch (group) {
- case adcGROUP0:
- // Group0 is unused on RPP
- break;
- case adcGROUP1:
- {
- signed portBASE_TYPE dummy;
- xSemaphoreGiveFromISR(adcSemaphore_ADC2GRP1, &dummy);
- }
- break;
- default:
- // Group2 is unused on RPP
- break;
- }
- }
+ signed portBASE_TYPE dummy;
+ int adc_idx = (adc == adcREG1) ? 0 : 1;
+ int grp_idx = (group == adcGROUP1) ? 0 : 1;
+ xSemaphoreGiveFromISR(sem[adc_idx][grp_idx], &dummy);
}
}
uint32_t drv_adc_generic_read(adcBASE_t *adc, uint32_t group,
- xSemaphoreHandle adcSemaphore, adcData_t *data)
+ adcData_t *data)
{
+ int adc_idx = (adc == adcREG1) ? 0 : 1;
+ int grp_idx = (group == adcGROUP1) ? 0 : 1;
+
+ xSemaphoreTake(mutex[adc_idx], portMAX_DELAY);
+
// Calibrate
adcCalibration(adc);
adcMidPointCalibration(adc);
adcStartConversion(adc, group);
// Wait for conversion to complete
- xSemaphoreTake(adcSemaphore, portMAX_DELAY);
+ xSemaphoreTake(sem[adc_idx][grp_idx], portMAX_DELAY);
adcDisableNotification(adc, group);
// Get data
// FIXME Should report somehow.
adcResetFiFo(adc, group);
- return channels;
-}
-
-
-uint32_t drv_adc_read_adc(adcData_t *data)
-{
- xSemaphoreTake(adcMutex_ADC, portMAX_DELAY);
- uint32_t result = drv_adc_generic_read(
- adcREG1,
- adcGROUP1,
- adcSemaphore_ADC1GRP1,
- data
- );
- xSemaphoreGive(adcMutex_ADC);
- return result;
-}
+ xSemaphoreGive(mutex[adc_idx]);
-uint32_t drv_adc_read_houtifbk(adcData_t *data)
-{
- xSemaphoreTake(adcMutex_HOUTIFBK, portMAX_DELAY);
- uint32_t result = drv_adc_generic_read(
- adcREG2,
- adcGROUP1,
- adcSemaphore_ADC2GRP1,
- data
- );
- xSemaphoreGive(adcMutex_HOUTIFBK);
- return result;
+ return channels;
}
#define MIN(a,b) ((a) < (b) ? (a) : (b))
drv_adc_generic_read(
port->cfg.adc.reg,
port->cfg.adc.group,
- (port->cfg.adc.sem == 1) ? adcSemaphore_ADC1GRP1 : adcSemaphore_ADC2GRP1,
data
);
+/adc.c eaton
/can.c eaton
/gio.c eaton
/rpp.c eaton
+++ /dev/null
-/adc.c eaton
+++ /dev/null
-/adc.c eaton
+++ /dev/null
-/* Copyright (C) 2013 Czech Technical University in Prague
- *
- * Authors:
- * - Carlos Jenkins <carlos@jenkins.co.cr>
- *
- * This document contains proprietary information belonging to Czech
- * Technical University in Prague. Passing on and copying of this
- * document, and communication of its contents is not permitted
- * without prior written authorization.
- *
- * File : adc.c
- * Abstract:
- * Analog Input RPP API implementation file.
- *
- * References:
- * adc.h
- * RPP API documentation.
- */
-
-
-#include "rpp/rpp.h"
-
-#ifndef FREERTOS_POSIX
-#include "drv/drv.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];
-#endif
-
-static boolean_t initialized = FALSE;
-
-int8_t rpp_adc_init()
-{
- if (initialized)
- return FAILURE;
- initialized = TRUE;
-
-#ifndef FREERTOS_POSIX
- drv_adc_init();
-#endif
-
- return SUCCESS;
-}
-
-
-int16_t rpp_adc_get(uint8_t pin)
-{
- if ((pin < 1) || (pin > 16))
- 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);
-#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);
-#endif
-
- return SUCCESS;
-}
+++ /dev/null
-/adc.c eaton
+++ /dev/null
-/* Copyright (C) 2013 Czech Technical University in Prague
- *
- * Authors:
- * - Carlos Jenkins <carlos@jenkins.co.cr>
- *
- * This document contains proprietary information belonging to Czech
- * Technical University in Prague. Passing on and copying of this
- * document, and communication of its contents is not permitted
- * without prior written authorization.
- *
- * File : adc.c
- * Abstract:
- * Analog Input RPP API implementation file.
- *
- * References:
- * adc.h
- * RPP API documentation.
- */
-
-
-#include "rpp/rpp.h"
-
-#ifndef FREERTOS_POSIX
-#include "drv/drv.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];
-#endif
-
-static boolean_t initialized = FALSE;
-
-int8_t rpp_adc_init()
-{
- if (initialized)
- return FAILURE;
- initialized = TRUE;
-
-#ifndef FREERTOS_POSIX
- drv_adc_init();
-#endif
-
- return SUCCESS;
-}
-
-
-int16_t rpp_adc_get(uint8_t pin)
-{
- if ((pin < 1) || (pin > 16))
- 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);
-#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);
-#endif
-
- return SUCCESS;
-}
+++ /dev/null
-/* Copyright (C) 2013 Czech Technical University in Prague
- *
- * Authors:
- * - Carlos Jenkins <carlos@jenkins.co.cr>
- *
- * This document contains proprietary information belonging to Czech
- * Technical University in Prague. Passing on and copying of this
- * document, and communication of its contents is not permitted
- * without prior written authorization.
- *
- * File : adc.c
- * Abstract:
- * Analog Input RPP API implementation file.
- *
- * References:
- * adc.h
- * RPP API documentation.
- */
-
-
-#include "rpp/rpp.h"
-
-#ifndef FREERTOS_POSIX
-#include "drv/drv.h"
-
-// RPP has 12 ADC channels
-// See s_adcSelect and s_adcFiFoSize in ti_drv_adc.c for hardware configuration.
-#define ADC_CHANNELS 12
-static adcData_t in_cache[ADC_CHANNELS];
-#endif
-
-static boolean_t initialized = FALSE;
-
-int8_t rpp_adc_init()
-{
- if (initialized)
- return FAILURE;
- initialized = TRUE;
-
-#ifndef FREERTOS_POSIX
- drv_adc_init();
-#endif
-
- return SUCCESS;
-}
-
-
-int16_t rpp_adc_get(uint8_t pin)
-{
- if ((pin < 1) || (pin > 12))
- 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);
-#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);
-#endif
-
- return SUCCESS;
-}
-/* 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;