94 lines
2.6 KiB
C
94 lines
2.6 KiB
C
#ifndef IO_H_
|
|
#define IO_H_
|
|
|
|
#include "fsl_gpio.h"
|
|
#include <stdbool.h>
|
|
|
|
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);
|
|
|
|
#define LOW 0
|
|
#define HIGH 1
|
|
|
|
// GPIO
|
|
#define IO_PORT0 0
|
|
#define IO_PORT1 1
|
|
|
|
#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)
|
|
|
|
#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)
|
|
|
|
#define _P1(p1, p2) p1
|
|
#define _P2(p1, p2) p2
|
|
|
|
#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)
|
|
|
|
|
|
// 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
|
|
|
|
// Bottom Shift Register (U35)
|
|
#define AMP_AB_SW 0b00000001
|
|
#define AMP_D_ON 0b00000010
|
|
#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
|
|
|
|
#define _TAP1_LF_ON (BOTTOM_SR, TAP_102_LF | TAP_204_LF)
|
|
#define _TAP2_LF_ON (BOTTOM_SR, TAP_102_LF)
|
|
#define _TAP3_LF_ON (BOTTOM_SR, TAP_204_LF)
|
|
#define _TAP4_LF_ON (BOTTOM_SR, 0)
|
|
|
|
#define BYPASS_ON (MID_SR, LF_BYPASS)
|
|
|
|
#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)
|
|
|
|
#endif
|