SmartSnippets DA1459x SDK
hw_sys.h
Go to the documentation of this file.
1 
42 #ifndef HW_SYS_H_
43 #define HW_SYS_H_
44 #if dg_configUSE_HW_SYS
45 
46 #include "sdk_defs.h"
47 #include "hw_pd.h"
48 
49 #include <hw_memctrl.h>
50 
51 /* \brief Specifies the HW BSR mask used for accessing the SW BSR */
52 #define SW_BSR_HW_BSR_MASK (0x3)
53 
54 /*
55  * \brief Enumerations used when accessing the HW BSR register
56  */
57 typedef enum {
58  HW_BSR_MASTER_NONE = 0,
59  HW_BSR_MASTER_SYSCPU = 2,
60  HW_BSR_MASTER_CMAC = 3,
61  HW_BSR_MASTER_NUM,
62 } HW_BSR_MASTER_ID;
63 
64 /*
65  * \brief HW BSR position
66  */
67 typedef enum {
68  HW_BSR_SW_POS = 0,
69  HW_BSR_POWER_CTRL_POS = 28,
70  HW_BSR_WAKEUP_CONFIG_POS = 30,
71 } HW_BSR_POS;
72 
73 /*
74  * \brief Enumerations used when accessing the SW BSR variable
75  */
76 typedef enum {
77  SW_BSR_MASTER_NONE = 1 << HW_BSR_MASTER_NONE,
78  SW_BSR_MASTER_SYSCPU = 1 << HW_BSR_MASTER_SYSCPU,
79  SW_BSR_MASTER_CMAC = 1 << HW_BSR_MASTER_CMAC,
80 } SW_BSR_MASTER_ID;
81 
82 typedef enum {
83  BSR_PERIPH_ID_SPI = 1,
84  BSR_PERIPH_ID_UART1 = 2,
85  BSR_PERIPH_ID_UART2 = 3,
86  BSR_PERIPH_ID_I2C = 4,
87  BSR_PERIPH_ID_GPADC = 5,
88  BSR_PERIPH_ID_SDADC = 6,
89  BSR_PERIPH_ID_MAX = 14,
90 } HW_SYS_BSR_PERIPH_ID;
91 
96 typedef struct {
97  __IO uint32_t *addr;
98  uint32_t value;
100 
101 /*
102  * Export hw_sys_sw_bsr so that other masters have access to its address.
103  */
104 extern __RETAINED uint32_t hw_sys_sw_bsr[BSR_PERIPH_ID_MAX];
105 
106 typedef enum {
107  HW_SYS_REMAP_ADDRESS_0_TO_ROM,
108  HW_SYS_REMAP_ADDRESS_0_TO_EFLASH,
109  HW_SYS_REMAP_ADDRESS_0_TO_QSPI_FLASH,
110  HW_SYS_REMAP_ADDRESS_0_TO_RAM,
111 } HW_SYS_REMAP_ADDRESS_0;
112 
113 __STATIC_INLINE void hw_sys_set_memory_remapping(HW_SYS_REMAP_ADDRESS_0 value)
114 {
116  REG_SETF(CRG_TOP, SYS_CTRL_REG, REMAP_ADR0, value);
118 }
119 
120 __STATIC_INLINE HW_SYS_REMAP_ADDRESS_0 hw_sys_get_memory_remapping(void)
121 {
122  HW_SYS_REMAP_ADDRESS_0 value;
124  value = REG_GETF(CRG_TOP, SYS_CTRL_REG, REMAP_ADR0);
126  return value;
127 }
128 
133 __STATIC_INLINE void hw_sys_set_cache_retained(void)
134 {
136  REG_SET_BIT(CRG_TOP, PMU_CTRL_REG, RETAIN_CACHE);
138 }
139 
140 
145 __STATIC_INLINE void hw_sys_setup_retmem(void)
146 {
148 
149  CRG_TOP->RAM_PWR_CTRL_REG = dg_configMEM_RETENTION_MODE;
150 
152 }
153 
158 __STATIC_INLINE void hw_sys_no_retmem(void)
159 {
161  REG_CLR_BIT(CRG_TOP, PMU_CTRL_REG, RETAIN_CACHE);
162  CRG_TOP->RAM_PWR_CTRL_REG = RETMEM_RETAIN_NONE;
164 }
165 
169 __STATIC_FORCEINLINE void hw_sys_track_reset_type(void)
170 {
171  CRG_TOP->RESET_STAT_REG = 0;
172 }
173 
174 
179 __STATIC_INLINE void hw_sys_enable_reset_on_wup(void)
180 {
182  REG_SET_BIT(CRG_TOP, PMU_CTRL_REG, RESET_ON_WAKEUP);
184 }
185 
192 
197 void hw_sys_setup_sw_cursor(void);
198 
203 void hw_sys_trigger_sw_cursor(void);
204 
209 __STATIC_FORCEINLINE void hw_sys_enable_debugger(void)
210 {
212  REG_SET_BIT(CRG_TOP, SYS_CTRL_REG, DEBUGGER_ENABLE);
214 }
215 
220 __STATIC_FORCEINLINE void hw_sys_disable_debugger(void)
221 {
223  REG_CLR_BIT(CRG_TOP, SYS_CTRL_REG, DEBUGGER_ENABLE);
225 }
226 
233 __STATIC_FORCEINLINE bool hw_sys_is_debugger_attached(void)
234 {
235  return (REG_GETF(CRG_TOP, SYS_STAT_REG, DBG_IS_ACTIVE) != 0);
236 }
237 
238 
243 __STATIC_FORCEINLINE void hw_sys_enable_hibernation(void)
244 {
246  REG_SET_BIT(CRG_TOP, HIBERN_CTRL_REG, HIBERNATION_ENABLE);
248 }
249 
257 __STATIC_FORCEINLINE void hw_sys_enable_cmac_cache_ram(void)
258 {
260  REG_SET_BIT(CRG_TOP, CLK_RADIO_REG, CMAC_CLK_ENABLE);
261 }
262 
269 __STATIC_FORCEINLINE void hw_sys_disable_cmac_cache_ram(void)
270 {
271  REG_CLR_BIT(CRG_TOP, CLK_RADIO_REG, CMAC_CLK_ENABLE);
273 }
274 
275 
280 __ALWAYS_RETAINED_CODE void hw_sys_assert_trigger_gpio(void);
281 
287 
293 
294 
319 __STATIC_FORCEINLINE void hw_sys_set_por_timer(uint8_t time)
320 {
321  ASSERT_WARNING(time <= (REG_MSK(CRG_TOP, POR_TIMER_REG, POR_TIME)
322  >> REG_POS(CRG_TOP, POR_TIMER_REG, POR_TIME)));
323  REG_SETF(CRG_TOP, POR_TIMER_REG, POR_TIME, time);
324 }
325 
335 bool hw_sys_hw_bsr_try_lock(HW_BSR_MASTER_ID hw_bsr_master_id, HW_BSR_POS pos);
336 
344 void hw_sys_hw_bsr_unlock(HW_BSR_MASTER_ID hw_bsr_master_id, HW_BSR_POS pos);
345 
349 void hw_sys_sw_bsr_init(void);
350 
361 bool hw_sys_sw_bsr_try_acquire(SW_BSR_MASTER_ID sw_bsr_master_id, uint32_t periph_id);
362 
372 bool hw_sys_sw_bsr_acquired(SW_BSR_MASTER_ID sw_bsr_master_id, uint32_t periph_id);
373 
382 void hw_sys_sw_bsr_release(SW_BSR_MASTER_ID sw_bsr_master_id, uint32_t periph_id);
383 
388 void hw_sys_pd_com_enable(void);
389 
394 void hw_sys_pd_com_disable(void);
395 
400 void hw_sys_pd_periph_enable(void);
401 
406 void hw_sys_pd_periph_disable(void);
407 
412 __RETAINED_CODE void hw_sys_pd_audio_enable(void);
413 
418 __RETAINED_CODE void hw_sys_pd_audio_disable(void);
419 
428 uint32_t hw_sys_reg_add_config(const hw_sys_reg_config_t *config, uint32_t num_of_entries);
429 
438 
446 void hw_sys_reg_modify_config(uint32_t index, __IO uint32_t *addr, uint32_t value);
447 
454 
461 __RETAINED_CODE void hw_sys_reg_apply_config(void);
473 void hw_sys_apply_default_values(void);
474 
475 
476 #endif /* dg_configUSE_HW_SYS */
477 #endif /* HW_SYS_H_ */
478 
REG_POS
#define REG_POS(base, reg, field)
Access register field position.
Definition: sdk_defs.h:591
hw_sys_setup_retmem
__STATIC_INLINE void hw_sys_setup_retmem(void)
Setup the Retention Memory configuration.
Definition: hw_sys.h:145
REG_SETF
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
HW_PD
HW_PD
Hardware power domains.
Definition: hw_pd.h:54
REG_CLR_BIT
#define REG_CLR_BIT(base, reg, field)
Clear a bit of a register.
Definition: sdk_defs.h:781
hw_sys_hw_bsr_unlock
void hw_sys_hw_bsr_unlock(HW_BSR_MASTER_ID hw_bsr_master_id, HW_BSR_POS pos)
Unlock a BSR entry.
hw_sys_enable_reset_on_wup
__STATIC_INLINE void hw_sys_enable_reset_on_wup(void)
Activate the "Reset on wake-up" functionality.
Definition: hw_sys.h:179
REG_SET_BIT
#define REG_SET_BIT(base, reg, field)
Set a bit of a register.
Definition: sdk_defs.h:766
__RETAINED
#define __RETAINED
Zero-initialized data retained memory attribute.
Definition: sdk_defs.h:312
hw_sys_is_debugger_attached
__STATIC_FORCEINLINE bool hw_sys_is_debugger_attached(void)
Check if the debugger is attached.
Definition: hw_sys.h:233
hw_sys_pd_com_disable
void hw_sys_pd_com_disable(void)
Disables the COM power domain. If it has not been enabled by any other modules, it will be disabled.
hw_sys_no_retmem
__STATIC_INLINE void hw_sys_no_retmem(void)
Disable memory retention.
Definition: hw_sys.h:158
hw_sys_assert_trigger_gpio
__ALWAYS_RETAINED_CODE void hw_sys_assert_trigger_gpio(void)
Trigger a GPIO when ASSERT_WARNING() or ASSERT_ERROR() hits.
hw_pd_power_up_rad
__STATIC_FORCEINLINE void hw_pd_power_up_rad(void)
Power up the Radio Power Domain.
Definition: hw_pd.h:111
hw_memctrl.h
Definition of API for the Memory Controller Low Level Driver.
sdk_defs.h
Central include header file with platform definitions.
dg_configMEM_RETENTION_MODE
#define dg_configMEM_RETENTION_MODE
Retention memory configuration.
Definition: bsp_memory_defaults_da1459x.h:216
hw_sys_reg_config_t::addr
__IO uint32_t * addr
Register address.
Definition: hw_sys.h:97
hw_sys_reg_add_config
uint32_t hw_sys_reg_add_config(const hw_sys_reg_config_t *config, uint32_t num_of_entries)
Add register configuration entries in the system register configuration table.
hw_sys_sw_bsr_try_acquire
bool hw_sys_sw_bsr_try_acquire(SW_BSR_MASTER_ID sw_bsr_master_id, uint32_t periph_id)
Tries to acquire exclusive access to a specific peripheral when it is also used by other masters (CMA...
hw_sys_pd_audio_disable
__RETAINED_CODE void hw_sys_pd_audio_disable(void)
Disables the AUDIO power domain. If it has not been enabled by any other modules, it will be disabled...
hw_sys_reg_get_num_of_config_entries
uint32_t * hw_sys_reg_get_num_of_config_entries(void)
Get the number of entries in the system register configuration table.
hw_sys_apply_default_values
void hw_sys_apply_default_values(void)
Checks whether there are register entries in CS for the following registers.
__IO
#define __IO
Definition: core_cm0.h:169
hw_sys_setup_sw_cursor
void hw_sys_setup_sw_cursor(void)
Set the GPIO used for the SW cursor to High-Z.
hw_sys_sw_bsr_init
void hw_sys_sw_bsr_init(void)
Initializes the software busy status register.
hw_sys_pd_com_enable
void hw_sys_pd_com_enable(void)
Enables the COM power domain.
hw_sys_pd_periph_enable
void hw_sys_pd_periph_enable(void)
Enables the PERIPH power domain.
hw_sys_enable_cmac_mem_protection
void hw_sys_enable_cmac_mem_protection(void)
Enables read only protection in CMAC code and data.
REG_MSK
#define REG_MSK(base, reg, field)
Access register field mask.
Definition: sdk_defs.h:583
hw_sys_enable_ivt_mem_protection
void hw_sys_enable_ivt_mem_protection(void)
Enables "Read-only by any privilege level" and "execute_never" memory protection of IVT.
hw_sys_disable_debugger
__STATIC_FORCEINLINE void hw_sys_disable_debugger(void)
Disable the debugger.
Definition: hw_sys.h:220
hw_sys_enable_hibernation
__STATIC_FORCEINLINE void hw_sys_enable_hibernation(void)
Enable hibernation mode.
Definition: hw_sys.h:243
hw_sys_reg_config_t
Register configuration.
Definition: hw_sys.h:96
hw_sys_sw_bsr_release
void hw_sys_sw_bsr_release(SW_BSR_MASTER_ID sw_bsr_master_id, uint32_t periph_id)
Releases the exclusive access from a specific peripheral so it it can be also used by other masters (...
hw_sys_reg_modify_config
void hw_sys_reg_modify_config(uint32_t index, __IO uint32_t *addr, uint32_t value)
Modify a register configuration entry.
hw_sys_set_preferred_values
void hw_sys_set_preferred_values(HW_PD pd)
Set the preferred settings of a power domain.
hw_pd.h
Power Domain Driver header file.
hw_pd_power_down_rad
__STATIC_INLINE void hw_pd_power_down_rad(void)
Power down the Radio Power Domain.
Definition: hw_pd.h:127
GLOBAL_INT_RESTORE
#define GLOBAL_INT_RESTORE()
Macro to restore all interrupts.
Definition: sdk_defs.h:477
hw_sys_hw_bsr_try_lock
bool hw_sys_hw_bsr_try_lock(HW_BSR_MASTER_ID hw_bsr_master_id, HW_BSR_POS pos)
Try to lock a BSR entry.
hw_sys_reg_config_t::value
uint32_t value
Register value.
Definition: hw_sys.h:98
hw_sys_sw_bsr_acquired
bool hw_sys_sw_bsr_acquired(SW_BSR_MASTER_ID sw_bsr_master_id, uint32_t periph_id)
Checks if exclusive access to a specific peripheral has been acquired from a given master.
hw_sys_trigger_sw_cursor
void hw_sys_trigger_sw_cursor(void)
Triggers the GPIO used for the SW cursor.
hw_sys_set_cache_retained
__STATIC_INLINE void hw_sys_set_cache_retained(void)
Enable Cache retainability.
Definition: hw_sys.h:133
REG_GETF
#define REG_GETF(base, reg, field)
Return the value of a register field.
Definition: sdk_defs.h:711
hw_sys_pd_periph_disable
void hw_sys_pd_periph_disable(void)
Disables the PERIPH power domain. If it has not been enabled by any other modules,...
hw_sys_set_por_timer
__STATIC_FORCEINLINE void hw_sys_set_por_timer(uint8_t time)
Set POR-trigger minimum duration.
Definition: hw_sys.h:319
hw_sys_disable_cmac_cache_ram
__STATIC_FORCEINLINE void hw_sys_disable_cmac_cache_ram(void)
Disable CMAC cache RAM.
Definition: hw_sys.h:269
hw_sys_reg_apply_config
__RETAINED_CODE void hw_sys_reg_apply_config(void)
Apply system register configuration.
hw_sys_pd_audio_enable
__RETAINED_CODE void hw_sys_pd_audio_enable(void)
Enables the AUDIO power domain.
hw_sys_enable_debugger
__STATIC_FORCEINLINE void hw_sys_enable_debugger(void)
Enable the debugger.
Definition: hw_sys.h:209
hw_sys_track_reset_type
__STATIC_FORCEINLINE void hw_sys_track_reset_type(void)
Prepare RESET type tracking.
Definition: hw_sys.h:169
hw_sys_reg_get_config
hw_sys_reg_config_t * hw_sys_reg_get_config(uint32_t index)
Get a register configuration entry.
GLOBAL_INT_DISABLE
#define GLOBAL_INT_DISABLE()
Macro to disable all interrupts.
Definition: sdk_defs.h:452
hw_sys_enable_cmac_cache_ram
__STATIC_FORCEINLINE void hw_sys_enable_cmac_cache_ram(void)
Enable CMAC cache RAM.
Definition: hw_sys.h:257