Skip to content

Commit 925e79b

Browse files
committed
Remove unused hardware_rosc functions
Also allow setting PICO_ALLOW_EXAMPLE_KEYS as a property, and allow it for test/ directory
1 parent 95e8a9c commit 925e79b

4 files changed

Lines changed: 12 additions & 96 deletions

File tree

src/rp2_common/hardware_rosc/include/hardware/rosc.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,6 @@ extern "C" {
2626
* more accurate than the ring oscillator.
2727
*/
2828

29-
/*! \brief Set frequency of the Ring Oscillator
30-
* \ingroup hardware_rosc
31-
*
32-
* \param code The drive strengths. See the datasheet for information on this value.
33-
*/
34-
void rosc_set_freq(uint32_t code);
35-
36-
/*! \brief Set range of the Ring Oscillator
37-
* \ingroup hardware_rosc
38-
*
39-
* Frequency range. Frequencies will vary with Process, Voltage & Temperature (PVT).
40-
* Clock output will not glitch when changing the range up one step at a time.
41-
*
42-
* \param range 0x01 Low, 0x02 Medium, 0x03 High, 0x04 Too High.
43-
*/
44-
void rosc_set_range(uint range);
45-
4629
/*! \brief Disable the Ring Oscillator
4730
* \ingroup hardware_rosc
4831
*
@@ -67,29 +50,6 @@ void rosc_set_dormant(void);
6750
*/
6851
void rosc_restart(void);
6952

70-
/*! \brief Get the next ROSC freq code
71-
* \ingroup hardware_rosc
72-
*
73-
* Given a ROSC freq code, return the next-numerically-higher code.
74-
* Top result bit is set when called on maximum ROSC code.
75-
*
76-
* \param code The current ROSC freq code.
77-
* \return The next ROSC freq code.
78-
*/
79-
uint32_t next_rosc_code(uint32_t code);
80-
81-
/*! \brief Set the frequency of the Ring Oscillator within a range
82-
* \ingroup hardware_rosc
83-
*
84-
* This function will set the frequency of the Ring Oscillator to the first frequency within the range.
85-
* This will only be accurate if clk_ref is currently running from an accurate source (eg the XOSC).
86-
*
87-
* \param low_mhz The bottom of the range to search for.
88-
* \param high_mhz The top of the range to search for.
89-
* \return The frequency of the Ring Oscillator within the range in MHz, or 0 if no frequency within the range is found.
90-
*/
91-
uint rosc_find_freq_mhz(uint32_t low_mhz, uint32_t high_mhz);
92-
9353
/*! \brief Measure the frequency of the Ring Oscillator
9454
* \ingroup hardware_rosc
9555
*
@@ -99,25 +59,6 @@ uint rosc_find_freq_mhz(uint32_t low_mhz, uint32_t high_mhz);
9959
*/
10060
uint rosc_measure_freq_khz(void);
10161

102-
/*! \brief Set the output divider of the Ring Oscillator
103-
* \ingroup hardware_rosc
104-
*
105-
* \if rp2040_specific
106-
* div = 0 divides by 32
107-
* div = 1-31 divides by div
108-
* any other value sets div=31
109-
* \endif
110-
*
111-
* \if rp2350_specific
112-
* div = 0 divides by 128
113-
* div = 1-127 divides by div
114-
* any other value sets div=128
115-
* \endif
116-
*
117-
* \param div The output divider.
118-
*/
119-
void rosc_set_div(uint32_t div);
120-
12162
inline static void rosc_clear_bad_write(void) {
12263
hw_clear_bits(&rosc_hw->status, ROSC_STATUS_BADWRITE_BITS);
12364
}

src/rp2_common/hardware_rosc/rosc.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,11 @@
1010
#include "hardware/clocks.h"
1111
#include "hardware/rosc.h"
1212

13-
// Given a ROSC delay stage code, return the next-numerically-higher code.
14-
// Top result bit is set when called on maximum ROSC code.
15-
uint32_t next_rosc_code(uint32_t code) {
16-
return ((code | 0x08888888u) + 1u) & 0xf7777777u;
17-
}
18-
19-
uint rosc_find_freq_mhz(uint32_t low_mhz, uint32_t high_mhz) {
20-
// TODO: This could be a lot better
21-
rosc_set_div(1);
22-
for (uint32_t code = 0; code <= 0x77777777u; code = next_rosc_code(code)) {
23-
rosc_set_freq(code);
24-
uint rosc_mhz = frequency_count_khz(CLOCKS_FC0_SRC_VALUE_ROSC_CLKSRC) / 1000;
25-
if ((rosc_mhz >= low_mhz) && (rosc_mhz <= high_mhz)) {
26-
return rosc_mhz;
27-
}
28-
}
29-
return 0;
30-
}
3113

3214
uint rosc_measure_freq_khz(void) {
3315
return frequency_count_khz(CLOCKS_FC0_SRC_VALUE_ROSC_CLKSRC);
3416
}
3517

36-
void rosc_set_div(uint32_t div) {
37-
#if PICO_RP2040
38-
assert(div <= 31);
39-
#else
40-
assert(div <= 127);
41-
#endif
42-
rosc_write(&rosc_hw->div, ROSC_DIV_VALUE_PASS + div);
43-
}
44-
45-
void rosc_set_freq(uint32_t code) {
46-
rosc_write(&rosc_hw->freqa, (ROSC_FREQA_PASSWD_VALUE_PASS << ROSC_FREQA_PASSWD_LSB) | (code & 0xffffu));
47-
rosc_write(&rosc_hw->freqb, (ROSC_FREQB_PASSWD_VALUE_PASS << ROSC_FREQB_PASSWD_LSB) | (code >> 16u));
48-
}
49-
50-
void rosc_set_range(uint range) {
51-
// Range should use enumvals from the headers and thus have the password correct
52-
rosc_write(&rosc_hw->ctrl, (ROSC_CTRL_ENABLE_VALUE_ENABLE << ROSC_CTRL_ENABLE_LSB) | range);
53-
}
54-
5518
void rosc_disable(void) {
5619
uint32_t tmp = rosc_hw->ctrl;
5720
tmp &= (~ROSC_CTRL_ENABLE_BITS);

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
add_subdirectory(pico_test)
22

3+
set_directory_properties(PROPERTIES PICO_ALLOW_EXAMPLE_KEYS 1)
4+
35
add_subdirectory(pico_stdlib_test)
46
add_subdirectory(pico_stdio_test)
57
add_subdirectory(pico_time_test)

tools/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ define_property(TARGET
107107
BRIEF_DOCS "Ensure a load map is added"
108108
FULL_DOCS "Ensure a load map is added"
109109
)
110+
define_property(TARGET
111+
PROPERTY PICO_ALLOW_EXAMPLE_KEYS
112+
INHERITED
113+
BRIEF_DOCS "Allow use of example keys"
114+
FULL_DOCS "Allow use of example keys"
115+
)
110116

111117
# Check pioasm is installed, or build it if not installed
112118
function(pico_init_pioasm)
@@ -648,6 +654,10 @@ function(picotool_postprocess_binary TARGET)
648654
PICOTOOL_PROCESSING_CONFIGURED true
649655
)
650656

657+
if (NOT DEFINED PICO_ALLOW_EXAMPLE_KEYS)
658+
get_target_property(PICO_ALLOW_EXAMPLE_KEYS ${TARGET} PICO_ALLOW_EXAMPLE_KEYS)
659+
endif()
660+
651661
# PICO_CMAKE_CONFIG: PICO_ALLOW_EXAMPLE_KEYS, Don't raise a warning when using default signing/encryption keys, type=bool, default=0, group=build
652662
if (NOT PICO_ALLOW_EXAMPLE_KEYS)
653663
picotool_check_default_keys(${TARGET})

0 commit comments

Comments
 (0)