Revision eedb8e58

View differences:

kernel/patches/QEI-driver.patch
1
commit a23878ddb85bb8fd069f02042f15ad4be2a0d709
2
Author: Marc Rothmann <mrothmann@techfak.uni-bielefeld.de>
3
Date:   Mon Sep 17 11:40:39 2018 +0200
4

  
5
    Added QEI driver to HAL.
6

  
7 1
diff --git a/os/hal/hal.mk b/os/hal/hal.mk
8 2
index f177a3f..64d96d9 100644
9 3
--- a/os/hal/hal.mk
10 4
+++ b/os/hal/hal.mk
11 5
@@ -41,6 +41,9 @@ endif
12
 ifneq ($(findstring HAL_USE_ICU TRUE,$(HALCONF)),)

13
 HALSRC += $(CHIBIOS)/os/hal/src/hal_icu.c

14
 endif

15
+ifneq ($(findstring HAL_USE_QEI TRUE,$(HALCONF)),)

16
+HALSRC += $(CHIBIOS)/os/hal/src/hal_qei.c

17
+endif

18
 ifneq ($(findstring HAL_USE_MAC TRUE,$(HALCONF)),)

19
 HALSRC += $(CHIBIOS)/os/hal/src/hal_mac.c

20
 endif

6
 ifneq ($(findstring HAL_USE_ICU TRUE,$(HALCONF)),)
7
 HALSRC += $(CHIBIOS)/os/hal/src/hal_icu.c
8
 endif
9
+ifneq ($(findstring HAL_USE_QEI TRUE,$(HALCONF)),)
10
+HALSRC += $(CHIBIOS)/os/hal/src/hal_qei.c
11
+endif
12
 ifneq ($(findstring HAL_USE_MAC TRUE,$(HALCONF)),)
13
 HALSRC += $(CHIBIOS)/os/hal/src/hal_mac.c
14
 endif
21 15
@@ -94,6 +97,7 @@ HALSRC = $(CHIBIOS)/os/hal/src/hal.c \
22
          $(CHIBIOS)/os/hal/src/hal_i2c.c \
23
          $(CHIBIOS)/os/hal/src/hal_i2s.c \
24
          $(CHIBIOS)/os/hal/src/hal_icu.c \
25
+         $(CHIBIOS)/os/hal/src/hal_qei.c \
26
          $(CHIBIOS)/os/hal/src/hal_mac.c \
27
          $(CHIBIOS)/os/hal/src/hal_mmc_spi.c \
28
          $(CHIBIOS)/os/hal/src/hal_pal.c \
16
          $(CHIBIOS)/os/hal/src/hal_i2c.c \
17
          $(CHIBIOS)/os/hal/src/hal_i2s.c \
18
          $(CHIBIOS)/os/hal/src/hal_icu.c \
19
+         $(CHIBIOS)/os/hal/src/hal_qei.c \
20
          $(CHIBIOS)/os/hal/src/hal_mac.c \
21
          $(CHIBIOS)/os/hal/src/hal_mmc_spi.c \
22
          $(CHIBIOS)/os/hal/src/hal_pal.c \
23
diff --git a/os/hal/include/hal.h b/os/hal/include/hal.h
24
index 79f7c42..8cf221f 100644
25
--- a/os/hal/include/hal.h
26
+++ b/os/hal/include/hal.h
27
@@ -78,6 +78,10 @@
28
 #define HAL_USE_PWM                         FALSE
29
 #endif
30
 
31
+#if !defined(HAL_USE_QEI)
32
+#define HAL_USE_QEI                         FALSE
33
+#endif
34
+
35
 #if !defined(HAL_USE_QSPI)
36
 #define HAL_USE_QSPI                        FALSE
37
 #endif
38
@@ -138,6 +142,7 @@
39
 #include "hal_icu.h"
40
 #include "hal_mac.h"
41
 #include "hal_pwm.h"
42
+#include "hal_qei.h"
43
 #include "hal_qspi.h"
44
 #include "hal_rtc.h"
45
 #include "hal_serial.h"
29 46
diff --git a/os/hal/include/hal_qei.h b/os/hal/include/hal_qei.h
30 47
new file mode 100644
31
index 0000000..aef5e62
48
index 0000000..8769729
32 49
--- /dev/null
33 50
+++ b/os/hal/include/hal_qei.h
34 51
@@ -0,0 +1,148 @@
......
58 75
+ * @{
59 76
+ */
60 77
+
61
+#ifndef _HAL_QEI_H_
62
+#define _HAL_QEI_H_
78
+#ifndef HAL_QEI_H
79
+#define HAL_QEI_H
63 80
+
64
+#if HAL_USE_QEI || defined(__DOXYGEN__)
81
+#if (HAL_USE_QEI == TRUE) || defined(__DOXYGEN__)
65 82
+
66 83
+/*===========================================================================*/
67 84
+/* Driver constants.                                                         */
......
177 194
+
178 195
+#endif /* HAL_USE_QEI */
179 196
+
180
+#endif /* _HAL_QEI_H_ */
197
+#endif /* HAL_QEI_H */
181 198
+
182 199
+/** @} */
183 200
diff --git a/os/hal/ports/STM32/LLD/TIMv1/driver.mk b/os/hal/ports/STM32/LLD/TIMv1/driver.mk
......
185 202
--- a/os/hal/ports/STM32/LLD/TIMv1/driver.mk
186 203
+++ b/os/hal/ports/STM32/LLD/TIMv1/driver.mk
187 204
@@ -10,10 +10,14 @@ endif
188
 ifneq ($(findstring HAL_USE_PWM TRUE,$(HALCONF)),)

189
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c

190
 endif

191
+ifneq ($(findstring HAL_USE_QEI TRUE,$(HALCONF)),)

192
+PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.c

193
+endif

194
 else

195
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c

196
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.c

197
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c

198
+PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.c

199
 endif

200
 
201
 PLATFORMINC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1

205
 ifneq ($(findstring HAL_USE_PWM TRUE,$(HALCONF)),)
206
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c
207
 endif
208
+ifneq ($(findstring HAL_USE_QEI TRUE,$(HALCONF)),)
209
+PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.c
210
+endif
211
 else
212
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c
213
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.c
214
 PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_pwm_lld.c
215
+PLATFORMSRC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.c
216
 endif
217
 
218
 PLATFORMINC += $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1
202 219
diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.c b/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.c
203 220
new file mode 100644
204
index 0000000..700704a
221
index 0000000..cd1ab9b
205 222
--- /dev/null
206 223
+++ b/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.c
207
@@ -0,0 +1,302 @@
224
@@ -0,0 +1,304 @@
208 225
+/*
209 226
+AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
210 227
+Copyright (C) 2016..2018  Thomas Schöpping et al.
......
233 250
+
234 251
+#include "hal.h"
235 252
+
236
+#include "hal_qei.h"
253
+#if (HAL_USE_QEI == TRUE) || defined(__DOXYGEN__)
237 254
+
238
+#if HAL_USE_QEI || defined(__DOXYGEN__)
255
+/*===========================================================================*/
256
+/* Driver local definitions.                                                 */
257
+/*===========================================================================*/
239 258
+
240 259
+/*===========================================================================*/
241 260
+/* Driver exported variables.                                                */
......
290 309
+#endif
291 310
+
292 311
+/*===========================================================================*/
293
+/* Driver local variables.                                                   */
312
+/* Driver local variables and types.                                         */
294 313
+/*===========================================================================*/
295 314
+
296 315
+/*===========================================================================*/
......
412 431
+  /* Timer configuration.*/
413 432
+  qeip->tim->PSC  = 0;
414 433
+  arr = qeip->config->range - 1;
415
+  osalDbgAssert((arr <= 0xFFFF), "qei_lld_start(), #1" /*, "invalid range"*/);
434
+  osalDbgAssert((arr <= 0xFFFF), "invalid range");
416 435
+  qeip->tim->ARR  = arr & 0xFFFF;
417 436
+
418 437
+  /* CCMR1_CC1S = 01 - CH1 Input on TI1.
......
509 528
+/** @} */
510 529
diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.h b/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.h
511 530
new file mode 100644
512
index 0000000..d4b7acc
531
index 0000000..ec1cd42
513 532
--- /dev/null
514 533
+++ b/os/hal/ports/STM32/LLD/TIMv1/hal_qei_lld.h
515 534
@@ -0,0 +1,302 @@
......
539 558
+ * @{
540 559
+ */
541 560
+
542
+#ifndef _HAL_QEI_LLD_H_
543
+#define _HAL_QEI_LLD_H_
561
+#ifndef HAL_QEI_LLD_H
562
+#define HAL_QEI_LLD_H
544 563
+
545
+#include "stm32_tim.h"
564
+#if (HAL_USE_QEI == TRUE) || defined(__DOXYGEN__)
546 565
+
547
+#if HAL_USE_QEI || defined(__DOXYGEN__)
566
+#include "stm32_tim.h"
548 567
+
549 568
+/*===========================================================================*/
550 569
+/* Driver constants.                                                         */
......
569 588
+ * @note    The default is @p TRUE.
570 589
+ */
571 590
+#if !defined(STM32_QEI_USE_TIM1) || defined(__DOXYGEN__)
572
+#define STM32_QEI_USE_TIM1                  TRUE
591
+#define STM32_QEI_USE_TIM1                  FALSE
573 592
+#endif
574 593
+
575 594
+/**
......
578 597
+ * @note    The default is @p TRUE.
579 598
+ */
580 599
+#if !defined(STM32_QEI_USE_TIM2) || defined(__DOXYGEN__)
581
+#define STM32_QEI_USE_TIM2                  TRUE
600
+#define STM32_QEI_USE_TIM2                  FALSE
582 601
+#endif
583 602
+
584 603
+/**
......
587 606
+ * @note    The default is @p TRUE.
588 607
+ */
589 608
+#if !defined(STM32_QEI_USE_TIM3) || defined(__DOXYGEN__)
590
+#define STM32_QEI_USE_TIM3                  TRUE
609
+#define STM32_QEI_USE_TIM3                  FALSE
591 610
+#endif
592 611
+
593 612
+/**
......
596 615
+ * @note    The default is @p TRUE.
597 616
+ */
598 617
+#if !defined(STM32_QEI_USE_TIM4) || defined(__DOXYGEN__)
599
+#define STM32_QEI_USE_TIM4                  TRUE
618
+#define STM32_QEI_USE_TIM4                  FALSE
600 619
+#endif
601 620
+
602 621
+/**
......
605 624
+ * @note    The default is @p TRUE.
606 625
+ */
607 626
+#if !defined(STM32_QEI_USE_TIM5) || defined(__DOXYGEN__)
608
+#define STM32_QEI_USE_TIM5                  TRUE
627
+#define STM32_QEI_USE_TIM5                  FALSE
609 628
+#endif
610 629
+
611 630
+/**
......
614 633
+ * @note    The default is @p TRUE.
615 634
+ */
616 635
+#if !defined(STM32_QEI_USE_TIM8) || defined(__DOXYGEN__)
617
+#define STM32_QEI_USE_TIM8                  TRUE
636
+#define STM32_QEI_USE_TIM8                  FALSE
618 637
+#endif
619 638
+/** @} */
620 639
+
......
812 831
+
813 832
+#endif /* HAL_USE_QEI */
814 833
+
815
+#endif /* _HAL_QEI_LLD_H_ */
834
+#endif /* HAL_QEI_LLD_H */
816 835
+
817 836
+/** @} */
818 837
diff --git a/os/hal/src/hal_qei.c b/os/hal/src/hal_qei.c
819 838
new file mode 100644
820
index 0000000..c08d175
839
index 0000000..00334bb
821 840
--- /dev/null
822 841
+++ b/os/hal/src/hal_qei.c
823
@@ -0,0 +1,156 @@
842
@@ -0,0 +1,152 @@
824 843
+/*
825 844
+AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
826 845
+Copyright (C) 2016..2018  Thomas Schöpping et al.
......
848 867
+ */
849 868
+
850 869
+#include "hal.h"
851
+#include "hal_qei.h"
852 870
+
853
+#if HAL_USE_QEI || defined(__DOXYGEN__)
871
+#if (HAL_USE_QEI == TRUE) || defined(__DOXYGEN__)
854 872
+
855 873
+/*===========================================================================*/
856 874
+/* Driver local definitions.                                                 */
......
907 925
+ */
908 926
+void qeiStart(QEIDriver *qeip, const QEIConfig *config) {
909 927
+
910
+  chDbgCheck((qeip != NULL) && (config != NULL) /*, "qeiStart"*/);
928
+  osalDbgCheck((qeip != NULL) && (config != NULL));
911 929
+
912
+  chSysLock();
913
+  chDbgAssert((qeip->state == QEI_STOP) || (qeip->state == QEI_READY),
914
+              "qeiStart(), #1" /*, "invalid state"*/);
930
+  osalSysLock();
931
+  osalDbgAssert((qeip->state == QEI_STOP) || (qeip->state == QEI_READY), "invalid state");
915 932
+  qeip->config = config;
916 933
+  qei_lld_start(qeip);
917 934
+  qeip->state = QEI_READY;
918
+  chSysUnlock();
935
+  osalSysUnlock();
919 936
+}
920 937
+
921 938
+/**
......
927 944
+ */
928 945
+void qeiStop(QEIDriver *qeip) {
929 946
+
930
+  chDbgCheck(qeip != NULL /*, "qeiStop"*/);
947
+  osalDbgCheck(qeip != NULL);
931 948
+
932
+  chSysLock();
933
+  chDbgAssert((qeip->state == QEI_STOP) || (qeip->state == QEI_READY),
934
+              "qeiStop(), #1" /*, "invalid state"*/);
949
+  osalSysLock();
950
+  osalDbgAssert((qeip->state == QEI_STOP) || (qeip->state == QEI_READY), "invalid state");
935 951
+  qei_lld_stop(qeip);
936 952
+  qeip->state = QEI_STOP;
937
+  chSysUnlock();
953
+  osalSysUnlock();
938 954
+}
939 955
+
940 956
+/**
......
946 962
+ */
947 963
+void qeiEnable(QEIDriver *qeip) {
948 964
+
949
+  chDbgCheck(qeip != NULL /*, "qeiEnable"*/);
965
+  osalDbgCheck(qeip != NULL);
950 966
+
951
+  chSysLock();
952
+  chDbgAssert(qeip->state == QEI_READY, "qeiEnable(), #1" /*, "invalid state"*/);
967
+  osalSysLock();
968
+  osalDbgAssert(qeip->state == QEI_READY, "invalid state");
953 969
+  qei_lld_enable(qeip);
954 970
+  qeip->state = QEI_ACTIVE;
955
+  chSysUnlock();
971
+  osalSysUnlock();
956 972
+}
957 973
+
958 974
+/**
......
964 980
+ */
965 981
+void qeiDisable(QEIDriver *qeip) {
966 982
+
967
+  chDbgCheck(qeip != NULL /*, "qeiDisable"*/);
983
+  osalDbgCheck(qeip != NULL);
968 984
+
969
+  chSysLock();
970
+  chDbgAssert((qeip->state == QEI_READY) || (qeip->state == QEI_ACTIVE),
971
+              "qeiDisable(), #1" /*, "invalid state"*/);
985
+  osalSysLock();
986
+  osalDbgAssert((qeip->state == QEI_READY) || (qeip->state == QEI_ACTIVE), "invalid state");
972 987
+  qei_lld_disable(qeip);
973 988
+  qeip->state = QEI_READY;
974
+  chSysUnlock();
989
+  osalSysUnlock();
975 990
+}
976 991
+
977 992
+#endif /* HAL_USE_QEI */
modules/DiWheelDrive_1-1/halconf.h
17 17
*/
18 18

  
19 19
/**
20
 * @file    
20
 * @file
21 21
 * @brief   HAL configuration header for the DiWheelDrive v1.1 module.
22 22
 * @details HAL configuration file, this file allows to enable or disable the
23 23
 *          various device drivers from your application. You may also use
......
127 127
#endif
128 128

  
129 129
/**
130
 * @brief   Enables the QEI subsystem.
131
 */
132
#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
133
#define HAL_USE_QEI                         TRUE
134
#endif
135

  
136
/**
130 137
 * @brief   Enables the QSPI subsystem.
131 138
 */
132 139
#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
modules/LightRing_1-0/halconf.h
127 127
#endif
128 128

  
129 129
/**
130
 * @brief   Enables the QEI subsystem.
131
 */
132
#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
133
#define HAL_USE_QEI                         FALSE
134
#endif
135

  
136
/**
130 137
 * @brief   Enables the QSPI subsystem.
131 138
 */
132 139
#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
modules/PowerManagement_1-1/halconf.h
127 127
#endif
128 128

  
129 129
/**
130
 * @brief   Enables the QEI subsystem.
131
 */
132
#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
133
#define HAL_USE_QEI                         FALSE
134
#endif
135

  
136
/**
130 137
 * @brief   Enables the QSPI subsystem.
131 138
 */
132 139
#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)

Also available in: Unified diff