Procházet zdrojové kódy

Update to ChibiOS 18.2.1

Another big ChibiOS update, this time to the first stable release in the
18.2.x series.  This time a few pieces of API that the firmware and
library used were renamed, so there were some changes that had to be
made there.  The build system is nicer now, as the included makefiles
add paths to the necessary variables so the main Makefile is much less
verbose in a few places.
Clara Hobbs před 5 roky
rodič
revize
b1de72215c
15 změnil soubory, kde provedl 508 přidání a 149 odebrání
  1. 1
    1
      .gitmodules
  2. 1
    1
      ChibiOS
  3. 13
    20
      Makefile
  4. 168
    27
      boards/PD_BUDDY_SINK/board.c
  5. 20
    20
      boards/PD_BUDDY_SINK/board.h
  6. 4
    0
      boards/PD_BUDDY_SINK/board.mk
  7. 91
    3
      chconf.h
  8. 172
    42
      halconf.h
  9. 8
    8
      lib/include/pd.h
  10. 3
    0
      lib/pd-buddy.mk
  11. 11
    11
      lib/src/policy_engine.c
  12. 1
    1
      lib/src/protocol_rx.c
  13. 1
    1
      lib/src/protocol_tx.c
  14. 11
    11
      mcuconf.h
  15. 3
    3
      src/led.c

+ 1
- 1
.gitmodules Zobrazit soubor

@@ -1,4 +1,4 @@
1 1
 [submodule "ChibiOS"]
2 2
 	path = ChibiOS
3 3
 	url = https://github.com/ChibiOS/ChibiOS.git
4
-	branch = stable_17.6.x
4
+	branch = stable_18.2.x

+ 1
- 1
ChibiOS

@@ -1 +1 @@
1
-Subproject commit 5b4a1f5837a83f32fd5e5e439eaa370cc7399237
1
+Subproject commit 98439bfe73841e3ba75cd1878c0db8eef46af576

+ 13
- 20
Makefile Zobrazit soubor

@@ -88,6 +88,9 @@ PROJECT = pd-buddy-firmware
88 88
 # Imported source files and paths
89 89
 CHIBIOS = ChibiOS
90 90
 PDBLIB = lib
91
+
92
+# Licensing files.
93
+include $(CHIBIOS)/os/license/license.mk
91 94
 # Startup files.
92 95
 include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f0xx.mk
93 96
 # HAL-OSAL files (optional).
@@ -95,11 +98,14 @@ include $(CHIBIOS)/os/hal/hal.mk
95 98
 include $(CHIBIOS)/os/hal/ports/STM32/STM32F0xx/platform.mk
96 99
 include $(CHIBIOS)/../boards/PD_BUDDY_SINK/board.mk
97 100
 include $(CHIBIOS)/os/hal/osal/rt/osal.mk
101
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
98 102
 # RTOS files (optional).
99 103
 include $(CHIBIOS)/os/rt/rt.mk
100 104
 include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk
101 105
 # Other files (optional).
102
-include $(CHIBIOS)/test/rt/test.mk
106
+include $(CHIBIOS)/test/lib/test.mk
107
+include $(CHIBIOS)/test/rt/rt_test.mk
108
+include $(CHIBIOS)/test/oslib/oslib_test.mk
103 109
 include $(PDBLIB)/pd-buddy.mk
104 110
 
105 111
 # Define linker script file here
@@ -107,21 +113,13 @@ LDSCRIPT=$(CHIBIOS)/../ld/STM32F072x8.ld
107 113
 
108 114
 # C sources that can be compiled in ARM or THUMB mode depending on the global
109 115
 # setting.
110
-CSRC = $(STARTUPSRC) \
111
-       $(KERNSRC) \
112
-       $(PORTSRC) \
113
-       $(OSALSRC) \
114
-       $(HALSRC) \
115
-       $(PLATFORMSRC) \
116
-       $(BOARDSRC) \
116
+CSRC = $(ALLCSRC) \
117 117
        $(TESTSRC) \
118
-       $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
119
-       $(PDBSRC) \
120 118
        $(wildcard src/*.c)
121 119
 
122 120
 # C++ sources that can be compiled in ARM or THUMB mode depending on the global
123 121
 # setting.
124
-CPPSRC =
122
+CPPSRC = $(ALLCPPSRC)
125 123
 
126 124
 # C sources to be compiled in ARM mode regardless of the global setting.
127 125
 # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
@@ -144,15 +142,10 @@ TCSRC =
144 142
 TCPPSRC =
145 143
 
146 144
 # List ASM source files here
147
-ASMSRC =
148
-ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
149
-
150
-INCDIR = $(CHIBIOS)/os/license \
151
-         $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
152
-         $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
153
-         $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various \
154
-	 $(PDBINC) \
155
-	 config
145
+ASMSRC = $(ALLASMSRC)
146
+ASMXSRC = $(ALLXASMSRC)
147
+
148
+INCDIR = $(ALLINC) $(TESTINC)
156 149
 
157 150
 #
158 151
 # Project, sources and paths

+ 168
- 27
boards/PD_BUDDY_SINK/board.c Zobrazit soubor

@@ -1,23 +1,5 @@
1 1
 /*
2
- * PD Buddy Sink Firmware - Smart power jack for USB Power Delivery
3
- * Copyright (C) 2017-2018 Clayton G. Hobbs <clay@lakeserv.net>
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
- */
18
-
19
-/*
20
-    ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
2
+    ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
21 3
 
22 4
     Licensed under the Apache License, Version 2.0 (the "License");
23 5
     you may not use this file except in compliance with the License.
@@ -39,14 +21,76 @@
39 21
 
40 22
 #include "stm32f072_bootloader.h"
41 23
 #include "hal.h"
24
+#include "stm32_gpio.h"
25
+
26
+/*===========================================================================*/
27
+/* Driver local definitions.                                                 */
28
+/*===========================================================================*/
29
+
30
+/*===========================================================================*/
31
+/* Driver exported variables.                                                */
32
+/*===========================================================================*/
33
+
34
+/*===========================================================================*/
35
+/* Driver local variables and types.                                         */
36
+/*===========================================================================*/
37
+
38
+/**
39
+ * @brief   Type of STM32 GPIO port setup.
40
+ */
41
+typedef struct {
42
+  uint32_t              moder;
43
+  uint32_t              otyper;
44
+  uint32_t              ospeedr;
45
+  uint32_t              pupdr;
46
+  uint32_t              odr;
47
+  uint32_t              afrl;
48
+  uint32_t              afrh;
49
+} gpio_setup_t;
42 50
 
43
-#if HAL_USE_PAL || defined(__DOXYGEN__)
44 51
 /**
45
- * @brief   PAL setup.
46
- * @details Digital I/O ports static configuration as defined in @p board.h.
47
- *          This variable is used by the HAL when initializing the PAL driver.
52
+ * @brief   Type of STM32 GPIO initialization data.
48 53
  */
49
-const PALConfig pal_default_config = {
54
+typedef struct {
55
+#if STM32_HAS_GPIOA || defined(__DOXYGEN__)
56
+  gpio_setup_t          PAData;
57
+#endif
58
+#if STM32_HAS_GPIOB || defined(__DOXYGEN__)
59
+  gpio_setup_t          PBData;
60
+#endif
61
+#if STM32_HAS_GPIOC || defined(__DOXYGEN__)
62
+  gpio_setup_t          PCData;
63
+#endif
64
+#if STM32_HAS_GPIOD || defined(__DOXYGEN__)
65
+  gpio_setup_t          PDData;
66
+#endif
67
+#if STM32_HAS_GPIOE || defined(__DOXYGEN__)
68
+  gpio_setup_t          PEData;
69
+#endif
70
+#if STM32_HAS_GPIOF || defined(__DOXYGEN__)
71
+  gpio_setup_t          PFData;
72
+#endif
73
+#if STM32_HAS_GPIOG || defined(__DOXYGEN__)
74
+  gpio_setup_t          PGData;
75
+#endif
76
+#if STM32_HAS_GPIOH || defined(__DOXYGEN__)
77
+  gpio_setup_t          PHData;
78
+#endif
79
+#if STM32_HAS_GPIOI || defined(__DOXYGEN__)
80
+  gpio_setup_t          PIData;
81
+#endif
82
+#if STM32_HAS_GPIOJ || defined(__DOXYGEN__)
83
+  gpio_setup_t          PJData;
84
+#endif
85
+#if STM32_HAS_GPIOK || defined(__DOXYGEN__)
86
+  gpio_setup_t          PKData;
87
+#endif
88
+} gpio_config_t;
89
+
90
+/**
91
+ * @brief   STM32 GPIO static initialization data.
92
+ */
93
+static const gpio_config_t gpio_default_config = {
50 94
 #if STM32_HAS_GPIOA
51 95
   {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
52 96
    VAL_GPIOA_ODR,   VAL_GPIOA_AFRL,   VAL_GPIOA_AFRH},
@@ -81,18 +125,92 @@ const PALConfig pal_default_config = {
81 125
 #endif
82 126
 #if STM32_HAS_GPIOI
83 127
   {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
84
-   VAL_GPIOI_ODR,   VAL_GPIOI_AFRL,   VAL_GPIOI_AFRH}
128
+   VAL_GPIOI_ODR,   VAL_GPIOI_AFRL,   VAL_GPIOI_AFRH},
129
+#endif
130
+#if STM32_HAS_GPIOJ
131
+  {VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR,
132
+   VAL_GPIOJ_ODR,   VAL_GPIOJ_AFRL,   VAL_GPIOJ_AFRH},
133
+#endif
134
+#if STM32_HAS_GPIOK
135
+  {VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR,
136
+   VAL_GPIOK_ODR,   VAL_GPIOK_AFRL,   VAL_GPIOK_AFRH}
85 137
 #endif
86 138
 };
139
+
140
+/*===========================================================================*/
141
+/* Driver local functions.                                                   */
142
+/*===========================================================================*/
143
+
144
+static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) {
145
+
146
+  gpiop->OTYPER  = config->otyper;
147
+  gpiop->OSPEEDR = config->ospeedr;
148
+  gpiop->PUPDR   = config->pupdr;
149
+  gpiop->ODR     = config->odr;
150
+  gpiop->AFRL    = config->afrl;
151
+  gpiop->AFRH    = config->afrh;
152
+  gpiop->MODER   = config->moder;
153
+}
154
+
155
+static void stm32_gpio_init(void) {
156
+
157
+  /* Enabling GPIO-related clocks, the mask comes from the
158
+     registry header file.*/
159
+  rccResetAHB(STM32_GPIO_EN_MASK);
160
+  rccEnableAHB(STM32_GPIO_EN_MASK, true);
161
+
162
+  /* Initializing all the defined GPIO ports.*/
163
+#if STM32_HAS_GPIOA
164
+  gpio_init(GPIOA, &gpio_default_config.PAData);
165
+#endif
166
+#if STM32_HAS_GPIOB
167
+  gpio_init(GPIOB, &gpio_default_config.PBData);
87 168
 #endif
169
+#if STM32_HAS_GPIOC
170
+  gpio_init(GPIOC, &gpio_default_config.PCData);
171
+#endif
172
+#if STM32_HAS_GPIOD
173
+  gpio_init(GPIOD, &gpio_default_config.PDData);
174
+#endif
175
+#if STM32_HAS_GPIOE
176
+  gpio_init(GPIOE, &gpio_default_config.PEData);
177
+#endif
178
+#if STM32_HAS_GPIOF
179
+  gpio_init(GPIOF, &gpio_default_config.PFData);
180
+#endif
181
+#if STM32_HAS_GPIOG
182
+  gpio_init(GPIOG, &gpio_default_config.PGData);
183
+#endif
184
+#if STM32_HAS_GPIOH
185
+  gpio_init(GPIOH, &gpio_default_config.PHData);
186
+#endif
187
+#if STM32_HAS_GPIOI
188
+  gpio_init(GPIOI, &gpio_default_config.PIData);
189
+#endif
190
+#if STM32_HAS_GPIOJ
191
+  gpio_init(GPIOJ, &gpio_default_config.PJData);
192
+#endif
193
+#if STM32_HAS_GPIOK
194
+  gpio_init(GPIOK, &gpio_default_config.PKData);
195
+#endif
196
+}
197
+
198
+/*===========================================================================*/
199
+/* Driver interrupt handlers.                                                */
200
+/*===========================================================================*/
201
+
202
+/*===========================================================================*/
203
+/* Driver exported functions.                                                */
204
+/*===========================================================================*/
88 205
 
89 206
 /**
90 207
  * @brief   Early initialization code.
91
- * @details This initialization must be performed just after stack setup
92
- *          and before any other initialization.
208
+ * @details GPIO ports and system clocks are initialized before everything
209
+ *          else.
93 210
  */
94 211
 void __early_init(void) {
95 212
 
213
+  stm32_gpio_init();
96 214
   stm32_clock_init();
97 215
   /* Jump to the bootloader if the magic value is set in
98 216
    * dfu_reset_to_bootloader_magic. */
@@ -106,6 +224,28 @@ void __early_init(void) {
106 224
   }
107 225
 }
108 226
 
227
+#if HAL_USE_SDC || defined(__DOXYGEN__)
228
+/**
229
+ * @brief   SDC card detection.
230
+ */
231
+bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
232
+
233
+  (void)sdcp;
234
+  /* TODO: Fill the implementation.*/
235
+  return true;
236
+}
237
+
238
+/**
239
+ * @brief   SDC card write protection detection.
240
+ */
241
+bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
242
+
243
+  (void)sdcp;
244
+  /* TODO: Fill the implementation.*/
245
+  return false;
246
+}
247
+#endif /* HAL_USE_SDC */
248
+
109 249
 #if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
110 250
 /**
111 251
  * @brief   MMC_SPI card detection.
@@ -133,4 +273,5 @@ bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
133 273
  * @todo    Add your board-specific code, if any.
134 274
  */
135 275
 void boardInit(void) {
276
+
136 277
 }

+ 20
- 20
boards/PD_BUDDY_SINK/board.h Zobrazit soubor

@@ -1,23 +1,5 @@
1 1
 /*
2
- * PD Buddy Sink Firmware - Smart power jack for USB Power Delivery
3
- * Copyright (C) 2017-2018 Clayton G. Hobbs <clay@lakeserv.net>
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
- */
18
-
19
-/*
20
-    ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
2
+    ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
21 3
 
22 4
     Licensed under the Apache License, Version 2.0 (the "License");
23 5
     you may not use this file except in compliance with the License.
@@ -40,6 +22,10 @@
40 22
 #ifndef BOARD_H
41 23
 #define BOARD_H
42 24
 
25
+/*===========================================================================*/
26
+/* Driver constants.                                                         */
27
+/*===========================================================================*/
28
+
43 29
 /*
44 30
  * Setup for PD Buddy Sink board.
45 31
  */
@@ -185,16 +171,27 @@
185 171
 #define LINE_SWDIO                  PAL_LINE(GPIOA, 13U)
186 172
 #define LINE_SWCLK                  PAL_LINE(GPIOA, 14U)
187 173
 #define LINE_LED                    PAL_LINE(GPIOA, 15U)
188
-
189 174
 #define LINE_BUTTON                 PAL_LINE(GPIOB, 3U)
190 175
 #define LINE_OUT_CTRL               PAL_LINE(GPIOB, 8U)
191 176
 #define LINE_SCL                    PAL_LINE(GPIOB, 10U)
192 177
 #define LINE_SDA                    PAL_LINE(GPIOB, 11U)
193 178
 #define LINE_INT_N                  PAL_LINE(GPIOB, 12U)
194 179
 
180
+/*===========================================================================*/
181
+/* Driver pre-compile time settings.                                         */
182
+/*===========================================================================*/
195 183
 
184
+/*===========================================================================*/
185
+/* Derived constants and error checks.                                       */
186
+/*===========================================================================*/
196 187
 
188
+/*===========================================================================*/
189
+/* Driver data structures and types.                                         */
190
+/*===========================================================================*/
197 191
 
192
+/*===========================================================================*/
193
+/* Driver macros.                                                            */
194
+/*===========================================================================*/
198 195
 
199 196
 /*
200 197
  * I/O ports initial setup, this configuration is established soon after reset
@@ -920,6 +917,9 @@
920 917
                                      PIN_AFIO_AF(GPIOF_PIN14, 0U) |         \
921 918
                                      PIN_AFIO_AF(GPIOF_PIN15, 0U))
922 919
 
920
+/*===========================================================================*/
921
+/* External declarations.                                                    */
922
+/*===========================================================================*/
923 923
 
924 924
 #if !defined(_FROM_ASM_)
925 925
 #ifdef __cplusplus

+ 4
- 0
boards/PD_BUDDY_SINK/board.mk Zobrazit soubor

@@ -3,3 +3,7 @@ BOARDSRC = $(CHIBIOS)/../boards/PD_BUDDY_SINK/board.c
3 3
 
4 4
 # Required include directories
5 5
 BOARDINC = $(CHIBIOS)/../boards/PD_BUDDY_SINK $(CHIBIOS)/../src
6
+
7
+# Shared variables
8
+ALLCSRC += $(BOARDSRC)
9
+ALLINC  += $(BOARDINC)

+ 91
- 3
chconf.h Zobrazit soubor

@@ -17,7 +17,7 @@
17 17
  */
18 18
 
19 19
 /*
20
-    ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
20
+    ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
21 21
 
22 22
     Licensed under the Apache License, Version 2.0 (the "License");
23 23
     you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@
47 47
 #define CHCONF_H
48 48
 
49 49
 #define _CHIBIOS_RT_CONF_
50
+#define _CHIBIOS_RT_CONF_VER_5_0_
50 51
 
51 52
 /*===========================================================================*/
52 53
 /**
@@ -68,6 +69,18 @@
68 69
  */
69 70
 #define CH_CFG_ST_FREQUENCY                 10000
70 71
 
72
+/**
73
+ * @brief   Time intervals data size.
74
+ * @note    Allowed values are 16, 32 or 64 bits.
75
+ */
76
+#define CH_CFG_INTERVALS_SIZE               32
77
+
78
+/**
79
+ * @brief   Time types data size.
80
+ * @note    Allowed values are 16 or 32 bits.
81
+ */
82
+#define CH_CFG_TIME_TYPES_SIZE              32
83
+
71 84
 /**
72 85
  * @brief   Time delta constant for the tick-less mode.
73 86
  * @note    If this value is zero then the system uses the classic
@@ -312,6 +325,15 @@
312 325
  */
313 326
 #define CH_CFG_USE_MEMPOOLS                 TRUE
314 327
 
328
+/**
329
+ * @brief  Objects FIFOs APIs.
330
+ * @details If enabled then the objects FIFOs APIs are included
331
+ *          in the kernel.
332
+ *
333
+ * @note    The default is @p TRUE.
334
+ */
335
+#define CH_CFG_USE_OBJ_FIFOS                FALSE
336
+
315 337
 /**
316 338
  * @brief   Dynamic Threads APIs.
317 339
  * @details If enabled then the dynamic threads creation APIs are included
@@ -325,6 +347,56 @@
325 347
 
326 348
 /** @} */
327 349
 
350
+/*===========================================================================*/
351
+/**
352
+ * @name Objects factory options
353
+ * @{
354
+ */
355
+/*===========================================================================*/
356
+
357
+/**
358
+ * @brief   Objects Factory APIs.
359
+ * @details If enabled then the objects factory APIs are included in the
360
+ *          kernel.
361
+ *
362
+ * @note    The default is @p FALSE.
363
+ */
364
+#define CH_CFG_USE_FACTORY                  FALSE
365
+
366
+/**
367
+ * @brief   Maximum length for object names.
368
+ * @details If the specified length is zero then the name is stored by
369
+ *          pointer but this could have unintended side effects.
370
+ */
371
+#define CH_CFG_FACTORY_MAX_NAMES_LENGTH     8
372
+
373
+/**
374
+ * @brief   Enables the registry of generic objects.
375
+ */
376
+#define CH_CFG_FACTORY_OBJECTS_REGISTRY     TRUE
377
+
378
+/**
379
+ * @brief   Enables factory for generic buffers.
380
+ */
381
+#define CH_CFG_FACTORY_GENERIC_BUFFERS      TRUE
382
+
383
+/**
384
+ * @brief   Enables factory for semaphores.
385
+ */
386
+#define CH_CFG_FACTORY_SEMAPHORES           TRUE
387
+
388
+/**
389
+ * @brief   Enables factory for mailboxes.
390
+ */
391
+#define CH_CFG_FACTORY_MAILBOXES            TRUE
392
+
393
+/**
394
+ * @brief   Enables factory for objects FIFOs.
395
+ */
396
+#define CH_CFG_FACTORY_OBJ_FIFOS            TRUE
397
+
398
+/** @} */
399
+
328 400
 /*===========================================================================*/
329 401
 /**
330 402
  * @name Debug options
@@ -424,6 +496,22 @@
424 496
  */
425 497
 /*===========================================================================*/
426 498
 
499
+/**
500
+ * @brief   System structure extension.
501
+ * @details User fields added to the end of the @p ch_system_t structure.
502
+ */
503
+#define CH_CFG_SYSTEM_EXTRA_FIELDS                                          \
504
+  /* Add threads custom fields here.*/
505
+
506
+/**
507
+ * @brief   System initialization hook.
508
+ * @details User initialization code added to the @p chSysInit() function
509
+ *          just before interrupts are enabled globally.
510
+ */
511
+#define CH_CFG_SYSTEM_INIT_HOOK(tp) {                                       \
512
+  /* Add threads initialization code here.*/                                \
513
+}
514
+
427 515
 /**
428 516
  * @brief   Threads descriptor structure extension.
429 517
  * @details User fields added to the end of the @p thread_t structure.
@@ -433,9 +521,9 @@
433 521
 
434 522
 /**
435 523
  * @brief   Threads initialization hook.
436
- * @details User initialization code added to the @p chThdInit() API.
524
+ * @details User initialization code added to the @p _thread_init() function.
437 525
  *
438
- * @note    It is invoked from within @p chThdInit() and implicitly from all
526
+ * @note    It is invoked from within @p _thread_init() and implicitly from all
439 527
  *          the threads creation APIs.
440 528
  */
441 529
 #define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \

+ 172
- 42
halconf.h Zobrazit soubor

@@ -17,7 +17,7 @@
17 17
  */
18 18
 
19 19
 /*
20
-    ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
20
+    ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
21 21
 
22 22
     Licensed under the Apache License, Version 2.0 (the "License");
23 23
     you may not use this file except in compliance with the License.
@@ -46,153 +46,183 @@
46 46
 #ifndef HALCONF_H
47 47
 #define HALCONF_H
48 48
 
49
+#define _CHIBIOS_HAL_CONF_
50
+#define _CHIBIOS_HAL_CONF_VER_6_0_
51
+
49 52
 #include "mcuconf.h"
50 53
 
51 54
 /**
52 55
  * @brief   Enables the PAL subsystem.
53 56
  */
54 57
 #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
55
-#define HAL_USE_PAL                 TRUE
58
+#define HAL_USE_PAL                         TRUE
56 59
 #endif
57 60
 
58 61
 /**
59 62
  * @brief   Enables the ADC subsystem.
60 63
  */
61 64
 #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
62
-#define HAL_USE_ADC                 FALSE
65
+#define HAL_USE_ADC                         FALSE
63 66
 #endif
64 67
 
65 68
 /**
66 69
  * @brief   Enables the CAN subsystem.
67 70
  */
68 71
 #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
69
-#define HAL_USE_CAN                 FALSE
72
+#define HAL_USE_CAN                         FALSE
73
+#endif
74
+
75
+/**
76
+ * @brief   Enables the cryptographic subsystem.
77
+ */
78
+#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
79
+#define HAL_USE_CRY                         FALSE
70 80
 #endif
71 81
 
72 82
 /**
73 83
  * @brief   Enables the DAC subsystem.
74 84
  */
75 85
 #if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
76
-#define HAL_USE_DAC                 FALSE
86
+#define HAL_USE_DAC                         FALSE
77 87
 #endif
78 88
 
79 89
 /**
80 90
  * @brief   Enables the EXT subsystem.
81 91
  */
82 92
 #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
83
-#define HAL_USE_EXT                 FALSE
93
+#define HAL_USE_EXT                         FALSE
84 94
 #endif
85 95
 
86 96
 /**
87 97
  * @brief   Enables the GPT subsystem.
88 98
  */
89 99
 #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
90
-#define HAL_USE_GPT                 FALSE
100
+#define HAL_USE_GPT                         FALSE
91 101
 #endif
92 102
 
93 103
 /**
94 104
  * @brief   Enables the I2C subsystem.
95 105
  */
96 106
 #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
97
-#define HAL_USE_I2C                 TRUE
107
+#define HAL_USE_I2C                         TRUE
98 108
 #endif
99 109
 
100 110
 /**
101 111
  * @brief   Enables the I2S subsystem.
102 112
  */
103 113
 #if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
104
-#define HAL_USE_I2S                 FALSE
114
+#define HAL_USE_I2S                         FALSE
105 115
 #endif
106 116
 
107 117
 /**
108 118
  * @brief   Enables the ICU subsystem.
109 119
  */
110 120
 #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
111
-#define HAL_USE_ICU                 FALSE
121
+#define HAL_USE_ICU                         FALSE
112 122
 #endif
113 123
 
114 124
 /**
115 125
  * @brief   Enables the MAC subsystem.
116 126
  */
117 127
 #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
118
-#define HAL_USE_MAC                 FALSE
128
+#define HAL_USE_MAC                         FALSE
119 129
 #endif
120 130
 
121 131
 /**
122 132
  * @brief   Enables the MMC_SPI subsystem.
123 133
  */
124 134
 #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
125
-#define HAL_USE_MMC_SPI             FALSE
135
+#define HAL_USE_MMC_SPI                     FALSE
126 136
 #endif
127 137
 
128 138
 /**
129 139
  * @brief   Enables the PWM subsystem.
130 140
  */
131 141
 #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
132
-#define HAL_USE_PWM                 FALSE
142
+#define HAL_USE_PWM                         FALSE
133 143
 #endif
134 144
 
135 145
 /**
136 146
  * @brief   Enables the QSPI subsystem.
137 147
  */
138 148
 #if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
139
-#define HAL_USE_QSPI                FALSE
149
+#define HAL_USE_QSPI                        FALSE
140 150
 #endif
141 151
 
142 152
 /**
143 153
  * @brief   Enables the RTC subsystem.
144 154
  */
145 155
 #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
146
-#define HAL_USE_RTC                 FALSE
156
+#define HAL_USE_RTC                         FALSE
147 157
 #endif
148 158
 
149 159
 /**
150 160
  * @brief   Enables the SDC subsystem.
151 161
  */
152 162
 #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
153
-#define HAL_USE_SDC                 FALSE
163
+#define HAL_USE_SDC                         FALSE
154 164
 #endif
155 165
 
156 166
 /**
157 167
  * @brief   Enables the SERIAL subsystem.
158 168
  */
159 169
 #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
160
-#define HAL_USE_SERIAL              FALSE
170
+#define HAL_USE_SERIAL                      FALSE
161 171
 #endif
162 172
 
163 173
 /**
164 174
  * @brief   Enables the SERIAL over USB subsystem.
165 175
  */
166 176
 #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
167
-#define HAL_USE_SERIAL_USB          TRUE
177
+#define HAL_USE_SERIAL_USB                  TRUE
168 178
 #endif
169 179
 
170 180
 /**
171 181
  * @brief   Enables the SPI subsystem.
172 182
  */
173 183
 #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
174
-#define HAL_USE_SPI                 FALSE
184
+#define HAL_USE_SPI                         FALSE
175 185
 #endif
176 186
 
177 187
 /**
178 188
  * @brief   Enables the UART subsystem.
179 189
  */
180 190
 #if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
181
-#define HAL_USE_UART                FALSE
191
+#define HAL_USE_UART                        FALSE
182 192
 #endif
183 193
 
184 194
 /**
185 195
  * @brief   Enables the USB subsystem.
186 196
  */
187 197
 #if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
188
-#define HAL_USE_USB                 TRUE
198
+#define HAL_USE_USB                         TRUE
189 199
 #endif
190 200
 
191 201
 /**
192 202
  * @brief   Enables the WDG subsystem.
193 203
  */
194 204
 #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
195
-#define HAL_USE_WDG                 FALSE
205
+#define HAL_USE_WDG                         FALSE
206
+#endif
207
+
208
+/*===========================================================================*/
209
+/* PAL driver related settings.                                              */
210
+/*===========================================================================*/
211
+
212
+/**
213
+ * @brief   Enables synchronous APIs.
214
+ * @note    Disabling this option saves both code and data space.
215
+ */
216
+#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
217
+#define PAL_USE_CALLBACKS                   FALSE
218
+#endif
219
+
220
+/**
221
+ * @brief   Enables synchronous APIs.
222
+ * @note    Disabling this option saves both code and data space.
223
+ */
224
+#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
225
+#define PAL_USE_WAIT                        FALSE
196 226
 #endif
197 227
 
198 228
 /*===========================================================================*/
@@ -204,7 +234,7 @@
204 234
  * @note    Disabling this option saves both code and data space.
205 235
  */
206 236
 #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
207
-#define ADC_USE_WAIT                TRUE
237
+#define ADC_USE_WAIT                        TRUE
208 238
 #endif
209 239
 
210 240
 /**
@@ -212,7 +242,7 @@
212 242
  * @note    Disabling this option saves both code and data space.
213 243
  */
214 244
 #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
215
-#define ADC_USE_MUTUAL_EXCLUSION    TRUE
245
+#define ADC_USE_MUTUAL_EXCLUSION            TRUE
216 246
 #endif
217 247
 
218 248
 /*===========================================================================*/
@@ -223,7 +253,56 @@
223 253
  * @brief   Sleep mode related APIs inclusion switch.
224 254
  */
225 255
 #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
226
-#define CAN_USE_SLEEP_MODE          TRUE
256
+#define CAN_USE_SLEEP_MODE                  TRUE
257
+#endif
258
+
259
+/**
260
+ * @brief   Enforces the driver to use direct callbacks rather than OSAL events.
261
+ */
262
+#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
263
+#define CAN_ENFORCE_USE_CALLBACKS           FALSE
264
+#endif
265
+
266
+/*===========================================================================*/
267
+/* CRY driver related settings.                                              */
268
+/*===========================================================================*/
269
+
270
+/**
271
+ * @brief   Enables the SW fall-back of the cryptographic driver.
272
+ * @details When enabled, this option, activates a fall-back software
273
+ *          implementation for algorithms not supported by the underlying
274
+ *          hardware.
275
+ * @note    Fall-back implementations may not be present for all algorithms.
276
+ */
277
+#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
278
+#define HAL_CRY_USE_FALLBACK                FALSE
279
+#endif
280
+
281
+/**
282
+ * @brief   Makes the driver forcibly use the fall-back implementations.
283
+ */
284
+#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
285
+#define HAL_CRY_ENFORCE_FALLBACK            FALSE
286
+#endif
287
+
288
+/*===========================================================================*/
289
+/* DAC driver related settings.                                              */
290
+/*===========================================================================*/
291
+
292
+/**
293
+ * @brief   Enables synchronous APIs.
294
+ * @note    Disabling this option saves both code and data space.
295
+ */
296
+#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
297
+#define DAC_USE_WAIT                        TRUE
298
+#endif
299
+
300
+/**
301
+ * @brief   Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
302
+ * @note    Disabling this option saves both code and data space.
303
+ */
304
+#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
305
+#define DAC_USE_MUTUAL_EXCLUSION            TRUE
227 306
 #endif
228 307
 
229 308
 /*===========================================================================*/
@@ -234,7 +313,7 @@
234 313
  * @brief   Enables the mutual exclusion APIs on the I2C bus.
235 314
  */
236 315
 #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
237
-#define I2C_USE_MUTUAL_EXCLUSION    TRUE
316
+#define I2C_USE_MUTUAL_EXCLUSION            TRUE
238 317
 #endif
239 318
 
240 319
 /*===========================================================================*/
@@ -242,17 +321,17 @@
242 321
 /*===========================================================================*/
243 322
 
244 323
 /**
245
- * @brief   Enables an event sources for incoming packets.
324
+ * @brief   Enables the zero-copy API.
246 325
  */
247 326
 #if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
248
-#define MAC_USE_ZERO_COPY           FALSE
327
+#define MAC_USE_ZERO_COPY                   FALSE
249 328
 #endif
250 329
 
251 330
 /**
252 331
  * @brief   Enables an event sources for incoming packets.
253 332
  */
254 333
 #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
255
-#define MAC_USE_EVENTS              TRUE
334
+#define MAC_USE_EVENTS                      TRUE
256 335
 #endif
257 336
 
258 337
 /*===========================================================================*/
@@ -268,7 +347,27 @@
268 347
  *          use a DMA channel and heavily loads the CPU.
269 348
  */
270 349
 #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
271
-#define MMC_NICE_WAITING            TRUE
350
+#define MMC_NICE_WAITING                    TRUE
351
+#endif
352
+
353
+/*===========================================================================*/
354
+/* QSPI driver related settings.                                             */
355
+/*===========================================================================*/
356
+
357
+/**
358
+ * @brief   Enables synchronous APIs.
359
+ * @note    Disabling this option saves both code and data space.
360
+ */
361
+#if !defined(QSPI_USE_WAIT) || defined(__DOXYGEN__)
362
+#define QSPI_USE_WAIT                       TRUE
363
+#endif
364
+
365
+/**
366
+ * @brief   Enables the @p qspiAcquireBus() and @p qspiReleaseBus() APIs.
367
+ * @note    Disabling this option saves both code and data space.
368
+ */
369
+#if !defined(QSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
370
+#define QSPI_USE_MUTUAL_EXCLUSION           TRUE
272 371
 #endif
273 372
 
274 373
 /*===========================================================================*/
@@ -280,7 +379,7 @@
280 379
  * @note    Attempts are performed at 10mS intervals.
281 380
  */
282 381
 #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
283
-#define SDC_INIT_RETRY              100
382
+#define SDC_INIT_RETRY                      100
284 383
 #endif
285 384
 
286 385
 /**
@@ -289,7 +388,7 @@
289 388
  *          at @p FALSE.
290 389
  */
291 390
 #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
292
-#define SDC_MMC_SUPPORT             FALSE
391
+#define SDC_MMC_SUPPORT                     FALSE
293 392
 #endif
294 393
 
295 394
 /**
@@ -299,7 +398,21 @@
299 398
  *          lower priority, this may slow down the driver a bit however.
300 399
  */
301 400
 #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
302
-#define SDC_NICE_WAITING            TRUE
401
+#define SDC_NICE_WAITING                    TRUE
402
+#endif
403
+
404
+/**
405
+ * @brief   OCR initialization constant for V20 cards.
406
+ */
407
+#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
408
+#define SDC_INIT_OCR_V20                    0x50FF8000U
409
+#endif
410
+
411
+/**
412
+ * @brief   OCR initialization constant for non-V20 cards.
413
+ */
414
+#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
415
+#define SDC_INIT_OCR                        0x80100000U
303 416
 #endif
304 417
 
305 418
 /*===========================================================================*/
@@ -312,7 +425,7 @@
312 425
  *          default configuration.
313 426
  */
314 427
 #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
315
-#define SERIAL_DEFAULT_BITRATE      38400
428
+#define SERIAL_DEFAULT_BITRATE              38400
316 429
 #endif
317 430
 
318 431
 /**
@@ -323,7 +436,7 @@
323 436
  *          buffers.
324 437
  */
325 438
 #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
326
-#define SERIAL_BUFFERS_SIZE         16
439
+#define SERIAL_BUFFERS_SIZE                 16
327 440
 #endif
328 441
 
329 442
 /*===========================================================================*/
@@ -338,7 +451,7 @@
338 451
  *          buffers.
339 452
  */
340 453
 #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
341
-#define SERIAL_USB_BUFFERS_SIZE     256
454
+#define SERIAL_USB_BUFFERS_SIZE             256
342 455
 #endif
343 456
 
344 457
 /**
@@ -346,7 +459,7 @@
346 459
  * @note    The default is 2 buffers.
347 460
  */
348 461
 #if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
349
-#define SERIAL_USB_BUFFERS_NUMBER   2
462
+#define SERIAL_USB_BUFFERS_NUMBER           2
350 463
 #endif
351 464
 
352 465
 /*===========================================================================*/
@@ -358,15 +471,32 @@
358 471
  * @note    Disabling this option saves both code and data space.
359 472
  */
360 473
 #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
361
-#define SPI_USE_WAIT                TRUE
474
+#define SPI_USE_WAIT                        TRUE
475
+#endif
476
+
477
+/**
478
+ * @brief   Enables circular transfers APIs.
479
+ * @note    Disabling this option saves both code and data space.
480
+ */
481
+#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
482
+#define SPI_USE_CIRCULAR                    FALSE
362 483
 #endif
363 484
 
485
+
364 486
 /**
365 487
  * @brief   Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
366 488
  * @note    Disabling this option saves both code and data space.
367 489
  */
368 490
 #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
369
-#define SPI_USE_MUTUAL_EXCLUSION    TRUE
491
+#define SPI_USE_MUTUAL_EXCLUSION            TRUE
492
+#endif
493
+
494
+/**
495
+ * @brief   Handling method for SPI CS line.
496
+ * @note    Disabling this option saves both code and data space.
497
+ */
498
+#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
499
+#define SPI_SELECT_MODE                     SPI_SELECT_MODE_PAD
370 500
 #endif
371 501
 
372 502
 /*===========================================================================*/
@@ -378,7 +508,7 @@
378 508
  * @note    Disabling this option saves both code and data space.
379 509
  */
380 510
 #if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
381
-#define UART_USE_WAIT               FALSE
511
+#define UART_USE_WAIT                       FALSE
382 512
 #endif
383 513
 
384 514
 /**
@@ -386,7 +516,7 @@
386 516
  * @note    Disabling this option saves both code and data space.
387 517
  */
388 518
 #if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
389
-#define UART_USE_MUTUAL_EXCLUSION   FALSE
519
+#define UART_USE_MUTUAL_EXCLUSION           FALSE
390 520
 #endif
391 521
 
392 522
 /*===========================================================================*/
@@ -398,7 +528,7 @@
398 528
  * @note    Disabling this option saves both code and data space.
399 529
  */
400 530
 #if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
401
-#define USB_USE_WAIT                FALSE
531
+#define USB_USE_WAIT                        FALSE
402 532
 #endif
403 533
 
404 534
 #endif /* HALCONF_H */

+ 8
- 8
lib/include/pd.h Zobrazit soubor

@@ -279,15 +279,15 @@
279 279
  * Where a range is specified, the middle of the range (rounded down to the
280 280
  * nearest millisecond) is used.
281 281
  */
282
-#define PD_T_CHUNKING_NOT_SUPPORTED MS2ST(45)
283
-#define PD_T_HARD_RESET_COMPLETE MS2ST(4)
284
-#define PD_T_PS_TRANSITION MS2ST(500)
285
-#define PD_T_SENDER_RESPONSE MS2ST(27)
286
-#define PD_T_SINK_REQUEST MS2ST(100)
287
-#define PD_T_TYPEC_SINK_WAIT_CAP MS2ST(465)
288
-#define PD_T_PPS_REQUEST S2ST(10)
282
+#define PD_T_CHUNKING_NOT_SUPPORTED TIME_MS2I(45)
283
+#define PD_T_HARD_RESET_COMPLETE TIME_MS2I(4)
284
+#define PD_T_PS_TRANSITION TIME_MS2I(500)
285
+#define PD_T_SENDER_RESPONSE TIME_MS2I(27)
286
+#define PD_T_SINK_REQUEST TIME_MS2I(100)
287
+#define PD_T_TYPEC_SINK_WAIT_CAP TIME_MS2I(465)
288
+#define PD_T_PPS_REQUEST TIME_S2I(10)
289 289
 /* This is actually from Type-C, not Power Delivery, but who cares? */
290
-#define PD_T_PD_DEBOUNCE MS2ST(15)
290
+#define PD_T_PD_DEBOUNCE TIME_MS2I(15)
291 291
 
292 292
 
293 293
 /*

+ 3
- 0
lib/pd-buddy.mk Zobrazit soubor

@@ -3,3 +3,6 @@ PDBSRC = $(wildcard $(PDBLIB)/src/*.c)
3 3
 
4 4
 # Include directories
5 5
 PDBINC = $(PDBLIB)/include
6
+
7
+ALLCSRC += $(PDBSRC)
8
+ALLINC  += $(PDBINC)

+ 11
- 11
lib/src/policy_engine.c Zobrazit soubor

@@ -103,7 +103,7 @@ static enum policy_engine_state pe_sink_wait_cap(struct pdb_config *cfg)
103 103
     /* If we got a message */
104 104
     if (evt & PDB_EVT_PE_MSG_RX) {
105 105
         /* Get the message */
106
-        if (chMBFetch(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
106
+        if (chMBFetchTimeout(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
107 107
             /* If we got a Source_Capabilities message, read it. */
108 108
             if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOURCE_CAPABILITIES
109 109
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
@@ -186,7 +186,7 @@ static enum policy_engine_state pe_sink_eval_cap(struct pdb_config *cfg)
186 186
 static enum policy_engine_state pe_sink_select_cap(struct pdb_config *cfg)
187 187
 {
188 188
     /* Transmit the request */
189
-    chMBPost(&cfg->prl.tx_mailbox, (msg_t) cfg->pe._last_dpm_request, TIME_IMMEDIATE);
189
+    chMBPostTimeout(&cfg->prl.tx_mailbox, (msg_t) cfg->pe._last_dpm_request, TIME_IMMEDIATE);
190 190
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
191 191
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
192 192
             | PDB_EVT_PE_RESET);
@@ -227,7 +227,7 @@ static enum policy_engine_state pe_sink_select_cap(struct pdb_config *cfg)
227 227
     }
228 228
 
229 229
     /* Get the response message */
230
-    if (chMBFetch(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
230
+    if (chMBFetchTimeout(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
231 231
         /* If the source accepted our request, wait for the new power */
232 232
         if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_ACCEPT
233 233
                 && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
@@ -290,7 +290,7 @@ static enum policy_engine_state pe_sink_transition_sink(struct pdb_config *cfg)
290 290
     }
291 291
 
292 292
     /* If we received a message, read it */
293
-    if (chMBFetch(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
293
+    if (chMBFetchTimeout(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
294 294
         /* If we got a PS_RDY, handle it */
295 295
         if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_PS_RDY
296 296
                 && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
@@ -384,7 +384,7 @@ static enum policy_engine_state pe_sink_ready(struct pdb_config *cfg)
384 384
 
385 385
     /* If we received a message */
386 386
     if (evt & PDB_EVT_PE_MSG_RX) {
387
-        if (chMBFetch(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
387
+        if (chMBFetchTimeout(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
388 388
             /* Ignore vendor-defined messages */
389 389
             if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_VENDOR_DEFINED
390 390
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
@@ -513,7 +513,7 @@ static enum policy_engine_state pe_sink_get_source_cap(struct pdb_config *cfg)
513 513
     get_source_cap->hdr = cfg->pe.hdr_template | PD_MSGTYPE_GET_SOURCE_CAP
514 514
         | PD_NUMOBJ(0);
515 515
     /* Transmit the Get_Source_Cap */
516
-    chMBPost(&cfg->prl.tx_mailbox, (msg_t) get_source_cap, TIME_IMMEDIATE);
516
+    chMBPostTimeout(&cfg->prl.tx_mailbox, (msg_t) get_source_cap, TIME_IMMEDIATE);
517 517
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
518 518
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
519 519
             | PDB_EVT_PE_RESET);
@@ -540,7 +540,7 @@ static enum policy_engine_state pe_sink_give_sink_cap(struct pdb_config *cfg)
540 540
     cfg->dpm.get_sink_capability(cfg, snk_cap);
541 541
 
542 542
     /* Transmit our capabilities */
543
-    chMBPost(&cfg->prl.tx_mailbox, (msg_t) snk_cap, TIME_IMMEDIATE);
543
+    chMBPostTimeout(&cfg->prl.tx_mailbox, (msg_t) snk_cap, TIME_IMMEDIATE);
544 544
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
545 545
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
546 546
             | PDB_EVT_PE_RESET);
@@ -606,7 +606,7 @@ static enum policy_engine_state pe_sink_soft_reset(struct pdb_config *cfg)
606 606
     /* Make an Accept message */
607 607
     accept->hdr = cfg->pe.hdr_template | PD_MSGTYPE_ACCEPT | PD_NUMOBJ(0);
608 608
     /* Transmit the Accept */
609
-    chMBPost(&cfg->prl.tx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
609
+    chMBPostTimeout(&cfg->prl.tx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
610 610
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
611 611
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
612 612
             | PDB_EVT_PE_RESET);
@@ -635,7 +635,7 @@ static enum policy_engine_state pe_sink_send_soft_reset(struct pdb_config *cfg)
635 635
     /* Make a Soft_Reset message */
636 636
     softrst->hdr = cfg->pe.hdr_template | PD_MSGTYPE_SOFT_RESET | PD_NUMOBJ(0);
637 637
     /* Transmit the soft reset */
638
-    chMBPost(&cfg->prl.tx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
638
+    chMBPostTimeout(&cfg->prl.tx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
639 639
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
640 640
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
641 641
             | PDB_EVT_PE_RESET);
@@ -664,7 +664,7 @@ static enum policy_engine_state pe_sink_send_soft_reset(struct pdb_config *cfg)
664 664
     }
665 665
 
666 666
     /* Get the response message */
667
-    if (chMBFetch(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
667
+    if (chMBFetchTimeout(&cfg->pe.mailbox, (msg_t *) &cfg->pe._message, TIME_IMMEDIATE) == MSG_OK) {
668 668
         /* If the source accepted our soft reset, wait for capabilities. */
669 669
         if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_ACCEPT
670 670
                 && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
@@ -701,7 +701,7 @@ static enum policy_engine_state pe_sink_send_not_supported(struct pdb_config *cf
701 701
     }
702 702
 
703 703
     /* Transmit the message */
704
-    chMBPost(&cfg->prl.tx_mailbox, (msg_t) not_supported, TIME_IMMEDIATE);
704
+    chMBPostTimeout(&cfg->prl.tx_mailbox, (msg_t) not_supported, TIME_IMMEDIATE);
705 705
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
706 706
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
707 707
             | PDB_EVT_PE_RESET);

+ 1
- 1
lib/src/protocol_rx.c Zobrazit soubor

@@ -136,7 +136,7 @@ static enum protocol_rx_state protocol_rx_store_messageid(struct pdb_config *cfg
136 136
     cfg->prl._rx_messageid = PD_MESSAGEID_GET(cfg->prl._rx_message);
137 137
 
138 138
     /* Pass the message to the policy engine. */
139
-    chMBPost(&cfg->pe.mailbox, (msg_t) cfg->prl._rx_message, TIME_IMMEDIATE);
139
+    chMBPostTimeout(&cfg->pe.mailbox, (msg_t) cfg->prl._rx_message, TIME_IMMEDIATE);
140 140
     chEvtSignal(cfg->pe.thread, PDB_EVT_PE_MSG_RX);
141 141
 
142 142
     /* Don't check if we got a RESET because we'd do nothing different. */

+ 1
- 1
lib/src/protocol_tx.c Zobrazit soubor

@@ -84,7 +84,7 @@ static enum protocol_tx_state protocol_tx_wait_message(struct pdb_config *cfg)
84 84
     /* If the policy engine is trying to send a message */
85 85
     if (evt & PDB_EVT_PRLTX_MSG_TX) {
86 86
         /* Get the message */
87
-        chMBFetch(&cfg->prl.tx_mailbox, (msg_t *) &cfg->prl._tx_message, TIME_IMMEDIATE);
87
+        chMBFetchTimeout(&cfg->prl.tx_mailbox, (msg_t *) &cfg->prl._tx_message, TIME_IMMEDIATE);
88 88
         /* If it's a Soft_Reset, reset the TX layer first */
89 89
         if (PD_MSGTYPE_GET(cfg->prl._tx_message) == PD_MSGTYPE_SOFT_RESET
90 90
                 && PD_NUMOBJ_GET(cfg->prl._tx_message) == 0) {

+ 11
- 11
mcuconf.h Zobrazit soubor

@@ -17,7 +17,7 @@
17 17
  */
18 18
 
19 19
 /*
20
-    ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
20
+    ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
21 21
 
22 22
     Licensed under the Apache License, Version 2.0 (the "License");
23 23
     you may not use this file except in compliance with the License.
@@ -78,6 +78,16 @@
78 78
 #define STM32_USART1SW                      STM32_USART1SW_PCLK
79 79
 #define STM32_RTCSEL                        STM32_RTCSEL_LSI
80 80
 
81
+/*
82
+ * IRQ system settings.
83
+ */
84
+#define STM32_IRQ_EXTI0_1_IRQ_PRIORITY      3
85
+#define STM32_IRQ_EXTI2_3_IRQ_PRIORITY      3
86
+#define STM32_IRQ_EXTI4_15_IRQ_PRIORITY     3
87
+#define STM32_IRQ_EXTI16_IRQ_PRIORITY       3
88
+#define STM32_IRQ_EXTI17_20_IRQ_PRIORITY    3
89
+#define STM32_IRQ_EXTI21_22_IRQ_PRIORITY    3
90
+
81 91
 /*
82 92
  * ADC driver system settings.
83 93
  */
@@ -106,16 +116,6 @@
106 116
 #define STM32_DAC_DAC1_CH1_DMA_STREAM       STM32_DMA_STREAM_ID(1, 3)
107 117
 #define STM32_DAC_DAC1_CH2_DMA_STREAM       STM32_DMA_STREAM_ID(1, 4)
108 118
 
109
-/*
110
- * EXT driver system settings.
111
- */
112
-#define STM32_EXT_EXTI0_1_IRQ_PRIORITY      3
113
-#define STM32_EXT_EXTI2_3_IRQ_PRIORITY      3
114
-#define STM32_EXT_EXTI4_15_IRQ_PRIORITY     3
115
-#define STM32_EXT_EXTI16_IRQ_PRIORITY       3
116
-#define STM32_EXT_EXTI17_20_IRQ_PRIORITY    3
117
-#define STM32_EXT_EXTI21_22_IRQ_PRIORITY    3
118
-
119 119
 /*
120 120
  * GPT driver system settings.
121 121
  */

+ 3
- 3
src/led.c Zobrazit soubor

@@ -23,9 +23,9 @@
23 23
 #include "priorities.h"
24 24
 
25 25
 /* Delays for blink modes */
26
-#define LED_FAST MS2ST(125)
27
-#define LED_MEDIUM MS2ST(250)
28
-#define LED_SLOW MS2ST(500)
26
+#define LED_FAST TIME_MS2I(125)
27
+#define LED_MEDIUM TIME_MS2I(250)
28
+#define LED_SLOW TIME_MS2I(500)
29 29
 
30 30
 /* Number of blinks for temporary modes */
31 31
 #define LED_MEDIUM_BLINKS 3

Loading…
Zrušit
Uložit