Skip to content

Commit

Permalink
Add usb activity to LED
Browse files Browse the repository at this point in the history
Bump everything up to version 1.0.0
  • Loading branch information
wickerwaka committed Jul 26, 2023
1 parent f31d1f4 commit def685b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
21 changes: 13 additions & 8 deletions firmware/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ void configure_address_pins(uint32_t mask)
}
}

static uint32_t identify_request = 0;
static uint8_t identify_request = 0;

#if ACTIVITY_LED==1
repeating_timer_t activity_timer;

static uint32_t identify_ack = 0;
static uint8_t identify_ack = 0;
static uint8_t activity_cycles = 0;
static uint8_t activity_duty = 0;
static uint8_t activity_count = 0;
Expand All @@ -117,21 +117,26 @@ bool activity_timer_callback(repeating_timer_t * /*unused*/)
if (activity_count >= activity_cycles)
{
bool rom_access = rom_check_oe();
bool usb_connected = pl_is_connected();
bool usb_activity = pl_check_activity();
bool identify_req = identify_request != identify_ack;

activity_cycles = 0;
activity_duty = 0;

if (identify_req)
{
identify_ack++;
activity_cycles = 10;
activity_duty = 8;
activity_cycles = 100;
activity_duty = 90;
}
else if (usb_activity)
{
activity_cycles = 20;
activity_duty = 10;
}
else if (rom_access)
{
activity_cycles = 3;
activity_cycles = 5;
activity_duty = 1;
}

Expand Down Expand Up @@ -170,7 +175,7 @@ int main()
gpio_set_dir(ACTIVITY_LED_PIN, true);
gpio_set_input_enabled(ACTIVITY_LED_PIN, false);

add_repeating_timer_ms(100, activity_timer_callback, nullptr, &activity_timer);
add_repeating_timer_ms(10, activity_timer_callback, nullptr, &activity_timer);
#endif

memcpy(rom_get_buffer(), flash_rom_data, ROM_SIZE);
Expand Down
19 changes: 19 additions & 0 deletions firmware/pico_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
static uint8_t incoming_buffer[sizeof(Packet)];
static uint8_t incoming_count;

static uint8_t activity_count = 0;
static uint8_t activity_report = 0;

void usb_send(const void *data, size_t len)
{
const uint8_t *ptr = (const uint8_t *)data;
Expand All @@ -23,6 +26,8 @@ void usb_send(const void *data, size_t len)
}

tud_cdc_write_flush();

activity_count++;
}


Expand Down Expand Up @@ -89,6 +94,8 @@ void pl_wait_for_connection()

incoming_count = 0;

activity_count = activity_report = 0;

// Write preamble
usb_send("PicoROM Hello", 13);
}
Expand Down Expand Up @@ -116,6 +123,7 @@ const Packet *pl_poll()
Packet *pkt = (Packet *)incoming_buffer;
if ((pkt->size + 2) <= incoming_count)
{
activity_count++;
return pkt;
}
}
Expand All @@ -135,3 +143,14 @@ void pl_consume_packet(const Packet *pkt)

incoming_count = remaining;
}

bool pl_check_activity()
{
if (activity_count != activity_report)
{
activity_report = activity_count;
return true;
}

return false;
}
2 changes: 2 additions & 0 deletions firmware/pico_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ bool pl_is_connected();
const Packet *pl_poll();
void pl_consume_packet(const Packet *pkt);

bool pl_check_activity();


#endif // PICO_LINK_H
1 change: 1 addition & 0 deletions firmware/rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void rom_init_programs()
for( uint ofs = 0; ofs < N_OE_PINS; ofs++ )
{
pio_gpio_init(data_pio, BASE_OE_PIN + ofs);
gpio_set_pulls(BASE_OE_PIN + ofs, true, false);
}

for( uint ofs = 0; ofs < N_BUF_OE_PINS; ofs++ )
Expand Down
2 changes: 1 addition & 1 deletion host/picolink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "picolink"
version = "0.9.0"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion host/picorom/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "picorom"
version = "0.9.0"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion host/pypicorom/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pypicorom"
version = "0.9.1"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down

0 comments on commit def685b

Please sign in to comment.