1 /* Copyright (C) 2012-2013 Czech Technical University in Prague
4 * - Michal Horn <hornmich@fel.cvut.cz>
6 * This document contains proprietary information belonging to Czech
7 * Technical University in Prague. Passing on and copying of this
8 * document, and communication of its contents is not permitted
9 * without prior written authorization.
14 * This file contains getter and setter functions for GPIO port type.
19 extern port_def_t port_definition[PORT_CNT];
21 uint32_t hal_gio_port_get_val(uint32_t *config, uint32_t num_val, uint32_t *values)
25 for (i = 0; i < num_val; i++) {
26 values[i] = hal_gpio_pin_get_value(config[i]);
31 uint32_t hal_gio_port_set_val(uint32_t *config, uint32_t num_val, const uint32_t *values)
35 for (i = 0; i < num_val; i++) {
36 hal_gpio_pin_set_value(config[i], (values[i/8] >> i%8) & 0x1);
41 const port_def_t *hal_port_get_definitions()
43 return (const port_def_t *)port_definition;
46 port_desc_t *hal_port_get_dsc(const char *port_name, int len)
49 const char *port_name_ptr;
50 char port_name_term[32];
52 if (len != -1) { // port name not terminated by '\0'
53 strncpy(port_name_term, port_name, len);
54 port_name_term[len] = '\0';
55 port_name_ptr = port_name_term;
57 else port_name_ptr = port_name;
59 for (i = 0; i < PORT_CNT; i++) {
60 if (strcmp(port_name_ptr, port_definition[i].name) == 0)
61 return port_definition[i].desc;