Tighten up radio API, stop leaking 1st/2nd IF instances.

This commit is contained in:
Jared Boone 2016-02-16 10:28:13 -08:00
parent ef86848139
commit 3e2b6087c2
4 changed files with 48 additions and 8 deletions

View File

@ -22,6 +22,9 @@
#include "radio.hpp" #include "radio.hpp"
#include "rf_path.hpp" #include "rf_path.hpp"
#include "rffc507x.hpp"
#include "max2837.hpp"
#include "max5864.hpp" #include "max5864.hpp"
#include "baseband_cpld.hpp" #include "baseband_cpld.hpp"
@ -183,4 +186,28 @@ void configure(Configuration configuration) {
set_direction(configuration.direction); set_direction(configuration.direction);
} }
namespace debug {
namespace first_if {
uint32_t register_read(const size_t register_number) {
return radio::first_if.read(register_number);
}
} /* namespace first_if */
namespace second_if {
uint32_t register_read(const size_t register_number) {
return radio::second_if.read(register_number);
}
uint8_t temp_sense() {
return radio::second_if.temp_sense() & 0x1f;
}
} /* namespace second_if */
} /* namespace debug */
} /* namespace radio */ } /* namespace radio */

View File

@ -27,9 +27,6 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
#include "rffc507x.hpp"
#include "max2837.hpp"
namespace radio { namespace radio {
struct Configuration { struct Configuration {
@ -59,8 +56,24 @@ void enable(Configuration configuration);
void configure(Configuration configuration); void configure(Configuration configuration);
void disable(); void disable();
extern rffc507x::RFFC507x first_if; namespace debug {
extern max2837::MAX2837 second_if;
namespace first_if {
uint32_t register_read(const size_t register_number);
} /* namespace first_if */
namespace second_if {
uint32_t register_read(const size_t register_number);
// TODO: This belongs somewhere else.
uint8_t temp_sense();
} /* namespace second_if */
} /* namespace debug */
} /* namespace radio */ } /* namespace radio */

View File

@ -54,7 +54,7 @@ std::vector<TemperatureLogger::sample_t> TemperatureLogger::history() const {
TemperatureLogger::sample_t TemperatureLogger::read_sample() { TemperatureLogger::sample_t TemperatureLogger::read_sample() {
// MAX2837 does not return a valid temperature if in "shutdown" mode. // MAX2837 does not return a valid temperature if in "shutdown" mode.
return radio::second_if.temp_sense() & 0x1f; return radio::debug::second_if::temp_sense();
} }
void TemperatureLogger::push_sample(const TemperatureLogger::sample_t sample) { void TemperatureLogger::push_sample(const TemperatureLogger::sample_t sample) {

View File

@ -248,11 +248,11 @@ DebugPeripheralsMenuView::DebugPeripheralsMenuView(NavigationView& nav) {
add_items<4>({ { add_items<4>({ {
{ "RFFC5072", [&nav](){ nav.push<RegistersView>( { "RFFC5072", [&nav](){ nav.push<RegistersView>(
"RFFC5072", RegistersWidgetConfig { 31, 2, 4, 4 }, "RFFC5072", RegistersWidgetConfig { 31, 2, 4, 4 },
[](const size_t register_number) { return radio::first_if.read(register_number); } [](const size_t register_number) { return radio::debug::first_if::register_read(register_number); }
); } }, ); } },
{ "MAX2837", [&nav](){ nav.push<RegistersView>( { "MAX2837", [&nav](){ nav.push<RegistersView>(
"MAX2837", RegistersWidgetConfig { 32, 2, 3, 4 }, "MAX2837", RegistersWidgetConfig { 32, 2, 3, 4 },
[](const size_t register_number) { return radio::second_if.read(register_number); } [](const size_t register_number) { return radio::debug::second_if::register_read(register_number); }
); } }, ); } },
{ "Si5351C", [&nav](){ nav.push<RegistersView>( { "Si5351C", [&nav](){ nav.push<RegistersView>(
"Si5351C", RegistersWidgetConfig { 96, 2, 2, 8 }, "Si5351C", RegistersWidgetConfig { 96, 2, 2, 8 },