@@ -231,8 +231,8 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
231231 return rc ;
232232}
233233
234- static __unused int write_optb (const struct device * dev , uint32_t mask ,
235- uint32_t value )
234+ int flash_stm32_option_bytes_write (const struct device * dev , uint32_t mask ,
235+ uint32_t value )
236236{
237237 FLASH_TypeDef * regs = FLASH_STM32_REGS (dev );
238238 int rc ;
@@ -264,6 +264,13 @@ static __unused int write_optb(const struct device *dev, uint32_t mask,
264264 return 0 ;
265265}
266266
267+ uint32_t flash_stm32_option_bytes_read (const struct device * dev )
268+ {
269+ FLASH_TypeDef * regs = FLASH_STM32_REGS (dev );
270+
271+ return regs -> OPTCR ;
272+ }
273+
267274#if defined(CONFIG_FLASH_STM32_WRITE_PROTECT )
268275int flash_stm32_update_wp_sectors (const struct device * dev ,
269276 uint32_t changed_sectors ,
@@ -279,7 +286,8 @@ int flash_stm32_update_wp_sectors(const struct device *dev,
279286 /* Sector is protected when bit == 0. Flip protected_sectors bits */
280287 protected_sectors = ~protected_sectors & changed_sectors ;
281288
282- return write_optb (dev , changed_sectors , protected_sectors );
289+ return flash_stm32_option_bytes_write (dev , changed_sectors ,
290+ protected_sectors );
283291}
284292
285293int flash_stm32_get_wp_sectors (const struct device * dev ,
@@ -304,8 +312,8 @@ uint8_t flash_stm32_get_rdp_level(const struct device *dev)
304312
305313void flash_stm32_set_rdp_level (const struct device * dev , uint8_t level )
306314{
307- write_optb (dev , FLASH_OPTCR_RDP_Msk ,
308- (uint32_t )level << FLASH_OPTCR_RDP_Pos );
315+ flash_stm32_option_bytes_write (dev , FLASH_OPTCR_RDP_Msk ,
316+ (uint32_t )level << FLASH_OPTCR_RDP_Pos );
309317}
310318#endif /* CONFIG_FLASH_STM32_READOUT_PROTECTION */
311319
0 commit comments