Skip to content

Commit

Permalink
Merge pull request #1230 from bdring/Jobs-new
Browse files Browse the repository at this point in the history
Merged stale Jobs branch atop main
  • Loading branch information
bdring committed Jun 28, 2024
2 parents ec8517e + 5f5a198 commit c0d4995
Show file tree
Hide file tree
Showing 118 changed files with 2,644 additions and 659 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ dist/
*.cppx
*.hx
/compile_commands.json
data-wmb/
*#
Binary file modified FluidNC/data/index.html.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion FluidNC/esp32/PwmPin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static uint8_t calc_pwm_precision(uint32_t frequency) {
return ledcMaxBits;
}

PwmPin::PwmPin(Pin& pin, uint32_t frequency) : _frequency(frequency) {
PwmPin::PwmPin(const Pin& pin, uint32_t frequency) : _frequency(frequency) {
uint8_t bits = calc_pwm_precision(frequency);
_period = (1 << bits) - 1;
_channel = allocateChannel();
Expand Down Expand Up @@ -107,6 +107,7 @@ PwmPin::PwmPin(Pin& pin, uint32_t frequency) : _frequency(frequency) {
}
}

// cppcheck-suppress unusedFunction
void IRAM_ATTR PwmPin::setDuty(uint32_t duty) {
uint8_t g = _channel >> 3, c = _channel & 7;
bool on = duty != 0;
Expand Down
1 change: 1 addition & 0 deletions FluidNC/esp32/StartupLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ size_t StartupLog::write(uint8_t data) {
_messages[_len++] = (char)data;
return 1;
}
// cppcheck-suppress unusedFunction
void StartupLog::dump(Channel& out) {
if (_paniced) {
log_error_to(out, "Showing startup log from previous panic");
Expand Down
7 changes: 7 additions & 0 deletions FluidNC/esp32/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
extern "C" {
#endif

// cppcheck-suppress unusedFunction
void esp_core_dump_init(void) {}

// cppcheck-suppress unusedFunction
void esp_core_dump_flash_init(void) {}

// cppcheck-suppress unusedFunction
void esp_core_dump_to_flash(void* info) {}

// cppcheck-suppress unusedFunction
esp_err_t esp_core_dump_image_check(void) {
return ESP_ERR_NOT_FOUND;
}
// cppcheck-suppress unusedFunction
esp_err_t esp_core_dump_image_get(size_t* out_addr, size_t* out_size) {
return ESP_ERR_NOT_FOUND;
}
// cppcheck-suppress unusedFunction
esp_err_t esp_core_dump_image_erase(void) {
return ESP_OK;
}
Expand Down
2 changes: 2 additions & 0 deletions FluidNC/esp32/delay_usecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
uint32_t ticks_per_us;
int esp_clk_cpu_freq(void);

// cppcheck-suppress unusedFunction
void timing_init() {
ticks_per_us = esp_clk_cpu_freq() / 1000000;
}

// cppcheck-suppress unusedFunction
void IRAM_ATTR delay_us(int32_t us) {
spinUntil(usToEndTicks(us));
}
Expand Down
3 changes: 3 additions & 0 deletions FluidNC/esp32/i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Driver/fluidnc_i2c.h"
#include "src/Logging.h"

// cppcheck-suppress unusedFunction
bool i2c_master_init(int bus_number, pinnum_t sda_pin, pinnum_t scl_pin, uint32_t frequency) {
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
Expand All @@ -31,6 +32,7 @@ bool i2c_master_init(int bus_number, pinnum_t sda_pin, pinnum_t scl_pin, uint32_
return false;
}

// cppcheck-suppress unusedFunction
int i2c_write(int bus_number, uint8_t address, const uint8_t* data, size_t count) {
#if 0
esp_err_t ret = ESP_FAIL;
Expand Down Expand Up @@ -72,6 +74,7 @@ int i2c_write(int bus_number, uint8_t address, const uint8_t* data, size_t count
#endif
}

// cppcheck-suppress unusedFunction
int i2c_read(int bus_number, uint8_t address, uint8_t* data, size_t count) {
return i2c_master_read_from_device((i2c_port_t)bus_number, address, data, count, 10 / portTICK_RATE_MS) ? -1 : count;
}
10 changes: 7 additions & 3 deletions FluidNC/esp32/sdspi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static esp_err_t mount_to_vfs_fat(int max_files, sdmmc_card_t* card, uint8_t pdr

// ESP_LOGD(TAG, "using pdrv=%i", pdrv);
// Drive names are "0:", "1:", etc.
char drv[3] = { (char)('0' + pdrv), ':', 0 };
const char drv[3] = { (char)('0' + pdrv), ':', 0 };

FRESULT res;

Expand Down Expand Up @@ -71,6 +71,7 @@ static void call_host_deinit(const sdmmc_host_t* host_config) {
}
}

// cppcheck-suppress unusedFunction
bool sd_init_slot(uint32_t freq_hz, int cs_pin, int cd_pin, int wp_pin) {
esp_err_t err;

Expand Down Expand Up @@ -136,6 +137,7 @@ bool init_spi_bus(int mosi_pin, int miso_pin, int clk_pin) {
#endif

// adapted from vfs_fat_sdmmc.c:esp_vfs_fat_sdmmc_mount()
// cppcheck-suppress unusedFunction
std::error_code sd_mount(int max_files) {
log_verbose("Mount_sd");
esp_err_t err;
Expand All @@ -154,7 +156,7 @@ std::error_code sd_mount(int max_files) {
// pdrv is now the index of the unused drive slot

// not using ff_memalloc here, as allocation in internal RAM is preferred
card = (sdmmc_card_t*)malloc(sizeof(sdmmc_card_t));
card = static_cast<sdmmc_card_t*>(malloc(sizeof(sdmmc_card_t)));
if (card == NULL) {
log_debug("could not allocate new sdmmc_card_t");
return esp_error::make_error_code(ESP_ERR_NO_MEM);
Expand All @@ -175,14 +177,15 @@ std::error_code sd_mount(int max_files) {
return esp_error::make_error_code(err);
}

// cppcheck-suppress unusedFunction
void sd_unmount() {
BYTE pdrv = ff_diskio_get_pdrv_card(card);
if (pdrv == 0xff) {
return;
}

// unmount
char drv[3] = { (char)('0' + pdrv), ':', 0 };
const char drv[3] = { (char)('0' + pdrv), ':', 0 };
f_mount(NULL, drv, 0);

esp_vfs_fat_unregister_path(base_path);
Expand All @@ -194,6 +197,7 @@ void sd_unmount() {
card = NULL;
}

// cppcheck-suppress unusedFunction
void sd_deinit_slot() {
sdspi_host_remove_device(host_config.slot);
call_host_deinit(&host_config);
Expand Down
2 changes: 2 additions & 0 deletions FluidNC/esp32/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# define HSPI_HOST SPI2_HOST
#endif

// cppcheck-suppress unusedFunction
bool spi_init_bus(pinnum_t sck_pin, pinnum_t miso_pin, pinnum_t mosi_pin, bool dma) {
// Start the SPI bus with the pins defined here. Once it has been started,
// those pins "stick" and subsequent attempts to restart it with defaults
Expand All @@ -30,6 +31,7 @@ bool spi_init_bus(pinnum_t sck_pin, pinnum_t miso_pin, pinnum_t mosi_pin, bool d
return !spi_bus_initialize(HSPI_HOST, &bus_cfg, dma ? SPI_DMA_CH_AUTO : SPI_DMA_DISABLED);
}

// cppcheck-suppress unusedFunction
void spi_deinit_bus() {
esp_err_t err = spi_bus_free(HSPI_HOST);
log_debug("deinit spi " << int(err));
Expand Down
3 changes: 3 additions & 0 deletions FluidNC/esp32/spiffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "wdt.h"
#include "src/Config.h"

// cppcheck-suppress unusedFunction
bool spiffs_format(const char* partition_label) {
disable_core0_WDT();
esp_err_t err = esp_spiffs_format(partition_label);
Expand All @@ -13,6 +14,7 @@ bool spiffs_format(const char* partition_label) {
}
return false;
}
// cppcheck-suppress unusedFunction
bool spiffs_mount(const char* label, bool format) {
esp_log_level_set("SPIFFS", ESP_LOG_NONE);
esp_vfs_spiffs_conf_t conf = { .base_path = "/spiffs", .partition_label = label, .max_files = 2, .format_if_mount_failed = format };
Expand All @@ -23,6 +25,7 @@ bool spiffs_mount(const char* label, bool format) {
}
return false;
}
// cppcheck-suppress unusedFunction
void spiffs_unmount() {
esp_vfs_spiffs_unregister("spiffs");
}
13 changes: 8 additions & 5 deletions FluidNC/esp32/tmc_spi_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static spi_ll_clock_val_t clk_reg_val = 0;
// Establish the SPI bus configuration needed for TMC device access
// This should be done one before every TMC read or write operation,
// to reconfigure the bus from whatever mode the SD card driver used.

// cppcheck-suppress unusedFunction
void tmc_spi_bus_setup() {
#if 0
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->miso_io_num], PIN_FUNC_GPIO);
Expand All @@ -44,7 +46,7 @@ void tmc_spi_bus_setup() {

// Perform a full-duplex transfer from out/out_bitlen to in/in_bitlen
// If in_bitlen is 0, the input data will be ignored
void tmc_spi_transfer_data(uint8_t* out, int out_bitlen, uint8_t* in, int in_bitlen) {
void tmc_spi_transfer_data(const uint8_t* out, int out_bitlen, uint8_t* in, int in_bitlen) {
spi_ll_set_mosi_bitlen(hw, out_bitlen);

spi_ll_set_miso_bitlen(hw, in_bitlen);
Expand All @@ -69,13 +71,14 @@ void tmc_spi_transfer_data(uint8_t* out, int out_bitlen, uint8_t* in, int in_bit
// accounting for the number of TMC devices (index) daisy-chained
// before the target device. For reads, this is the first register
// access that latches the register data into the output register.

// cppcheck-suppress unusedFunction
void tmc_spi_rw_reg(uint8_t cmd, uint32_t data, int index) {
int before = index > 0 ? index - 1 : 0;

const size_t packetLen = 5;
size_t dummy_out_bytes = before * packetLen;
size_t total_bytes = (before + 1) * packetLen;
size_t total_bits = total_bytes * 8;
const size_t packetLen = 5;
size_t total_bytes = (before + 1) * packetLen;
size_t total_bits = total_bytes * 8;

uint8_t out[total_bytes];

Expand Down
2 changes: 2 additions & 0 deletions FluidNC/esp32/wdt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static void get_wdt_task_handle() {
}
}

// cppcheck-suppress unusedFunction
void enable_core0_WDT() {
if (!wdt_task_handle) {
return;
Expand All @@ -35,6 +36,7 @@ void enable_core0_WDT() {
}
}

// cppcheck-suppress unusedFunction
void disable_core0_WDT() {
get_wdt_task_handle();
if (!wdt_task_handle) {
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/include/Driver/PwmPin.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class PwmPin {
public:
PwmPin(Pin& pin, uint32_t frequency);
PwmPin(const Pin& pin, uint32_t frequency);
~PwmPin();
uint32_t frequency() { return _frequency; }
uint32_t period() { return _period; }
Expand Down
15 changes: 10 additions & 5 deletions FluidNC/src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,16 @@ void Channel::autoReport() {
if (_reportInterval) {
auto thisProbeState = config->_probe->get_state();
report_recompute_pin_string();
if (_reportWco || !state_is(_lastState) || thisProbeState != _lastProbe || _lastPinString != report_pin_string ||
if (_reportOvr || _reportWco || !state_is(_lastState) || thisProbeState != _lastProbe || _lastPinString != report_pin_string ||
(motionState() && (int32_t(xTaskGetTickCount()) - _nextReportTime) >= 0)) {
if (_reportOvr) {
report_ovr_counter = 0;
_reportOvr = false;
}
if (_reportWco) {
report_wco_counter = 0;
_reportWco = false;
}
_reportWco = false;
_lastState = sys.state;
_lastProbe = thisProbeState;
_lastPinString = report_pin_string;
Expand Down Expand Up @@ -181,7 +185,7 @@ void Channel::push(uint8_t byte) {
}
}

Channel* Channel::pollLine(char* line) {
Error Channel::pollLine(char* line) {
handle();
while (1) {
int ch = -1;
Expand All @@ -193,6 +197,7 @@ Channel* Channel::pollLine(char* line) {
if (ch < 0) {
break;
}
_active = true;
if (realtimeOkay(ch) && is_realtime_command(ch)) {
handleRealtimeCharacter((uint8_t)ch);
continue;
Expand All @@ -205,13 +210,13 @@ Channel* Channel::pollLine(char* line) {
}

if (lineComplete(line, ch)) {
return this;
return Error::Ok;
}
}
if (_active) {
autoReport();
}
return nullptr;
return Error::NoData;
}

void Channel::setAttr(int index, bool* value, const std::string& attrString, const char* tag) {
Expand Down
Loading

0 comments on commit c0d4995

Please sign in to comment.