Skip to content

Commit

Permalink
Add lost changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-van-Tol committed Feb 4, 2025
1 parent d4a22dc commit 508c1b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All versions in this changelog have two entries: ``driver`` and ``firmware``. Th
have the same version, as communication protocol might change between versions. In the firmware/driver there
is a safeguard to prevent miscommunication.

Version 1.3.3
=============

An error in ``stepgen`` related to index pulses has been resolved in this version. No need to re-compile the
firmware, only reinstallation of the drivers is required.

Version 1.3.2
=============

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "litexcnc"
version = "1.3.2"
version = "1.3.3"
description = "Generic CNC firmware and driver for FPGA cards which are supported by LiteX"
authors = [
{ name = "Peter van Tol", email = "[email protected]" },
Expand Down
17 changes: 11 additions & 6 deletions src/litexcnc/driver/modules/litexcnc_stepgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ int litexcnc_stepgen_prepare_write(void *module, uint8_t **data, int period) {
static float sign;
static float dv;
static float dp;
static uint32_t index_flag;

// Check whether there are stepgen instances. If no instances, no need to write any
// data (NOTE: when this guard is not in place, the apply_time would be written out
Expand Down Expand Up @@ -334,7 +335,11 @@ int litexcnc_stepgen_prepare_write(void *module, uint8_t **data, int period) {
instance->data.fpga_time = instance->data.flt_time * (*(stepgen->data.clock_frequency));

// Convert the integers used and scale it to the FPGA
instance_data.speed_target = htobe32(instance->data.fpga_speed & 0x7FFFFFFF + *(instance->hal.pin.index_enable) * 1 << 31);
index_flag = 0;
if (instance->memo.has_index && *(instance->hal.pin.index_enable)) {
index_flag = 0xF0000000;
}
instance_data.speed_target = htobe32(instance->data.fpga_speed & 0x7FFFFFFF + index_flag);
instance_data.acceleration = htobe32(instance->data.fpga_acc);

// Put the data on the data-stream and advance the pointer
Expand Down Expand Up @@ -415,7 +420,9 @@ int litexcnc_stepgen_process_read(void *module, uint8_t **data, int period) {
*data += 8; // The data read is 64 bit-wide. The buffer is 8-bit wide
memcpy(&speed, *data, sizeof speed);
instance->data.speed = (int64_t) (be32toh(speed) & 0x7FFFFFFF) - 0x40000000;
*(instance->hal.pin.index_pulse) = (be32toh(speed) & 0xF0000000) ? true : false;
if (instance->memo.has_index) {
*(instance->hal.pin.index_pulse) = (be32toh(speed) & 0xF0000000) ? true : false;
}
*data += 4; // The data read is 32 bit-wide. The buffer is 8-bit wide
// Convert the received position to HAL pins for counts and floating-point position
*(instance->hal.pin.counts) = instance->data.position >> instance->data.pick_off_pos;
Expand Down Expand Up @@ -567,6 +574,7 @@ size_t litexcnc_stepgen_init(litexcnc_module_instance_t **module, litexcnc_t *li

// Create the pin for index-enable, only when the pin is defined for this instance
if (*(*config) & 0x80) {
instance->memo.has_index = true;
LITEXCNC_CREATE_HAL_PIN("index-enable", bit, HAL_IN, &(instance->hal.pin.index_enable));
LITEXCNC_CREATE_HAL_PIN("index-pulse", bit, HAL_OUT, &(instance->hal.pin.index_pulse));
}
Expand All @@ -579,7 +587,4 @@ size_t litexcnc_stepgen_init(litexcnc_module_instance_t **module, litexcnc_t *li
LITEXCNC_ERR_NO_DEVICE("%d\n", (4 - ((1 + stepgen->num_instances) & 0x03) & 0x03));

return 0;
}



}
1 change: 1 addition & 0 deletions src/litexcnc/driver/modules/litexcnc_stepgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ typedef struct {
hal_float_t acceleration;
hal_float_t maxaccel;
hal_float_t maxvel;
hal_bit_t has_index;
bool error_max_speed_printed;
} memo;

Expand Down

0 comments on commit 508c1b8

Please sign in to comment.