mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-29 23:57:38 +00:00
920b98f7c9
* Power: Turn off additional peripheral clock branches. * Update schematic with new symbol table and KiCad standard symbols. Fix up wires. * Schematic: Update power net labels. * Schematic: Update footprint names to match library changes. * Schematic: Update header vendor and part numbers. * Schematic: Specify (arbitrary) value for PDN# net. * Schematic: Remove fourth fiducial. Not standard practice, and was taking up valuable board space. * Schematic: Add reference oscillator -- options for clipped sine or HCMOS output. * Schematic: Update copyright year. * Schematic: Remove CLKOUT to CPLD. It was a half-baked idea. * Schematic: Add (experimental) GPS circuit. Add note about charging circuit. Update date and revision to match PCB. * PCB: Update from schematic change: now revision 20180819. Diff was extensive due to net renumbering... * PCB: Fix GPS courtyard to accommodate crazy solder paste recommendation in integration manual. PCB: Address DRC clearance violation between via and oscillator pad. * PCB: Update copyright on drawing. * Update schematic and PCB date and revision. * gitignore: Sublime Text editor project/workspace files * Power: Power up or power down peripheral clock at appropriate times, so firmware doesn't freeze... * Clocking: Fix incorrect shift for CGU IDIVx_CTRL.PD field. * LPC43xx: Add CGU IDIVx struct/union type. * Power: Switch off unused IDIV dividers. Make note of active IDIVs and their use. * HackRF Mode: Upgrade firmware to 2018.01.1 (API 1.02) * MAX V CPLD: Refactor class to look more like Xilinx CoolRunner II CPLD class. * MAX V CPLD: Add BYPASS, SAMPLE support. Rename enter_isp -> enable, exit_isp -> disable. Use SAMPLE at start of flash process, which somehow addresses the problem where CFM wouldn't load into SRAM (and become the active bitstream) after flashing. * MAX V CPLD: Reverse verify data checking logic to make it a little faster. * CPLD: After reprogramming flash, immediately clamp I/O signals, load to SRAM, and "execute" the new bitstream. * Si5351: Refactor code, make one of the registers more type-safe. Clock Manager: Track selected reference clock source for later use in user interface. * Clock Manager: Add note about PPM only affecting Si5351C PLLA, which always runs from the HackRF 25MHz crystal. It is assumed an external clock does not need adjustment, though I am open to being convinced otherwise... * PPM UI: Show "EXT" when showing PPM adjustment and reference clock is external. * CPLD: Add pins and logic for new PortaPack hardware feature(s). * CPLD: Bitstream to support new hardware features. * Clock Generator: Add a couple more setter methods for ClockControl registers. * Clock Manager: Use shared MCU CLKIN clock control configuration constant. * Clock Manager: Reduce MCU CLKIN driver current. 2mA should be plenty. * Clock Manager: Remove redundant clock generator output enable. * Bootstrap: Remove unnecessary ldscript hack to locate SPIFI mode change code in RAM. * Bootstrap: Get CPU operating at max frequency as soon as possible. Update SPIFI speed comment. Make some more LPC43xx types into unions with uint32_t. * Bootstrap: Explicitly configure IDIVB for SPIFI, despite LPC43xx bootloader setting it. * Clock Manager: Init peripherals before CPLD reconfig. Do the clock generator setup after, so we can check presence of PortaPack reference clock with the help of the latest CPLD bitstream. * Clock Manager: Reverse sense of conditional that determines crystal or non-crystal reference source. This is for an expected upcoming change where multiple external options can be differentiated. * Bootstrap: Consolidate clock configuration, update SPIFI rate comment. * Clock Manager: Use IDIVA for clock source for all peripherals, instead of PLL1. Should make switching easier going forward. Don't use IRC as clock during initial clock manager configuration. Until we switch to GP_CLKIN, we should go flat out... * ChibiOS M0: Change default clock speed to 204MHz, since bootstrap now maxes out clock speed before starting M0 execution. * PortaPack IO: Expose method to set reference oscillator enable pin. * Pin configuration: Do SPIFI pin config with other pins, in preparation for eliminating separate bootloader. * Pin configuration: Disable input buffers on pins that are never read. * Revert "ChibiOS M0: Change default clock speed to 204MHz, since bootstrap now maxes out clock speed before starting M0 execution." This reverts commit c0e2bb6cc4cc656769323bdbb8ee5a16d2d5bb03. * Remove unused board files. * Add LPC43xx functions. * chibios: Replace code with per-peripheral structs defining clocks, interrupts, and reset bits. * LPC43xx: Add MCPWM peripheral struct. * clock generator: Use recommended PLL reset register value. Datasheet recommends a value. AN619 is quiet on the topic, claims the low nibble is default 0b0000. * GPIO: Tweak masking of SCU function. I don't remember why I thought this was necessary... * HAL: Explicitly turn on timer peripheral clocks used as systicks, during init. * SCU: Add struct to hold pin configuration. * PAL: Add functions to address The Glitch. https://greatscottgadgets.com/2018/02-28-we-fixed-the-glitch/ * PAL/board: New IO initialization code Declare initial state for SCU pin config, GPIOs. Apply initial state during PAL init. Perform VAA slow turn-on to address The Glitch. * Merge M0 and M4 to eliminate need for bootstrap firmware During _early_init, detect if we're running on the M4 or M0. If M4: do M4-specific core initialization, reset peripherals, speed up SPIFI clock, start M0, go to sleep. If M0: do all the other things. * Pins: Miscellaneous SCU configuration tweaks. * Little code clarity improvement. * bootstrap: Remove, not necessary. * Clock Manager: Large re-working to support external references. * Fix merge conflicts
188 lines
5.2 KiB
VHDL
188 lines
5.2 KiB
VHDL
--
|
|
-- Copyright (C) 2012 Jared Boone, ShareBrained Technology, Inc.
|
|
--
|
|
-- This file is part of PortaPack.
|
|
--
|
|
-- This program is free software; you can redistribute it and/or modify
|
|
-- it under the terms of the GNU General Public License as published by
|
|
-- the Free Software Foundation; either version 2, or (at your option)
|
|
-- any later version.
|
|
--
|
|
-- This program is distributed in the hope that it will be useful,
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
-- GNU General Public License for more details.
|
|
--
|
|
-- You should have received a copy of the GNU General Public License
|
|
-- along with this program; see the file COPYING. If not, write to
|
|
-- the Free Software Foundation, Inc., 51 Franklin Street,
|
|
-- Boston, MA 02110-1301, USA.
|
|
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
entity top is
|
|
port (
|
|
MCU_D : inout std_logic_vector(7 downto 0);
|
|
MCU_DIR : in std_logic;
|
|
MCU_IO_STBX : in std_logic;
|
|
MCU_LCD_WRX : in std_logic;
|
|
MCU_ADDR : in std_logic;
|
|
MCU_LCD_TE : out std_logic;
|
|
MCU_P2_8 : in std_logic;
|
|
MCU_LCD_RDX : in std_logic;
|
|
|
|
TP_U : out std_logic;
|
|
TP_D : out std_logic;
|
|
TP_L : out std_logic;
|
|
TP_R : out std_logic;
|
|
|
|
SW_SEL : in std_logic;
|
|
SW_ROT_A : in std_logic;
|
|
SW_ROT_B : in std_logic;
|
|
SW_U : in std_logic;
|
|
SW_D : in std_logic;
|
|
SW_L : in std_logic;
|
|
SW_R : in std_logic;
|
|
|
|
LCD_RESETX : out std_logic;
|
|
LCD_RS : out std_logic;
|
|
LCD_WRX : out std_logic;
|
|
LCD_RDX : out std_logic;
|
|
LCD_DB : inout std_logic_vector(15 downto 0);
|
|
LCD_TE : in std_logic;
|
|
LCD_BACKLIGHT : out std_logic;
|
|
|
|
AUDIO_RESETX : out std_logic;
|
|
|
|
REF_EN : out std_logic;
|
|
|
|
GPS_RESETX : out std_logic;
|
|
GPS_TX_READY : in std_logic;
|
|
GPS_TIMEPULSE : in std_logic
|
|
);
|
|
end top;
|
|
|
|
architecture rtl of top is
|
|
|
|
signal switches : std_logic_vector(7 downto 0);
|
|
|
|
type data_direction_t is (from_mcu, to_mcu);
|
|
signal data_dir : data_direction_t;
|
|
|
|
signal mcu_data_out_lcd : std_logic_vector(7 downto 0);
|
|
signal mcu_data_out_io : std_logic_vector(7 downto 0);
|
|
signal mcu_data_out : std_logic_vector(7 downto 0);
|
|
signal mcu_data_in : std_logic_vector(7 downto 0);
|
|
|
|
signal lcd_data_in : std_logic_vector(15 downto 0);
|
|
signal lcd_data_in_mux : std_logic_vector(7 downto 0);
|
|
signal lcd_data_out : std_logic_vector(15 downto 0);
|
|
|
|
signal lcd_data_in_q : std_logic_vector(7 downto 0) := (others => '0');
|
|
signal lcd_data_out_q : std_logic_vector(7 downto 0) := (others => '0');
|
|
|
|
signal tp_q : std_logic_vector(7 downto 0) := (others => '0');
|
|
|
|
signal lcd_reset_q : std_logic := '1';
|
|
signal lcd_backlight_q : std_logic := '0';
|
|
|
|
signal audio_reset_q : std_logic := '1';
|
|
|
|
signal ref_en_q : std_logic := '0';
|
|
|
|
signal dir_read : boolean;
|
|
signal dir_write : boolean;
|
|
|
|
signal lcd_read_strobe : boolean;
|
|
signal lcd_write_strobe : boolean;
|
|
signal lcd_write : boolean;
|
|
|
|
signal io_strobe : boolean;
|
|
signal io_read_strobe : boolean;
|
|
signal io_write_strobe : boolean;
|
|
|
|
begin
|
|
|
|
-- I/O data
|
|
switches <= LCD_TE & not SW_ROT_B & not SW_ROT_A & not SW_SEL & not SW_U & not SW_D & not SW_L & not SW_R;
|
|
|
|
TP_U <= tp_q(3) when tp_q(7) = '1' else 'Z';
|
|
TP_D <= tp_q(2) when tp_q(6) = '1' else 'Z';
|
|
TP_L <= tp_q(1) when tp_q(5) = '1' else 'Z';
|
|
TP_R <= tp_q(0) when tp_q(4) = '1' else 'Z';
|
|
|
|
LCD_BACKLIGHT <= lcd_backlight_q;
|
|
|
|
MCU_LCD_TE <= LCD_TE;
|
|
|
|
-- State management
|
|
data_dir <= to_mcu when MCU_DIR = '1' else from_mcu;
|
|
dir_read <= (data_dir = to_mcu);
|
|
dir_write <= (data_dir = from_mcu);
|
|
|
|
io_strobe <= (MCU_IO_STBX = '0');
|
|
io_read_strobe <= io_strobe and dir_read;
|
|
|
|
lcd_read_strobe <= (MCU_LCD_RDX = '0');
|
|
lcd_write <= not lcd_read_strobe;
|
|
|
|
-- LCD interface
|
|
LCD_RS <= MCU_ADDR;
|
|
LCD_RDX <= MCU_LCD_RDX;
|
|
LCD_WRX <= MCU_LCD_WRX;
|
|
|
|
lcd_data_out <= lcd_data_out_q & mcu_data_in;
|
|
lcd_data_in <= LCD_DB;
|
|
LCD_DB <= lcd_data_out when lcd_write else (others => 'Z');
|
|
|
|
-- Reference clock
|
|
REF_EN <= ref_en_q;
|
|
|
|
-- Peripheral reset control
|
|
LCD_RESETX <= not lcd_reset_q;
|
|
AUDIO_RESETX <= not audio_reset_q;
|
|
GPS_RESETX <= '1';
|
|
|
|
-- MCU interface
|
|
mcu_data_out_lcd <= lcd_data_in(15 downto 8) when lcd_read_strobe else lcd_data_in_q;
|
|
mcu_data_out_io <= switches;
|
|
mcu_data_out <= mcu_data_out_io when io_read_strobe else mcu_data_out_lcd;
|
|
|
|
mcu_data_in <= MCU_D;
|
|
MCU_D <= mcu_data_out when dir_read else (others => 'Z');
|
|
|
|
-- Synchronous behaviors:
|
|
-- LCD write: Capture LCD high byte on LCD_WRX falling edge.
|
|
process(MCU_LCD_WRX, mcu_data_in)
|
|
begin
|
|
if falling_edge(MCU_LCD_WRX) then
|
|
lcd_data_out_q <= mcu_data_in;
|
|
end if;
|
|
end process;
|
|
|
|
-- LCD read: Capture LCD low byte on LCD_RD falling edge.
|
|
process(MCU_LCD_RDX, lcd_data_in)
|
|
begin
|
|
if rising_edge(MCU_LCD_RDX) then
|
|
lcd_data_in_q <= lcd_data_in(7 downto 0);
|
|
end if;
|
|
end process;
|
|
|
|
-- I/O write (to resistive touch panel): Capture data from
|
|
-- MCU and hold on TP pins until further notice.
|
|
process(MCU_IO_STBX, dir_write, mcu_data_in, MCU_ADDR)
|
|
begin
|
|
if rising_edge(MCU_IO_STBX) and dir_write then
|
|
if MCU_ADDR = '0' then
|
|
tp_q <= mcu_data_in;
|
|
else
|
|
lcd_reset_q <= mcu_data_in(0);
|
|
audio_reset_q <= mcu_data_in(1);
|
|
ref_en_q <= mcu_data_in(6);
|
|
lcd_backlight_q <= mcu_data_in(7);
|
|
end if;
|
|
end if;
|
|
end process;
|
|
end rtl;
|