Created
July 28, 2020 14:25
-
-
Save Yatekii/173153b4af30f8e24dddde53bd431f50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __PORT_EXPANDER_ | |
#define __PORT_EXPANDER_ | |
#include <xil_types.h> | |
#include "common.h" | |
/// Perform all necessary setup of the underlying I2C peripheral and port expander. | |
void pe_setup(u16 device_id, u32 bus_clock_hz); | |
/// Sets given GPIO pin state. | |
void pe_set_gpio(u32 pin, pin_state_t value); | |
enum | |
{ | |
PORT_A = 0x000, | |
PORT_B = 0x100, | |
} t_pe_port; | |
enum | |
{ | |
DEVICE_1 = 0x00000, | |
DEVICE_2 = 0x10000, | |
} t_pe_device; | |
typedef struct | |
{ | |
u8 pin; | |
u8 port; | |
u8 device; | |
} t_pe_pin; | |
// MCP23017 1 | |
// Port A | |
#define PIN_QUENCH_RELAY \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x00 \ | |
} | |
#define PIN_BCM_EN3 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x01 \ | |
} | |
#define PIN_BCM_EN2 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x02 \ | |
} | |
#define PIN_BCM_EN1 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x03 \ | |
} | |
#define PIN_BCM_EN0 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x04 \ | |
} | |
#define PIN_LED_BLUE \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x05 \ | |
} | |
#define PIN_LED_RED \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x06 \ | |
} | |
#define PIN_LED_GREEN \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_A, .pin = 0x07 \ | |
} | |
// Port B | |
#define PIN_RELAY_A \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x00 \ | |
} | |
#define PIN_RELAY_B \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x01 \ | |
} | |
#define PIN_REL3 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x02 \ | |
} | |
#define PIN_REL4 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x03 \ | |
} | |
#define PIN_REL5 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x04 \ | |
} | |
#define PIN_REL1 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x05 \ | |
} | |
#define PIN_REL2 \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x06 \ | |
} | |
#define PIN_SERPAR \ | |
{ \ | |
.device = DEVICE_1, .port = PORT_B, .pin = 0x07 \ | |
} | |
// MCP23017 2 | |
// Port A | |
#define PIN_EN_PSH_MAIN \ | |
{ \ | |
.device = DEVICE_2, .port = PORT_A, .pin = 0x00 \ | |
} | |
#define PIN_EN_PSH_123 \ | |
{ \ | |
.device = DEVICE_2, .port = PORT_A, .pin = 0x01 \ | |
} | |
#define PIN_EN_PSH_PWR \ | |
{ \ | |
.device = DEVICE_2, .port = PORT_A, .pin = 0x02 \ | |
} | |
#define PIN_BCM_EN_LVDS \ | |
{ \ | |
.device = DEVICE_2, .port = PORT_A, .pin = 0x03 \ | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment