1 /* Copyright (C) 2013-2015 Czech Technical University in Prague
3 * - Michal Horn <hornmich@fel.cvut.cz>
5 * This document contains proprietary information belonging to Czech
6 * Technical University in Prague. Passing on and copying of this
7 * document, and communication of its contents is not permitted
8 * without prior written authorization.
14 static uint32_t ports_initialized = 0;
16 /* Configuration consistency check */
17 #if RPP_GIO_PORT_GIOA != (1 << PORT_ID_GIOA) || \
18 RPP_GIO_PORT_GIOB != (1 << PORT_ID_GIOB) || \
19 RPP_GIO_PORT_NHET1 != (1 << PORT_ID_HET1)
20 #error Port configuration is not consistent.
23 int8_t rpp_gio_init(uint32_t init_ports)
27 gioREG->GCR0 = 1; // Bring GIO out of reset
28 pin_map_element_t* pin_map = hal_gpio_get_pin_map();
31 for (pin = 0; pin < hal_gpio_get_pin_cnt(); pin++) {
32 int port_num = hal_gpio_pin_get_port_num(pin_map[pin].pin_desc);
33 if ((init_ports & (1 << port_num)) &&
34 !(ports_initialized & (1 << port_num)))
35 hal_gpio_pin_conf(pin_map[pin].pin_desc);
38 ports_initialized |= init_ports;