rpp/src/rpp/sci.c \
rpp/src/drv/_$(TARGET)/adc.c \
rpp/src/drv/sci.c \
- rpp/src/hal/gpio.c \
+ rpp/src/hal/hal.c \
rpp/src/hal/_$(TARGET)/gpio_def.c \
rpp/src/hal/_$(TARGET)/port_def.c \
- rpp/src/hal/port_gpio.c \
rpp/src/sys/asm/dabort.asm \
rpp/src/sys/asm/sys_core.asm \
rpp/src/sys/asm/sys_intvecs.asm \
rpp/src/hal/pom_vect_remap.c \
rpp/src/drv/spi.c \
rpp/src/drv/spi_tms570.c \
- rpp/src/hal/port_spi.c \
rpp/src/hal/spi_resp_transl.c \
rpp/src/rpp/dac.c \
rpp/src/rpp/din.c \
+++ /dev/null
-/* Copyright (C) 2013-2014 Czech Technical University in Prague
- * Authors:
- * - Michal Horn <hornmich@fel.cvut.cz>
- *
- * 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.
- *
- * Abstract:
- * The file contains GPIO pins read, write and configure inline functions.
- */
-
-/**
- * @file
- *
- * This file contains gpio pin inline functions.
- * - Get pin descriptor from name function
- * - Get port base (pointer to registers) from port number
- * - Get port number from pin descriptor
- * - Get port base (pointer to registers) from pin descriptor
- * - Get/Set pin value
- * - Get/Set pin direction
- * - Set pin configuration (can be used for initial configuration after MCU reset
- *
- * Each pin is defined by its descriptor defined in hal_gpio_platform_def. The descriptor can be obtained
- * by hal_gpio_get_pin_dsc by giving a pin name as an argument.
- */
-
-#ifndef _HAL_GPIO_H
-#define _HAL_GPIO_H_
-
-#include "hal/hal.h"
-
-uint8_t hal_gpio_get_pin_cnt();
-
-pin_map_element_t* hal_gpio_get_pin_map();
-
-/**
- * Get port base assigned to port number
- * @param[in] port_num Port number <0;4>
- * @return Pointer to port registers
- */
-gioPORT_t *hal_gpio_get_port_base(uint32_t port_num);
-
-/**
- * Get port number assigned to pin in its descriptor
- * @param[in] pin descriptor
- * @return Index of port
- */
-uint32_t hal_gpio_pin_get_port_num(uint32_t pin_dsc);
-
-/**
- * Get port base from pin descriptor
- * Combines two upper defined functions
- * @param[in] pin_dcs Pin descriptor
- * @return Pointer to port registers
- */
-gioPORT_t *hal_gpio_pin_get_port_base(uint32_t pin_dsc);
-
-/**
- * Get pin descriptor assigned to pin name.
- * @param[in] pin_name Pointer to string - the name of the pin.
- * @param[in] len Length of the name, if terminated by '/0', then len=-1
- * @return Pin descriptor or NULL if not found
- */
-uint32_t *hal_gpio_pin_get_dsc(const char *pin_name, int len);
-
-/**
- * Get value from GPIO pin
- * @param[in] pin_dsc pin descriptor
- * @return value read from specified gpio pin
- */
-uint32_t hal_gpio_pin_get_value(uint32_t pin_dsc);
-
-/**
- * Set value to gpio pin
- * @param[in] pin_dsc pin descriptor
- * @param[in] value value to be assigned to the pin
- */
-void hal_gpio_pin_set_value(uint32_t pin_dsc, uint32_t value);
-
-/**
- * Set pin direction to input
- * @param[in] pin_dsc pin descriptor
- * @return always 0
- */
-int hal_gpio_pin_direction_input(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);
-
-/**
- * Get pin direction
- * @param[in] pin_dsc pin descriptor
- * @return 1 - output, 0 - input
- */
-int hal_gpio_pin_get_direction(uint32_t pin_dsc);
-
-/**
- * Set pin as pull down or pull up and pull resistor enabled or disabled.
- * @param[in] pin_dsc Descriptor of the pin
- * @param[in] Mode on which pin will be configured to.
- * PORT_CONF_MODE_PU - pull up
- * PORT_CONF_MODE_PD - pull down
- * must be | with
- * PORT_CONF_MODE_PEN - pull resistor enable
- * PORT_CONF_MODE_PDIS - pull resistor disable
- * @return always 0
- */
-uint32_t hal_gpio_pin_conf_mode(uint32_t pin_dsc, uint32_t mode);
-
-/**
- * Configure pin to be open drain or not
- * @param[in] pin_dsc Descriptor of the pin
- * @param[in] Mode on which pin will be configured to.
- * PORT_CONF_OD_OFF - open-drain disabled
- * PORT_CONF_OD_ON - open drain enabled
- *
- * @return always 0
- */
-uint32_t hal_gpio_pin_conf_od(uint32_t pin_dsc, uint32_t od);
-
-/**
- * Configure pin
- * @param[in] pin_dsc Descriptor of the pin
- * @param[in] Mode on which pin will be configured to.
- * PORT_CONF_OD_OFF - open-drain disabled
- * PORT_CONF_OD_ON - open drain enabled
- *
- * PORT_CONF_MODE_PU - pull up
- * PORT_CONF_MODE_PD - pull down
- *
- * PORT_CONF_MODE_PEN - pull resistor enable
- * PORT_CONF_MODE_PDIS - pull resistor disable
- *
- * PORT_CONF_DIR_IN - direction input
- * PORT_CONF_DIR_OUT - direction output
- *
- * PORT_CONF_INIT_LOW - init value 0
- * PORT_CONF_INIT_HIGH - init value 1
- *
- * PORT_CONF_FNC_GPIO - port function GPIO
- * PORT_CONF_FNC_FNCX - port alternate function X
- *
- * @return always 0
- */
-uint32_t hal_gpio_pin_conf_set(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);
-
-
-#endif //_HAL_GPIO_H_
#error No supported target specified!
#endif
-#include "hal/gpio.h"
-#include "hal/port_gpio.h"
+uint8_t hal_gpio_get_pin_cnt();
+
+pin_map_element_t* hal_gpio_get_pin_map();
+
+/**
+ * Get port base assigned to port number
+ * @param[in] port_num Port number <0;4>
+ * @return Pointer to port registers
+ */
+gioPORT_t *hal_gpio_get_port_base(uint32_t port_num);
+
+/**
+ * Get port number assigned to pin in its descriptor
+ * @param[in] pin descriptor
+ * @return Index of port
+ */
+uint32_t hal_gpio_pin_get_port_num(uint32_t pin_dsc);
+
+/**
+ * Get port base from pin descriptor
+ * Combines two upper defined functions
+ * @param[in] pin_dcs Pin descriptor
+ * @return Pointer to port registers
+ */
+gioPORT_t *hal_gpio_pin_get_port_base(uint32_t pin_dsc);
+
+/**
+ * Get pin descriptor assigned to pin name.
+ * @param[in] pin_name Pointer to string - the name of the pin.
+ * @param[in] len Length of the name, if terminated by '/0', then len=-1
+ * @return Pin descriptor or NULL if not found
+ */
+uint32_t *hal_gpio_pin_get_dsc(const char *pin_name, int len);
+
+/**
+ * Get value from GPIO pin
+ * @param[in] pin_dsc pin descriptor
+ * @return value read from specified gpio pin
+ */
+uint32_t hal_gpio_pin_get_value(uint32_t pin_dsc);
+
+/**
+ * Set value to gpio pin
+ * @param[in] pin_dsc pin descriptor
+ * @param[in] value value to be assigned to the pin
+ */
+void hal_gpio_pin_set_value(uint32_t pin_dsc, uint32_t value);
+
+/**
+ * Set pin direction to input
+ * @param[in] pin_dsc pin descriptor
+ * @return always 0
+ */
+int hal_gpio_pin_direction_input(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);
+
+/**
+ * Get pin direction
+ * @param[in] pin_dsc pin descriptor
+ * @return 1 - output, 0 - input
+ */
+int hal_gpio_pin_get_direction(uint32_t pin_dsc);
+
+/**
+ * Set pin as pull down or pull up and pull resistor enabled or disabled.
+ * @param[in] pin_dsc Descriptor of the pin
+ * @param[in] Mode on which pin will be configured to.
+ * PORT_CONF_MODE_PU - pull up
+ * PORT_CONF_MODE_PD - pull down
+ * must be | with
+ * PORT_CONF_MODE_PEN - pull resistor enable
+ * PORT_CONF_MODE_PDIS - pull resistor disable
+ * @return always 0
+ */
+uint32_t hal_gpio_pin_conf_mode(uint32_t pin_dsc, uint32_t mode);
+
+/**
+ * Configure pin to be open drain or not
+ * @param[in] pin_dsc Descriptor of the pin
+ * @param[in] Mode on which pin will be configured to.
+ * PORT_CONF_OD_OFF - open-drain disabled
+ * PORT_CONF_OD_ON - open drain enabled
+ *
+ * @return always 0
+ */
+uint32_t hal_gpio_pin_conf_od(uint32_t pin_dsc, uint32_t od);
+
+/**
+ * Configure pin
+ * @param[in] pin_dsc Descriptor of the pin
+ * @param[in] Mode on which pin will be configured to.
+ * PORT_CONF_OD_OFF - open-drain disabled
+ * PORT_CONF_OD_ON - open drain enabled
+ *
+ * PORT_CONF_MODE_PU - pull up
+ * PORT_CONF_MODE_PD - pull down
+ *
+ * PORT_CONF_MODE_PEN - pull resistor enable
+ * PORT_CONF_MODE_PDIS - pull resistor disable
+ *
+ * PORT_CONF_DIR_IN - direction input
+ * PORT_CONF_DIR_OUT - direction output
+ *
+ * PORT_CONF_INIT_LOW - init value 0
+ * PORT_CONF_INIT_HIGH - init value 1
+ *
+ * PORT_CONF_FNC_GPIO - port function GPIO
+ * PORT_CONF_FNC_FNCX - port alternate function X
+ *
+ * @return always 0
+ */
+uint32_t hal_gpio_pin_conf_set(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);
+
+/**
+ * Get values of all pins of given port.
+ * @param[in] config Pointer to array of pin descriptors
+ * @param[in] num_val Number of pins assigned to the 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);
+
+/**
+ * Set values to all pins of given port.
+ * @param[in] config Pointer to array of pin descriptors
+ * @param[in] num_val Number of pins assigned to the 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);
+
+/**
+ * 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_definitions();
+
+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.
+ * @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);
+
+/**
+ * Transfer command through the spi
+ * @param[in] config Address of the SPI
+ * @param[in] num_bytes Number of bytes to be trasfered
+ * @param[in] commands SPI command to be sent
+ * @return spi response
+ */
+uint32_t hal_spi_port_transfer_command(uint32_t *config, uint32_t num_bytes, const uint32_t *commands);
+
#endif /* __HAL_H */
+++ /dev/null
-/* Copyright (C) 2013-2014 Czech Technical University in Prague
- * Authors:
- * - Michal Horn <hornmich@fel.cvut.cz>
- *
- * 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.
- */
-
-#ifndef PORT_GPIO_H_
-#define PORT_GPIO_H_
-
-//#include "sys_common.h"
-#include "hal/hal.h"
-
-/**
- * Get values of all pins of given port.
- * @param[in] config Pointer to array of pin descriptors
- * @param[in] num_val Number of pins assigned to the 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);
-
-/**
- * Set values to all pins of given port.
- * @param[in] config Pointer to array of pin descriptors
- * @param[in] num_val Number of pins assigned to the 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);
-
-/**
- * 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_definitions();
-
-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.
- * @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);
-
-#endif /* PORT_GPIO_H_ */
+++ /dev/null
-/**
- *
- * @file port_spi.h
- *
- * @copyright Copyright (C) 2012-2013 Czech Technical University in Prague
- *
- * @author Michal Horn <hornmich@fel.cvut.cz>
- */
-
-#ifndef PORT_SPI_H_
-#define PORT_SPI_H_
-
-//#include "sys_common.h"
-#include "hal/hal.h"
-
-/**
- * Transfer command through the spi
- * @param[in] config Address of the SPI
- * @param[in] num_bytes Number of bytes to be trasfered
- * @param[in] commands SPI command to be sent
- * @return spi response
- */
-uint32_t hal_spi_port_transfer_command(uint32_t *config, uint32_t num_bytes, const uint32_t *commands);
-
-
-#endif /* PORT_SPI_H_ */
*/
#include "hal/hal.h"
-
-#include "hal/port_spi.h"
#include "drv/spi.h"
// Lists of pins assigned to the ports
-/* Copyright (C) 2012-2013 Czech Technical University in Prague
+/*
+ * hal.c
*
- * Authors:
- * - Michal Horn <hornmich@fel.cvut.cz>
- *
- * 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 : gpio.c
- *
- * Abstract:
- * This file contains gpio pin configuration functions.
- * Some additional function for setting and getting pin values, getting
- * descriptors etc. are defined in header file as inline functions.
- *
- * Each pin is defined by its descriptor defined in hal_gpio_platform_def. The descriptor can be obtained
- * by hal_gpio_get_pin_dsc by giving a pin name as an argument.
+ * Created on: 16.7.2015
+ * Author: michal
*/
#include "hal/hal.h"
+#include "drv/spi.h"
extern gioPORT_t *port_id_map[MAX_PORT_CNT];
extern pin_map_element_t pin_map[MAX_PIN_CNT];
+extern port_def_t port_definition[PORT_CNT];
+
+#define SPI_PORT_BUF_LEN 4
+/** Buffer for spi command to be sent */
+uint8_t spi_port_buf_tx[SPI_PORT_BUF_LEN];
+/** Buffer for spi response */
+uint8_t spi_port_buf_rx[SPI_PORT_BUF_LEN];
uint8_t hal_gpio_get_pin_cnt() {
return MAX_PIN_CNT;
{
return hal_gpio_pin_conf_set(pin_dsc, pin_dsc);
}
+
+
+uint32_t hal_gio_port_get_val(uint32_t *config, uint32_t num_val, uint32_t *values)
+{
+ uint32_t i;
+
+ for (i = 0; i < num_val; i++) {
+ values[i] = hal_gpio_pin_get_value(config[i]);
+ }
+ return 0;
+}
+
+uint32_t hal_gio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_t *values)
+{
+ uint32_t i;
+
+ for (i = 0; i < num_val; i++) {
+ hal_gpio_pin_set_value(config[i], (values[i/8] >> i%8) & 0x1);
+ }
+ return 0;
+}
+
+const port_def_t *hal_port_get_definitions()
+{
+ return (const port_def_t *)port_definition;
+}
+
+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;
+}
+
+uint32_t hal_spi_port_transfer_command(uint32_t *config, uint32_t num_bytes, const uint32_t *commands)
+{
+ spi_drv_t *ifc;
+ int i;
+ uint32_t ret;
+
+ for (i = 0; i < num_bytes; i++)
+ spi_port_buf_tx[i] = commands[i];
+
+ ifc = spi_find_drv(NULL, config[0]);
+ if (ifc == NULL)
+ return 0;
+
+ if (!(ifc->flags & SPI_IFC_ON))
+ return 0;
+
+ spi_transfer(ifc, config[1], num_bytes, spi_port_buf_tx, spi_port_buf_rx);
+ ret = 0;
+ for (i = 0; i < num_bytes; i++)
+ ret |= spi_port_buf_rx[i] << i*8;
+ return ret;
+}
+++ /dev/null
-/* Copyright (C) 2012-2013 Czech Technical University in Prague
- *
- * Authors:
- * - Michal Horn <hornmich@fel.cvut.cz>
- *
- * 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 : port_gpio.c
- *
- * Abstract:
- * This file contains getter and setter functions for GPIO port type.
- */
-
-#include "hal/hal.h"
-
-extern port_def_t port_definition[PORT_CNT];
-
-uint32_t hal_gio_port_get_val(uint32_t *config, uint32_t num_val, uint32_t *values)
-{
- uint32_t i;
-
- for (i = 0; i < num_val; i++) {
- values[i] = hal_gpio_pin_get_value(config[i]);
- }
- return 0;
-}
-
-uint32_t hal_gio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_t *values)
-{
- uint32_t i;
-
- for (i = 0; i < num_val; i++) {
- hal_gpio_pin_set_value(config[i], (values[i/8] >> i%8) & 0x1);
- }
- return 0;
-}
-
-const port_def_t *hal_port_get_definitions()
-{
- return (const port_def_t *)port_definition;
-}
-
-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;
-}
+++ /dev/null
-/* Copyright (C) 2012-2013, 2015 Czech Technical University in Prague
- *
- * Authors:
- * - Michal Horn <hornmich@fel.cvut.cz>
- *
- * 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 : port_spi.c
- *
- * Abstract:
- * This file contains getter and setter functions for SPI port type.
- */
-
-#include "drv/spi.h"
-
-#define PORT_BUF 4
-/** Buffer for spi command to be sent */
-uint8_t spi_port_buf_tx[PORT_BUF];
-/** Buffer for spi response */
-uint8_t spi_port_buf_rx[PORT_BUF];
-
-uint32_t hal_spi_port_transfer_command(uint32_t *config, uint32_t num_bytes, const uint32_t *commands)
-{
- spi_drv_t *ifc;
- int i;
- uint32_t ret;
-
- for (i = 0; i < num_bytes; i++)
- spi_port_buf_tx[i] = commands[i];
-
- ifc = spi_find_drv(NULL, config[0]);
- if (ifc == NULL)
- return 0;
-
- if (!(ifc->flags & SPI_IFC_ON))
- return 0;
-
- spi_transfer(ifc, config[1], num_bytes, spi_port_buf_tx, spi_port_buf_rx);
- ret = 0;
- for (i = 0; i < num_bytes; i++)
- ret |= spi_port_buf_rx[i] << i*8;
- return ret;
-}