libpynq  (release 5EID0-2023 version 0.3.0 of 2024-04-25 09:42 )
switchbox.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2023 Eindhoven University of Technology
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22 #ifndef SWITCHBOX_H
23 #define SWITCHBOX_H
24 #include <pinmap.h>
25 #include <stdbool.h>
26 #include <stdint.h>
27 
62 typedef enum io_configuration {
64  SWB_GPIO = 0x00,
68  SWB_UART0_TX = 0x02,
70  SWB_UART0_RX = 0x03,
72  SWB_SPI0_CLK = 0x04,
74  SWB_SPI0_MISO = 0x05,
76  SWB_SPI0_MOSI = 0x06,
78  SWB_SPI0_SS = 0x07,
80  SWB_SPI1_CLK = 0x08,
82  SWB_SPI1_MISO = 0x09,
84  SWB_SPI1_MOSI = 0x0A,
86  SWB_SPI1_SS = 0x0B,
88  SWB_IIC0_SDA = 0x0C,
90  SWB_IIC0_SCL = 0x0D,
92  SWB_IIC1_SDA = 0x0E,
94  SWB_IIC1_SCL = 0x0F,
96  SWB_PWM0 = 0x10,
98  SWB_PWM1 = 0x11,
100  SWB_PWM2 = 0x12,
102  SWB_PWM3 = 0x13,
104  SWB_PWM4 = 0x14,
106  SWB_PWM5 = 0x15,
107  SWB_TIMER_G0 = 0x18,
108  SWB_TIMER_G1 = 0x19,
110  SWB_TIMER_G2 = 0x1A,
112  SWB_TIMER_G3 = 0x1B,
114  SWB_TIMER_G4 = 0x1C,
116  SWB_TIMER_G5 = 0x1D,
118  SWB_TIMER_G6 = 0x1E,
120  SWB_TIMER_G7 = 0x1F,
121  SWB_UART1_TX = 0x22,
122  SWB_UART1_RX = 0x23,
134 
135 #define NUM_SWITCHBOX_NAMES 40
136 
140 extern char *const switchbox_names[NUM_SWITCHBOX_NAMES];
141 
147 extern void switchbox_init(void);
148 
155 extern void switchbox_set_pin(const io_t pin_number,
156  const io_configuration_t pin_type);
157 
162 extern void switchbox_reset(void);
163 
167 extern void switchbox_destroy(void);
168 
175 extern io_configuration_t switchbox_get_pin(const io_t pin_number);
176 
180 #endif // SWITCHBOX_H
SWB_SPI0_MOSI
@ SWB_SPI0_MOSI
Definition: switchbox.h:76
SWB_TIMER_IC7
@ SWB_TIMER_IC7
Definition: switchbox.h:130
SWB_PWM1
@ SWB_PWM1
Definition: switchbox.h:98
SWB_TIMER_G7
@ SWB_TIMER_G7
Definition: switchbox.h:120
SWB_GPIO
@ SWB_GPIO
Definition: switchbox.h:64
SWB_PWM5
@ SWB_PWM5
Definition: switchbox.h:106
SWB_Interrupt_In
@ SWB_Interrupt_In
Definition: switchbox.h:66
SWB_SPI0_CLK
@ SWB_SPI0_CLK
Definition: switchbox.h:72
SWB_TIMER_IC1
@ SWB_TIMER_IC1
Definition: switchbox.h:124
SWB_PWM4
@ SWB_PWM4
Definition: switchbox.h:104
SWB_UART0_RX
@ SWB_UART0_RX
Definition: switchbox.h:70
SWB_TIMER_G1
@ SWB_TIMER_G1
Definition: switchbox.h:108
NUM_SWITCHBOX_NAMES
#define NUM_SWITCHBOX_NAMES
Definition: switchbox.h:135
SWB_PWM0
@ SWB_PWM0
Definition: switchbox.h:96
SWB_TIMER_IC5
@ SWB_TIMER_IC5
Definition: switchbox.h:128
SWB_IIC1_SCL
@ SWB_IIC1_SCL
Definition: switchbox.h:94
SWB_TIMER_G2
@ SWB_TIMER_G2
Definition: switchbox.h:110
SWB_SPI1_CLK
@ SWB_SPI1_CLK
Definition: switchbox.h:80
SWB_TIMER_IC0
@ SWB_TIMER_IC0
Definition: switchbox.h:123
SWB_SPI1_MOSI
@ SWB_SPI1_MOSI
Definition: switchbox.h:84
SWB_IIC0_SDA
@ SWB_IIC0_SDA
Definition: switchbox.h:88
switchbox_init
void switchbox_init(void)
Initializes the switch box.
Definition: switchbox.c:3
SWB_SPI0_SS
@ SWB_SPI0_SS
Definition: switchbox.h:78
switchbox_set_pin
void switchbox_set_pin(const io_t pin_number, const io_configuration_t pin_type)
Set the type of a switch pin.
Definition: switchbox.c:126
SWB_IIC1_SDA
@ SWB_IIC1_SDA
Definition: switchbox.h:92
switchbox_reset
void switchbox_reset(void)
Resets all pins of the switch box to be input.
Definition: switchbox.c:5
SWB_UART0_TX
@ SWB_UART0_TX
Definition: switchbox.h:68
SWB_IIC0_SCL
@ SWB_IIC0_SCL
Definition: switchbox.h:90
SWB_UART1_TX
@ SWB_UART1_TX
Definition: switchbox.h:121
SWB_PWM3
@ SWB_PWM3
Definition: switchbox.h:102
pinmap.h
switchbox_get_pin
io_configuration_t switchbox_get_pin(const io_t pin_number)
Sets the mode of a specified pin.
Definition: switchbox.c:162
SWB_TIMER_G0
@ SWB_TIMER_G0
Definition: switchbox.h:107
SWB_PWM2
@ SWB_PWM2
Definition: switchbox.h:100
SWB_TIMER_IC4
@ SWB_TIMER_IC4
Definition: switchbox.h:127
switchbox_destroy
void switchbox_destroy(void)
Resets all pins of the switch box to be input.
Definition: switchbox.c:6
SWB_TIMER_G3
@ SWB_TIMER_G3
Definition: switchbox.h:112
SWB_UART1_RX
@ SWB_UART1_RX
Definition: switchbox.h:122
SWB_SPI0_MISO
@ SWB_SPI0_MISO
Definition: switchbox.h:74
switchbox_names
char *const switchbox_names[NUM_SWITCHBOX_NAMES]
Taken from scpi_names.h, lookup table for channels in the mapping_info function.
Definition: switchbox.c:2
SWB_TIMER_IC6
@ SWB_TIMER_IC6
Definition: switchbox.h:129
SWB_TIMER_G6
@ SWB_TIMER_G6
Definition: switchbox.h:118
SWB_SPI1_MISO
@ SWB_SPI1_MISO
Definition: switchbox.h:82
SWB_TIMER_G5
@ SWB_TIMER_G5
Definition: switchbox.h:116
SWB_TIMER_G4
@ SWB_TIMER_G4
Definition: switchbox.h:114
io_configuration_t
enum io_configuration io_configuration_t
SWB_SPI1_SS
@ SWB_SPI1_SS
Definition: switchbox.h:86
io_t
io_t
Definition: pinmap.h:45
SWB_TIMER_IC3
@ SWB_TIMER_IC3
Definition: switchbox.h:126
NUM_IO_CONFIGURATIONS
@ NUM_IO_CONFIGURATIONS
Definition: switchbox.h:132
io_configuration
io_configuration
Definition: switchbox.h:62
SWB_TIMER_IC2
@ SWB_TIMER_IC2
Definition: switchbox.h:125