2016-11-02 22:34:02 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 RnDity Sp. z o.o.
|
|
|
|
*
|
2017-01-19 23:38:51 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-11-02 22:34:02 +08:00
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_DRIVERS_FLASH_FLASH_STM32F3X_H_
|
|
|
|
#define ZEPHYR_DRIVERS_FLASH_FLASH_STM32F3X_H_
|
2016-11-02 22:34:02 +08:00
|
|
|
|
|
|
|
#include <soc.h>
|
|
|
|
#include <flash.h>
|
|
|
|
#include <clock_control.h>
|
|
|
|
#include <flash_registers.h>
|
|
|
|
|
|
|
|
struct flash_stm32_dev_config {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t *base;
|
2017-01-24 18:31:43 +08:00
|
|
|
struct stm32_pclken pclken;
|
2016-11-02 22:34:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct flash_stm32_dev_data {
|
|
|
|
/* For future use. */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FLASH_CFG(dev) \
|
|
|
|
((const struct flash_stm32_dev_config * const)(dev)->config->config_info)
|
|
|
|
#define FLASH_DATA(dev) \
|
|
|
|
((struct flash_stm32_dev_data * const)(dev)->driver_data)
|
|
|
|
#define FLASH_STRUCT(base) \
|
|
|
|
(volatile struct stm32_flash *)(base)
|
|
|
|
|
|
|
|
/* Flash programming timeout definition. */
|
2017-04-21 23:03:20 +08:00
|
|
|
#define FLASH_ER_PRG_TIMEOUT ((u32_t)0x000B0000)
|
2016-11-02 22:34:02 +08:00
|
|
|
|
|
|
|
enum flash_status {
|
|
|
|
FLASH_BUSY = 1,
|
|
|
|
FLASH_ERROR_WRITE_PROTECTION,
|
|
|
|
FLASH_ERROR_PROGRAM,
|
|
|
|
FLASH_COMPLETE,
|
|
|
|
FLASH_TIMEOUT
|
|
|
|
};
|
|
|
|
|
|
|
|
void flash_stm32_lock(struct device *flash);
|
|
|
|
|
|
|
|
void flash_stm32_unlock(struct device *flash);
|
|
|
|
|
2017-04-21 23:03:20 +08:00
|
|
|
u8_t flash_stm32_program_halfword(struct device *flash,
|
|
|
|
u32_t address,
|
|
|
|
u16_t data);
|
2016-11-02 22:34:02 +08:00
|
|
|
|
2017-04-21 23:03:20 +08:00
|
|
|
u8_t flash_stm32_program_word(struct device *flash,
|
|
|
|
u32_t address,
|
|
|
|
u32_t data);
|
2016-11-02 22:34:02 +08:00
|
|
|
|
2017-04-21 23:03:20 +08:00
|
|
|
void flash_stm32_read_data(void *data, u32_t address, size_t len);
|
2016-11-02 22:34:02 +08:00
|
|
|
|
2017-04-21 23:03:20 +08:00
|
|
|
u8_t flash_stm32_wait_for_last_operation(struct device *flash,
|
|
|
|
u32_t timeout);
|
2016-11-02 22:34:02 +08:00
|
|
|
|
2017-04-21 23:03:20 +08:00
|
|
|
u8_t flash_stm32_get_status(struct device *flash);
|
2016-11-02 22:34:02 +08:00
|
|
|
|
2017-04-21 23:03:20 +08:00
|
|
|
u8_t flash_stm32_erase_page(struct device *flash,
|
|
|
|
u32_t page_address);
|
2016-11-02 22:34:02 +08:00
|
|
|
|
2017-04-21 23:03:20 +08:00
|
|
|
u8_t flash_stm32_erase_all_pages(struct device *flash);
|
2016-11-02 22:34:02 +08:00
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_DRIVERS_FLASH_FLASH_STM32F3X_H_ */
|