libpynq (release 5EWC0-2023 version 0.2.1 of 2023-09-01 11:02)
Loading...
Searching...
No Matches
I/O Switchbox library

Macros

#define NUM_SWITCHBOX_NAMES   40
 

Enumerations

enum  io_configuration {
  SWB_GPIO = 0x00 , SWB_Interrupt_In = 0x01 , SWB_UART0_TX = 0x02 , SWB_UART0_RX = 0x03 ,
  SWB_SPI0_CLK = 0x04 , SWB_SPI0_MISO = 0x05 , SWB_SPI0_MOSI = 0x06 , SWB_SPI0_SS = 0x07 ,
  SWB_SPI1_CLK = 0x08 , SWB_SPI1_MISO = 0x09 , SWB_SPI1_MOSI = 0x0A , SWB_SPI1_SS = 0x0B ,
  SWB_IIC0_SDA = 0x0C , SWB_IIC0_SCL = 0x0D , SWB_IIC1_SDA = 0x0E , SWB_IIC1_SCL = 0x0F ,
  SWB_PWM0 = 0x10 , SWB_PWM1 = 0x11 , SWB_PWM2 = 0x12 , SWB_PWM3 = 0x13 ,
  SWB_PWM4 = 0x14 , SWB_PWM5 = 0x15 , SWB_TIMER_G0 = 0x18 , SWB_TIMER_G1 = 0x19 ,
  SWB_TIMER_G2 = 0x1A , SWB_TIMER_G3 = 0x1B , SWB_TIMER_G4 = 0x1C , SWB_TIMER_G5 = 0x1D ,
  SWB_TIMER_G6 = 0x1E , SWB_TIMER_G7 = 0x1F , SWB_UART1_TX = 0x22 , SWB_UART1_RX = 0x23 ,
  SWB_TIMER_IC0 = 0x38 , SWB_TIMER_IC1 = 0x39 , SWB_TIMER_IC2 = 0x3A , SWB_TIMER_IC3 = 0x3B ,
  SWB_TIMER_IC4 = 0x3C , SWB_TIMER_IC5 = 0x3D , SWB_TIMER_IC6 = 0x3E , SWB_TIMER_IC7 = 0x3F ,
  NUM_IO_CONFIGURATIONS
}
 

Functions

void switchbox_init (void)
 
void switchbox_set_pin (const pin_t pin_number, const uint8_t pin_type)
 
void switchbox_reset (void)
 
void switchbox_destroy (void)
 
uint8_t switchbox_get_pin (const pin_t pin_number)
 

Variables

char *const switchbox_names [NUM_SWITCHBOX_NAMES]
 

Detailed Description

The switchbox enables run-time (re)mapping of I/O pins.

For example, output pin of UART 0 (SWB_UART0_TX) can be mapped to analog pins 0 and 1 (SWB_AR0 & SWB_AR1). Or output pin PWM 0 (SWB_PWM0) can be mapped to green LED 0 (SWB_LD0). Or output pin PWM 0 (SWB_PWM0) can be mapped to the green component of color LED 0 (SWB_LD0).

Warning
For switchbox functions use the SWB_* naming of pins that is part of switchbox.h (enum io_configuration), not the names in pinmap.h.
#include<pinmap.h>
#include<switchbox.h>
int main (void)
{
// setup UART here (not shown)
// remap pin SWB_AR0 (analog reference pin 0) to UART 0 transmit
// remap pin SWB_AR1 (analog reference pin 1) to UART 0 receive
// your code here
}
void switchbox_set_pin(const int32_t pin_number, const uint8_t pin_type)
Definition switchbox.c:4
@ SWB_AR1
Definition pinmap.h:50
@ SWB_AR0
Analog reference pins.
Definition pinmap.h:49
void switchbox_destroy(void)
Resets all pins of the switch box to be input.
Definition switchbox.c:6
void switchbox_init(void)
Initializes the switch box.
Definition switchbox.c:3

Macro Definition Documentation

◆ NUM_SWITCHBOX_NAMES

#define NUM_SWITCHBOX_NAMES   40

Definition at line 134 of file switchbox.h.

Enumeration Type Documentation

◆ io_configuration

Enumerator
SWB_GPIO 

Map pin to GPIO

SWB_Interrupt_In 

Map pin to internal interrupt (UNUSED)

SWB_UART0_TX 

Map pin to TX channel of UART 0

SWB_UART0_RX 

Map pin to RX channel of UART 0

SWB_SPI0_CLK 

Map pin to clock channel of SPI 0

SWB_SPI0_MISO 

Map pin to miso channel of SPI 0

SWB_SPI0_MOSI 

Map pin to mosi channel of SPI 0

SWB_SPI0_SS 

Map pin to ss channel of SPI 0

SWB_SPI1_CLK 

Map pin to clock channel of SPI 1

SWB_SPI1_MISO 

Map pin to miso channel of SPI 1

SWB_SPI1_MOSI 

Map pin to mosi channel of SPI 1

SWB_SPI1_SS 

Map pin to ss channel of SPI 1

SWB_IIC0_SDA 

Map pin to sda channel of IIC 0

SWB_IIC0_SCL 

Map pin to scl channel of IIC 0

SWB_IIC1_SDA 

Map pin to sda channel of IIC 1

SWB_IIC1_SCL 

Map pin to scl channel of IIC 1

SWB_PWM0 

Map pin to output channel of PWM 0

SWB_PWM1 

Map pin to output channel of PWM 1

SWB_PWM2 

not connected

SWB_PWM3 

not connected

SWB_PWM4 

not connected

SWB_PWM5 

not connected

SWB_TIMER_G0 
SWB_TIMER_G1 
SWB_TIMER_G2 

not connected

SWB_TIMER_G3 

not connected

SWB_TIMER_G4 

not connected

SWB_TIMER_G5 

not connected

SWB_TIMER_G6 

not connected

SWB_TIMER_G7 

not connected

SWB_UART1_TX 
SWB_UART1_RX 
SWB_TIMER_IC0 
SWB_TIMER_IC1 
SWB_TIMER_IC2 
SWB_TIMER_IC3 
SWB_TIMER_IC4 
SWB_TIMER_IC5 
SWB_TIMER_IC6 
SWB_TIMER_IC7 
NUM_IO_CONFIGURATIONS 

number elements in this enum

Definition at line 61 of file switchbox.h.

Function Documentation

◆ switchbox_destroy()

void switchbox_destroy ( void  )

Resets all pins of the switch box to be input.

Definition at line 6 of file switchbox.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ switchbox_get_pin()

uint8_t switchbox_get_pin ( const pin_t  pin_number)

Sets the mode of a specified pin.

Parameters
pin_numberThe pin number to set the mode for
pin_typeThe mode to set the pin to (input/output)

Sets the mode of the specified pin on the io switch

Definition at line 163 of file switchbox.c.

◆ switchbox_init()

void switchbox_init ( void  )

Initializes the switch box.

Initializes the shared memory and sets the io switch base address

Definition at line 3 of file switchbox.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ switchbox_reset()

void switchbox_reset ( void  )

Resets all pins of the switch box to be input.

Definition at line 5 of file switchbox.c.

Here is the caller graph for this function:

◆ switchbox_set_pin()

void switchbox_set_pin ( const pin_t  pin_number,
const uint8_t  pin_type 
)

Set the type of a switch pin.

Parameters
pin_numberThe number of the pin to set
pin_typeThe type of the pin (0 for input, 1 for output)

Definition at line 128 of file switchbox.c.

Here is the call graph for this function:

Variable Documentation

◆ switchbox_names

char* const switchbox_names[NUM_SWITCHBOX_NAMES]
extern

Taken from scpi_names.h, lookup table for channels in the mapping_info function.

Definition at line 2 of file switchbox.c.