#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_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_gio_port_get_val
-#define PORT_SFC_GIOB &hal_gio_port_set_val
+#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. */
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_gio_port_get_val
-#define PORT_SFC_NHET1 &hal_gio_port_set_val
+#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_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_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_gio_port_get_val
-#define PORT_SFC_GIOB &hal_gio_port_set_val
+#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. */
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_gio_port_get_val
-#define PORT_SFC_NHET1 &hal_gio_port_set_val
+#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_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_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_gio_port_get_val
-#define PORT_SFC_GIOB &hal_gio_port_set_val
+#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. */
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_gio_port_get_val
-#define PORT_SFC_NHET1 &hal_gio_port_set_val
+#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_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_GFC_DINMCU &hal_gpio_port_get_val
#define PORT_SFC_DINMCU NULL
#define PORT_INT_TYPE_DINMCU PORT_INTERFACE_GPIO
#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_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_gio_port_get_val
-#define PORT_SFC_HOUTIN &hal_gio_port_set_val
+#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
#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_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_gio_port_get_val
-#define PORT_SFC_MOUTIN &hal_gio_port_set_val
+#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_ */
* @param[in] pin_dsc pin descriptor
* @return always 0
*/
-int hal_gpio_pin_direction_input(uint32_t pin_dsc);
+int hal_gpio_pin_set_dir_in(uint32_t pin_dsc);
/**
* Set pin direction to output
* @param[in] pin_dsc pin descriptor
* @return always 0
*/
-int hal_gpio_pin_direction_output(uint32_t pin_dsc, uint32_t value);
+int hal_gpio_pin_set_dir_out(uint32_t pin_dsc, uint32_t value);
/**
* Get pin direction
* @param[in] pin_dsc pin descriptor
* @return 1 - output, 0 - input
*/
-int hal_gpio_pin_get_direction(uint32_t pin_dsc);
+int hal_gpio_pin_get_dir(uint32_t pin_dsc);
/**
* Set pin as pull down or pull up and pull resistor enabled or disabled.
* PORT_CONF_MODE_PDIS - pull resistor disable
* @return always 0
*/
-uint32_t hal_gpio_pin_conf_mode(uint32_t pin_dsc, uint32_t mode);
+uint32_t hal_gpio_pin_set_mode(uint32_t pin_dsc, uint32_t mode);
/**
* Configure pin to be open drain or not
*
* @return always 0
*/
-uint32_t hal_gpio_pin_conf_od(uint32_t pin_dsc, uint32_t od);
+uint32_t hal_gpio_pin_set_od(uint32_t pin_dsc, uint32_t od);
/**
* Configure pin
*
* @return always 0
*/
-uint32_t hal_gpio_pin_conf_set(uint32_t pin_dsc, uint32_t conf);
+uint32_t hal_gpio_pin_set_config(uint32_t pin_dsc, uint32_t conf);
/**
* Do the initial pin configuration according values in pin descriptor
* @param[in] pin_dsc pin descriptor
* @return always 0;
*/
-uint32_t hal_gpio_pin_conf(uint32_t pin_dsc);
+uint32_t hal_gpio_pin_configure(uint32_t pin_dsc);
/**
* Get values of all pins of given port.
* @param[out] values Stored values of all pins of the port. 1st bit -> pin0, 2nd bit -> pin1...
* @return always 0
*/
-uint32_t hal_gio_port_get_val(uint32_t *config, uint32_t num_val, uint32_t *values);
+uint32_t hal_gpio_port_get_val(uint32_t *config, uint32_t num_val, uint32_t *values);
/**
* Set values to all pins of given port.
* @param[in] values Stored values of all pins of the port. 1st bit -> pin0, 2nd bit -> pin1...
* @return always 0
*/
-uint32_t hal_gio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_t *values);
+uint32_t hal_gpio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_t *values);
/**
* Get port descriptor assigned to port name.
* @param[in] len Length of the name, if terminated by '/0', then len=-1
* @return Port descriptor or NULL if not found
*/
-const port_def_t *hal_port_get_definitions();
+const port_def_t *hal_port_get_map();
port_desc_t *hal_port_get_dsc(const char *port_name, int len);
{.name = PORT_NAME_NHET1, .desc = &port_desc_nhet1},
{.name = PORT_NAME_ADC, .desc = &port_desc_adc}
};
+
+/**
+ * Get port descriptor assigned to port name.
+ * @param[in] port_name Pointer to string - the name of the port.
+ * @param[in] len Length of the name, if terminated by '/0', then len=-1
+ * @return Port descriptor or NULL if not found
+ */
+port_desc_t *hal_port_get_dsc(const char *port_name, int len)
+{
+ uint32_t i;
+ const char *port_name_ptr;
+ char port_name_term[32];
+
+ if (len != -1) { // port name not terminated by '\0'
+ strncpy(port_name_term, port_name, len);
+ port_name_term[len] = '\0';
+ port_name_ptr = port_name_term;
+ }
+ else port_name_ptr = port_name;
+
+ for (i = 0; i < PORT_CNT; i++) {
+ if (strcmp(port_name_ptr, port_definition[i].name) == 0)
+ return port_definition[i].desc;
+ }
+ return NULL;
+}
+
+/**
+ * Get port descriptor assigned to port name.
+ * @param[in] port_name Pointer to string - the name of the port.
+ * @param[in] len Length of the name, if terminated by '/0', then len=-1
+ * @return Port descriptor or NULL if not found
+ */
+const port_def_t *hal_port_get_map()
+{
+ return (const port_def_t *)port_definition;
+}
{.name = PORT_NAME_NHET1, .desc = &port_desc_nhet1},
{.name = PORT_NAME_ADC, .desc = &port_desc_adc}
};
+
+/**
+ * Get port descriptor assigned to port name.
+ * @param[in] port_name Pointer to string - the name of the port.
+ * @param[in] len Length of the name, if terminated by '/0', then len=-1
+ * @return Port descriptor or NULL if not found
+ */
+port_desc_t *hal_port_get_dsc(const char *port_name, int len)
+{
+ uint32_t i;
+ const char *port_name_ptr;
+ char port_name_term[32];
+
+ if (len != -1) { // port name not terminated by '\0'
+ strncpy(port_name_term, port_name, len);
+ port_name_term[len] = '\0';
+ port_name_ptr = port_name_term;
+ }
+ else port_name_ptr = port_name;
+
+ for (i = 0; i < PORT_CNT; i++) {
+ if (strcmp(port_name_ptr, port_definition[i].name) == 0)
+ return port_definition[i].desc;
+ }
+ return NULL;
+}
+
+/**
+ * Get port descriptor assigned to port name.
+ * @param[in] port_name Pointer to string - the name of the port.
+ * @param[in] len Length of the name, if terminated by '/0', then len=-1
+ * @return Port descriptor or NULL if not found
+ */
+const port_def_t *hal_port_get_map()
+{
+ return (const port_def_t *)port_definition;
+}
{.name = PORT_NAME_NHET1, .desc = &port_desc_nhet1},
{.name = PORT_NAME_ADC, .desc = &port_desc_adc}
};
+
+/**
+ * Get port descriptor assigned to port name.
+ * @param[in] port_name Pointer to string - the name of the port.
+ * @param[in] len Length of the name, if terminated by '/0', then len=-1
+ * @return Port descriptor or NULL if not found
+ */
+port_desc_t *hal_port_get_dsc(const char *port_name, int len)
+{
+ uint32_t i;
+ const char *port_name_ptr;
+ char port_name_term[32];
+
+ if (len != -1) { // port name not terminated by '\0'
+ strncpy(port_name_term, port_name, len);
+ port_name_term[len] = '\0';
+ port_name_ptr = port_name_term;
+ }
+ else port_name_ptr = port_name;
+
+ for (i = 0; i < PORT_CNT; i++) {
+ if (strcmp(port_name_ptr, port_definition[i].name) == 0)
+ return port_definition[i].desc;
+ }
+ return NULL;
+}
+
+/**
+ * Get port descriptor assigned to port name.
+ * @param[in] port_name Pointer to string - the name of the port.
+ * @param[in] len Length of the name, if terminated by '/0', then len=-1
+ * @return Port descriptor or NULL if not found
+ */
+const port_def_t *hal_port_get_map()
+{
+ return (const port_def_t *)port_definition;
+}
}
-int hal_gpio_pin_direction_input(uint32_t pin_dsc)
+int hal_gpio_pin_set_dir_in(uint32_t pin_dsc)
{
hal_gpio_pin_get_port_base(pin_dsc)->DIR &= ~(1 << (pin_dsc & 0x1f));
return 0;
}
-int hal_gpio_pin_direction_output(uint32_t pin_dsc, uint32_t value)
+int hal_gpio_pin_set_dir_out(uint32_t pin_dsc, uint32_t value)
{
hal_gpio_pin_set_value(pin_dsc, value);
hal_gpio_pin_get_port_base(pin_dsc)->DIR |= (1 << (pin_dsc & 0x1f));
return 0;
}
-int hal_gpio_pin_get_direction(uint32_t pin_dsc)
+int hal_gpio_pin_get_dir(uint32_t pin_dsc)
{
return (hal_gpio_pin_get_port_base(pin_dsc)->DIR >> (pin_dsc & 0x1f)) & 1;
}
-uint32_t hal_gpio_pin_conf_mode(uint32_t pin_dsc, uint32_t mode)
+uint32_t hal_gpio_pin_set_mode(uint32_t pin_dsc, uint32_t mode)
{
gioPORT_t *gioPort = hal_gpio_pin_get_port_base(pin_dsc);
}
-uint32_t hal_gpio_pin_conf_od(uint32_t pin_dsc, uint32_t od)
+uint32_t hal_gpio_pin_set_od(uint32_t pin_dsc, uint32_t od)
{
gioPORT_t *gioPort = hal_gpio_pin_get_port_base(pin_dsc);
}
-uint32_t hal_gpio_pin_conf_set(uint32_t pin_dsc, uint32_t conf)
+uint32_t hal_gpio_pin_set_config(uint32_t pin_dsc, uint32_t conf)
{
pin_dsc &= ~PORT_CONF_MASK;
- hal_gpio_pin_conf_mode(pin_dsc, conf & PORT_CONF_MODE_MASK);
- hal_gpio_pin_conf_od(pin_dsc, conf & PORT_CONF_OD_MASK);
+ hal_gpio_pin_set_mode(pin_dsc, conf & PORT_CONF_MODE_MASK);
+ hal_gpio_pin_set_od(pin_dsc, conf & PORT_CONF_OD_MASK);
if (conf & PORT_CONF_SET_DIR) {
if ((conf & PORT_CONF_DIR_MASK) == (PORT_CONF_DIR_IN & PORT_CONF_DIR_MASK))
- hal_gpio_pin_direction_input(pin_dsc);
+ hal_gpio_pin_set_dir_in(pin_dsc);
else
- hal_gpio_pin_direction_output(pin_dsc, conf & PORT_CONF_INIT_HIGH);
+ hal_gpio_pin_set_dir_out(pin_dsc, conf & PORT_CONF_INIT_HIGH);
}
return 0;
}
-uint32_t hal_gpio_pin_conf(uint32_t pin_dsc)
+uint32_t hal_gpio_pin_configure(uint32_t pin_dsc)
{
- return hal_gpio_pin_conf_set(pin_dsc, pin_dsc);
+ return hal_gpio_pin_set_config(pin_dsc, pin_dsc);
}
-uint32_t hal_gio_port_get_val(uint32_t *config, uint32_t num_val, uint32_t *values)
+uint32_t hal_gpio_port_get_val(uint32_t *config, uint32_t num_val, uint32_t *values)
{
uint32_t i;
return 0;
}
-uint32_t hal_gio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_t *values)
+uint32_t hal_gpio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_t *values)
{
uint32_t i;
return 0;
}
-const port_def_t *hal_port_get_definitions()
+const port_def_t *hal_port_get_map()
{
return (const port_def_t *)port_definition;
}
int port_num = hal_gpio_pin_get_port_num(pin_map[pin].pin_desc);
if ((init_ports & (1 << port_num)) &&
!(ports_initialized & (1 << port_num)))
- hal_gpio_pin_conf(pin_map[pin].pin_desc);
+ hal_gpio_pin_configure(pin_map[pin].pin_desc);
}
ports_initialized |= init_ports;