#include <math.h>#include <string.h>#include "hal.h"#include "protocol.h"#include "state_machine.h"#include "settings.h"Data Structures | |
| struct | spindle_reg_t |
| Structure for holding spindle registration data. More... | |
| struct | spindle_sys_t |
| Structure for holding data about an enabled spindle. More... | |
| struct | rpm_override_t |
Functions | |
| FLASHMEM spindle_id_t | spindle_register (const spindle_ptrs_t *spindle, const char *name) |
| Register a spindle with the core. More... | |
| FLASHMEM spindle_num_t | spindle_enable (spindle_id_t spindle_id) |
| Enable a spindle and make it available for use by gcode. More... | |
| FLASHMEM bool | spindle_select (spindle_id_t spindle_id) |
| Enables a spindle and sets it as default spindle (spindle number 0). More... | |
| FLASHMEM spindle_ptrs_t * | spindle_get_hal (spindle_id_t spindle_id, spindle_hal_t hal) |
| Get the handlers (function pointers) etc. associated with the spindle. More... | |
| FLASHMEM spindle_id_t | spindle_get_default (void) |
| Get the spindle id of the default spindle (spindle number 0). More... | |
| FLASHMEM spindle_cap_t | spindle_get_caps (bool active) |
| Get the merged spindle capabilities of all registered spindles. More... | |
| FLASHMEM const char * | spindle_get_name (spindle_id_t spindle_id) |
| Get the registered name of a spindle. More... | |
| FLASHMEM void | spindle_update_caps (spindle_ptrs_t *spindle, spindle_pwm_t *pwm_caps) |
| Update the capabilities of a registered PWM spindle. May be used by the driver on spindle initialization or when spindle settings has been changed. More... | |
| FLASHMEM uint8_t | spindle_get_count (void) |
| Get number of registered spindles. More... | |
| FLASHMEM bool | spindle_get_id (uint8_t ref_id, spindle_id_t *spindle_id) |
| FLASHMEM void | spindle_bind_encoder (const spindle_data_ptrs_t *encoder_data) |
| FLASHMEM bool | spindle_set_at_speed_range (spindle_ptrs_t *spindle, spindle_data_t *spindle_data, float rpm) |
| FLASHMEM bool | spindle_enumerate_spindles (spindle_enumerate_callback_ptr callback, void *data) |
| Enumerate registered spindles by calling a callback function for each of them. More... | |
| FLASHMEM bool | spindle_is_enabled (spindle_num_t spindle_num) |
| Check if a spindle is enabled and available or not. More... | |
| FLASHMEM spindle_ptrs_t * | spindle_get (spindle_num_t spindle_num) |
| Get the handlers (function pointers) etc. associated with an enabled spindle. More... | |
| FLASHMEM spindle_id_t | spindle_add_null (void) |
| Register a null spindle that has no connection to the outside world. This is done automatically on startup if no spindle can be succesfully enabled. More... | |
| FLASHMEM float | spindle_set_override (spindle_ptrs_t *spindle, override_t speed_override) |
| Set spindle speed override. More... | |
| FLASHMEM bool | spindle_override_disable (spindle_ptrs_t *spindle, bool disable) |
| FLASHMEM bool | spindle_check_state (spindle_ptrs_t *spindle, spindle_state_t state) |
| Checks actual spindle state against given state. More... | |
| FLASHMEM bool | spindle_set_state (spindle_ptrs_t *spindle, spindle_state_t state, float rpm) |
| FLASHMEM bool | spindle_set_state_synced (spindle_ptrs_t *spindle, spindle_state_t state, float rpm, spindle_rpm_mode_t mode) |
| G-code parser entry-point for setting spindle state. Forces a planner buffer sync and bails if an abort or check-mode is active. If the spindle supports at speed functionality it will wait for it to reach the speed and raise an alarm if the speed is not reached within the timeout period. More... | |
| FLASHMEM bool | spindle_restore (spindle_ptrs_t *spindle, spindle_state_t state, float rpm, uint16_t delay_ms) |
| Restore spindle running state with direction, enable, spindle RPM and appropriate delay. More... | |
| float | spindle_set_rpm (spindle_ptrs_t *spindle, float rpm, override_t override_pct) |
| Calculate and set programmed RPM according to override and max/min limits. More... | |
| FLASHMEM void | spindle_all_off (bool reset) |
| Turn off all enabled spindles. More... | |
| FLASHMEM bool | spindle_is_on (void) |
| Check if any of the enabled spindles is running. More... | |
| FLASHMEM bool | spindle_precompute_pwm_values (spindle_ptrs_t *spindle, spindle_pwm_t *pwm_data, spindle_pwm_settings_t *settings, uint32_t clock_hz) |
| Precompute PWM values for faster conversion. More... | |
| FLASHMEM spindle_id_t spindle_add_null | ( | void | ) |
Register a null spindle that has no connection to the outside world. This is done automatically on startup if no spindle can be succesfully enabled.
| FLASHMEM void spindle_all_off | ( | bool | reset | ) |
Turn off all enabled spindles.
| FLASHMEM void spindle_bind_encoder | ( | const spindle_data_ptrs_t * | encoder_data | ) |
| FLASHMEM bool spindle_check_state | ( | spindle_ptrs_t * | spindle, |
| spindle_state_t | state | ||
| ) |
Checks actual spindle state against given state.
| spindle | pointer to a spindle_ptrs_t structure. |
| state | a spindle_state_t structure. |
| FLASHMEM spindle_num_t spindle_enable | ( | spindle_id_t | spindle_id | ) |
Enable a spindle and make it available for use by gcode.
| spindle_id | spindle id as a spindle_id_t. |
NOTE: up to N_SYS_SPINDLE spindles can be enabled at a time.
| FLASHMEM bool spindle_enumerate_spindles | ( | spindle_enumerate_callback_ptr | callback, |
| void * | data | ||
| ) |
Enumerate registered spindles by calling a callback function for each of them.
| callback | pointer to a spindle_enumerate_callback_ptr type function. |
| data | pointer to optional data to pass to the callback function. |
| FLASHMEM spindle_ptrs_t* spindle_get | ( | spindle_num_t | spindle_num | ) |
Get the handlers (function pointers) etc. associated with an enabled spindle.
| spindle_num | spindle number as a spindle_num_t. |
NOTE: do not modify the returned structure!
| FLASHMEM spindle_cap_t spindle_get_caps | ( | bool | active | ) |
Get the merged spindle capabilities of all registered spindles.
| active | true to return active capabilities, false to return default capabilities. |
| FLASHMEM uint8_t spindle_get_count | ( | void | ) |
Get number of registered spindles.
| FLASHMEM spindle_id_t spindle_get_default | ( | void | ) |
Get the spindle id of the default spindle (spindle number 0).
| FLASHMEM spindle_ptrs_t* spindle_get_hal | ( | spindle_id_t | spindle_id, |
| spindle_hal_t | hal | ||
| ) |
Get the handlers (function pointers) etc. associated with the spindle.
| spindle_id | spindle id as a spindle_id_t. |
| hal | a spindle_hal_t enum value: SpindleHAL_Raw - get the read only version as supplied at registration SpindleHAL_Configured - get the version with run-time modifications applied by the spindle driver. SpindleHAL_Active - get the enabled version available from gcode. Can be overriden by event handlers prior to activation. |
NOTE: do not modify the returned structure!
| FLASHMEM bool spindle_get_id | ( | uint8_t | ref_id, |
| spindle_id_t * | spindle_id | ||
| ) |
| FLASHMEM const char* spindle_get_name | ( | spindle_id_t | spindle_id | ) |
Get the registered name of a spindle.
| spindle_id | spindle id as a spindle_id_t. |
| FLASHMEM bool spindle_is_enabled | ( | spindle_num_t | spindle_num | ) |
Check if a spindle is enabled and available or not.
| spindle_num | spindle number as a spindle_num_t. |
| FLASHMEM bool spindle_is_on | ( | void | ) |
Check if any of the enabled spindles is running.
| FLASHMEM bool spindle_override_disable | ( | spindle_ptrs_t * | spindle, |
| bool | disable | ||
| ) |
| FLASHMEM bool spindle_precompute_pwm_values | ( | spindle_ptrs_t * | spindle, |
| spindle_pwm_t * | pwm_data, | ||
| spindle_pwm_settings_t * | settings, | ||
| uint32_t | clock_hz | ||
| ) |
Precompute PWM values for faster conversion.
| spindle | pointer to a spindle_ptrs_t structure. |
| pwm_data | pointer to a spindle_pwm_t structure, to hold the precomputed values. |
| clock_hz | timer clock frequency used for PWM generation. |
| FLASHMEM spindle_id_t spindle_register | ( | const spindle_ptrs_t * | spindle, |
| const char * | name | ||
| ) |
Register a spindle with the core.
| spindle | pointer to a spindle_ptrs_t structure. |
| name | pointer to a null terminated string. |
NOTE: The first spindle registered will become the default active spindle. NOTE: up to N_SPINDLE spindles can be registered at a time.
| FLASHMEM bool spindle_restore | ( | spindle_ptrs_t * | spindle, |
| spindle_state_t | state, | ||
| float | rpm, | ||
| uint16_t | delay_ms | ||
| ) |
Restore spindle running state with direction, enable, spindle RPM and appropriate delay.
| spindle | pointer to a spindle_ptrs_t structure. |
| state | a spindle_state_t structure. |
| rpm | the spindle RPM to set. |
| FLASHMEM bool spindle_select | ( | spindle_id_t | spindle_id | ) |
Enables a spindle and sets it as default spindle (spindle number 0).
| spindle_id | spindle id as a spindle_id_t. |
| FLASHMEM bool spindle_set_at_speed_range | ( | spindle_ptrs_t * | spindle, |
| spindle_data_t * | spindle_data, | ||
| float | rpm | ||
| ) |
| FLASHMEM float spindle_set_override | ( | spindle_ptrs_t * | spindle, |
| override_t | speed_override | ||
| ) |
Set spindle speed override.
| spindle | pointer to a spindle_ptrs_t structure. |
| speed_override | override as a percentage of the programmed RPM. |
| float spindle_set_rpm | ( | spindle_ptrs_t * | spindle, |
| float | rpm, | ||
| override_t | override_pct | ||
| ) |
Calculate and set programmed RPM according to override and max/min limits.
| spindle | pointer to a spindle_ptrs_t structure. |
| rpm | the programmed RPM. |
| override_pct | override value in percent. |
| FLASHMEM bool spindle_set_state | ( | spindle_ptrs_t * | spindle, |
| spindle_state_t | state, | ||
| float | rpm | ||
| ) |
| FLASHMEM bool spindle_set_state_synced | ( | spindle_ptrs_t * | spindle, |
| spindle_state_t | state, | ||
| float | rpm, | ||
| spindle_rpm_mode_t | mode | ||
| ) |
G-code parser entry-point for setting spindle state. Forces a planner buffer sync and bails if an abort or check-mode is active. If the spindle supports at speed functionality it will wait for it to reach the speed and raise an alarm if the speed is not reached within the timeout period.
| spindle | pointer to a spindle_ptrs_t structure. |
| state | a spindle_state_t structure. |
| rpm | the spindle RPM to set. |
| FLASHMEM void spindle_update_caps | ( | spindle_ptrs_t * | spindle, |
| spindle_pwm_t * | pwm_caps | ||
| ) |
Update the capabilities of a registered PWM spindle. May be used by the driver on spindle initialization or when spindle settings has been changed.
| spindle | pointer to a spindle_ptrs_t structure. |
| pwm_caps | pointer to a spindle_pwm_t structure. |