From: Michal Horn Date: Thu, 16 Jul 2015 13:16:21 +0000 (+0200) Subject: Remove indirect port definition and the related macros X-Git-Tag: eaton-0.5.5~24 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/pes-rpp/rpp-lib.git/commitdiff_plain/cde8691bfe8f6263dce84d87db0a9d274b8b7c13 Remove indirect port definition and the related macros --- diff --git a/rpp/include/hal/_rm48_hdk/port_def.h b/rpp/include/hal/_rm48_hdk/port_def.h index 3ec8180..5d87b6b 100644 --- a/rpp/include/hal/_rm48_hdk/port_def.h +++ b/rpp/include/hal/_rm48_hdk/port_def.h @@ -11,9 +11,13 @@ #ifndef PORT_DEF_H_ #define PORT_DEF_H_ -#include "hal/hal.h" -#include "drv/drv.h" +#include "types.h" +enum port_interface_type { + ADC = 1, + SPI, + GPIO +}; /** * @brief Port descriptor * @@ -31,7 +35,7 @@ typedef struct port_desc_st { for GPIO: number of pins on the port for ADC: number of channels to be read from ADC. */ - uint32_t interfaceType; /**< Type of the interface to which the port or its controller is connected. + enum port_interface_type interfaceType; /**< Type of the interface to which the port or its controller is connected. Can be SPI, ADC or GPIO */ uint32_t (*port_getfnc_ptr)(uint32_t *config, uint32_t num_val, uint32_t *values); /**< Pointer to a getter function. If it is NULL, than port is write only. @@ -52,49 +56,11 @@ typedef struct port_def_st { port_desc_t *desc; } port_def_t; -#define PORT_INTERFACE_ADC 0x1 -#define PORT_INTERFACE_SPI 0x2 -#define PORT_INTERFACE_GPIO 0x3 - #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_gpio_port_get_val -#define PORT_SFC_GIOA &hal_gpio_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_gpio_port_get_val -#define PORT_SFC_GIOB &hal_gpio_port_set_val -#define PORT_INT_TYPE_GIOB PORT_INTERFACE_GPIO - -/* Some pins are commented out, because they are muxed with SCI. */ -#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 30 -#define PORT_GFC_NHET1 &hal_gpio_port_get_val -#define PORT_SFC_NHET1 &hal_gpio_port_set_val -#define PORT_INT_TYPE_NHET1 PORT_INTERFACE_GPIO - -#define PORT_ADC_CHANNEL_NUM 16 +#define PORT_NAME_NHET1 "NHET1" #define PORT_NAME_ADC "ADC" -#define PORT_CFG_ADC { (uint32_t)adcREG1, adcGROUP1, 1 } -#define PORT_NV_ADC PORT_ADC_CHANNEL_NUM -#define PORT_GFC_ADC &adc_get_port_val -#define PORT_SFC_ADC NULL -#define PORT_INT_TYPE_ADC PORT_INTERFACE_ADC #endif /* PORT_DEF_H_ */ diff --git a/rpp/include/hal/_tms570_hdk/port_def.h b/rpp/include/hal/_tms570_hdk/port_def.h index 3ec8180..32f94c1 100644 --- a/rpp/include/hal/_tms570_hdk/port_def.h +++ b/rpp/include/hal/_tms570_hdk/port_def.h @@ -11,8 +11,13 @@ #ifndef PORT_DEF_H_ #define PORT_DEF_H_ -#include "hal/hal.h" -#include "drv/drv.h" +#include "types.h" + +enum port_interface_type { + ADC = 1, + SPI, + GPIO +}; /** * @brief Port descriptor @@ -31,7 +36,7 @@ typedef struct port_desc_st { for GPIO: number of pins on the port for ADC: number of channels to be read from ADC. */ - uint32_t interfaceType; /**< Type of the interface to which the port or its controller is connected. + enum port_interface_type interfaceType; /**< Type of the interface to which the port or its controller is connected. Can be SPI, ADC or GPIO */ uint32_t (*port_getfnc_ptr)(uint32_t *config, uint32_t num_val, uint32_t *values); /**< Pointer to a getter function. If it is NULL, than port is write only. @@ -52,49 +57,11 @@ typedef struct port_def_st { port_desc_t *desc; } port_def_t; -#define PORT_INTERFACE_ADC 0x1 -#define PORT_INTERFACE_SPI 0x2 -#define PORT_INTERFACE_GPIO 0x3 - #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_gpio_port_get_val -#define PORT_SFC_GIOA &hal_gpio_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_gpio_port_get_val -#define PORT_SFC_GIOB &hal_gpio_port_set_val -#define PORT_INT_TYPE_GIOB PORT_INTERFACE_GPIO - -/* Some pins are commented out, because they are muxed with SCI. */ -#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 30 -#define PORT_GFC_NHET1 &hal_gpio_port_get_val -#define PORT_SFC_NHET1 &hal_gpio_port_set_val -#define PORT_INT_TYPE_NHET1 PORT_INTERFACE_GPIO - -#define PORT_ADC_CHANNEL_NUM 16 +#define PORT_NAME_NHET1 "NHET1" #define PORT_NAME_ADC "ADC" -#define PORT_CFG_ADC { (uint32_t)adcREG1, adcGROUP1, 1 } -#define PORT_NV_ADC PORT_ADC_CHANNEL_NUM -#define PORT_GFC_ADC &adc_get_port_val -#define PORT_SFC_ADC NULL -#define PORT_INT_TYPE_ADC PORT_INTERFACE_ADC #endif /* PORT_DEF_H_ */ diff --git a/rpp/include/hal/_tms570_hydctr/port_def.h b/rpp/include/hal/_tms570_hydctr/port_def.h index 3ec8180..7cb900f 100644 --- a/rpp/include/hal/_tms570_hydctr/port_def.h +++ b/rpp/include/hal/_tms570_hydctr/port_def.h @@ -11,8 +11,13 @@ #ifndef PORT_DEF_H_ #define PORT_DEF_H_ -#include "hal/hal.h" -#include "drv/drv.h" +#include "types.h" + +enum port_interface_type { + ADC = 1, + SPI, + GPIO +}; /** * @brief Port descriptor @@ -31,7 +36,7 @@ typedef struct port_desc_st { for GPIO: number of pins on the port for ADC: number of channels to be read from ADC. */ - uint32_t interfaceType; /**< Type of the interface to which the port or its controller is connected. + enum port_interface_type interfaceType; /**< Type of the interface to which the port or its controller is connected. Can be SPI, ADC or GPIO */ uint32_t (*port_getfnc_ptr)(uint32_t *config, uint32_t num_val, uint32_t *values); /**< Pointer to a getter function. If it is NULL, than port is write only. @@ -52,49 +57,11 @@ typedef struct port_def_st { port_desc_t *desc; } port_def_t; -#define PORT_INTERFACE_ADC 0x1 -#define PORT_INTERFACE_SPI 0x2 -#define PORT_INTERFACE_GPIO 0x3 - #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_gpio_port_get_val -#define PORT_SFC_GIOA &hal_gpio_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_gpio_port_get_val -#define PORT_SFC_GIOB &hal_gpio_port_set_val -#define PORT_INT_TYPE_GIOB PORT_INTERFACE_GPIO - -/* Some pins are commented out, because they are muxed with SCI. */ #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 30 -#define PORT_GFC_NHET1 &hal_gpio_port_get_val -#define PORT_SFC_NHET1 &hal_gpio_port_set_val -#define PORT_INT_TYPE_NHET1 PORT_INTERFACE_GPIO - -#define PORT_ADC_CHANNEL_NUM 16 #define PORT_NAME_ADC "ADC" -#define PORT_CFG_ADC { (uint32_t)adcREG1, adcGROUP1, 1 } -#define PORT_NV_ADC PORT_ADC_CHANNEL_NUM -#define PORT_GFC_ADC &adc_get_port_val -#define PORT_SFC_ADC NULL -#define PORT_INT_TYPE_ADC PORT_INTERFACE_ADC #endif /* PORT_DEF_H_ */ diff --git a/rpp/include/hal/_tms570_rpp/port_def.h b/rpp/include/hal/_tms570_rpp/port_def.h index cbda7e1..e65cbaf 100644 --- a/rpp/include/hal/_tms570_rpp/port_def.h +++ b/rpp/include/hal/_tms570_rpp/port_def.h @@ -10,8 +10,13 @@ #ifndef PORT_DEF_H_ #define PORT_DEF_H_ -//#include "hal_gpio_tms570_def.h" -#include "hal/hal.h" +#include "types.h" + +enum port_interface_type { + ADC = 1, + SPI, + GPIO +}; /** * @brief Port descriptor @@ -30,7 +35,7 @@ typedef struct port_desc_st { for GPIO: number of pins on the port for ADC: number of channels to be read from ADC. */ - uint32_t interfaceType; /**< Type of the interface to which the port or its controller is connected. + enum port_interface_type interfaceType; /**< Type of the interface to which the port or its controller is connected. Can be SPI, ADC or GPIO */ uint32_t (*port_getfnc_ptr)(uint32_t *config, uint32_t num_val, uint32_t *values); /**< Pointer to a getter function. If it is NULL, than port is write only. @@ -51,121 +56,22 @@ typedef struct port_def_st { port_desc_t *desc; } port_def_t; -#define PORT_INTERFACE_ADC 0x1 -#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_gpio_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 -#define PORT_SFC_DINSPI &hal_spi_port_transfer_command -#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_gpio_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_gpio_port_get_val -#define PORT_SFC_HOUTIN &hal_gpio_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_ADC_CHANNEL_NUM 12 #define PORT_NAME_ADC "ADC" -#define PORT_CFG_ADC { (uint32_t)adcREG1, adcGROUP1, 1 } -#define PORT_NV_ADC PORT_ADC_CHANNEL_NUM -#define PORT_GFC_ADC &adc_get_port_val -#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 -#define PORT_SFC_LOUT &hal_spi_port_transfer_command -#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 -#define PORT_SFC_DAC1_2 &hal_spi_port_transfer_command -#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 -#define PORT_SFC_DAC3_4 &hal_spi_port_transfer_command -#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 -#define PORT_SFC_DACDREF &hal_spi_port_transfer_command -#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 -#define PORT_SFC_HBR &hal_spi_port_transfer_command -#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 -#define PORT_SFC_FRAY1 &hal_spi_port_transfer_command -#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 -#define PORT_SFC_FRAY2 &hal_spi_port_transfer_command -#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_gpio_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_gpio_port_get_val -#define PORT_SFC_MOUTIN &hal_gpio_port_set_val -#define PORT_INT_TYPE_MOUTIN PORT_INTERFACE_GPIO #endif /* PORT_DEF_H_ */ diff --git a/rpp/include/hal/hal.h b/rpp/include/hal/hal.h index 3076035..43d9a43 100644 --- a/rpp/include/hal/hal.h +++ b/rpp/include/hal/hal.h @@ -184,8 +184,6 @@ uint32_t hal_gpio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_ */ const port_def_t *hal_port_get_map(); -port_desc_t *hal_port_get_dsc(const char *port_name, int len); - /** * Get port descriptor assigned to port name. * @param[in] port_name Pointer to string - the name of the port. @@ -194,6 +192,8 @@ port_desc_t *hal_port_get_dsc(const char *port_name, int len); */ port_desc_t *hal_port_get_dsc(const char *port_name, int len); +uint32_t hal_port_get_val_cnt(const port_desc_t* port_desc); + /** * Transfer command through the spi * @param[in] config Address of the SPI diff --git a/rpp/src/drv/hout.c b/rpp/src/drv/hout.c index 8c60532..80bad2e 100644 --- a/rpp/src/drv/hout.c +++ b/rpp/src/drv/hout.c @@ -23,11 +23,11 @@ #define HOUT_PWM_RUNNING 0x100 /** Map of hout_in pin descriptors to their index **/ -static uint32_t hout_pin_in_descs[PORT_NV_HOUTIN] = {PIN_DSC_HOUT1IN, PIN_DSC_HOUT2IN, PIN_DSC_HOUT3IN, PIN_DSC_HOUT4IN, PIN_DSC_HOUT5IN, PIN_DSC_HOUT6IN}; +static uint32_t hout_pin_in_descs[] = {PIN_DSC_HOUT1IN, PIN_DSC_HOUT2IN, PIN_DSC_HOUT3IN, PIN_DSC_HOUT4IN, PIN_DSC_HOUT5IN, PIN_DSC_HOUT6IN}; /** Map of hout_diag pin descriptors to their index **/ -static uint32_t hout_pin_diag_descs[PORT_NV_HOUTDIAG] = {PIN_DSC_HOUT1DIAG, PIN_DSC_HOUT2DIAG, PIN_DSC_HOUT3DIAG, PIN_DSC_HOUT4DIAG, PIN_DSC_HOUT5DIAG, PIN_DSC_HOUT6DIAG}; +static uint32_t hout_pin_diag_descs[] = {PIN_DSC_HOUT1DIAG, PIN_DSC_HOUT2DIAG, PIN_DSC_HOUT3DIAG, PIN_DSC_HOUT4DIAG, PIN_DSC_HOUT5DIAG, PIN_DSC_HOUT6DIAG}; /** PWM modules from N2HET mapped to HOUT pin ID 0-5 **/ -static uint8_t hout_pwm_map[PORT_NV_HOUTIN] = {pwm1, pwm2, pwm3, pwm4, pwm5, pwm6}; +static uint8_t hout_pwm_map[] = {pwm1, pwm2, pwm3, pwm4, pwm5, pwm6}; /** Flag variable * 1st byte - if pwm for each HOUT pin was set a period and duty, so it can be started. * 2nd byte - if pwm is currently running @@ -144,7 +144,8 @@ int hout_fail(uint8_t hout_id) uint16_t pwm_running; int err_cnt = 0; - if (hout_id >= PORT_NV_HOUTIN) return -1; // Bad parameter + if (hout_id >= hal_port_get_val_cnt(hal_port_get_dsc(PORT_NAME_HOUTIN, -1))) + return -1; // Bad parameter pwm_running = hout_pwm_state & (HOUT_PWM_RUNNING << hout_id); if (!pwm_running) diff --git a/rpp/src/hal/_rm48_hdk/port_def.c b/rpp/src/hal/_rm48_hdk/port_def.c index 14f6c54..61f4521 100644 --- a/rpp/src/hal/_rm48_hdk/port_def.c +++ b/rpp/src/hal/_rm48_hdk/port_def.c @@ -24,46 +24,63 @@ */ #include "hal/hal.h" +#include "drv/spi.h" +#include "drv/_rm48_hdk/adc.h" // Lists of pins assigned to the ports -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_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 +}; +static uint32_t 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 +}; +static uint32_t 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_7, PIN_DSC_NHET1_8, PIN_DSC_NHET1_9, + PIN_DSC_NHET1_10, PIN_DSC_NHET1_11, PIN_DSC_NHET1_12, + 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 +}; +static uint32_t port_cfg_adc[] = { (uint32_t)adcREG1, adcGROUP1, 1 }; // Port descriptors 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, + .config = port_cfg_gioa, + .numValues = 8, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - 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, + .config = port_cfg_giob, + .numValues = 8, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - 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, + .config = port_cfg_nhet1, + .numValues = 30, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - static port_desc_t port_desc_adc = { - .config = port_cfg_adc, - .numValues = PORT_NV_ADC, - .interfaceType = PORT_INT_TYPE_ADC, - .port_getfnc_ptr = PORT_GFC_ADC, - .port_setfnc_ptr = PORT_SFC_ADC, + .config = port_cfg_adc, + .numValues = 16, + .interfaceType = ADC, + .port_getfnc_ptr = &adc_get_port_val, + .port_setfnc_ptr = ((void *)0), }; + // Maps of port names to port descriptors port_def_t port_definition[PORT_CNT] = { {.name = PORT_NAME_GIOA, .desc = &port_desc_gioa}, diff --git a/rpp/src/hal/_tms570_hdk/port_def.c b/rpp/src/hal/_tms570_hdk/port_def.c index 14f6c54..aaab689 100644 --- a/rpp/src/hal/_tms570_hdk/port_def.c +++ b/rpp/src/hal/_tms570_hdk/port_def.c @@ -24,46 +24,63 @@ */ #include "hal/hal.h" +#include "drv/spi.h" +#include "drv/_tms570_hdk/adc.h" // Lists of pins assigned to the ports -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_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 +}; +static uint32_t 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 +}; +static uint32_t 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_7, PIN_DSC_NHET1_8, PIN_DSC_NHET1_9, + PIN_DSC_NHET1_10, PIN_DSC_NHET1_11, PIN_DSC_NHET1_12, + 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 +}; +static uint32_t port_cfg_adc[] = { (uint32_t)adcREG1, adcGROUP1, 1 }; // Port descriptors 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, + .config = port_cfg_gioa, + .numValues = 8, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - 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, + .config = port_cfg_giob, + .numValues = 8, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - 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, + .config = port_cfg_nhet1, + .numValues = 30, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - static port_desc_t port_desc_adc = { - .config = port_cfg_adc, - .numValues = PORT_NV_ADC, - .interfaceType = PORT_INT_TYPE_ADC, - .port_getfnc_ptr = PORT_GFC_ADC, - .port_setfnc_ptr = PORT_SFC_ADC, + .config = port_cfg_adc, + .numValues = 16, + .interfaceType = ADC, + .port_getfnc_ptr = &adc_get_port_val, + .port_setfnc_ptr = ((void *)0), }; + // Maps of port names to port descriptors port_def_t port_definition[PORT_CNT] = { {.name = PORT_NAME_GIOA, .desc = &port_desc_gioa}, diff --git a/rpp/src/hal/_tms570_hydctr/port_def.c b/rpp/src/hal/_tms570_hydctr/port_def.c index 14f6c54..c9537ef 100644 --- a/rpp/src/hal/_tms570_hydctr/port_def.c +++ b/rpp/src/hal/_tms570_hydctr/port_def.c @@ -24,44 +24,64 @@ */ #include "hal/hal.h" +#include "drv/spi.h" +#include "drv/_tms570_hydctr/adc.h" + +// 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); // Lists of pins assigned to the ports -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_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 +}; +static uint32_t 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 +}; +static uint32_t 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_7, PIN_DSC_NHET1_8, PIN_DSC_NHET1_9, + PIN_DSC_NHET1_10, PIN_DSC_NHET1_11, PIN_DSC_NHET1_12, + 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 +}; +static uint32_t port_cfg_adc[] = { (uint32_t)adcREG1, adcGROUP1, 1 }; // Port descriptors 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, + .config = port_cfg_gioa, + .numValues = 8, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - 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, + .config = port_cfg_giob, + .numValues = 8, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - 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, + .config = port_cfg_nhet1, + .numValues = 30, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - static port_desc_t port_desc_adc = { - .config = port_cfg_adc, - .numValues = PORT_NV_ADC, - .interfaceType = PORT_INT_TYPE_ADC, - .port_getfnc_ptr = PORT_GFC_ADC, - .port_setfnc_ptr = PORT_SFC_ADC, + .config = port_cfg_adc, + .numValues = 16, + .interfaceType = ADC, + .port_getfnc_ptr = &adc_get_port_val, + .port_setfnc_ptr = ((void *)0), }; // Maps of port names to port descriptors diff --git a/rpp/src/hal/_tms570_rpp/port_def.c b/rpp/src/hal/_tms570_rpp/port_def.c index 1f21131..bc48325 100644 --- a/rpp/src/hal/_tms570_rpp/port_def.c +++ b/rpp/src/hal/_tms570_rpp/port_def.c @@ -25,143 +25,150 @@ #include "hal/hal.h" #include "drv/spi.h" +#include "drv/_tms570_rpp/adc.h" + +// 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); + // 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_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; +static uint32_t 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 +}; +static uint32_t port_cfg_dinspi[] = { 1, 0 }; +static uint32_t port_cfg_houtdiag[] = { + PIN_DSC_HOUT1DIAG, PIN_DSC_HOUT2DIAG, PIN_DSC_HOUT3DIAG, + PIN_DSC_HOUT4DIAG, PIN_DSC_HOUT5DIAG, PIN_DSC_HOUT6DIAG +}; +static uint32_t port_cfg_houtin[] = { + PIN_DSC_HOUT1IN, PIN_DSC_HOUT2IN, PIN_DSC_HOUT3IN, + PIN_DSC_HOUT4IN, PIN_DSC_HOUT5IN, PIN_DSC_HOUT6IN +}; +static uint32_t port_cfg_houtifbk[] = { (uint32_t)adcREG2, adcGROUP1, 0 }; +static uint32_t port_cfg_adc[] = { (uint32_t)adcREG1, adcGROUP1, 1 }; +static uint32_t port_cfg_lout[] = { 1, 1 }; +static uint32_t port_cfg_dac1_2[] = { 3, 0 }; +static uint32_t port_cfg_dac3_4[] = { 3, 1 }; +static uint32_t port_cfg_dacdref[] = { 3, 2 }; +static uint32_t port_cfg_hbr[] = { 4, 0 }; +static uint32_t port_cfg_fray1[] = { 4, 1 }; +static uint32_t port_cfg_fray2[] = { 4, 2 }; +static uint32_t port_cfg_mouten[] = { + PIN_DSC_MOUT1EN, PIN_DSC_MOUT2EN, PIN_DSC_MOUT3EN, + PIN_DSC_MOUT4EN, PIN_DSC_MOUT5EN, PIN_DSC_MOUT6EN +}; +static uint32_t port_cfg_moutin[] = { + PIN_DSC_MOUT1IN, PIN_DSC_MOUT2IN, PIN_DSC_MOUT3IN, + PIN_DSC_MOUT4IN, PIN_DSC_MOUT5IN, PIN_DSC_MOUT6IN +}; // 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, + .config = port_cfg_dinmcu, + .numValues = 8, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = ((void *)0), }; - 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, + .config = port_cfg_dinspi, + .numValues = 3, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_houtdiag, + .numValues = 6, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = ((void *)0), }; - 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, + .config = port_cfg_houtin, + .numValues = 6, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; - 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, + .config = port_cfg_houtifbk, + .numValues = 6, + .interfaceType = ADC, + .port_getfnc_ptr = &adc_get_port_val, + .port_setfnc_ptr = ((void *)0), }; - static port_desc_t port_desc_adc = { - .config = port_cfg_adc, - .numValues = PORT_NV_ADC, - .interfaceType = PORT_INT_TYPE_ADC, - .port_getfnc_ptr = PORT_GFC_ADC, - .port_setfnc_ptr = PORT_SFC_ADC, + .config = port_cfg_adc, + .numValues = 12, + .interfaceType = ADC, + .port_getfnc_ptr = &adc_get_port_val, + .port_setfnc_ptr = ((void *)0), }; - 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, + .config = port_cfg_lout, + .numValues = 4, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_dac1_2, + .numValues = 2, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_dac3_4, + .numValues = 2, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_dacdref, + .numValues = 2, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_hbr, + .numValues = 2, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_fray1, + .numValues = 2, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_fray2, + .numValues = 2, + .interfaceType = SPI, + .port_getfnc_ptr = ((void *)0), + .port_setfnc_ptr = &hal_spi_port_transfer_command, }; - 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, + .config = port_cfg_mouten, + .numValues = 6, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = ((void *)0), }; - 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, + .config = port_cfg_moutin, + .numValues = 6, + .interfaceType = GPIO, + .port_getfnc_ptr = &hal_gpio_port_get_val, + .port_setfnc_ptr = &hal_gpio_port_set_val, }; // Maps of port names to port descriptors diff --git a/rpp/src/hal/hal.c b/rpp/src/hal/hal.c index 5156226..c7c3483 100644 --- a/rpp/src/hal/hal.c +++ b/rpp/src/hal/hal.c @@ -192,6 +192,15 @@ port_desc_t *hal_port_get_dsc(const char *port_name, int len) return NULL; } +uint32_t hal_port_get_val_cnt(const port_desc_t* port_desc) { + if (port_desc != NULL) { + return port_desc->numValues; + } + else { + return 0; + } +} + uint32_t hal_spi_port_transfer_command(uint32_t *config, uint32_t num_bytes, const uint32_t *commands) { spi_drv_t *ifc;