Skip to content

Commit 3ef6763

Browse files
committed
Build 20240921
Added generic HAL timer API and function for getting which G65 parameter words were supplied.
1 parent fabec73 commit 3ef6763

File tree

9 files changed

+195
-20
lines changed

9 files changed

+195
-20
lines changed

changelog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
## grblHAL changelog
22

3+
<a name="20240921">Build 20240921
4+
5+
Core:
6+
7+
* Added generic HAL timer API and function for getting which `G65` parameter words were supplied.
8+
9+
Networking:
10+
11+
* Made parsing of HTTP header keywords case insensitive. Ref. [issue #11](https://github.com/grblHAL/Plugin_networking/issues/11).
12+
13+
SD card (macros):
14+
15+
* Added inbuilt `G65` macro `P3` for getting and setting NGC numerical parameters, typical use case will be for indexed access. Ref. [discussion #309 comment](https://github.com/grblHAL/core/discussions/309#discussioncomment-10710468).
16+
17+
---
18+
319
<a name="20240907">Build 20240907
420

521
Core:

crossbar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ typedef enum {
187187
Output_MOSI,
188188
Output_SPICLK,
189189
Output_SPICS,
190+
Output_FlashCS,
190191
Output_SdCardCS,
191192
Input_SdCardDetect,
192193
Output_SPIRST,
@@ -385,6 +386,7 @@ PROGMEM static const pin_name_t pin_names[] = {
385386
{ .function = Output_MOSI, .name = "MOSI" },
386387
{ .function = Output_SPICLK, .name = "SPI CLK" },
387388
{ .function = Output_SPICS, .name = "SPI CS" },
389+
{ .function = Output_FlashCS, .name = "Flash CS" },
388390
{ .function = Output_SdCardCS, .name = "SD card CS" },
389391
{ .function = Input_SdCardDetect, .name = "SD card detect" },
390392
{ .function = Output_SPIRST, .name = "SPI reset" },

gcode.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,17 @@ static status_code_t read_parameter (char *line, uint_fast8_t *char_counter, flo
509509
return status;
510510
}
511511

512-
513512
#endif // NGC_EXPRESSIONS_ENABLE
514513

515514
#if NGC_PARAMETERS_ENABLE
516515

516+
static parameter_words_t g65_words = {0};
517+
518+
parameter_words_t gc_get_g65_arguments (void)
519+
{
520+
return g65_words;
521+
}
522+
517523
bool gc_modal_state_restore (gc_modal_t *copy)
518524
{
519525
bool ok = false;
@@ -950,6 +956,7 @@ status_code_t gc_execute_block (char *block)
950956
if(!is_user_mcode && isnanf(value))
951957
FAIL(Status_BadNumberFormat); // [Expected word value]
952958

959+
g65_words.value = 0;
953960
#else
954961

955962
if((letter < 'A' && letter != '$') || letter > 'Z')
@@ -2435,11 +2442,14 @@ status_code_t gc_execute_block (char *block)
24352442

24362443
while(gc_block.words.value) {
24372444
if(gc_block.words.value & 0x1 && gc_value_ptr[idx].value) switch(gc_value_ptr[idx].type) {
2445+
24382446
case ValueType_Float:
2447+
g65_words.value |= (1 << idx);
24392448
ngc_param_set((ngc_param_id_t)idx, *(float *)gc_value_ptr[idx].value);
24402449
break;
24412450

24422451
case ValueType_UInt32:
2452+
g65_words.value |= (1 << idx);
24432453
ngc_param_set((ngc_param_id_t)idx, (float)*(uint32_t *)gc_value_ptr[idx].value);
24442454
break;
24452455

gcode.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ typedef enum {
238238
UserMCode_Generic3 = 103, //!< 103 - For private use only
239239
UserMCode_Generic4 = 104, //!< 104 - For private use only
240240
OpenPNP_GetADCReading = 105, //!< 105 - M105
241-
Fan_On = 106, //!< 106 - M106
242-
Fan_Off = 107, //!< 107 - M107
241+
Fan_On = 106, //!< 106 - M106, Marlin format
242+
Fan_Off = 107, //!< 107 - M107, Marlin format
243243
OpenPNP_GetCurrentPosition = 114, //!< 114 - M114
244244
OpenPNP_FirmwareInfo = 115, //!< 115 - M115
245245
Trinamic_DebugReport = 122, //!< 122 - M122, Marlin format
@@ -685,6 +685,7 @@ void gc_set_tool_offset (tool_offset_mode_t mode, uint_fast8_t idx, int32_t offs
685685
plane_t *gc_get_plane_data (plane_t *plane, plane_select_t select);
686686

687687
#if NGC_PARAMETERS_ENABLE
688+
parameter_words_t gc_get_g65_arguments (void);
688689
bool gc_modal_state_restore (gc_modal_t *copy);
689690
#endif
690691

grbl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#else
4343
#define GRBL_VERSION "1.1f"
4444
#endif
45-
#define GRBL_BUILD 20240907
45+
#define GRBL_BUILD 20240921
4646

4747
#define GRBL_URL "https://github.com/grblHAL"
4848

hal.h

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ typedef void (*stepper_output_step_ptr)(axes_signals_t step_outbits, axes_signal
302302
*/
303303
typedef axes_signals_t (*stepper_get_ganged_ptr)(bool auto_squared);
304304

305+
/*! \brief Pointer to function for claiming/releasing motor(s) from/to normal step/dir signalling.
306+
307+
\param axis_id a \a the axis to claim/release motor(s) for.
308+
\param claim \a true to claim a motor(s), \a false to release.
309+
*/
310+
typedef void (*stepper_claim_motor_ptr)(uint_fast8_t axis_id, bool claim);
311+
305312
/*! \brief Pointer to callback function for outputting the next direction and step pulse signals. _Set by the core on startup._
306313
307314
To be called by the driver from the main stepper interrupt handler (when the timer times out).
@@ -318,6 +325,7 @@ typedef struct {
318325
stepper_pulse_start_ptr pulse_start; //!< Handler for starting outputting direction signals and a step pulse. Called from interrupt context.
319326
stepper_interrupt_callback_ptr interrupt_callback; //!< Callback for informing about the next step pulse to output. _Set by the core at startup._
320327
stepper_get_ganged_ptr get_ganged; //!< Optional handler getting which axes are configured for ganging or auto squaring.
328+
stepper_claim_motor_ptr claim_motor; //!< Optional handler for claiming/releasing motor(s) from normal step/dir control.
321329
stepper_output_step_ptr output_step; //!< Optional handler for outputting a single step pulse. _Experimental._ Called from interrupt context.
322330
motor_iterator_ptr motor_iterator; //!< Optional handler iteration over motor vs. axis mappings. Required for the motors plugin (Trinamic drivers).
323331
} stepper_ptrs_t;
@@ -484,20 +492,87 @@ typedef struct {
484492
*/
485493
typedef bool (*irq_claim_ptr)(irq_type_t irq, uint_fast8_t id, irq_callback_ptr callback);
486494

495+
/************
496+
* Timers *
497+
************/
498+
499+
typedef void *hal_timer_t; //!< Timer handle, actual type defined by driver implementation.
500+
501+
typedef enum {
502+
Timer_16bit = 0,
503+
Timer_32bit,
504+
Timer_64bit
505+
} timer_resolution_t;
506+
507+
typedef union {
508+
uint8_t value; //!< All bitmap flags.
509+
struct {
510+
uint8_t periodic :1, //!<
511+
up :1, //!< Timer supports upcounting
512+
comp1 :1, //!< Timer supports compare interrupt 0
513+
comp2 :1; //!< Timer supports compare interrupt 1
514+
};
515+
} timer_cap_t;
516+
517+
typedef void (*timer_irq_handler_ptr)(void *context);
518+
519+
typedef struct {
520+
void *context; //!< Pointer to data to be passed on to the interrupt handlers
521+
bool single_shot; //!< Set to true if timer is single shot
522+
timer_irq_handler_ptr timeout_callback; //!< Pointer to main timeout callback
523+
uint32_t irq0; //!< Compare value for compare interrupt 0
524+
timer_irq_handler_ptr irq0_callback; //!< Pointer to compare interrupt 0 callback
525+
uint32_t irq1; //!< Compare value for compare interrupt 10
526+
timer_irq_handler_ptr irq1_callback; //!< Pointer to compare interrupt 1 callback
527+
} timer_cfg_t;
528+
529+
/*! \brief Pointer to function for claiming a timer.
530+
\param cap pointer to a \a timer_cap_t struct containing the required capabilities.
531+
\param timebase timebase in ns.
532+
\returns a \a hal_timer_t pointer if successful, \a NULL if not.
533+
*/
534+
typedef hal_timer_t (*timer_claim_ptr)(timer_cap_t cap, uint32_t timebase);
535+
536+
/*! \brief Pointer to function for configuring a timer.
537+
\param timer a \a hal_timer_t pointer.
538+
\param cfg pointer to a \a timer_cfg_t struct.
539+
\returns \a true if successful.
540+
*/
541+
typedef bool (*timer_cfg_ptr)(hal_timer_t timer, timer_cfg_t *cfg);
542+
543+
/*! \brief Pointer to function for starting a timer.
544+
\param timer a \a hal_timer_t pointer.
545+
\param period delay in.
546+
\returns \a true if successful.
547+
*/
548+
typedef bool (*timer_start_ptr)(hal_timer_t timer, uint32_t period);
549+
550+
/*! \brief Pointer to function for stopping a running timer.
551+
\param timer a \a hal_timer_t pointer.
552+
\returns \a true if successful.
553+
*/
554+
typedef bool (*timer_stop_ptr)(hal_timer_t timer);
555+
556+
typedef struct {
557+
timer_claim_ptr claim;
558+
timer_cfg_ptr configure;
559+
timer_start_ptr start;
560+
timer_stop_ptr stop;
561+
} timer_ptrs_t;
487562

488563
/**************************
489564
* RTC (Real Time Clock *
490565
**************************/
491566

492567
/*! \brief Pointer to function for setting the current datetime.
493568
\param datetime pointer to a \a tm struct.
494-
\returns true if successful.
569+
\\returns \a true if successful.
495570
*/
496571
typedef bool (*rtc_get_datetime_ptr)(struct tm *datetime);
497572

498573
/*! \brief Pointer to function for setting the current datetime.
499574
\param datetime pointer to a \a tm struct.
500-
\returns true if successful.
575+
\returns \a true if successful.
501576
*/
502577
typedef bool (*rtc_set_datetime_ptr)(struct tm *datetime);
503578

@@ -541,7 +616,7 @@ typedef struct {
541616
/*! \brief Driver setup handler.
542617
Called once by the core after settings has been loaded. The driver should enable MCU peripherals in the provided function.
543618
\param settings pointer to settings_t structure.
544-
\returns true if completed successfully and the driver supports the _settings->version_ number, false otherwise.
619+
\returns \a true if completed successfully and the driver supports the _settings->version_ number, false otherwise.
545620
*/
546621
driver_setup_ptr driver_setup;
547622

@@ -595,6 +670,7 @@ typedef struct {
595670
settings_changed_ptr settings_changed; //!< Callback handler to be called on settings loaded or settings changed events.
596671
probe_ptrs_t probe; //!< Optional handlers for probe input(s).
597672
tool_ptrs_t tool; //!< Optional handlers for tool changes.
673+
timer_ptrs_t timer; //!< Optional handlers for claiming and controlling timers.
598674
rtc_ptrs_t rtc; //!< Optional handlers for real time clock (RTC).
599675
io_port_t port; //!< Optional handlers for axuillary I/O (adds support for M62-M66).
600676
rgb_ptr_t rgb0; //!< Optional handler for RGB output to LEDs (neopixels) or lamps.
@@ -649,7 +725,7 @@ Then _hal.driver_setup()_ will be called so that the driver can configure the re
649725
650726
__NOTE__: This is the only driver function that is called directly from the core, all others are called via HAL function pointers.
651727
652-
\returns true if completed successfully and the driver matches the _hal.version number_, false otherwise.
728+
\returns \a true if completed successfully and the driver matches the _hal.version number_, \a false otherwise.
653729
*/
654730
extern bool driver_init (void);
655731

nuts_bolts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ extern char const *const axis_letter[];
129129

130130
typedef union {
131131
uint8_t mask;
132+
uint8_t bits;
132133
uint8_t value;
133134
struct {
134135
uint8_t x :1,

0 commit comments

Comments
 (0)