@@ -302,6 +302,13 @@ typedef void (*stepper_output_step_ptr)(axes_signals_t step_outbits, axes_signal
302
302
*/
303
303
typedef axes_signals_t (* stepper_get_ganged_ptr )(bool auto_squared );
304
304
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
+
305
312
/*! \brief Pointer to callback function for outputting the next direction and step pulse signals. _Set by the core on startup._
306
313
307
314
To be called by the driver from the main stepper interrupt handler (when the timer times out).
@@ -318,6 +325,7 @@ typedef struct {
318
325
stepper_pulse_start_ptr pulse_start ; //!< Handler for starting outputting direction signals and a step pulse. Called from interrupt context.
319
326
stepper_interrupt_callback_ptr interrupt_callback ; //!< Callback for informing about the next step pulse to output. _Set by the core at startup._
320
327
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.
321
329
stepper_output_step_ptr output_step ; //!< Optional handler for outputting a single step pulse. _Experimental._ Called from interrupt context.
322
330
motor_iterator_ptr motor_iterator ; //!< Optional handler iteration over motor vs. axis mappings. Required for the motors plugin (Trinamic drivers).
323
331
} stepper_ptrs_t ;
@@ -484,20 +492,87 @@ typedef struct {
484
492
*/
485
493
typedef bool (* irq_claim_ptr )(irq_type_t irq , uint_fast8_t id , irq_callback_ptr callback );
486
494
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 ;
487
562
488
563
/**************************
489
564
* RTC (Real Time Clock *
490
565
**************************/
491
566
492
567
/*! \brief Pointer to function for setting the current datetime.
493
568
\param datetime pointer to a \a tm struct.
494
- \returns true if successful.
569
+ \\ returns \a true if successful.
495
570
*/
496
571
typedef bool (* rtc_get_datetime_ptr )(struct tm * datetime );
497
572
498
573
/*! \brief Pointer to function for setting the current datetime.
499
574
\param datetime pointer to a \a tm struct.
500
- \returns true if successful.
575
+ \returns \a true if successful.
501
576
*/
502
577
typedef bool (* rtc_set_datetime_ptr )(struct tm * datetime );
503
578
@@ -541,7 +616,7 @@ typedef struct {
541
616
/*! \brief Driver setup handler.
542
617
Called once by the core after settings has been loaded. The driver should enable MCU peripherals in the provided function.
543
618
\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.
545
620
*/
546
621
driver_setup_ptr driver_setup ;
547
622
@@ -595,6 +670,7 @@ typedef struct {
595
670
settings_changed_ptr settings_changed ; //!< Callback handler to be called on settings loaded or settings changed events.
596
671
probe_ptrs_t probe ; //!< Optional handlers for probe input(s).
597
672
tool_ptrs_t tool ; //!< Optional handlers for tool changes.
673
+ timer_ptrs_t timer ; //!< Optional handlers for claiming and controlling timers.
598
674
rtc_ptrs_t rtc ; //!< Optional handlers for real time clock (RTC).
599
675
io_port_t port ; //!< Optional handlers for axuillary I/O (adds support for M62-M66).
600
676
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
649
725
650
726
__NOTE__: This is the only driver function that is called directly from the core, all others are called via HAL function pointers.
651
727
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.
653
729
*/
654
730
extern bool driver_init (void );
655
731
0 commit comments