aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2018-03-27 20:38:57 +1100
committerDamien George2018-03-27 20:38:57 +1100
commita6009a9e3569b93fd2209f041576931bdc4811f0 (patch)
tree22ca3cc471f5cbfce34acdf31a3ecc8aa63d6fc0
parent6f1e85762409e815dfdd2d563173bf0e8634a6e6 (diff)
stm32/*bdev.c: Eliminate dependency on sys_tick_has_passed.
Explicitly writing out the implementation of sys_tick_has_passed makes these bdev files independent of systick.c and more reusable as a general component. It also reduces the code size slightly. The irq.h header is added to spibdev.c because it uses declarations in that file (irq.h is usually included implicitly via mphalport.h but not always).
-rw-r--r--ports/stm32/flashbdev.c3
-rw-r--r--ports/stm32/spibdev.c4
2 files changed, 3 insertions, 4 deletions
diff --git a/ports/stm32/flashbdev.c b/ports/stm32/flashbdev.c
index 64faf0eac..4245dd1ec 100644
--- a/ports/stm32/flashbdev.c
+++ b/ports/stm32/flashbdev.c
@@ -29,7 +29,6 @@
#include "py/obj.h"
#include "py/mperrno.h"
-#include "systick.h"
#include "led.h"
#include "flash.h"
#include "storage.h"
@@ -231,7 +230,7 @@ static void flash_bdev_irq_handler(void) {
// If not a forced write, wait at least 5 seconds after last write to flush
// On file close and flash unmount we get a forced write, so we can afford to wait a while
- if ((flash_flags & FLASH_FLAG_FORCE_WRITE) || sys_tick_has_passed(flash_tick_counter_last_write, 5000)) {
+ if ((flash_flags & FLASH_FLAG_FORCE_WRITE) || HAL_GetTick() - flash_tick_counter_last_write >= 5000) {
// sync the cache RAM buffer by writing it to the flash page
flash_write(flash_cache_sector_start, (const uint32_t*)CACHE_MEM_START_ADDR, flash_cache_sector_size / 4);
// clear the flash flags now that we have a clean cache
diff --git a/ports/stm32/spibdev.c b/ports/stm32/spibdev.c
index 007a96a6c..91ec4df5e 100644
--- a/ports/stm32/spibdev.c
+++ b/ports/stm32/spibdev.c
@@ -26,7 +26,7 @@
#include "py/obj.h"
#include "py/mperrno.h"
-#include "systick.h"
+#include "irq.h"
#include "led.h"
#include "storage.h"
@@ -39,7 +39,7 @@ int32_t spi_bdev_ioctl(spi_bdev_t *bdev, uint32_t op, uint32_t arg) {
return 0;
case BDEV_IOCTL_IRQ_HANDLER:
- if ((bdev->spiflash.flags & 1) && sys_tick_has_passed(bdev->flash_tick_counter_last_write, 1000)) {
+ if ((bdev->spiflash.flags & 1) && HAL_GetTick() - bdev->flash_tick_counter_last_write >= 1000) {
mp_spiflash_flush(&bdev->spiflash);
led_state(PYB_LED_RED, 0); // indicate a clean cache with LED off
}