Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prawnblaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ foreach (overclock IN LISTS overclocks)
endif()

# Pull in our pico_stdlib which aggregates commonly used features
target_link_libraries(${firmware_name} pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board)
target_link_libraries(${firmware_name} pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma hardware_vreg tinyusb_device tinyusb_board)
target_include_directories(${firmware_name} PRIVATE .)

# create map/bin/hex/uf2 file etc.
Expand Down
26 changes: 24 additions & 2 deletions prawnblaster/prawnblaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "hardware/clocks.h"
#include "hardware/structs/pll.h"
#include "hardware/structs/clocks.h"
#include "hardware/vreg.h"

#include "pseudoclock.pio.h"

Expand Down Expand Up @@ -756,6 +757,14 @@ void measure_freqs(void)
#endif
}

void measure_voltage(void)
{
enum vreg_voltage vreg_val = vreg_get_voltage();
// Voltage is
float voltage = 0.55f + (vreg_val * 0.05f);
fast_serial_printf("voltage = %.2fV\r\n", voltage);
}

void resus_callback(void)
{
// Switch back to internal clock with the dfeault frequency
Expand Down Expand Up @@ -802,6 +811,11 @@ void loop()
{
measure_freqs();
fast_serial_printf("ok\r\n");
}
else if (strncmp(readstring, "getvolts", 8) == 0)
{
measure_voltage();
fast_serial_printf("ok\r\n");
}
else if (strncmp(readstring, "abort", 5) == 0)
{
Expand Down Expand Up @@ -1016,14 +1030,22 @@ void loop()
else if (strncmp(readstring, "setclock", 8) == 0)
{
unsigned int src; // 0 = internal, 1=GPIO pin 20, 2=GPIO pin 22
unsigned int freq; // in Hz (up to 133 or 150 MHz depending on board)
unsigned int freq; // in Hz (up to 133 or 200 MHz depending on board)
int parsed = sscanf(readstring, "%*s %u %u", &src, &freq);
if (parsed < 2)
{
fast_serial_printf("invalid request\r\n");
}
else
{
if (freq >= 150 * MHZ)
{
vreg_set_voltage(VREG_VOLTAGE_1_30);
}
if (freq < 150 * MHZ)
{
vreg_set_voltage(VREG_VOLTAGE_1_10);
}
if (DEBUG)
{
fast_serial_printf("Got request mode=%u, freq=%u MHz\r\n", src, freq / MHZ);
Expand All @@ -1039,7 +1061,7 @@ void loop()
# if PRAWNBLASTER_PICO_BOARD == 1
if (freq > 133 * MHZ)
# elif PRAWNBLASTER_PICO_BOARD == 2
if (freq > 150 * MHZ)
if (freq > 200 * MHZ)
# else
# error "Unsupported PICO_BOARD"
# endif // PICO_BOARD
Expand Down
Loading