@@ -84,8 +84,8 @@ static void iwdg_stm32_convert_timeout(uint32_t timeout,
8484
8585static int iwdg_stm32_setup (const struct device * dev , uint8_t options )
8686{
87- struct iwdg_stm32_data * data = IWDG_STM32_DATA ( dev ) ;
88- IWDG_TypeDef * iwdg = IWDG_STM32_STRUCT ( dev ) ;
87+ const struct iwdg_stm32_config * cfg = dev -> config ;
88+ struct iwdg_stm32_data * data = dev -> data ;
8989 uint32_t tickstart ;
9090
9191 /* Deactivate running when debugger is attached. */
@@ -111,23 +111,23 @@ static int iwdg_stm32_setup(const struct device *dev, uint8_t options)
111111 }
112112
113113 /* Enable the IWDG now and write IWDG registers at the same time */
114- LL_IWDG_Enable (iwdg );
115- LL_IWDG_EnableWriteAccess (iwdg );
114+ LL_IWDG_Enable (cfg -> instance );
115+ LL_IWDG_EnableWriteAccess (cfg -> instance );
116116 /* Write the prescaler and reload counter to the IWDG registers*/
117- LL_IWDG_SetPrescaler (iwdg , data -> prescaler );
118- LL_IWDG_SetReloadCounter (iwdg , data -> reload );
117+ LL_IWDG_SetPrescaler (cfg -> instance , data -> prescaler );
118+ LL_IWDG_SetReloadCounter (cfg -> instance , data -> reload );
119119
120120 tickstart = k_uptime_get_32 ();
121121
122122 /* Wait for the update operation completed */
123- while (LL_IWDG_IsReady (iwdg ) == 0 ) {
123+ while (LL_IWDG_IsReady (cfg -> instance ) == 0 ) {
124124 if ((k_uptime_get_32 () - tickstart ) > IWDG_SR_UPDATE_TIMEOUT ) {
125125 return - ENODEV ;
126126 }
127127 }
128128
129129 /* Reload counter just before leaving */
130- LL_IWDG_ReloadCounter (iwdg );
130+ LL_IWDG_ReloadCounter (cfg -> instance );
131131
132132 return 0 ;
133133}
@@ -143,7 +143,7 @@ static int iwdg_stm32_disable(const struct device *dev)
143143static int iwdg_stm32_install_timeout (const struct device * dev ,
144144 const struct wdt_timeout_cfg * config )
145145{
146- struct iwdg_stm32_data * data = IWDG_STM32_DATA ( dev ) ;
146+ struct iwdg_stm32_data * data = dev -> data ;
147147 uint32_t timeout = config -> window .max * USEC_PER_MSEC ;
148148 uint32_t prescaler = 0U ;
149149 uint32_t reload = 0U ;
@@ -175,10 +175,10 @@ static int iwdg_stm32_install_timeout(const struct device *dev,
175175
176176static int iwdg_stm32_feed (const struct device * dev , int channel_id )
177177{
178- IWDG_TypeDef * iwdg = IWDG_STM32_STRUCT ( dev ) ;
178+ const struct iwdg_stm32_config * cfg = dev -> config ;
179179
180180 ARG_UNUSED (channel_id );
181- LL_IWDG_ReloadCounter (iwdg );
181+ LL_IWDG_ReloadCounter (cfg -> instance );
182182
183183 return 0 ;
184184}
@@ -214,11 +214,12 @@ static int iwdg_stm32_init(const struct device *dev)
214214 return 0 ;
215215}
216216
217- static struct iwdg_stm32_data iwdg_stm32_dev_data = {
218- .Instance = (IWDG_TypeDef * )DT_INST_REG_ADDR (0 )
217+ static const struct iwdg_stm32_config iwdg_stm32_dev_cfg = {
218+ .instance = (IWDG_TypeDef * )DT_INST_REG_ADDR (0 ),
219219};
220+ static struct iwdg_stm32_data iwdg_stm32_dev_data ;
220221
221222DEVICE_DT_INST_DEFINE (0 , iwdg_stm32_init , NULL ,
222- & iwdg_stm32_dev_data , NULL ,
223+ & iwdg_stm32_dev_data , & iwdg_stm32_dev_cfg ,
223224 POST_KERNEL , CONFIG_KERNEL_INIT_PRIORITY_DEVICE ,
224225 & iwdg_stm32_api );
0 commit comments