mirror of
https://gitlab.com/zephray/glider.git
synced 2025-03-17 06:15:05 +00:00
Back port to r0p6
This commit is contained in:
parent
e178b6dff9
commit
d1eb78aa9e
7 changed files with 68 additions and 25 deletions
|
@ -21,6 +21,7 @@
|
|||
//
|
||||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "config.h"
|
||||
#include "button.h"
|
||||
|
||||
#define BTN1 6
|
||||
|
@ -33,6 +34,7 @@
|
|||
#define RELEASE_THRESHOLD 20
|
||||
|
||||
void button_init() {
|
||||
#ifdef HAS_BUTTON
|
||||
gpio_init(BTN1);
|
||||
gpio_set_dir(BTN1, GPIO_IN);
|
||||
gpio_pull_up(BTN1);
|
||||
|
@ -40,6 +42,7 @@ void button_init() {
|
|||
gpio_init(BTN2);
|
||||
gpio_set_dir(BTN2, GPIO_IN);
|
||||
gpio_pull_up(BTN2);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Scan a single key, ID is the key number from 0, gpio is pin number
|
||||
|
@ -119,8 +122,12 @@ static uint32_t button_scan_single(int id, int gpio) {
|
|||
}
|
||||
|
||||
uint32_t button_scan() {
|
||||
#ifdef HAS_BUTTON
|
||||
uint32_t btn1 = button_scan_single(0, BTN1);
|
||||
uint32_t btn2 = button_scan_single(1, BTN2);
|
||||
uint32_t retval = (btn1 & 0x3) | ((btn2 & 0x3) << 2);
|
||||
return retval;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
54
fw/config.h
54
fw/config.h
|
@ -23,7 +23,8 @@
|
|||
|
||||
/* BOARD REVISION CONFIGURATION */
|
||||
// Eariler revisions are not supported
|
||||
#define BOARD_REV_R0P7
|
||||
#define BOARD_REV_R0P6
|
||||
//#define BOARD_REV_R0P7
|
||||
|
||||
/* SCREEN CONFIGURATION */
|
||||
|
||||
|
@ -53,12 +54,61 @@
|
|||
|
||||
|
||||
/* SET BASED ON PREVIOUS DEFINES, DO NOT MODIFY */
|
||||
#if defined(BOARD_REV_R0P7)
|
||||
#if defined(BOARD_REV_R0P6)
|
||||
#define POWER_GPIO
|
||||
#define INPUT_PTN3460
|
||||
#define HAS_TYPEC
|
||||
|
||||
#define TYPEC_MB_ORI_INV 1
|
||||
#define TYPEC_AUX_ORI_INV 1
|
||||
|
||||
#define I2C_SDA 0
|
||||
#define I2C_SCL 1
|
||||
|
||||
#define TCPC_I2C i2c0
|
||||
|
||||
#define FPGA_CS 12
|
||||
#define FPGA_MOSI 13
|
||||
#define FPGA_MISO 14
|
||||
#define FPGA_SCLK 15
|
||||
#define FPGA_PROG 17
|
||||
#define FPGA_DONE 18
|
||||
#define FPGA_SUSP 19
|
||||
|
||||
#define PTN3460_I2C (i2c0)
|
||||
#define PTN3460_HPD_PIN (8)
|
||||
#define PTN3460_PDN_PIN (9)
|
||||
#define PTN3460_VALID_PIN (2)
|
||||
|
||||
#elif defined(BOARD_REV_R0P7)
|
||||
#define POWER_GPIO
|
||||
#define POWER_GPIO_VCOM_MEASURE
|
||||
#define INPUT_ADV7611
|
||||
#define INPUT_PTN3460
|
||||
#define HAS_TYPEC
|
||||
#define HAS_BUTTON
|
||||
|
||||
#define TYPEC_MB_ORI_INV 0
|
||||
#define TYPEC_AUX_ORI_INV 1
|
||||
|
||||
#define I2C_SDA 2
|
||||
#define I2C_SCL 3
|
||||
|
||||
#define TCPC_I2C i2c1
|
||||
|
||||
#define FPGA_CS 13
|
||||
#define FPGA_MOSI 15
|
||||
#define FPGA_MISO 12
|
||||
#define FPGA_SCLK 14
|
||||
#define FPGA_PROG 17
|
||||
#define FPGA_DONE 18
|
||||
#define FPGA_SUSP 19
|
||||
|
||||
#define PTN3460_I2C (i2c1)
|
||||
#define PTN3460_HPD_PIN (7)
|
||||
#define PTN3460_PDN_PIN (9)
|
||||
#define PTN3460_VALID_PIN (4)
|
||||
|
||||
#else
|
||||
#error "Unknown board revision"
|
||||
#endif
|
||||
|
|
|
@ -22,17 +22,10 @@
|
|||
#include "pico/stdlib.h"
|
||||
#include <stdio.h>
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "fpga.h"
|
||||
#include "bitstream.h"
|
||||
|
||||
#define FPGA_CS 13
|
||||
#define FPGA_MOSI 15
|
||||
#define FPGA_MISO 12
|
||||
#define FPGA_SCLK 14
|
||||
#define FPGA_PROG 17
|
||||
#define FPGA_DONE 18
|
||||
#define FPGA_SUSP 19
|
||||
|
||||
static int fpga_done = 0;
|
||||
|
||||
static void gpio_init_out(uint32_t pin, bool val) {
|
||||
|
|
10
fw/fw.c
10
fw/fw.c
|
@ -51,11 +51,11 @@ int main()
|
|||
#endif
|
||||
|
||||
// Initialize I2C for TCPC/PTN3460/ADV7611 use
|
||||
i2c_init(i2c1, 100*1000);
|
||||
gpio_set_function(2, GPIO_FUNC_I2C);
|
||||
gpio_set_function(3, GPIO_FUNC_I2C);
|
||||
gpio_pull_up(2);
|
||||
gpio_pull_up(3);
|
||||
i2c_init(TCPC_I2C, 100*1000);
|
||||
gpio_set_function(I2C_SDA, GPIO_FUNC_I2C);
|
||||
gpio_set_function(I2C_SCL, GPIO_FUNC_I2C);
|
||||
gpio_pull_up(I2C_SDA);
|
||||
gpio_pull_up(I2C_SCL);
|
||||
|
||||
#ifdef HAS_TYPEC
|
||||
int result = tcpm_init(0);
|
||||
|
|
|
@ -31,10 +31,6 @@
|
|||
#ifdef INPUT_PTN3460
|
||||
|
||||
#define PTN3460_I2C_ADDRESS (0x60)
|
||||
#define PTN3460_I2C (i2c1)
|
||||
#define PTN3460_HPD_PIN (7)
|
||||
#define PTN3460_PDN_PIN (9)
|
||||
#define PTN3460_VALID_PIN (4)
|
||||
|
||||
void ptn3460_select_edid_emulation(uint8_t id) {
|
||||
uint8_t buf[2];
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
#include "config.h"
|
||||
#include "tcpm_driver.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include "hardware/i2c.h"
|
||||
|
@ -29,8 +30,6 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
|
|||
{0, FUSB302_I2C_SLAVE_ADDR, &fusb302_tcpm_drv},
|
||||
};
|
||||
|
||||
#define TCPC_I2C i2c1
|
||||
|
||||
void tcpc_i2c_init(void) {
|
||||
// Should be initialized at board level init to avoid dependencies between
|
||||
// drivers that need I2C
|
||||
|
|
|
@ -48,15 +48,13 @@ void usb_mux_set(int port, enum typec_mux mux_mode,
|
|||
if (polarity == 0) {
|
||||
// Not flipped
|
||||
printf("Setting orientation to not flipped\n");
|
||||
gpio_put(USBC_ORI_PIN, 0);
|
||||
ptn3460_set_aux_polarity(1);
|
||||
}
|
||||
else {
|
||||
// Flipped
|
||||
printf("Setting orientation to flipped\n");
|
||||
gpio_put(USBC_ORI_PIN, 1);
|
||||
ptn3460_set_aux_polarity(0);
|
||||
}
|
||||
gpio_put(USBC_ORI_PIN, polarity ^ TYPEC_MB_ORI_INV);
|
||||
ptn3460_set_aux_polarity(polarity ^ TYPEC_AUX_ORI_INV);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue