2025-05-16 07:56:18 -05:00
|
|
|
#ifndef IO_H_
|
|
|
|
|
#define IO_H_
|
|
|
|
|
|
|
|
|
|
#include "fsl_gpio.h"
|
2025-06-11 10:55:00 -05:00
|
|
|
#include <stdbool.h>
|
2025-08-26 16:10:47 -05:00
|
|
|
#include "utils.h"
|
|
|
|
|
|
2025-06-11 10:55:00 -05:00
|
|
|
|
|
|
|
|
void io_expanderSet(uint8_t port, uint8_t pins, bool update);
|
|
|
|
|
void io_expanderClear(uint8_t port, uint8_t pins, bool update);
|
|
|
|
|
void io_expanderSetSafe(void);
|
|
|
|
|
void io_update(void);
|
2025-05-16 07:56:18 -05:00
|
|
|
|
|
|
|
|
#define LOW 0
|
|
|
|
|
#define HIGH 1
|
|
|
|
|
|
2025-06-11 10:55:00 -05:00
|
|
|
// GPIO
|
|
|
|
|
#define IO_PORT0 0
|
|
|
|
|
#define IO_PORT1 1
|
2025-05-16 07:56:18 -05:00
|
|
|
|
2025-06-11 10:55:00 -05:00
|
|
|
#define PIN_VBUS (IO_PORT1, 6)
|
|
|
|
|
#define PIN_SIG_CS (IO_PORT1, 9)
|
|
|
|
|
#define PIN_SD_CS (IO_PORT1, 10)
|
|
|
|
|
#define PIN_RAMP_CS (IO_PORT1, 11)
|
|
|
|
|
#define PIN_SIG_RESET (IO_PORT1, 12)
|
|
|
|
|
#define PIN_SD_RESET (IO_PORT1, 13)
|
|
|
|
|
#define PIN_RAMP_RST (IO_PORT1, 14)
|
|
|
|
|
#define PIN_POWER_CTL (IO_PORT1, 16)
|
|
|
|
|
#define PIN_ESTOP (IO_PORT1, 17)
|
2025-05-16 07:56:18 -05:00
|
|
|
|
2025-06-11 10:55:00 -05:00
|
|
|
#define PIN_KEY_UP (IO_PORT0, 2)
|
|
|
|
|
#define PIN_KEY_DOWN (IO_PORT0, 3)
|
|
|
|
|
#define PIN_POT_CS (IO_PORT0, 7)
|
|
|
|
|
#define PIN_EEP_CS (IO_PORT0, 10)
|
|
|
|
|
#define PIN_PORT_LE_CS (IO_PORT0, 19)
|
|
|
|
|
#define PIN_POT_CS2 (IO_PORT0, 21)
|
2025-05-16 17:11:59 -05:00
|
|
|
|
2025-05-16 07:56:18 -05:00
|
|
|
#define _P1(p1, p2) p1
|
|
|
|
|
#define _P2(p1, p2) p2
|
|
|
|
|
|
2025-06-20 18:02:50 -05:00
|
|
|
#define PORT(port_pin) _P1 port_pin
|
|
|
|
|
#define PIN(port_pin) _P2 port_pin
|
|
|
|
|
|
2025-05-16 07:56:18 -05:00
|
|
|
#define GPIO_WRITE(port_pin, value) GPIO_PinWrite(GPIO, _P1 port_pin, _P2 port_pin, value )
|
|
|
|
|
#define GPIO_READ(port_pin) GPIO_PinRead (GPIO, _P1 port_pin, _P2 port_pin)
|
|
|
|
|
|
|
|
|
|
|
2025-06-11 10:55:00 -05:00
|
|
|
// Shift Register Port Expander
|
|
|
|
|
#define UPDATE true
|
|
|
|
|
#define NO_UPDATE false
|
|
|
|
|
|
|
|
|
|
#define TOP_SR 0
|
|
|
|
|
#define MID_SR 1
|
|
|
|
|
#define BOT_SR 2
|
|
|
|
|
|
|
|
|
|
#define TAPS_OFF_MASK 0b11100111
|
2025-08-26 16:10:47 -05:00
|
|
|
#define OUT_RELAY_OFF_MASK 0b11100111
|
2025-06-11 10:55:00 -05:00
|
|
|
|
|
|
|
|
// Bottom Shift Register (U35)
|
|
|
|
|
#define AMP_AB_SW 0b00000001
|
2025-08-26 16:10:47 -05:00
|
|
|
#define AMP_D_ON_ 0b00000010
|
2025-06-11 10:55:00 -05:00
|
|
|
#define AMP_PSU 0b00000100
|
|
|
|
|
#define TAP_204_LF 0b00001000
|
|
|
|
|
#define TAP_102_LF 0b00010000
|
|
|
|
|
#define BKLITE_ON 0b00100000
|
|
|
|
|
#define SLCT_AMP 0b01000000
|
|
|
|
|
#define V_GAIN 0b10000000
|
|
|
|
|
|
|
|
|
|
// Mid Shift Register (U33)
|
|
|
|
|
#define LF_BYPASS 0b00000001
|
|
|
|
|
#define SLCT_XFRMR 0b00000010
|
|
|
|
|
#define TAP_102_HF 0b00000100
|
|
|
|
|
#define SLCT_GRP 0b00001000
|
|
|
|
|
#define SLCT_OUTPUT 0b00010000
|
|
|
|
|
#define DAMP_EN 0b00100000
|
|
|
|
|
#define I_GAIN 0b01000000
|
|
|
|
|
#define ANT_AMP_EN 0b10000000
|
|
|
|
|
|
|
|
|
|
// Top Shift Register (U34)
|
|
|
|
|
#define MUX_AB_AMP 0b00000001
|
|
|
|
|
#define ANT_AMP_SW 0b00000010
|
|
|
|
|
#define EXTEND_PSU 0b00000100
|
|
|
|
|
#define OSC_MUX0 0b00001000
|
|
|
|
|
#define OSC_MUX1 0b00010000
|
|
|
|
|
#define RST_RF 0b00100000
|
|
|
|
|
#define TOP_SR_NC1 0b01000000
|
|
|
|
|
#define TOP_SR_NC2 0b10000000
|
|
|
|
|
|
2025-06-20 18:02:50 -05:00
|
|
|
#define _TAP1_LF_ON (BOT_SR, TAP_102_LF | TAP_204_LF)
|
|
|
|
|
#define _TAP2_LF_ON (BOT_SR, TAP_102_LF)
|
|
|
|
|
#define _TAP3_LF_ON (BOT_SR, TAP_204_LF)
|
|
|
|
|
#define _TAP4_LF_ON (BOT_SR, 0)
|
|
|
|
|
|
2025-08-26 16:10:47 -05:00
|
|
|
#define TAPS_OFF (BOT_SR, (uint8_t)~TAPS_OFF_MASK)
|
|
|
|
|
#define OUT_RELAY_OFF (MID_SR, (uint8_t)~OUT_RELAY_OFF_MASK)
|
|
|
|
|
|
|
|
|
|
#define BYPASS_ON (MID_SR, LF_BYPASS)
|
|
|
|
|
#define BACKLIGHT_ON (BOT_SR, BKLITE_ON)
|
|
|
|
|
#define DISCONNECT_AB (TOP_SR, MUX_AB_AMP)
|
|
|
|
|
#define BROADCAST_AMP_EN (MID_SR, ANT_AMP_EN)
|
|
|
|
|
#define BROADCAST_AMP_PWR (TOP_SR, ANT_AMP_SW)
|
2025-06-20 18:02:50 -05:00
|
|
|
|
2025-08-26 16:10:47 -05:00
|
|
|
#define AMP_AB_ON (BOT_SR, AMP_AB_SW)
|
|
|
|
|
#define AMP_D_EN (MID_SR, DAMP_EN)
|
|
|
|
|
#define AMP_D_ON (BOT_SR, AMP_D_ON_)
|
2025-06-25 11:18:44 -05:00
|
|
|
|
2025-08-26 16:10:47 -05:00
|
|
|
#define PORT1A_ON (MID_SR, SLCT_GRP)
|
|
|
|
|
#define PORT1B_ON (MID_SR, SLCT_GRP | SLCT_OUTPUT)
|
|
|
|
|
#define PORT2A_ON (MID_SR, 0)
|
|
|
|
|
#define PORT2B_ON (MID_SR, SLCT_OUTPUT)
|
2025-06-20 18:02:50 -05:00
|
|
|
|
|
|
|
|
#define _AMP_PSU_ON (BOT_SR, AMP_PSU)
|
|
|
|
|
|
2025-08-26 16:10:47 -05:00
|
|
|
#define SELECT_AB_AMP (BOT_SR, SLCT_AMP)
|
|
|
|
|
|
2025-06-11 10:55:00 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#define EXPANDER_SET(port_pins, update) io_expanderSet (_P1 port_pins, _P2 port_pins, update)
|
|
|
|
|
#define EXPANDER_CLEAR(port_pins, update) io_expanderClear(_P1 port_pins, _P2 port_pins, update)
|
|
|
|
|
|
2025-06-20 18:02:50 -05:00
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
uint32_t port;
|
|
|
|
|
uint32_t pin;
|
|
|
|
|
} gpio_pin_t;
|
|
|
|
|
|
|
|
|
|
void io_expanderClearAll(bool update);
|
|
|
|
|
void io_backlightOn(bool on, bool update);
|
|
|
|
|
void io_ampDOn(bool on, bool update);
|
2025-08-26 16:10:47 -05:00
|
|
|
void io_ampDEnable(bool enable, bool update);
|
|
|
|
|
void io_ampABOn(bool on, bool update);
|
2025-06-20 18:02:50 -05:00
|
|
|
void io_broadcastOn(bool on, bool update);
|
|
|
|
|
void io_ampPsuOn(bool on, bool update);
|
2025-06-25 11:18:44 -05:00
|
|
|
void io_connectAmpAB(bool connect, bool update);
|
|
|
|
|
void io_expanderSetSafe(void);
|
|
|
|
|
|
2025-08-26 16:10:47 -05:00
|
|
|
void io_setOutputPort(AccessoryPortId_t port, AccyChannelId_t channel);
|
|
|
|
|
void io_selectAmpAB(bool update);
|
|
|
|
|
void io_selectAmpD(bool update);
|
|
|
|
|
void io_bypassProtection(bool bypass, bool update);
|
2025-05-16 07:56:18 -05:00
|
|
|
#endif
|