Skip to content

Commit

Permalink
rebase onto main
Browse files Browse the repository at this point in the history
  • Loading branch information
cyber-murmel committed Jun 10, 2024
1 parent 2baf437 commit b5664cd
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 17 deletions.
3 changes: 3 additions & 0 deletions firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/button.c
${CMAKE_CURRENT_SOURCE_DIR}/src/console.c
${CMAKE_CURRENT_SOURCE_DIR}/src/debug_spi.c
${CMAKE_CURRENT_SOURCE_DIR}/src/fpga.c
${CMAKE_CURRENT_SOURCE_DIR}/src/jtag.c
${CMAKE_CURRENT_SOURCE_DIR}/src/jtag_tap.c
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_switch.c
${CMAKE_CURRENT_SOURCE_DIR}/src/vendor.c
${CMAKE_CURRENT_SOURCE_DIR}/src/boards/${BOARD}/dfu.c
${CMAKE_CURRENT_SOURCE_DIR}/src/boards/${BOARD}/jtag.c
${CMAKE_CURRENT_SOURCE_DIR}/src/boards/${BOARD}/fpga_adv.c
${CMAKE_CURRENT_SOURCE_DIR}/src/boards/${BOARD}/fpga.c
${CMAKE_CURRENT_SOURCE_DIR}/src/boards/${BOARD}/debug_spi.c
${CMAKE_CURRENT_SOURCE_DIR}/src/boards/${BOARD}/spi.c
Expand All @@ -50,6 +52,7 @@ target_compile_definitions(${PROJECT} PUBLIC
# CFG_TUSB_OS=OPT_OS_PICO
_BOARD_REVISION_MAJOR_=${BOARD_REVISION_MAJOR}
_BOARD_REVISION_MINOR_=${BOARD_REVISION_MINOR}
VERSION_STRING="${VERSION_STRING}"
)

# Configure compilation flags and libraries for the example... see the corresponding function
Expand Down
3 changes: 3 additions & 0 deletions firmware/src/boards/raspberry_pi_pico/apollo_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ enum {
// // Connected to orangecrab pins 0 and 1. SERCOM0
UART_RX = UART_RX_PIN,
UART_TX = UART_TX_PIN,

// Connected to orangecrab RSTFPGA_RESET, ecp5 PROGRAMN
PIN_PROG = 7,
};


Expand Down
3 changes: 2 additions & 1 deletion firmware/src/boards/raspberry_pi_pico/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ BOARD_REVISION_MINOR := 3

CMAKE_DEFSYM += \
-DBOARD_REVISION_MAJOR=$(BOARD_REVISION_MAJOR) \
-DBOARD_REVISION_MINOR=$(BOARD_REVISION_MINOR)
-DBOARD_REVISION_MINOR=$(BOARD_REVISION_MINOR) \
-DVERSION_STRING="$(VERSION_STRING)"

ifeq "$(PICO_SDK_PATH)" ""
CMAKE_DEFSYM += -DPICO_SDK_FETCH_FROM_GIT=1
Expand Down
33 changes: 25 additions & 8 deletions firmware/src/boards/raspberry_pi_pico/fpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <bsp/board_api.h>
#include <apollo_board.h>

#include "apollo_board.h"
#include "jtag.h"
#include "fpga.h"


/*
* Allows or disallows the FPGA from configuring. When disallowed,
Expand All @@ -33,12 +37,25 @@ void fpga_io_init(void)
*/
void trigger_fpga_reconfiguration(void)
{
}


/**
* Requests that we hold the FPGA in an unconfigured state.
*/
void force_fpga_offline(void)
{
/*
* If the JTAG TAP was left in certain states, pulsing PROGRAMN has no
* effect, so we reset the state first.
*/
jtag_init();
jtag_go_to_state(STATE_TEST_LOGIC_RESET);
jtag_wait_time(2);
jtag_deinit();
/*
* Now pulse PROGRAMN to instruct the FPGA to configure itself.
*/
gpio_set_pin_direction(PIN_PROG, GPIO_DIRECTION_OUT);
gpio_set_pin_level(PIN_PROG, false);

board_delay(1);

gpio_set_pin_level(PIN_PROG, true);
gpio_set_pin_direction(PIN_PROG, GPIO_DIRECTION_IN);

// Update internal state.
fpga_set_online(true);
}
38 changes: 38 additions & 0 deletions firmware/src/boards/raspberry_pi_pico/fpga_adv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* FPGA advertisement pin handling code.
*
* This file is part of Apollo.
*
* Copyright (c) 2023 Great Scott Gadgets <[email protected]>
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdbool.h>

/**
* Initialize FPGA_ADV receive-only serial port
*/
void fpga_adv_init(void)
{
}

/**
* Task for things related with the advertisement pin
*/
void fpga_adv_task(void)
{
}

/**
* Allow FPGA takeover of the USB port
*/
void allow_fpga_takeover_usb(bool allow)
{
}

/**
* True if we received an advertisement message within the last time window.
*/
bool fpga_requesting_port(void)
{
return false;
}
16 changes: 8 additions & 8 deletions firmware/src/boards/raspberry_pi_pico/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@


/** Store the current LED blink pattern. */
static blink_pattern_t blink_pattern = BLINK_IDLE;
static led_pattern_t led_pattern = LED_IDLE;


/**
* Sets the active LED blink pattern.
* Sets the active LED pattern.
*/
void led_set_blink_pattern(blink_pattern_t pattern)
void led_set_pattern(led_pattern_t pattern)
{
blink_pattern = pattern;
led_pattern = pattern;
leds_off();
}

Expand Down Expand Up @@ -111,17 +111,17 @@ static void display_led_number(uint8_t number)


/**
* Task that handles blinking the heartbeat LED.
* Task that handles LED updates.
*/
void heartbeat_task(void)
void led_task(void)
{
static uint32_t start_ms = 0;

// Blink every interval ms
if ( board_millis() - start_ms < blink_pattern) {
if ( board_millis() - start_ms < led_pattern) {
return; // not enough time
}

start_ms += blink_pattern;
start_ms += led_pattern;
led_toggle(LED_A);
}

0 comments on commit b5664cd

Please sign in to comment.