aboutsummaryrefslogtreecommitdiff
path: root/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'platforms')
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_H723XG/configs/mcuconf.h2
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h23
-rw-r--r--platforms/chibios/boards/common/configs/chconf.h23
-rw-r--r--platforms/chibios/drivers/audio_pwm_hardware.c18
-rw-r--r--platforms/chibios/timer.c4
-rw-r--r--platforms/timer.h7
6 files changed, 64 insertions, 13 deletions
diff --git a/platforms/chibios/boards/GENERIC_STM32_H723XG/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_H723XG/configs/mcuconf.h
index 0239ec5273..09096c3977 100644
--- a/platforms/chibios/boards/GENERIC_STM32_H723XG/configs/mcuconf.h
+++ b/platforms/chibios/boards/GENERIC_STM32_H723XG/configs/mcuconf.h
@@ -182,6 +182,7 @@
#define STM32_IRQ_FDCAN1_PRIORITY 10
#define STM32_IRQ_FDCAN2_PRIORITY 10
+#define STM32_IRQ_FDCAN3_PRIORITY 10
#define STM32_IRQ_MDMA_PRIORITY 9
@@ -235,6 +236,7 @@
*/
#define STM32_CAN_USE_FDCAN1 FALSE
#define STM32_CAN_USE_FDCAN2 FALSE
+#define STM32_CAN_USE_FDCAN3 FALSE
/*
* DAC driver system settings.
diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h b/platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h
index cc10304a3f..e92b7aeb98 100644
--- a/platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h
+++ b/platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h
@@ -49,6 +49,19 @@
#define CH_CFG_SMP_MODE FALSE
#endif
+/**
+ * @brief Kernel hardening level.
+ * @details This option is the level of functional-safety checks enabled
+ * in the kerkel. The meaning is:
+ * - 0: No checks, maximum performance.
+ * - 1: Reasonable checks.
+ * - 2: All checks.
+ * .
+ */
+#if !defined(CH_CFG_HARDENING_LEVEL)
+#define CH_CFG_HARDENING_LEVEL 0
+#endif
+
/** @} */
/*===========================================================================*/
@@ -361,6 +374,16 @@
#endif
/**
+ * @brief Memory checks APIs.
+ * @details If enabled then the memory checks APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_CFG_USE_MEMCHECKS)
+#define CH_CFG_USE_MEMCHECKS TRUE
+#endif
+
+/**
* @brief Core Memory Manager APIs.
* @details If enabled then the core memory manager APIs are included
* in the kernel.
diff --git a/platforms/chibios/boards/common/configs/chconf.h b/platforms/chibios/boards/common/configs/chconf.h
index 5db836e37c..6381298ef7 100644
--- a/platforms/chibios/boards/common/configs/chconf.h
+++ b/platforms/chibios/boards/common/configs/chconf.h
@@ -49,6 +49,19 @@
#define CH_CFG_SMP_MODE FALSE
#endif
+/**
+ * @brief Kernel hardening level.
+ * @details This option is the level of functional-safety checks enabled
+ * in the kerkel. The meaning is:
+ * - 0: No checks, maximum performance.
+ * - 1: Reasonable checks.
+ * - 2: All checks.
+ * .
+ */
+#if !defined(CH_CFG_HARDENING_LEVEL)
+#define CH_CFG_HARDENING_LEVEL 0
+#endif
+
/** @} */
/*===========================================================================*/
@@ -361,6 +374,16 @@
#endif
/**
+ * @brief Memory checks APIs.
+ * @details If enabled then the memory checks APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_CFG_USE_MEMCHECKS)
+#define CH_CFG_USE_MEMCHECKS TRUE
+#endif
+
+/**
* @brief Core Memory Manager APIs.
* @details If enabled then the core memory manager APIs are included
* in the kernel.
diff --git a/platforms/chibios/drivers/audio_pwm_hardware.c b/platforms/chibios/drivers/audio_pwm_hardware.c
index 1ba7ec13bc..afa341abb6 100644
--- a/platforms/chibios/drivers/audio_pwm_hardware.c
+++ b/platforms/chibios/drivers/audio_pwm_hardware.c
@@ -41,18 +41,19 @@ static float channel_1_frequency = 0.0f;
void channel_1_set_frequency(float freq) {
channel_1_frequency = freq;
+ pwmcnt_t period;
+ pwmcnt_t width;
if (freq <= 0.0) {
- // a pause/rest has freq=0
- return;
+ period = 2;
+ width = 0;
+ } else {
+ period = (pwmCFG.frequency / freq);
+ width = (pwmcnt_t)(((period) * (pwmcnt_t)((100 - note_timbre) * 100)) / (pwmcnt_t)(10000));
}
-
- pwmcnt_t period = (pwmCFG.frequency / freq);
chSysLockFromISR();
pwmChangePeriodI(&AUDIO_PWM_DRIVER, period);
- pwmEnableChannelI(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1,
- // adjust the duty-cycle so that the output is for 'note_timbre' duration HIGH
- PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100));
+ pwmEnableChannelI(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1, width);
chSysUnlockFromISR();
}
@@ -67,6 +68,9 @@ void channel_1_start(void) {
void channel_1_stop(void) {
pwmStop(&AUDIO_PWM_DRIVER);
+ pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
+ pwmEnableChannel(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1, 0);
+ pwmStop(&AUDIO_PWM_DRIVER);
}
static virtual_timer_t audio_vt;
diff --git a/platforms/chibios/timer.c b/platforms/chibios/timer.c
index 4a347b445d..a07cf5714f 100644
--- a/platforms/chibios/timer.c
+++ b/platforms/chibios/timer.c
@@ -99,7 +99,7 @@ uint16_t timer_read(void) {
}
uint32_t timer_read32(void) {
- chSysLock();
+ syssts_t sts = chSysGetStatusAndLockX();
uint32_t ticks = get_system_time_ticks() - ticks_offset;
if (ticks < last_ticks) {
// The 32-bit tick counter overflowed and wrapped around. We cannot just extend the counter to 64 bits here,
@@ -114,7 +114,7 @@ uint32_t timer_read32(void) {
}
last_ticks = ticks;
uint32_t ms_offset_copy = ms_offset; // read while still holding the lock to ensure a consistent value
- chSysUnlock();
+ chSysRestoreStatusX(sts);
return (uint32_t)TIME_I2MS(ticks) + ms_offset_copy;
}
diff --git a/platforms/timer.h b/platforms/timer.h
index fb8ff6bc54..8a2ffd476b 100644
--- a/platforms/timer.h
+++ b/platforms/timer.h
@@ -24,10 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
-#define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a)))))
-#define TIMER_DIFF_8(a, b) TIMER_DIFF(a, b, UINT8_MAX)
-#define TIMER_DIFF_16(a, b) TIMER_DIFF(a, b, UINT16_MAX)
-#define TIMER_DIFF_32(a, b) TIMER_DIFF(a, b, UINT32_MAX)
+#define TIMER_DIFF_8(a, b) (uint8_t)((a) - (b))
+#define TIMER_DIFF_16(a, b) (uint16_t)((a) - (b))
+#define TIMER_DIFF_32(a, b) (uint32_t)((a) - (b))
#define TIMER_DIFF_RAW(a, b) TIMER_DIFF_8(a, b)
#ifdef __cplusplus