Skip to content

Commit

Permalink
Merge pull request #871 from bdring/SDCard_Freq
Browse files Browse the repository at this point in the history
Sd card freq
  • Loading branch information
bdring authored Apr 24, 2023
2 parents b409cce + d3163e0 commit 855b0c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions FluidNC/esp32/sdspi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ bool sd_init_slot(uint32_t freq_hz, int cs_pin, int cd_pin, int wp_pin) {

sdspi_device_config_t slot_config;

// If freq_hz is 0, use the system default
if (freq_hz) {
host_config.max_freq_khz = freq_hz / 1000;
}
host_config.max_freq_khz = freq_hz / 1000;

err = host_config.init();
CHECK_EXECUTE_RESULT(err, "host init failed");
Expand All @@ -104,7 +101,6 @@ bool sd_init_slot(uint32_t freq_hz, int cs_pin, int cd_pin, int wp_pin) {
// If you do it only once below, the attempt to change it seems to
// be ignored, and you get 20 MHz regardless of what you ask for.
if (freq_hz) {
printf("hz = %d\n", freq_hz);
err = sdspi_host_set_card_clk(host_config.slot, freq_hz / 1000);
CHECK_EXECUTE_RESULT(err, "set slot clock speed failed");
}
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static void check_startup_state() {
}

if (sys.state == State::Alarm || sys.state == State::Sleep) {
report_error_message(Message::AlarmLock);
report_feedback_message(Message::AlarmLock);
sys.state = State::Alarm; // Ensure alarm state is set.
} else {
// Check if the safety door is open.
Expand Down
4 changes: 2 additions & 2 deletions FluidNC/src/SDCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SDCard : public Configuration::Configurable {
Pin _cardDetect;
Pin _cs;

uint32_t _frequency_hz = 0; // Set to nonzero to override the default
uint32_t _frequency_hz = 8000000; // Set to nonzero to override the default

public:
SDCard();
Expand All @@ -60,7 +60,7 @@ class SDCard : public Configuration::Configurable {
void group(Configuration::HandlerBase& handler) override {
handler.item("cs_pin", _cs);
handler.item("card_detect_pin", _cardDetect);
handler.item("frequency_hz", _frequency_hz);
handler.item("frequency_hz", _frequency_hz, 400000, 20000000);
}

~SDCard();
Expand Down

0 comments on commit 855b0c9

Please sign in to comment.