2016-03-16 19:54:03 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Open-RnD Sp. z o.o.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-03-16 19:54:03 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STM32_IWDG_H_
|
|
|
|
#define _STM32_IWDG_H_
|
|
|
|
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 23:32:08 +08:00
|
|
|
#include <zephyr/types.h>
|
2016-03-16 19:54:03 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Driver for Independent Watchdog (IWDG) for STM32 MCUs
|
|
|
|
*
|
|
|
|
* Based on reference manual:
|
|
|
|
* STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and STM32F107xx
|
|
|
|
* advanced ARM ® -based 32-bit MCUs
|
|
|
|
*
|
|
|
|
* Chapter 19: Independent watchdog (IWDG)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* counter reload trigger */
|
|
|
|
#define STM32_IWDG_KR_RELOAD 0xaaaa
|
|
|
|
/* magic value for unlocking write access to PR and RLR */
|
|
|
|
#define STM32_IWDG_KR_UNLOCK 0x5555
|
|
|
|
/* watchdog start */
|
|
|
|
#define STM32_IWDG_KR_START 0xcccc
|
|
|
|
|
|
|
|
/* 19.4.1 IWDG_KR */
|
|
|
|
union __iwdg_kr {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t val;
|
2016-03-16 19:54:03 +08:00
|
|
|
struct {
|
2017-04-21 23:03:20 +08:00
|
|
|
u16_t key;
|
|
|
|
u16_t rsvd;
|
2016-03-16 19:54:03 +08:00
|
|
|
} bit;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 19.4.2 IWDG_PR */
|
|
|
|
union __iwdg_pr {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t val;
|
2016-03-16 19:54:03 +08:00
|
|
|
struct {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t pr :3 __packed;
|
|
|
|
u32_t rsvd__3_31 :29 __packed;
|
2016-03-16 19:54:03 +08:00
|
|
|
} bit;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 19.4.3 IWDG_RLR */
|
|
|
|
union __iwdg_rlr {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t val;
|
2016-03-16 19:54:03 +08:00
|
|
|
struct {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t rl :12 __packed;
|
|
|
|
u32_t rsvd__12_31 :20 __packed;
|
2016-03-16 19:54:03 +08:00
|
|
|
} bit;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 19.4.4 IWDG_SR */
|
|
|
|
union __iwdg_sr {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t val;
|
2016-03-16 19:54:03 +08:00
|
|
|
struct {
|
2017-04-21 23:03:20 +08:00
|
|
|
u32_t pvu :1 __packed;
|
|
|
|
u32_t rvu :1 __packed;
|
|
|
|
u32_t rsvd__2_31 :30 __packed;
|
2016-03-16 19:54:03 +08:00
|
|
|
} bit;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 19.4.5 IWDG register map */
|
|
|
|
struct iwdg_stm32 {
|
|
|
|
union __iwdg_kr kr;
|
|
|
|
union __iwdg_pr pr;
|
|
|
|
union __iwdg_rlr rlr;
|
|
|
|
union __iwdg_sr sr;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _STM32_IWDG_H_ */
|