rpp_lib_SOURCES += \
rpp/src/rpp/adc.c \
rpp/src/rpp/can.c \
- rpp/src/rpp/din.c \
rpp/src/rpp/rpp.c \
rpp/src/rpp/sci.c
rpp_lib_SOURCES_7.0.2_tms570 += \
rpp/src/drv/adc.c \
- rpp/src/drv/din.c \
rpp/src/drv/sci.c \
rpp/src/hal/gpio_tms570.c \
rpp/src/hal/gpio_tms570_def.c \
-rpp-test-suite_SOURCES := src/ain.c src/can.c src/din.c \
+rpp-test-suite_SOURCES := src/ain.c src/can.c \
src/main.c src/sci.c
void test_adc();
void test_can();
-void test_din();
void test_sci();
+++ /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 : din.c
- * Abstract:
- * RPP test suite - module for testing DIN.
- *
- * References:
- * test.h
- */
-
-
-#include "rpp/rpp.h"
-#include "test.h"
-
-#define FREQ_MILLIS 100
-
-
-// Task control
-static boolean_t stop_tasks = FALSE;
-static uint8_t tasks_running = 0;
-
-
-/**
- * FreeRTOS Task that read digital inputs and prints them on the SCI.
- */
-void din_test_task(void *par)
-{
- rpp_sci_printf((const char *)
- "Digital Inputs Test [1-16]:\r\n"
- );
- rpp_sci_printf((const char *)
- "===========================================================\r\n"
- );
- rpp_sci_printf((const char *)
- " 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A B C D E F G H\r\n"
- // 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
- );
-
- // Calculate wait time in OS ticks
- static const portTickType freq_ticks = FREQ_MILLIS / portTICK_RATE_MS;
- portTickType last_wake_time = xTaskGetTickCount();
-
- uint8_t i;
- uint8_t pin;
- while (!stop_tasks) {
-
- // Update inputs
- rpp_din_update();
-
- // Print inputs
- // Terminal needs to be at least 47 chars long
- if (stop_tasks)
- continue;
-
- for (i = 0; i < 72; i++) {
- rpp_sci_putc('\b');
- }
-
- for (pin = 0; pin <= 15; pin++) {
- rpp_sci_printf((const char *)" %d ", rpp_din_get(pin));
- }
- for (pin = 8; pin <= 15; pin++) {
- rpp_sci_printf((const char *)" %d ", rpp_din_get_tr(pin));
- }
-
- // Wait until next step
- if (!stop_tasks)
- vTaskDelayUntil(&last_wake_time, freq_ticks);
- }
-
- // Delete myself
- tasks_running--;
- vTaskDelete(NULL);
-}
-
-
-/**
- * DIN Test entry point.
- */
-void test_din()
-{
- /// Configure module
- // Configure voltage reference
- rpp_din_ref(900, 900);
- // Configure pins
- int pin;
- for (pin = 0; pin <= 15; pin++) {
- // Configure pin as pull-down, active, non-wake up
- rpp_din_setup(pin, FALSE, TRUE, FALSE);
- }
- rpp_din_update();
-
-
- /// Spawn tasks
- xTaskHandle test_task_handle;
-
- portBASE_TYPE task_created = xTaskCreate(din_test_task,
- (const signed char *)"din_test_task",
- TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
- &test_task_handle
- );
-
- if (task_created != pdPASS) {
-
- rpp_sci_printf((const char *)
- "ERROR: Problem spawning the test task. "
- "Error code: %d\r\n", (uint32_t)task_created
- );
- wait_for_quit();
- return;
- }
- tasks_running++;
-
-
- // Wait for user exit
- wait_for_quit();
- stop_tasks = TRUE;
- while (tasks_running > 0)
- taskYIELD();
- stop_tasks = FALSE;
-
-
- /// Reset module configuration
- // - Not required
-
-
- rpp_sci_printf((const char *)"\r\n");
-
- return;
-}
test_adc();
else if (strncmp(string, "can", BUF_SIZE) == 0)
test_can();
- else if (strncmp(string, "din", BUF_SIZE) == 0)
- test_din();
else if (strncmp(string, "sci", BUF_SIZE) == 0)
test_sci();
else if (strncmp(string, "help", BUF_SIZE) == 0) {
rpp_sci_printf((const char *)"\thelp - Display this help.\r\n");
rpp_sci_printf((const char *)"\tain - Test Analog Input.\r\n");
rpp_sci_printf((const char *)"\tcan - Test CAN communication.\r\n");
- rpp_sci_printf((const char *)"\tdin - Test Digital Inputs.\r\n");
rpp_sci_printf((const char *)"\tsci - Test Serial Communication Interface.\r\n");
}
else
+++ /dev/null
-/**
- *
- * @file din_spi.h
- *
- * @copyright Copyright (C) 2012-2013 Czech Technical University in Prague
- *
- * @author Michal Horn <hornmich@fel.cvut.cz>
- * Martin Koubek <martin.koubek@porsche-engineering.com>
- */
-
-
-#ifndef DIN_SPI_H_
-#define DIN_SPI_H_
-
-
-/******************************************************************************
-* Include Files
-******************************************************************************/
-#include "drv/drv.h"
-
-
-/******************************************************************************
-* Macro declaration sections
-******************************************************************************/
-
-enum SpiCmdTable {
- DIN_SWITCH_STATUS_CMD = 0, //0x00000000,
- DIN_SETTINGS_CMD, //0x00010000,
- DIN_WAKE_UP_CMD_ENB, //0x00020000,
- DIN_WAKE_UP_CMD_DIS, //0x00030000,
- DIN_METALLIC_CMD_YES, //0x00040000,
- DIN_METALLIC_CMD_NO, //0x00050000,
- DIN_ANALOG_CMD, //0x00060000,
- DIN_WETTING_CRNT_CMD_ON, //0x00070000,
- DIN_WETTING_CRNT_CMD_OFF, //0x00080000,
- DIN_TRI_STATE_CMD_YES, //0x00090000,
- DIN_TRI_STATE_CMD_NO, //0x000A0000,
- DIN_CALIBRATION_CMD, //0x000B0000,
- DIN_SLEEP_CMD, //0x000C0000,
- DIN_RESET_CMD, //0x0007F000
-
- DIN_NUM_SPI_CMD
-};
-
-
-/******************************************************************************
-* Function declaration sections
-******************************************************************************/
-/**
- * Send command and data through SPI. It modifies data by AND and XOR, updates
- * shadow register in din_spi_shadow_reg_list and send the command + data to SPI
- * din_set_reg(DIN_BIT_XY|DIN_BIT_AB, 0); // erase bits XY a AB
- * din_set_reg(DIN_BIT_XY|DIN_BIT_AB, DIN_BIT_XY|DIN_BIT_AB); // set XY a AB
- * din_set_reg(0, DIN_BIT_XY|DIN_BIT_AB); // modify XY a AB
- *
- * @param[in] SpiCmdTable list of supported commands
- * @param[in] and_ and_ value is bitwise AND by shadow register for the command
- * @param[in] xor_ xor_ value is bitwise XOR by product of shadow register AND
- * and_
- * @return return spi response or zero in case of error
- */
-uint16_t din_set_reg(enum SpiCmdTable cmd_index, uint16_t and_, uint16_t xor_);
-
-/**
- * Set voltage for DAC A and DAC B
- *
- */
-int8_t drv_din_ref(uint16_t ref_a, uint16_t ref_b);
-
-/**
- * Read GPIO pin value
- *
- */
-int8_t drv_din_get_varthr(uint8_t pin);
-
-/**
- * Get values of all DIN pins in form of 16-bit word DIN15,...,DIN0
- * @return values of all pins.
- */
-uint16_t din_get_val_word();
-
-/**
- * Get latest response from SPI. Function does not send anything.
- * @return latest spi response
- */
-int din_spi_response();
-
-/**
- * Get last command sent on SPI
- * @return latest sent command
- */
-int din_spi_get_cmd();
-
-#endif /* DIN_SPI_H_ */
#include "hal/hal.h"
#include "drv/adc.h"
-#include "drv/din.h"
#include "drv/sci.h"
#ifndef HAL_GPIO_TMS570_DEF_H_
#define HAL_GPIO_TMS570_DEF_H_
-//#include "ti_drv_dmm.h"
-//#include "ti_drv_gio.h"
-//#include "ti_drv_het.h"
-//#include "hal_port_spi.h"
#include "hal/hal.h"
uint32_t pin_desc; // Pin descriptor assigned to the pin name
} pin_map_element_t;
-#define MAX_PIN_CNT 103
+#define MAX_PIN_CNT 48
#define MAX_PORT_CNT 5
/* Begin and end indexes of each port group to pin map */
#define PIN_MAP_DMM_BEGIN 0
#define PORT_ID_HET1 0x3
#define PORT_ID_HET2 0x4
/* Pin names */
-#define PIN_NAME_DIN8 "DIN8"
-#define PIN_NAME_DIN9 "DIN9"
-#define PIN_NAME_DIN10 "DIN10"
-#define PIN_NAME_DIN11 "DIN11"
-#define PIN_NAME_DIN12 "DIN12"
-#define PIN_NAME_DIN13 "DIN13"
-#define PIN_NAME_DIN14 "DIN14"
-#define PIN_NAME_DIN15 "DIN15"
-#define PIN_NAME_DININT "DININT"
-#define PIN_NAME_HOUT1IN "HOUT1IN"
-#define PIN_NAME_HOUT2IN "HOUT2IN"
-#define PIN_NAME_HOUT3IN "HOUT3IN"
-#define PIN_NAME_HOUT4IN "HOUT4IN"
-#define PIN_NAME_HOUT5IN "HOUT5IN"
-#define PIN_NAME_HOUT6IN "HOUT6IN"
-#define PIN_NAME_HOUT1DIAG "HOUT1DIAG"
-#define PIN_NAME_HOUT2DIAG "HOUT2DIAG"
-#define PIN_NAME_HOUT3DIAG "HOUT3DIAG"
-#define PIN_NAME_HOUT4DIAG "HOUT4DIAG"
-#define PIN_NAME_HOUT5DIAG "HOUT5DIAG"
-#define PIN_NAME_HOUT6DIAG "HOUT6DIAG"
-#define PIN_NAME_MOUT1IN "MOUT1IN"
-#define PIN_NAME_MOUT2IN "MOUT2IN"
-#define PIN_NAME_MOUT3IN "MOUT3IN"
-#define PIN_NAME_MOUT4IN "MOUT4IN"
-#define PIN_NAME_MOUT5IN "MOUT5IN"
-#define PIN_NAME_MOUT6IN "MOUT6IN"
-#define PIN_NAME_MOUT1EN "MOUT1EN"
-#define PIN_NAME_MOUT2EN "MOUT2EN"
-#define PIN_NAME_MOUT3EN "MOUT3EN"
-#define PIN_NAME_MOUT4EN "MOUT4EN"
-#define PIN_NAME_MOUT5EN "MOUT5EN"
-#define PIN_NAME_MOUT6EN "MOUT6EN"
-#define PIN_NAME_VBAT1EN "VBAT1EN"
-#define PIN_NAME_VBAT2EN "VBAT2EN"
-#define PIN_NAME_VBAT3EN "VBAT3EN"
-#define PIN_NAME_VBATEN "VBATEN"
-#define PIN_NAME_FANCTRL "FANCTRL"
-#define PIN_NAME_ETHRST "ETHRST"
-#define PIN_NAME_SPICSA "SPICSA"
-#define PIN_NAME_SPICSB "SPICSB"
-#define PIN_NAME_CANNSTB "CANNSTB"
-#define PIN_NAME_CANEN "CANEN"
-#define PIN_NAME_LIN2NSLP "LIN2NSLP"
-#define PIN_NAME_LIN1NSLP "LIN1NSLP"
-#define PIN_NAME_HBREN "HBREN"
-#define PIN_NAME_HBRDIR "HBRDIR"
-#define PIN_NAME_HBRPWM "HBRPWM"
-#define PIN_NAME_UNUSED NULL
+#define PIN_NAME_GIOA0 "GIOA0"
+#define PIN_NAME_GIOA1 "GIOA1"
+#define PIN_NAME_GIOA2 "GIOA2"
+#define PIN_NAME_GIOA3 "GIOA3"
+#define PIN_NAME_GIOA4 "GIOA4"
+#define PIN_NAME_GIOA5 "GIOA5"
+#define PIN_NAME_GIOA6 "GIOA6"
+#define PIN_NAME_GIOA7 "GIOA7"
+
+#define PIN_NAME_GIOB0 "GIOB0"
+#define PIN_NAME_GIOB1 "GIOB1"
+#define PIN_NAME_GIOB2 "GIOB2"
+#define PIN_NAME_GIOB3 "GIOB3"
+#define PIN_NAME_GIOB4 "GIOB4"
+#define PIN_NAME_GIOB5 "GIOB5"
+#define PIN_NAME_GIOB6 "GIOB6"
+#define PIN_NAME_GIOB7 "GIOB7"
+
+#define PIN_NAME_NHET1_0 "NHET1_0"
+#define PIN_NAME_NHET1_1 "NHET1_1"
+#define PIN_NAME_NHET1_2 "NHET1_2"
+#define PIN_NAME_NHET1_3 "NHET1_3"
+#define PIN_NAME_NHET1_4 "NHET1_4"
+#define PIN_NAME_NHET1_5 "NHET1_5"
+#define PIN_NAME_NHET1_6 "NHET1_6"
+#define PIN_NAME_NHET1_7 "NHET1_7"
+#define PIN_NAME_NHET1_8 "NHET1_8"
+#define PIN_NAME_NHET1_9 "NHET1_9"
+#define PIN_NAME_NHET1_10 "NHET1_10"
+#define PIN_NAME_NHET1_11 "NHET1_11"
+#define PIN_NAME_NHET1_12 "NHET1_12"
+#define PIN_NAME_NHET1_13 "NHET1_13"
+#define PIN_NAME_NHET1_14 "NHET1_14"
+#define PIN_NAME_NHET1_15 "NHET1_15"
+#define PIN_NAME_NHET1_16 "NHET1_16"
+#define PIN_NAME_NHET1_17 "NHET1_17"
+#define PIN_NAME_NHET1_18 "NHET1_18"
+#define PIN_NAME_NHET1_19 "NHET1_19"
+#define PIN_NAME_NHET1_20 "NHET1_20"
+#define PIN_NAME_NHET1_21 "NHET1_21"
+#define PIN_NAME_NHET1_22 "NHET1_22"
+#define PIN_NAME_NHET1_23 "NHET1_23"
+#define PIN_NAME_NHET1_24 "NHET1_24"
+#define PIN_NAME_NHET1_25 "NHET1_25"
+#define PIN_NAME_NHET1_26 "NHET1_26"
+#define PIN_NAME_NHET1_27 "NHET1_27"
+#define PIN_NAME_NHET1_28 "NHET1_28"
+#define PIN_NAME_NHET1_29 "NHET1_29"
+#define PIN_NAME_NHET1_30 "NHET1_30"
+#define PIN_NAME_NHET1_31 "NHET1_31"
+
+#define PIN_NAME_UNUSED "unused"
+
/* Pins descriptors */
-#define PIN_DSC_FANCTRL PORT_PIN(PORT_ID_DMM, 0, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_ETHRST PORT_PIN(PORT_ID_DMM, 1, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_VBAT1EN PORT_PIN(PORT_ID_DMM, 2, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_VBAT2EN PORT_PIN(PORT_ID_DMM, 3, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_VBAT3EN PORT_PIN(PORT_ID_DMM, 4, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_VBATEN PORT_PIN(PORT_ID_DMM, 5, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_SPICSA PORT_PIN(PORT_ID_DMM, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_SPICSB PORT_PIN(PORT_ID_DMM, 8, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_MOUT1EN PORT_PIN(PORT_ID_DMM, 11, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
-#define PIN_DSC_MOUT2EN PORT_PIN(PORT_ID_DMM, 12, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
-#define PIN_DSC_CANNSTB PORT_PIN(PORT_ID_DMM, 13, PORT_CONF_GPIO_OUT_HI_PD_PEN_ODOFF)
-#define PIN_DSC_CANEN PORT_PIN(PORT_ID_DMM, 15, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_LIN2NSLP PORT_PIN(PORT_ID_DMM, 16, PORT_CONF_GPIO_OUT_HI_PD_PEN_ODOFF)
-#define PIN_DSC_LIN1NSLP PORT_PIN(PORT_ID_DMM, 17, PORT_CONF_GPIO_OUT_HI_PD_PEN_ODOFF)
-#define PIN_DSC_DININT PORT_PIN(PORT_ID_DMM, 18, PORT_CONF_GPIO_IN_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_DIN8 PORT_PIN(PORT_ID_GIOA, 0, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DIN9 PORT_PIN(PORT_ID_GIOA, 1, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DIN10 PORT_PIN(PORT_ID_GIOA, 2, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DIN11 PORT_PIN(PORT_ID_GIOA, 3, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DIN12 PORT_PIN(PORT_ID_GIOA, 4, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DIN13 PORT_PIN(PORT_ID_GIOA, 5, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DIN14 PORT_PIN(PORT_ID_GIOA, 6, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DIN15 PORT_PIN(PORT_ID_GIOA, 7, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_MOUT6EN PORT_PIN(PORT_ID_GIOB, 0, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
-#define PIN_DSC_MOUT5EN PORT_PIN(PORT_ID_GIOB, 1, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
-#define PIN_DSC_MOUT6IN PORT_PIN(PORT_ID_GIOB, 2, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT5IN PORT_PIN(PORT_ID_GIOB, 3, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT4EN PORT_PIN(PORT_ID_GIOB, 4, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
-#define PIN_DSC_MOUT3EN PORT_PIN(PORT_ID_GIOB, 5, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
-#define PIN_DSC_MOUT4IN PORT_PIN(PORT_ID_GIOB, 6, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT3IN PORT_PIN(PORT_ID_GIOB, 7, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_HBREN PORT_PIN(PORT_ID_HET1, 1, PORT_CONF_GPIO_OUT_LO_PU_PDIS_ODOFF)
-#define PIN_DSC_HBRDIR PORT_PIN(PORT_ID_HET1, 4, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_HBRPWM PORT_PIN(PORT_ID_HET1, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_MOUT1IN PORT_PIN(PORT_ID_HET1, 9, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT2IN PORT_PIN(PORT_ID_HET1, 14, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_HOUT1IN PORT_PIN(PORT_ID_HET1, 16, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT1DIAG PORT_PIN(PORT_ID_HET1, 17, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT2IN PORT_PIN(PORT_ID_HET1, 18, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT2DIAG PORT_PIN(PORT_ID_HET1, 19, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT3IN PORT_PIN(PORT_ID_HET1, 20, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT3DIAG PORT_PIN(PORT_ID_HET1, 21, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT4IN PORT_PIN(PORT_ID_HET1, 22, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT4DIAG PORT_PIN(PORT_ID_HET1, 23, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT5IN PORT_PIN(PORT_ID_HET1, 25, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT5DIAG PORT_PIN(PORT_ID_HET1, 27, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT6IN PORT_PIN(PORT_ID_HET1, 29, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HOUT6DIAG PORT_PIN(PORT_ID_HET1, 31, PORT_CONF_GPIO_IN_LO_PD_PEN_ODOFF)
-#define PIN_DSC_DMM_UNUSED(b) PORT_PIN(PORT_ID_HET2, b, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_GIOA_UNUSED(b) PORT_PIN(PORT_ID_HET2, b, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_GIOB_UNUSED(b) PORT_PIN(PORT_ID_HET2, b, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HET1_UNUSED(b) PORT_PIN(PORT_ID_HET2, b, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_HET2_UNUSED(b) PORT_PIN(PORT_ID_HET2, b, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA0 PORT_PIN(PORT_ID_GIOA, 0, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA1 PORT_PIN(PORT_ID_GIOA, 1, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA2 PORT_PIN(PORT_ID_GIOA, 2, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA3 PORT_PIN(PORT_ID_GIOA, 3, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA4 PORT_PIN(PORT_ID_GIOA, 4, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA5 PORT_PIN(PORT_ID_GIOA, 5, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA6 PORT_PIN(PORT_ID_GIOA, 6, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOA7 PORT_PIN(PORT_ID_GIOA, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+
+#define PIN_DSC_GIOB0 PORT_PIN(PORT_ID_GIOB, 0, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOB1 PORT_PIN(PORT_ID_GIOB, 1, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOB2 PORT_PIN(PORT_ID_GIOB, 2, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOB3 PORT_PIN(PORT_ID_GIOB, 3, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOB4 PORT_PIN(PORT_ID_GIOB, 4, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOB5 PORT_PIN(PORT_ID_GIOB, 5, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOB6 PORT_PIN(PORT_ID_GIOB, 6, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_GIOB7 PORT_PIN(PORT_ID_GIOB, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+
+#define PIN_DSC_NHET1_0 PORT_PIN(PORT_ID_HET1, 0, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_1 PORT_PIN(PORT_ID_HET1, 1, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_2 PORT_PIN(PORT_ID_HET1, 2, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_3 PORT_PIN(PORT_ID_HET1, 3, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_4 PORT_PIN(PORT_ID_HET1, 4, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_5 PORT_PIN(PORT_ID_HET1, 5, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_6 PORT_PIN(PORT_ID_HET1, 6, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_7 PORT_PIN(PORT_ID_HET1, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_8 PORT_PIN(PORT_ID_HET1, 8, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_9 PORT_PIN(PORT_ID_HET1, 9, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_10 PORT_PIN(PORT_ID_HET1, 10, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_11 PORT_PIN(PORT_ID_HET1, 11, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_12 PORT_PIN(PORT_ID_HET1, 12, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_13 PORT_PIN(PORT_ID_HET1, 13, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_14 PORT_PIN(PORT_ID_HET1, 14, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_15 PORT_PIN(PORT_ID_HET1, 15, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_16 PORT_PIN(PORT_ID_HET1, 16, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_17 PORT_PIN(PORT_ID_HET1, 17, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_18 PORT_PIN(PORT_ID_HET1, 18, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_19 PORT_PIN(PORT_ID_HET1, 19, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_20 PORT_PIN(PORT_ID_HET1, 20, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_21 PORT_PIN(PORT_ID_HET1, 21, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_22 PORT_PIN(PORT_ID_HET1, 22, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_23 PORT_PIN(PORT_ID_HET1, 23, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_24 PORT_PIN(PORT_ID_HET1, 24, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_25 PORT_PIN(PORT_ID_HET1, 25, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_26 PORT_PIN(PORT_ID_HET1, 26, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_27 PORT_PIN(PORT_ID_HET1, 27, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_28 PORT_PIN(PORT_ID_HET1, 28, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_29 PORT_PIN(PORT_ID_HET1, 29, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_30 PORT_PIN(PORT_ID_HET1, 30, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_NHET1_31 PORT_PIN(PORT_ID_HET1, 31, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
#endif /* HAL_GPIO_TMS570_DEF_H_ */
#ifndef PORT_DEF_H_
#define PORT_DEF_H_
-//#include "hal_gpio_tms570_def.h"
#include "hal/hal.h"
+#include "drv/adc.h"
/**
* @brief Port descriptor
* The API is designed to provide an interface for setting and reading from ports connected to the MCU by SPI, GPIO or ADC.
*/
typedef struct port_desc_st {
- uint32_t *config; /**< Configuration of the port. An arry of values, which meaning differs for the interface type:
+ uint32_t *config; /**< Configuration of the port. An array of values, which meaning differs for the interface type:
for SPI: address, chip-select
for GPIO: descriptors for pins (defined in gpio_tms570_def.h)
for ADC: ADC base address, ADC group number, Peripheral type (HOUTIFBK or ADC)
#define PORT_INTERFACE_SPI 0x2
#define PORT_INTERFACE_GPIO 0x3
-#define PORT_CNT 15
-
-#define PORT_NAME_DINMCU "DINMCU"
-#define PORT_CFG_DINMCU { PIN_DSC_DIN8, PIN_DSC_DIN9, PIN_DSC_DIN10, PIN_DSC_DIN11, PIN_DSC_DIN12, PIN_DSC_DIN13, PIN_DSC_DIN14, PIN_DSC_DIN15 }
-#define PORT_NV_DINMCU 8
-#define PORT_GFC_DINMCU &hal_gio_port_get_val
-#define PORT_SFC_DINMCU NULL
-#define PORT_INT_TYPE_DINMCU PORT_INTERFACE_GPIO
-
-#define PORT_NAME_DINSPI "DINSPI"
-#define PORT_CFG_DINSPI { 1, 0 }
-#define PORT_NV_DINSPI 3
-#define PORT_GFC_DINSPI NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_DINSPI NULL
-#define PORT_INT_TYPE_DINSPI PORT_INTERFACE_SPI
-
-#define PORT_NAME_HOUTDIAG "HOUTDIAG"
-#define PORT_CFG_HOUTDIAG { PIN_DSC_HOUT1DIAG, PIN_DSC_HOUT2DIAG, PIN_DSC_HOUT3DIAG, PIN_DSC_HOUT4DIAG, PIN_DSC_HOUT5DIAG, PIN_DSC_HOUT6DIAG }
-#define PORT_NV_HOUTDIAG 6
-#define PORT_GFC_HOUTDIAG &hal_gio_port_get_val
-#define PORT_SFC_HOUTDIAG NULL
-#define PORT_INT_TYPE_HOUTDIAG PORT_INTERFACE_GPIO
-
-#define PORT_NAME_HOUTIN "HOUTIN"
-#define PORT_CFG_HOUTIN { PIN_DSC_HOUT1IN, PIN_DSC_HOUT2IN, PIN_DSC_HOUT3IN, PIN_DSC_HOUT4IN, PIN_DSC_HOUT5IN, PIN_DSC_HOUT6IN }
-#define PORT_NV_HOUTIN 6
-#define PORT_GFC_HOUTIN &hal_gio_port_get_val
-#define PORT_SFC_HOUTIN &hal_gio_port_set_val
-#define PORT_INT_TYPE_HOUTIN PORT_INTERFACE_GPIO
-
-// FIXME Upper layer dependency/coupling
-// Declared in drv/adc.h
-extern uint32_t adc_get_port_val(uint32_t *config, uint32_t num_channels, uint32_t *values);
-
-#define PORT_HOUTIFBK_CHANNEL_NUM 6
-#define PORT_NAME_HOUTIFBK "HOUTIFBK"
-#define PORT_CFG_HOUTIFBK { (uint32_t)adcREG2, adcGROUP1, 0 }
-#define PORT_NV_HOUTIFBK PORT_HOUTIFBK_CHANNEL_NUM
-#define PORT_GFC_HOUTIFBK &adc_get_port_val
-#define PORT_SFC_HOUTIFBK NULL
-#define PORT_INT_TYPE_HOUTIFBK PORT_INTERFACE_ADC
+#define PORT_CNT 4
+
+#define PORT_NAME_GIOA "GIOA"
+#define PORT_CFG_GIOA { PIN_DSC_GIOA0, PIN_DSC_GIOA1, PIN_DSC_GIOA2, PIN_DSC_GIOA3, \
+ PIN_DSC_GIOA4, PIN_DSC_GIOA5, PIN_DSC_GIOA6, PIN_DSC_GIOA7 }
+#define PORT_NV_GIOA 8
+#define PORT_GFC_GIOA &hal_gio_port_get_val
+#define PORT_SFC_GIOA &hal_gio_port_set_val
+#define PORT_INT_TYPE_GIOA PORT_INTERFACE_GPIO
+
+#define PORT_NAME_GIOB "GIOB"
+#define PORT_CFG_GIOB { PIN_DSC_GIOB0, PIN_DSC_GIOB1, PIN_DSC_GIOB2, PIN_DSC_GIOB3, \
+ PIN_DSC_GIOB4, PIN_DSC_GIOB5, PIN_DSC_GIOB6, PIN_DSC_GIOB7 }
+#define PORT_NV_GIOB 8
+#define PORT_GFC_GIOB &hal_gio_port_get_val
+#define PORT_SFC_GIOB &hal_gio_port_set_val
+#define PORT_INT_TYPE_GIOB PORT_INTERFACE_GPIO
+
+#define PORT_NAME_NHET1 "NHET1"
+#define PORT_CFG_NHET1 { PIN_DSC_NHET1_0, PIN_DSC_NHET1_1, PIN_DSC_NHET1_2, PIN_DSC_NHET1_3, \
+ PIN_DSC_NHET1_4, PIN_DSC_NHET1_5, PIN_DSC_NHET1_6, PIN_DSC_NHET1_7, \
+ PIN_DSC_NHET1_8, PIN_DSC_NHET1_9, PIN_DSC_NHET1_10, PIN_DSC_NHET1_11, \
+ PIN_DSC_NHET1_12, PIN_DSC_NHET1_13, PIN_DSC_NHET1_14, PIN_DSC_NHET1_15, \
+ PIN_DSC_NHET1_16, PIN_DSC_NHET1_17, PIN_DSC_NHET1_18, PIN_DSC_NHET1_19, \
+ PIN_DSC_NHET1_20, PIN_DSC_NHET1_21, PIN_DSC_NHET1_22, PIN_DSC_NHET1_23, \
+ PIN_DSC_NHET1_24, PIN_DSC_NHET1_25, PIN_DSC_NHET1_26, PIN_DSC_NHET1_27, \
+ PIN_DSC_NHET1_28, PIN_DSC_NHET1_29, PIN_DSC_NHET1_30, PIN_DSC_NHET1_31 }
+#define PORT_NV_NHET1 32
+#define PORT_GFC_NHET1 &hal_gio_port_get_val
+#define PORT_SFC_NHET1 &hal_gio_port_set_val
+#define PORT_INT_TYPE_NHET1 PORT_INTERFACE_GPIO
#define PORT_ADC_CHANNEL_NUM 12
#define PORT_NAME_ADC "ADC"
#define PORT_SFC_ADC NULL
#define PORT_INT_TYPE_ADC PORT_INTERFACE_ADC
-#define PORT_NAME_LOUT "LOUT"
-#define PORT_CFG_LOUT { 1, 1 }
-#define PORT_NV_LOUT 4
-#define PORT_GFC_LOUT NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_LOUT NULL
-#define PORT_INT_TYPE_LOUT PORT_INTERFACE_SPI
-
-#define PORT_NAME_DAC1_2 "DAC12"
-#define PORT_CFG_DAC1_2 { 3, 0 }
-#define PORT_NV_DAC1_2 2
-#define PORT_GFC_DAC1_2 NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_DAC1_2 NULL
-#define PORT_INT_TYPE_DAC1_2 PORT_INTERFACE_SPI
-
-#define PORT_NAME_DAC3_4 "DAC34"
-#define PORT_CFG_DAC3_4 { 3, 1 }
-#define PORT_NV_DAC3_4 2
-#define PORT_GFC_DAC3_4 NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_DAC3_4 NULL
-#define PORT_INT_TYPE_DAC3_4 PORT_INTERFACE_SPI
-
-#define PORT_NAME_DACDREF "DACDREF"
-#define PORT_CFG_DACDREF { 3, 2 }
-#define PORT_NV_DACDREF 2
-#define PORT_GFC_DACDREF NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_DACDREF NULL
-#define PORT_INT_TYPE_DACDREF PORT_INTERFACE_SPI
-
-#define PORT_NAME_HBR "HBR"
-#define PORT_CFG_HBR { 4, 0 }
-#define PORT_NV_HBR 2
-#define PORT_GFC_HBR NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_HBR NULL
-#define PORT_INT_TYPE_HBR PORT_INTERFACE_SPI
-
-#define PORT_NAME_FRAY1 "FRAY1"
-#define PORT_CFG_FRAY1 { 4, 1 }
-#define PORT_NV_FRAY1 2
-#define PORT_GFC_FRAY1 NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_FRAY1 NULL
-#define PORT_INT_TYPE_FRAY1 PORT_INTERFACE_SPI
-
-#define PORT_NAME_FRAY2 "FRAY2"
-#define PORT_CFG_FRAY2 { 4, 2 }
-#define PORT_NV_FRAY2 2
-#define PORT_GFC_FRAY2 NULL
-/* FIXME: redefine ports */
-#define PORT_SFC_FRAY2 NULL
-#define PORT_INT_TYPE_FRAY2 PORT_INTERFACE_SPI
-
-#define PORT_NAME_MOUTEN "MOUTEN"
-#define PORT_CFG_MOUTEN { PIN_DSC_MOUT1EN, PIN_DSC_MOUT2EN, PIN_DSC_MOUT3EN, PIN_DSC_MOUT4EN, PIN_DSC_MOUT5EN, PIN_DSC_MOUT6EN }
-#define PORT_NV_MOUTEN 6
-#define PORT_GFC_MOUTEN &hal_gio_port_get_val
-#define PORT_SFC_MOUTEN NULL
-#define PORT_INT_TYPE_MOUTEN PORT_INTERFACE_GPIO
-
-#define PORT_NAME_MOUTIN "MOUTIN"
-#define PORT_CFG_MOUTIN { PIN_DSC_MOUT1IN, PIN_DSC_MOUT2IN, PIN_DSC_MOUT3IN, PIN_DSC_MOUT4IN, PIN_DSC_MOUT5IN, PIN_DSC_MOUT6IN }
-#define PORT_NV_MOUTIN 6
-#define PORT_GFC_MOUTIN &hal_gio_port_get_val
-#define PORT_SFC_MOUTIN &hal_gio_port_set_val
-#define PORT_INT_TYPE_MOUTIN PORT_INTERFACE_GPIO
-
port_desc_t *hal_port_get_dsc(const char *port_name, int len);
const port_def_t *hal_port_get_definitions();
+++ /dev/null
-/**
- * Digital Input RPP API header file.
- *
- * @file din.h
- *
- * @copyright Copyright (C) 2013 Czech Technical University in Prague
- *
- * @author Carlos Jenkins <carlos@jenkins.co.cr>
- */
-
-
-#ifndef __RPP_DIN_H
-#define __RPP_DIN_H
-
-/**
- * DIN module initialization.
- *
- * Call this method before using this module.
- *
- * @return SUCCESS if initialization successful.\n
- * FAILURE if module already initialized.
- */
-int8_t rpp_din_init();
-
-
-/**
- * Configure voltage reference levels for digital inputs using variable
- * reference threshold.
- *
- * @param[in] refA [0-4095] value to set (DAC is 12bits) the reference
- * voltage A (pins 12-15).
- * @param[in] refB [0-4095] value to set (DAC is 12bits) the reference
- * voltage B (pins 8-11).
- *
- * @return SUCCESS if successful.\n
- * -1 if pin millivolts is out of range.
- */
-int8_t rpp_din_ref(uint16_t refA, uint16_t refB);
-
-
-/**
- * Configure given pin.
- *
- * Call rpp_din_update() to commit configuration changes to the hardware.
- *
- * @param[in] pin The pin number to setup [0-15].
- * @param[in] pull_up TRUE to setup pin as pull-up (a switch-to-ground device
- * is connected) or FALSE to setup as pull-down
- * (switch-to-battery).
- * Note that pins [8-15] are pull-down only.
- * @param[in] active TRUE to setup pin as active or FALSE to set it as
- * tri-stated.
- * @param[in] can_wake TRUE is given pin can wake module from sleep state and
- * trigger an interrupt on MCU. FALSE otherwise.
- *
- * @return SUCCESS if successful.\n
- * -1 if pin number is out of range.\n
- * -2 if pull_type is requested for pins without this feature.
- * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
- */
-int8_t rpp_din_setup(uint8_t pin, boolean_t pull_up,
- boolean_t active, boolean_t can_wake);
-
-
-/**
- * Get the current cached value of the switch state on the given pin.
- *
- * Call rpp_din_update() to update cached values.
- *
- * @param[in] pin The pin number to read [0-15].
- *
- * @return RPP_CLOSED or RPP_OPEN if successful.\n
- * -1 if pin number is out of range.\n
- * -2 if var_thr is requested for inputs without this feature.
- * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
- */
-int8_t rpp_din_get(uint8_t pin);
-
-
-/**
- * Get uncached logical value of the given pin read via comparator with programmable threshold.
- *
- * Inputs [8-11] use programmable threshold B and [12-15] use
- * programmable threshold A.\n
- *
- * @see rpp_din_ref().
- *
- * @param[in] pin The pin number to read [8-15].
- *
- * @return HIGH or LOW if successful.\n
- * -1 if pin number is out of range.\n
- * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
- */
-int8_t rpp_din_get_tr(uint8_t pin);
-
-
-/**
- * Get the diagnostic cached value for given pin.
- *
- * Call rpp_din_update() to update cached values.
- *
- * @param[in] pin The pin number to read [0-15].
- *
- * @return HIGH or LOW if successful.\n
- * -1 if pin number is out of range.
- * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
- */
-int8_t rpp_din_diag(uint8_t pin);
-
-
-/**
- * Read and update cached values and diagnostic values of all pins. Also commit
- * configuration changes.
- *
- * @return SUCCESS when transaction was successful.\n
- * FAILURE if transaction could not be confirmed.
- */
-int8_t rpp_din_update();
-
-
-#endif /* __RPP_DIN_H */
#include "base.h"
/* Include modules */
-#include "rpp/din.h"
#include "rpp/adc.h"
#include "rpp/can.h"
#include "rpp/sci.h"
+++ /dev/null
-/* Copyright (C) 2012-2013 Czech Technical University in Prague
- *
- * Authors:
- * - Michal Horn <hornmich@fel.cvut.cz>
- * - Martin Koubek <martin.koubek@porsche-engineering.com>
- *
- * 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 : din.c
-
- * Abstract:
- * This file is written for 33972 Multiple Switch
- * http://www.freescale.com/files/analog/doc/data_sheet/MC33972.pdf
- *
- * This file contains functions to control DIN
- * Voltage on each pin can be set
- * switch to ground or to battery on programable pins can be set
- * interrupts on each pins can be disabled and enabled
- */
-
-
-/******************************************************************************
-* Include Files
-******************************************************************************/
-#include "drv/drv.h"
-
-
-
-/******************************************************************************
-* Static Variable Definitions
-******************************************************************************/
-/** Stored response from SPI */
-static uint32_t din_spi_resp = 0;
-
-/** Store commands in shadow registers */
-static uint16_t shadow_reg_list[DIN_NUM_SPI_CMD];
-
-
-const static uint32_t dsc_pin_map[8U] = {
- PIN_DSC_DIN8,
- PIN_DSC_DIN9,
- PIN_DSC_DIN10,
- PIN_DSC_DIN11,
- PIN_DSC_DIN12,
- PIN_DSC_DIN13,
- PIN_DSC_DIN14,
- PIN_DSC_DIN15
-};
-
-
-/******************************************************************************
-* Function Prototypes
-******************************************************************************/
-/**
- * Switch copy command, prepared by other functions, to shadow variable,
- * convert command to MSB,
- * transfer command to DIN
- * store spi response
- * return spi response
- */
-int din_spi_transfer_mst(const uint32_t din_spi_cmd);
-
-/******************************************************************************
-* Close variable declaration sections
-******************************************************************************/
-/* Private defines */
-/* --------------- */
-/** Options: */
-/** Bit 13: Output Gain Selection bit set = 1x (VOUT = VREF * D/4096) */
-/** Bit 15: DACA (0) or DACB (1) Selection bit. */
-#define DACA_INIT_VAL (_BV(13) | _BV(12) )
-#define DACB_INIT_VAL (_BV(13) | _BV(12) | _BV(15))
-
-/**
- * This find an index in register list
- * @param command
- * @return index
- */
-static uint32_t enum2cmd(const enum SpiCmdTable index)
-{
- if (index == DIN_RESET_CMD)
- return 0x007F0000;
- else
- return index << 16;
-}
-
-/* Public functions */
-/* ---------------- */
-
-uint16_t din_set_reg(
- enum SpiCmdTable spi_cmd_index, uint16_t clear_mask, uint16_t xor_mask)
-{
- if (spi_cmd_index >= DIN_NUM_SPI_CMD)
- return 0;
-
- shadow_reg_list[spi_cmd_index] =
- shadow_reg_list[spi_cmd_index] & ~clear_mask ^ xor_mask;
-
- uint32_t din_spi_cmd = enum2cmd(spi_cmd_index) | shadow_reg_list[spi_cmd_index];
-
- return din_spi_transfer_mst(din_spi_cmd);
-}
-
-int8_t drv_din_ref(uint16_t ref_a, uint16_t ref_b)
-{
-
- uint16_t cmd;
-
- // Get descriptor
- uint32_t commands[2];
- port_desc_t *desc = hal_port_get_dsc(PORT_NAME_DACDREF, -1);
-
- // Send command for DAC A
- cmd = DACA_INIT_VAL | (ref_a & 0x0FFF);
-
- commands[0] = (cmd & 0xFF00) >> 8;
- commands[1] = (cmd & 0xFF);
- desc->port_setfnc_ptr(desc->config, desc->numValues, commands);
-
- // Send command for DAC B
- cmd = DACB_INIT_VAL | (ref_b & 0x0FFF);
-
- commands[0] = (cmd & 0xFF00) >> 8;
- commands[1] = (cmd & 0xFF);
- desc->port_setfnc_ptr(desc->config, desc->numValues, commands);
-
- // Fixme: check SPI return value.
- return SUCCESS;
-}
-
-
-int8_t drv_din_get_varthr(uint8_t pin)
-{
-
- // Check range
- if ((pin < 8) || (pin > 15))
- return FAILURE;
-
- return hal_gpio_pin_get_value(dsc_pin_map[pin - 8]);
-}
-
-uint16_t din_get_val_word()
-{
- // How it should be.
- //uint16_t sp = ((din_spi_resp >> 14) & 0x00FF);
- //uint16_t sg = ((din_spi_resp << 8 ) & 0xFF00);
-
- // How it actually is.
- // Ignore datasheet, this is the actual response from the SPI driver:
- // [xxxx xxxx][SG7-SG0][SP1 SP0 yy yyyy][zz SP7-SP2]
- // x: Unknown.
- // y: Maybe SG13-SG8, but untested.
- // z: Maybe therm flag and int flag.
- // For SP: First get SP7-SP2 right, then add SP1 and SP0
- uint16_t sp = ((din_spi_resp << 2) & 0x00FF) | ((din_spi_resp >> 14) & 0x3);
- uint16_t sg = ((din_spi_resp >> 8) & 0xFF00);
- uint16_t word = sg | sp;
-
- return word;
-}
-
-
-int din_spi_response()
-{
- return din_spi_resp;
-}
-
-
-/* Private functions */
-/* ----------------- */
-/**
- * Switch copy command, prepared by other functions, to shadow variable,
- * convert command to MSB,
- * transfer command to DIN
- * store spi response
- * return spi response
- */
-int din_spi_transfer_mst(const uint32_t din_spi_cmd)
-{
- port_desc_t *desc;
-
- desc = hal_port_get_dsc(PORT_NAME_DINSPI, -1);
- uint32_t commands[3];
- commands[0] = (din_spi_cmd & 0xFF0000) >> 16; // command
- commands[1] = (din_spi_cmd & 0xFF00) >> 8; // 1.st B of data
- commands[2] = (din_spi_cmd & 0xFF); // 2.nd B of data
-
- din_spi_resp = desc->port_setfnc_ptr(desc->config, desc->numValues, \
- commands);
- return din_spi_resp;
-}
* function*/
pin_map_element_t pin_map[MAX_PIN_CNT] = {
/* DMM pins */
- { .pin_name = PIN_NAME_FANCTRL, .pin_desc = PIN_DSC_FANCTRL },
- { .pin_name = PIN_NAME_ETHRST, .pin_desc = PIN_DSC_ETHRST },
- { .pin_name = PIN_NAME_VBAT1EN, .pin_desc = PIN_DSC_VBAT1EN },
- { .pin_name = PIN_NAME_VBAT2EN, .pin_desc = PIN_DSC_VBAT2EN },
- { .pin_name = PIN_NAME_VBAT3EN, .pin_desc = PIN_DSC_VBAT3EN },
- { .pin_name = PIN_NAME_VBATEN, .pin_desc = PIN_DSC_VBATEN },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_DMM_UNUSED(6) },
- { .pin_name = PIN_NAME_SPICSA, .pin_desc = PIN_DSC_SPICSA },
- { .pin_name = PIN_NAME_SPICSB, .pin_desc = PIN_DSC_SPICSB },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_DMM_UNUSED(9)},
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_DMM_UNUSED(10) },
- { .pin_name = PIN_NAME_MOUT1EN, .pin_desc = PIN_DSC_MOUT1EN },
- { .pin_name = PIN_NAME_MOUT2EN, .pin_desc = PIN_DSC_MOUT2EN },
- { .pin_name = PIN_NAME_CANNSTB, .pin_desc = PIN_DSC_CANNSTB },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_DMM_UNUSED(14) },
- { .pin_name = PIN_NAME_CANEN, .pin_desc = PIN_DSC_CANEN },
- { .pin_name = PIN_NAME_LIN2NSLP,.pin_desc = PIN_DSC_LIN2NSLP },
- { .pin_name = PIN_NAME_LIN1NSLP,.pin_desc = PIN_DSC_LIN1NSLP },
- { .pin_name = PIN_NAME_DININT, .pin_desc = PIN_DSC_DININT },
- /* GIOA pins */
- { .pin_name = PIN_NAME_DIN8, .pin_desc = PIN_DSC_DIN8 },
- { .pin_name = PIN_NAME_DIN9, .pin_desc = PIN_DSC_DIN9 },
- { .pin_name = PIN_NAME_DIN10, .pin_desc = PIN_DSC_DIN10 },
- { .pin_name = PIN_NAME_DIN11, .pin_desc = PIN_DSC_DIN11 },
- { .pin_name = PIN_NAME_DIN12, .pin_desc = PIN_DSC_DIN12 },
- { .pin_name = PIN_NAME_DIN13, .pin_desc = PIN_DSC_DIN13 },
- { .pin_name = PIN_NAME_DIN14, .pin_desc = PIN_DSC_DIN14 },
- { .pin_name = PIN_NAME_DIN15, .pin_desc = PIN_DSC_DIN15 },
- /* GIOB pins */
- { .pin_name = PIN_NAME_MOUT6EN, .pin_desc = PIN_DSC_MOUT6EN },
- { .pin_name = PIN_NAME_MOUT5EN, .pin_desc = PIN_DSC_MOUT5EN },
- { .pin_name = PIN_NAME_MOUT6IN, .pin_desc = PIN_DSC_MOUT6IN },
- { .pin_name = PIN_NAME_MOUT5IN, .pin_desc = PIN_DSC_MOUT5IN },
- { .pin_name = PIN_NAME_MOUT4EN, .pin_desc = PIN_DSC_MOUT4EN },
- { .pin_name = PIN_NAME_MOUT3EN, .pin_desc = PIN_DSC_MOUT3EN },
- { .pin_name = PIN_NAME_MOUT4IN, .pin_desc = PIN_DSC_MOUT4IN },
- { .pin_name = PIN_NAME_MOUT3IN, .pin_desc = PIN_DSC_MOUT3IN },
- /* HET1 pins */
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(0) },
- { .pin_name = PIN_NAME_HBREN, .pin_desc = PIN_DSC_HBREN },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(2) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(3) },
- { .pin_name = PIN_NAME_HBRDIR, .pin_desc = PIN_DSC_HBRDIR },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(5) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(6) },
- { .pin_name = PIN_NAME_HBRPWM, .pin_desc = PIN_DSC_HBRPWM },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(8) },
- { .pin_name = PIN_NAME_MOUT1IN, .pin_desc = PIN_DSC_MOUT1IN },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(10) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(11) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(12) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(13) },
- { .pin_name = PIN_NAME_MOUT2IN, .pin_desc = PIN_DSC_MOUT2IN },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(15) },
- { .pin_name = PIN_NAME_HOUT1IN, .pin_desc = PIN_DSC_HOUT1IN },
- { .pin_name = PIN_NAME_HOUT1DIAG,.pin_desc = PIN_DSC_HOUT1DIAG },
- { .pin_name = PIN_NAME_HOUT2IN, .pin_desc = PIN_DSC_HOUT2IN },
- { .pin_name = PIN_NAME_HOUT2DIAG,.pin_desc = PIN_DSC_HOUT2DIAG },
- { .pin_name = PIN_NAME_HOUT3IN, .pin_desc = PIN_DSC_HOUT3IN },
- { .pin_name = PIN_NAME_HOUT3DIAG,.pin_desc = PIN_DSC_HOUT3DIAG },
- { .pin_name = PIN_NAME_HOUT4IN, .pin_desc = PIN_DSC_HOUT4IN },
- { .pin_name = PIN_NAME_HOUT4DIAG,.pin_desc = PIN_DSC_HOUT4DIAG },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(22) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(23) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(24) },
- { .pin_name = PIN_NAME_HOUT5IN, .pin_desc = PIN_DSC_HOUT5IN },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(26) },
- { .pin_name = PIN_NAME_HOUT5DIAG,.pin_desc = PIN_DSC_HOUT5DIAG },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(28) },
- { .pin_name = PIN_NAME_HOUT6IN, .pin_desc = PIN_DSC_HOUT6IN },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET1_UNUSED(30) },
- { .pin_name = PIN_NAME_HOUT6DIAG,.pin_desc = PIN_DSC_HOUT6DIAG },
- /* HET2 pins */
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(0) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(1) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(2) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(3) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(4) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(5) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(6) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(7) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(8) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(9) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(10) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(11) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(12) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(13) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(14) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(15) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(16) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(17) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(18) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(19) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(20) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(21) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(22) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(23) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(24) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(25) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(26) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(27) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(28) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(29) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(30) },
- { .pin_name = PIN_NAME_UNUSED, .pin_desc = PIN_DSC_HET2_UNUSED(31) }
+ { .pin_name = PIN_NAME_GIOA0, .pin_desc = PIN_DSC_GIOA0 },
+ { .pin_name = PIN_NAME_GIOA1, .pin_desc = PIN_DSC_GIOA1 },
+ { .pin_name = PIN_NAME_GIOA2, .pin_desc = PIN_DSC_GIOA2 },
+ { .pin_name = PIN_NAME_GIOA3, .pin_desc = PIN_DSC_GIOA3 },
+ { .pin_name = PIN_NAME_GIOA4, .pin_desc = PIN_DSC_GIOA4 },
+ { .pin_name = PIN_NAME_GIOA5, .pin_desc = PIN_DSC_GIOA5 },
+ { .pin_name = PIN_NAME_GIOA6, .pin_desc = PIN_DSC_GIOA6 },
+ { .pin_name = PIN_NAME_GIOA7, .pin_desc = PIN_DSC_GIOA7 },
+ { .pin_name = PIN_NAME_GIOB0, .pin_desc = PIN_DSC_GIOA0 },
+ { .pin_name = PIN_NAME_GIOB1, .pin_desc = PIN_DSC_GIOB1 },
+ { .pin_name = PIN_NAME_GIOB2, .pin_desc = PIN_DSC_GIOB2 },
+ { .pin_name = PIN_NAME_GIOB3, .pin_desc = PIN_DSC_GIOB3 },
+ { .pin_name = PIN_NAME_GIOB4, .pin_desc = PIN_DSC_GIOB4 },
+ { .pin_name = PIN_NAME_GIOB5, .pin_desc = PIN_DSC_GIOB5 },
+ { .pin_name = PIN_NAME_GIOB6, .pin_desc = PIN_DSC_GIOB6 },
+ { .pin_name = PIN_NAME_GIOB7, .pin_desc = PIN_DSC_GIOB7 },
+ { .pin_name = PIN_NAME_NHET1_0, .pin_desc = PIN_DSC_NHET1_0 },
+ { .pin_name = PIN_NAME_NHET1_1, .pin_desc = PIN_DSC_NHET1_1 },
+ { .pin_name = PIN_NAME_NHET1_2, .pin_desc = PIN_DSC_NHET1_2 },
+ { .pin_name = PIN_NAME_NHET1_3, .pin_desc = PIN_DSC_NHET1_3 },
+ { .pin_name = PIN_NAME_NHET1_4, .pin_desc = PIN_DSC_NHET1_4 },
+ { .pin_name = PIN_NAME_NHET1_5, .pin_desc = PIN_DSC_NHET1_5 },
+ { .pin_name = PIN_NAME_NHET1_6, .pin_desc = PIN_DSC_NHET1_6 },
+ { .pin_name = PIN_NAME_NHET1_7, .pin_desc = PIN_DSC_NHET1_7 },
+ { .pin_name = PIN_NAME_NHET1_8, .pin_desc = PIN_DSC_NHET1_8 },
+ { .pin_name = PIN_NAME_NHET1_9, .pin_desc = PIN_DSC_NHET1_9 },
+ { .pin_name = PIN_NAME_NHET1_10, .pin_desc = PIN_DSC_NHET1_10 },
+ { .pin_name = PIN_NAME_NHET1_11, .pin_desc = PIN_DSC_NHET1_11 },
+ { .pin_name = PIN_NAME_NHET1_12, .pin_desc = PIN_DSC_NHET1_12 },
+ { .pin_name = PIN_NAME_NHET1_13, .pin_desc = PIN_DSC_NHET1_13 },
+ { .pin_name = PIN_NAME_NHET1_14, .pin_desc = PIN_DSC_NHET1_14 },
+ { .pin_name = PIN_NAME_NHET1_15, .pin_desc = PIN_DSC_NHET1_15 },
+ { .pin_name = PIN_NAME_NHET1_16, .pin_desc = PIN_DSC_NHET1_16 },
+ { .pin_name = PIN_NAME_NHET1_17, .pin_desc = PIN_DSC_NHET1_17 },
+ { .pin_name = PIN_NAME_NHET1_18, .pin_desc = PIN_DSC_NHET1_18 },
+ { .pin_name = PIN_NAME_NHET1_19, .pin_desc = PIN_DSC_NHET1_19 },
+ { .pin_name = PIN_NAME_NHET1_20, .pin_desc = PIN_DSC_NHET1_20 },
+ { .pin_name = PIN_NAME_NHET1_21, .pin_desc = PIN_DSC_NHET1_21 },
+ { .pin_name = PIN_NAME_NHET1_22, .pin_desc = PIN_DSC_NHET1_22 },
+ { .pin_name = PIN_NAME_NHET1_23, .pin_desc = PIN_DSC_NHET1_23 },
+ { .pin_name = PIN_NAME_NHET1_24, .pin_desc = PIN_DSC_NHET1_24 },
+ { .pin_name = PIN_NAME_NHET1_25, .pin_desc = PIN_DSC_NHET1_25 },
+ { .pin_name = PIN_NAME_NHET1_26, .pin_desc = PIN_DSC_NHET1_26 },
+ { .pin_name = PIN_NAME_NHET1_27, .pin_desc = PIN_DSC_NHET1_27 },
+ { .pin_name = PIN_NAME_NHET1_28, .pin_desc = PIN_DSC_NHET1_28 },
+ { .pin_name = PIN_NAME_NHET1_29, .pin_desc = PIN_DSC_NHET1_29 },
+ { .pin_name = PIN_NAME_NHET1_30, .pin_desc = PIN_DSC_NHET1_30 },
+ { .pin_name = PIN_NAME_NHET1_31, .pin_desc = PIN_DSC_NHET1_31 },
+ /* FIXME: add definitions of all unused pins DMM, HET2, SCI... */
};
* Get and set value function are defined for each port style (ADC, SPI, GPIO) in separated files.
*/
-//#include "hal/port_def.h"
-// Cannot include upper layer
-//#include "drv_adc.h"
-//#include "hal/port_spi.h"
-//#include "hal/port_gpio.h"
#include "hal/hal.h"
// Lists of pins assigned to the ports
-static uint32_t port_cfg_dinmcu[] = PORT_CFG_DINMCU;
-static uint32_t port_cfg_dinspi[] = PORT_CFG_DINSPI;
-static uint32_t port_cfg_houtdiag[] = PORT_CFG_HOUTDIAG;
-static uint32_t port_cfg_houtin[] = PORT_CFG_HOUTIN;
-static uint32_t port_cfg_houtifbk[] = PORT_CFG_HOUTIFBK;
+static uint32_t port_cfg_gioa[] = PORT_CFG_GIOA;
+static uint32_t port_cfg_giob[] = PORT_CFG_GIOB;
+static uint32_t port_cfg_nhet1[] = PORT_CFG_NHET1;
static uint32_t port_cfg_adc[] = PORT_CFG_ADC;
-static uint32_t port_cfg_lout[] = PORT_CFG_LOUT;
-static uint32_t port_cfg_dac1_2[] = PORT_CFG_DAC1_2;
-static uint32_t port_cfg_dac3_4[] = PORT_CFG_DAC3_4;
-static uint32_t port_cfg_dacdref[] = PORT_CFG_DACDREF;
-static uint32_t port_cfg_hbr[] = PORT_CFG_HBR;
-static uint32_t port_cfg_fray1[] = PORT_CFG_FRAY1;
-static uint32_t port_cfg_fray2[] = PORT_CFG_FRAY2;
-static uint32_t port_cfg_mouten[] = PORT_CFG_MOUTEN;
-static uint32_t port_cfg_moutin[] = PORT_CFG_MOUTIN;
// Port descriptors
-static port_desc_t port_desc_dinmcu = {
- .config = port_cfg_dinmcu,
- .numValues = PORT_NV_DINMCU,
- .interfaceType = PORT_INT_TYPE_DINMCU,
- .port_getfnc_ptr = PORT_GFC_DINMCU,
- .port_setfnc_ptr = PORT_SFC_DINMCU,
+static port_desc_t port_desc_gioa = {
+ .config = port_cfg_gioa,
+ .numValues = PORT_NV_GIOA,
+ .interfaceType = PORT_INT_TYPE_GIOA,
+ .port_getfnc_ptr = PORT_GFC_GIOA,
+ .port_setfnc_ptr = PORT_SFC_GIOA,
};
-static port_desc_t port_desc_dinspi = {
- .config = port_cfg_dinspi,
- .numValues = PORT_NV_DINSPI,
- .interfaceType = PORT_INT_TYPE_DINSPI,
- .port_getfnc_ptr = PORT_GFC_DINSPI,
- .port_setfnc_ptr = PORT_SFC_DINSPI,
+static port_desc_t port_desc_giob = {
+ .config = port_cfg_giob,
+ .numValues = PORT_NV_GIOB,
+ .interfaceType = PORT_INT_TYPE_GIOB,
+ .port_getfnc_ptr = PORT_GFC_GIOB,
+ .port_setfnc_ptr = PORT_SFC_GIOB,
};
-static port_desc_t port_desc_houtdiag = {
- .config = port_cfg_houtdiag,
- .numValues = PORT_NV_HOUTDIAG,
- .interfaceType = PORT_INT_TYPE_HOUTDIAG,
- .port_getfnc_ptr = PORT_GFC_HOUTDIAG,
- .port_setfnc_ptr = PORT_SFC_HOUTDIAG,
-};
-
-static port_desc_t port_desc_houtin = {
- .config = port_cfg_houtin,
- .numValues = PORT_NV_HOUTIN,
- .interfaceType = PORT_INT_TYPE_HOUTIN,
- .port_getfnc_ptr = PORT_GFC_HOUTIN,
- .port_setfnc_ptr = PORT_SFC_HOUTIN,
-};
-
-static port_desc_t port_desc_houtifbk = {
- .config = port_cfg_houtifbk,
- .numValues = PORT_NV_HOUTIFBK,
- .interfaceType = PORT_INT_TYPE_HOUTIFBK,
- .port_getfnc_ptr = PORT_GFC_HOUTIFBK,
- .port_setfnc_ptr = PORT_SFC_HOUTIFBK,
+static port_desc_t port_desc_nhet1 = {
+ .config = port_cfg_nhet1,
+ .numValues = PORT_NV_NHET1,
+ .interfaceType = PORT_INT_TYPE_NHET1,
+ .port_getfnc_ptr = PORT_GFC_NHET1,
+ .port_setfnc_ptr = PORT_SFC_NHET1,
};
static port_desc_t port_desc_adc = {
.port_setfnc_ptr = PORT_SFC_ADC,
};
-static port_desc_t port_desc_lout = {
- .config = port_cfg_lout,
- .numValues = PORT_NV_LOUT,
- .interfaceType = PORT_INT_TYPE_LOUT,
- .port_getfnc_ptr = PORT_GFC_LOUT,
- .port_setfnc_ptr = PORT_SFC_LOUT,
-};
-
-static port_desc_t port_desc_dac1_2 = {
- .config = port_cfg_dac1_2,
- .numValues = PORT_NV_DAC1_2,
- .interfaceType = PORT_INT_TYPE_DAC1_2,
- .port_getfnc_ptr = PORT_GFC_DAC1_2,
- .port_setfnc_ptr = PORT_SFC_DAC1_2,
-};
-
-static port_desc_t port_desc_dac3_4 = {
- .config = port_cfg_dac3_4,
- .numValues = PORT_NV_DAC3_4,
- .interfaceType = PORT_INT_TYPE_DAC3_4,
- .port_getfnc_ptr = PORT_GFC_DAC3_4,
- .port_setfnc_ptr = PORT_SFC_DAC3_4,
-};
-
-static port_desc_t port_desc_dacdref = {
- .config = port_cfg_dacdref,
- .numValues = PORT_NV_DACDREF,
- .interfaceType = PORT_INT_TYPE_DACDREF,
- .port_getfnc_ptr = PORT_GFC_DACDREF,
- .port_setfnc_ptr = PORT_SFC_DACDREF,
-};
-
-static port_desc_t port_desc_hbr = {
- .config = port_cfg_hbr,
- .numValues = PORT_NV_HBR,
- .interfaceType = PORT_INT_TYPE_HBR,
- .port_getfnc_ptr = PORT_GFC_HBR,
- .port_setfnc_ptr = PORT_SFC_HBR,
-};
-
-static port_desc_t port_desc_fray1 = {
- .config = port_cfg_fray1,
- .numValues = PORT_NV_FRAY1,
- .interfaceType = PORT_INT_TYPE_FRAY1,
- .port_getfnc_ptr = PORT_GFC_FRAY1,
- .port_setfnc_ptr = PORT_SFC_FRAY1,
-};
-
-static port_desc_t port_desc_fray2 = {
- .config = port_cfg_fray2,
- .numValues = PORT_NV_FRAY2,
- .interfaceType = PORT_INT_TYPE_FRAY2,
- .port_getfnc_ptr = PORT_GFC_FRAY2,
- .port_setfnc_ptr = PORT_SFC_FRAY2,
-};
-
-static port_desc_t port_desc_mouten = {
- .config = port_cfg_mouten,
- .numValues = PORT_NV_MOUTEN,
- .interfaceType = PORT_INT_TYPE_MOUTEN,
- .port_getfnc_ptr = PORT_GFC_MOUTEN,
- .port_setfnc_ptr = PORT_SFC_MOUTEN,
-};
-
-static port_desc_t port_desc_moutin = {
- .config = port_cfg_moutin,
- .numValues = PORT_NV_MOUTIN,
- .interfaceType = PORT_INT_TYPE_MOUTIN,
- .port_getfnc_ptr = PORT_GFC_MOUTIN,
- .port_setfnc_ptr = PORT_SFC_MOUTIN,
-};
-
// Maps of port names to port descriptors
static port_def_t port_definition[PORT_CNT] = {
- {.name = PORT_NAME_DINMCU, .desc = &port_desc_dinmcu},
- {.name = PORT_NAME_DINSPI, .desc = &port_desc_dinspi},
- {.name = PORT_NAME_HOUTDIAG, .desc = &port_desc_houtdiag},
- {.name = PORT_NAME_HOUTIN, .desc = &port_desc_houtin},
- {.name = PORT_NAME_HOUTIFBK, .desc = &port_desc_houtifbk},
- {.name = PORT_NAME_ADC, .desc = &port_desc_adc},
- {.name = PORT_NAME_LOUT, .desc = &port_desc_lout},
- {.name = PORT_NAME_DAC1_2, .desc = &port_desc_dac1_2},
- {.name = PORT_NAME_DAC3_4, .desc = &port_desc_dac3_4},
- {.name = PORT_NAME_DACDREF, .desc = &port_desc_dacdref},
- {.name = PORT_NAME_HBR, .desc = &port_desc_hbr},
- {.name = PORT_NAME_FRAY1, .desc = &port_desc_fray1},
- {.name = PORT_NAME_FRAY2, .desc = &port_desc_fray2},
- {.name = PORT_NAME_MOUTEN, .desc = &port_desc_mouten},
- {.name = PORT_NAME_MOUTIN, .desc = &port_desc_moutin}
+ {.name = PORT_NAME_GIOA, .desc = &port_desc_gioa},
+ {.name = PORT_NAME_GIOB, .desc = &port_desc_giob},
+ {.name = PORT_NAME_NHET1, .desc = &port_desc_nhet1},
+ {.name = PORT_NAME_ADC, .desc = &port_desc_adc}
};
/**
+++ /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 : din.c
- * Abstract:
- * Digital Input RPP API implementation file.
- *
- * References:
- * din.h
- * RPP API documentation.
- */
-
-
-#include "rpp/rpp.h"
-
-#ifndef FREERTOS_POSIX
-#include "drv/din.h"
-#endif
-
-static boolean_t initialized = FALSE;
-
-int8_t rpp_din_init()
-{
- if (initialized)
- return FAILURE;
- initialized = TRUE;
-#ifndef FREERTOS_POSIX
- dmmInit();
- gioInit();
- hetInit();
-#endif
-
- return SUCCESS;
-}
-
-int8_t rpp_din_ref(uint16_t ref_a, uint16_t ref_b)
-{
- if ((ref_a > 4095) || (ref_b > 4095))
- return -1;
-
-#ifndef FREERTOS_POSIX
- drv_din_ref(ref_a, ref_b);
-#endif
- return SUCCESS;
-}
-
-
-// Check for configuration changes to avoid SPI overhead
-static boolean_t config_changed = FALSE;
-
-// All cached values are 16 bits in the form [SG7,...,SG0][SP7,...,SP0]
-static uint16_t pull_cache = 0x0; /* 0 - pull-down, 1 - pull-up */
-static uint16_t active_cache = 0x0; /* 0 - tri-state, 1 - active */
-static uint16_t can_wake_cache = 0x0;
-
-int8_t rpp_din_setup(uint8_t pin, boolean_t pull_up,
- boolean_t active, boolean_t can_wake)
-{
- // Check range
- if (pin > 15)
- return -1;
-
- // Check programmable feature
- if (!pull_up && (pin > 7))
- return -2;
-
- // Set bits
- if (pull_up)
- bit_set(pull_cache, pin);
- else
- bit_clear(pull_cache, pin);
-
- if (active)
- bit_set(active_cache, pin);
- else
- bit_clear(active_cache, pin);
-
- if (can_wake)
- bit_set(can_wake_cache, pin);
- else
- bit_clear(can_wake_cache, pin);
-
- config_changed = TRUE;
- return SUCCESS;
-}
-
-
-static uint16_t in_cache = 0x0;
-
-int8_t rpp_din_get(uint8_t pin)
-{
- // Check range
- if (pin > 15)
- return -1;
-
- if (is_bit_set(in_cache, pin))
- return RPP_CLOSED;
- return RPP_OPEN;
-}
-
-int8_t rpp_din_get_tr(uint8_t pin)
-{
- // Check range
- if (pin < 8 || pin > 15)
- return -1;
-
-#ifndef FREERTOS_POSIX
- if (drv_din_get_varthr(pin) == 1)
- return HIGH;
-
-#endif
- return LOW;
-}
-
-
-
-static uint16_t diag_cache = 0x0;
-
-int8_t rpp_din_diag(uint8_t pin)
-{
- // Check range
- if (pin > 15)
- return -1;
-
- if (is_bit_set(diag_cache, pin))
- return HIGH;
- return LOW;
-}
-
-/*
- * pouzivat din_mod s pouzivanim enumu
- */
-int8_t rpp_din_update()
-{
-#ifndef FREERTOS_POSIX
- /// Setup pins
- if (config_changed) {
- uint16_t sp = 0x0;
- uint16_t sg = 0x0;
-
- // Reset chip
- din_set_reg(DIN_RESET_CMD, 0, 0);
- //rpp_sci_printf("din_reset()\r\n");
-
- // Set pull-type.
- // In DRV logic is inverted:
- // DRV: 1 - set pin as switch-to-battery. RPP: 0 - pull-down.
- // DRV: 0 - set pin as switch-to-ground. RPP: 1 - pull-up.
- sp = (~pull_cache) & 0xFF;
- din_set_reg(DIN_SETTINGS_CMD, 0xffff, sp);
- //rpp_sci_printf("din_set_pr(%X)\r\n", sp);
-
- // Set state type, active or tri-stated.
- // In DRV logic is inverted:
- // DRV: 1 - tri-state. RPP: 0 - tri-state.
- // DRV: 0 - active. RPP: 1 - active.
- sp = ((~active_cache) ) & 0xFF;
- sg = ((~active_cache) >> 8) & 0xFF;
- din_set_reg(DIN_TRI_STATE_CMD_YES, 0xffff, sp);
- din_set_reg(DIN_TRI_STATE_CMD_NO, 0xffff, sg);
- //rpp_sci_printf("din_set_stat(%X, %X)\r\n", sp, sg);
-
- // Set wake / interrupt.
- // IN DRV logic is not inverted.
- // DRV: 1 - can wake. RPP: 1 - can wake.
- // DRV: 0 - interrupt disabled. RPP: 0 - interrupt disabled.
- sp = (can_wake_cache ) & 0xFF;
- sg = (can_wake_cache >> 8) & 0xFF;
-
- din_set_reg(DIN_WAKE_UP_CMD_ENB, 0xffff, sp);
- din_set_reg(DIN_WAKE_UP_CMD_DIS, 0xffff, sg);
- //rpp_sci_printf("din_set_int(%X, %X)\r\n", sp, sg);
-
- // Mark configuration as commited
- config_changed = FALSE;
- }
-
- // Update cached values
- din_set_reg(DIN_SWITCH_STATUS_CMD, 0, 0);
- in_cache = din_get_val_word();
-
- // FIXME: Implement. Dummy assign for now.
- diag_cache = in_cache;
-
- if (diag_cache != in_cache)
- return FAILURE;
-
- #else /* ifndef FREERTOS_POSIX */
- UNUSED(config_changed);
- #endif /* ifndef FREERTOS_POSIX */
-
- return SUCCESS;
-}
linInit();
#endif
- rpp_din_init();
rpp_adc_init();
rpp_sci_init();
#ifndef FREERTOS_POSIX