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).
This commit is contained in:
parent
6f1e857624
commit
a6009a9e35
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue