gr55xx_sys.h
Go to the documentation of this file.
1
51 #ifndef __GR55XX_SYS_H__
52 #define __GR55XX_SYS_H__
53
54 #include "gr55xx_sys_cfg.h"
55 #include "gr55xx_nvds.h"
56 #include "gr55xx_pwr.h"
57 #include "gr55xx_fpb.h"
58 #include "ble.h"
59
60 #include <stdint.h>
61 #include <stdio.h>
62 #include <stdbool.h>
63 #include <stdarg.h>
64
68 #define SYS_INVALID_TIMER_ID 0xFF
69 #define SYS_BD_ADDR_LEN GAP_ADDR_LEN
70 #define SYS_CHIP_UID_LEN 0x10
71 #define SYS_SET_BD_ADDR(BD_ADDR_ARRAY) nvds_put(0xC001, SYS_BD_ADDR_LEN, BD_ADDR_ARRAY)
79 typedef void (*callback_t)(int);
80
82 typedef void (*timer_callback_t)(uint8_t timer_id);
83
85 typedef int (*vprintf_callback_t) (const char *fmt, va_list argp);
86
88 typedef void (*void_func_t)(void);
89
91 typedef int (*int_func_t)(void);
92
94 typedef void (*sys_context_func_t)(void);
95
97 typedef void (*assert_err_cb_t)(const char *expr, const char *file, int line);
98
100 typedef void (*assert_param_cb_t)(int param0, int param1, const char *file, int line);
101
103 typedef void (*assert_warn_cb_t)(int param0, int param1, const char *file, int line);
110 typedef enum
111 {
112 SYS_DEV_SRAM_64K = 0x02,
113 SYS_DEV_SRAM_128K = 0x01,
114 SYS_DEV_SRAM_256K = 0x00,
115 } sram_size_t;
116
118 typedef enum
119 {
120 PACKAGE_NONE = 0,
121 PACKAGE_GR5515RGBD = 1,
122 PACKAGE_GR5515GGBD = 2,
123 PACKAGE_GR5515IGND = 3,
124 PACKAGE_GR5515I0ND = 4,
125 PACKAGE_GR5513BEND = 5,
126 PACKAGE_GR5515BEND = 6,
127 PACKAGE_GR5513BENDU = 7,
128 } package_type_t;
135 typedef struct
136 {
137 uint8_t major;
138 uint8_t minor;
139 uint16_t build;
140 uint32_t commit_id;
141 }sdk_version_t;
142
144 typedef struct
145 {
146 assert_err_cb_t assert_err_cb;
147 assert_param_cb_t assert_param_cb;
148 assert_warn_cb_t assert_warn_cb;
149 }sys_assert_cb_t;
150
152 typedef struct
153 {
154 uint32_t rx_total_cnt;
155 uint32_t rx_sync_err_cnt;
156 uint32_t rx_crc_err_cnt;
157 uint32_t rx_other_err_cnt;
158 uint32_t rx_sn_err_cnt;
159 uint32_t rx_mic_err_cnt;
160 uint32_t rx_normal_cnt;
161 } link_rx_info_t;
162
164 typedef struct
165 {
166 int8_t rssi_cali;
167 int8_t tx_power;
168 } rf_trim_info_t;
169
171 typedef struct
172 {
173 uint16_t adc_temp;
174 uint16_t slope_int_0p8;
175 uint16_t offset_int_0p8;
176 uint16_t slope_int_1p2;
177 uint16_t offset_int_1p2;
178 uint16_t slope_int_1p6;
179 uint16_t offset_int_1p6;
180 uint16_t slope_int_2p0;
181 uint16_t offset_int_2p0;
182 uint16_t slope_ext_1p0;
183 uint16_t offset_ext_1p0;
184 } adc_trim_info_t;
185
187 typedef struct
188 {
189 uint8_t io_ldo_bypass;
190 uint8_t io_ldo_vout;
191 uint8_t dig_ldo_64m;
192 uint8_t dig_ldo_16m;
193 uint8_t dcdc_vout;
194 } pmu_trim_info_t;
195
208 void sys_app_printf(const char *format, ...);
209
217 void sys_delay_us(uint32_t us);
218
226 void sys_delay_ms(uint32_t ms);
227
237 void *sys_malloc(uint32_t size);
238
246 void sys_free(void *p_mem);
247
258 void sys_signal_handler_register(callback_t isr_handler);
259
269 void sys_sdk_verison_get(sdk_version_t *p_version);
270
279 void sys_context_save(void);
280
288 void restore_sys_context(void);
289
300 void sys_regs_save(volatile uint32_t *p_address, uint32_t value);
301
310 void sys_context_checksum_gen(void);
311
324 void sys_security_data_use_present(uint32_t addr, uint8_t *input, uint32_t size, uint8_t *output);
325
334 uint32_t sys_security_enable_status_check(void);
335
345 uint16_t sys_rf_trim_get(rf_trim_info_t *p_rf_trim);
346
356 uint16_t sys_adc_trim_get(adc_trim_info_t *p_adc_trim);
357
367 uint16_t sys_pmu_trim_get(pmu_trim_info_t *p_pmu_trim);
368
378 uint16_t sys_crystal_trim_get(uint16_t *p_crystal_trim);
379
387 void sys_firmware_jump(uint32_t fw_addr);
388
398 uint16_t sys_trim_sum_get(uint16_t *p_trim_sum);
399
409 uint16_t sys_device_addr_get(uint8_t *p_device_addr);
410
420 uint16_t sys_device_uid_get(uint8_t *p_device_uid);
421
431 uint16_t sys_device_lp_gain_offset_2m_get(uint8_t *p_offset);
432
442 uint16_t sys_device_sram_get(sram_size_t *p_sram_size);
443
453 uint16_t sys_device_package_get(package_type_t *p_package_type);
454
455
456 #if defined(GR5515_D)
457
469 uint16_t sys_get_efuse_io_ldo(uint16_t *io_ldo);
470
471 #endif
472
480 void sys_lpclk_set(uint32_t user_lpclk);
481
494 uint32_t sys_us_2_lpcycles(uint32_t us);
495
508 uint32_t sys_lpcycles_2_hus(uint32_t lpcycles, uint32_t *error_corr);
509
521 uint16_t sys_ble_heartbeat_period_set(uint32_t period_hus);
522
523
535 uint16_t sys_ble_heartbeat_period_get(uint32_t* p_period_hus);
536
548 void sys_max_msg_usage_ratio_set(uint8_t usage_ratio);
549
561 void sys_lld_max_msg_usage_ratio_set(uint8_t usage_ratio);
562
573 uint8_t sys_msg_usage_ratio_get(void);
574
585 uint8_t sys_env_usage_ratio_get(void);
586
597 uint8_t sys_attdb_usage_ratio_get(void);
598
609 uint8_t sys_nonret_usage_ratio_get(void);
610
621 uint8_t sys_link_quality_get(uint8_t conn_idx, link_rx_info_t* rx_info);
622
630 void sys_link_quality_clear(uint8_t conn_idx);
631
639 void sys_lpclk_update_func_register(void_func_t func_update_lpclk);
640
648 void sys_lpclk_update_func_with_return_register(int_func_t func_update_lpclk);
649
659 uint32_t sys_lpclk_get(void);
660
670 uint32_t sys_lpper_get(void);
671
679 void sys_assert_cb_register(sys_assert_cb_t *p_assert_cb);
680
687 bool sys_ke_sleep_check(void);
688
694 void sys_swd_enable(void);
695
701 void sys_swd_disable(void);
702
709 void rtc_calibration(void);
710
718 void rng_calibration(void);
719
726 uint32_t sys_reverse_word(uint32_t value);
727
734 uint16_t sys_reverse_hword(uint16_t value);
735
736
737
738
739
741 #endif
742
sys_lpcycles_2_hus
uint32_t sys_lpcycles_2_hus(uint32_t lpcycles, uint32_t *error_corr)
Convert a duration in lp cycles into a duration in half μs.
sram_size_t
sram_size_t
Definition of Device SRAM Size Enumerations.
Definition: gr55xx_sys.h:111
assert_warn_cb_t
void(* assert_warn_cb_t)(int param0, int param1, const char *file, int line)
Warning assert callback type.
Definition: gr55xx_sys.h:103
callback_t
void(* callback_t)(int)
The function pointers to register event callback.
Definition: gr55xx_sys.h:79
adc_trim_info_t::offset_int_1p2
uint16_t offset_int_1p2
Definition: gr55xx_sys.h:177
vprintf_callback_t
int(* vprintf_callback_t)(const char *fmt, va_list argp)
Printf callback type.
Definition: gr55xx_sys.h:85
pmu_trim_info_t::io_ldo_vout
uint8_t io_ldo_vout
Definition: gr55xx_sys.h:190
sdk_version_t::major
uint8_t major
Definition: gr55xx_sys.h:137
adc_trim_info_t::offset_int_2p0
uint16_t offset_int_2p0
Definition: gr55xx_sys.h:181
adc_trim_info_t::slope_int_1p6
uint16_t slope_int_1p6
Definition: gr55xx_sys.h:178
assert_err_cb_t
void(* assert_err_cb_t)(const char *expr, const char *file, int line)
Error assert callback type.
Definition: gr55xx_sys.h:97
sys_lld_max_msg_usage_ratio_set
void sys_lld_max_msg_usage_ratio_set(uint8_t usage_ratio)
Set system lld layer maximum usage ratio of message heap.
sys_reverse_word
uint32_t sys_reverse_word(uint32_t value)
Reverse byte order (32 bit). For example, 0x12345678 becomes 0x78563412.
sys_context_checksum_gen
void sys_context_checksum_gen(void)
Generate checksum info for system context.
sys_rf_trim_get
uint16_t sys_rf_trim_get(rf_trim_info_t *p_rf_trim)
Get the RF trim information.
link_rx_info_t::rx_other_err_cnt
uint32_t rx_other_err_cnt
Definition: gr55xx_sys.h:157
sys_lpclk_get
uint32_t sys_lpclk_get(void)
Get low power CLK frequency.
rf_trim_info_t
RF trim parameter information definition.
Definition: gr55xx_sys.h:165
sdk_version_t::minor
uint8_t minor
Definition: gr55xx_sys.h:138
sys_attdb_usage_ratio_get
uint8_t sys_attdb_usage_ratio_get(void)
Get system attriute database heap usage ratio.
sys_max_msg_usage_ratio_set
void sys_max_msg_usage_ratio_set(uint8_t usage_ratio)
Set system maximum usage ratio of message heap.
adc_trim_info_t::offset_int_0p8
uint16_t offset_int_0p8
Definition: gr55xx_sys.h:175
PACKAGE_NONE
@ PACKAGE_NONE
Definition: gr55xx_sys.h:120
adc_trim_info_t::slope_ext_1p0
uint16_t slope_ext_1p0
Definition: gr55xx_sys.h:182
sys_device_addr_get
uint16_t sys_device_addr_get(uint8_t *p_device_addr)
Get the device address information.
sys_lpclk_update_func_with_return_register
void sys_lpclk_update_func_with_return_register(int_func_t func_update_lpclk)
Register low power clock update function with int return.
sys_firmware_jump
void sys_firmware_jump(uint32_t fw_addr)
Jump to firmware and run.
sys_signal_handler_register
void sys_signal_handler_register(callback_t isr_handler)
Register signal handler.
timer_callback_t
void(* timer_callback_t)(uint8_t timer_id)
Timer callback type.
Definition: gr55xx_sys.h:82
link_rx_info_t::rx_crc_err_cnt
uint32_t rx_crc_err_cnt
Definition: gr55xx_sys.h:156
PACKAGE_GR5513BEND
@ PACKAGE_GR5513BEND
Definition: gr55xx_sys.h:125
link_rx_info_t::rx_mic_err_cnt
uint32_t rx_mic_err_cnt
Definition: gr55xx_sys.h:159
sys_context_func_t
void(* sys_context_func_t)(void)
Function type for saving user context before deep sleep.
Definition: gr55xx_sys.h:94
PACKAGE_GR5515I0ND
@ PACKAGE_GR5515I0ND
Definition: gr55xx_sys.h:124
PACKAGE_GR5515BEND
@ PACKAGE_GR5515BEND
Definition: gr55xx_sys.h:126
adc_trim_info_t::slope_int_0p8
uint16_t slope_int_0p8
Definition: gr55xx_sys.h:174
sys_assert_cb_t::assert_warn_cb
assert_warn_cb_t assert_warn_cb
Definition: gr55xx_sys.h:148
pmu_trim_info_t
PMU trim parameter information definition.
Definition: gr55xx_sys.h:188
SYS_DEV_SRAM_128K
@ SYS_DEV_SRAM_128K
Definition: gr55xx_sys.h:113
sdk_version_t
SDK version definition.
Definition: gr55xx_sys.h:136
PACKAGE_GR5515GGBD
@ PACKAGE_GR5515GGBD
Definition: gr55xx_sys.h:122
link_rx_info_t::rx_normal_cnt
uint32_t rx_normal_cnt
Definition: gr55xx_sys.h:160
sys_free
void sys_free(void *p_mem)
Free allocated memory.
sys_app_printf
void sys_app_printf(const char *format,...)
Output debug logs.
assert_param_cb_t
void(* assert_param_cb_t)(int param0, int param1, const char *file, int line)
Parameter assert callback type.
Definition: gr55xx_sys.h:100
gr55xx_sys_cfg.h
Define the chip configuration.
sys_link_quality_clear
void sys_link_quality_clear(uint8_t conn_idx)
Clear link quality info.
restore_sys_context
void restore_sys_context(void)
Load system context.
void_func_t
void(* void_func_t)(void)
Low power clock update function type.
Definition: gr55xx_sys.h:88
sys_device_package_get
uint16_t sys_device_package_get(package_type_t *p_package_type)
Get the chip's package type.
adc_trim_info_t::slope_int_2p0
uint16_t slope_int_2p0
Definition: gr55xx_sys.h:180
sys_msg_usage_ratio_get
uint8_t sys_msg_usage_ratio_get(void)
Get system message heap usage ratio.
sys_crystal_trim_get
uint16_t sys_crystal_trim_get(uint16_t *p_crystal_trim)
Get the crystal trim information.
link_rx_info_t::rx_sn_err_cnt
uint32_t rx_sn_err_cnt
Definition: gr55xx_sys.h:158
sys_link_quality_get
uint8_t sys_link_quality_get(uint8_t conn_idx, link_rx_info_t *rx_info)
Get link quality info.
gr55xx_nvds.h
NVDS API.
sys_context_save
void sys_context_save(void)
Save system context.
gr55xx_pwr.h
GR55XX Platform Power Manager Module API.
sys_security_data_use_present
void sys_security_data_use_present(uint32_t addr, uint8_t *input, uint32_t size, uint8_t *output)
Encrypt and decrypt data using Present.
sys_env_usage_ratio_get
uint8_t sys_env_usage_ratio_get(void)
Get system environment heap usage ratio.
adc_trim_info_t::adc_temp
uint16_t adc_temp
Definition: gr55xx_sys.h:173
int_func_t
int(* int_func_t)(void)
Low power clock update function type with resturn.
Definition: gr55xx_sys.h:91
sys_ble_heartbeat_period_set
uint16_t sys_ble_heartbeat_period_set(uint32_t period_hus)
Set BLE Sleep HeartBeat Period.
sys_delay_ms
void sys_delay_ms(uint32_t ms)
Delay the function execution.
sys_delay_us
void sys_delay_us(uint32_t us)
Delay the function execution.
package_type_t
package_type_t
package type.
Definition: gr55xx_sys.h:119
sys_pmu_trim_get
uint16_t sys_pmu_trim_get(pmu_trim_info_t *p_pmu_trim)
Get the PMU trim information.
pmu_trim_info_t::io_ldo_bypass
uint8_t io_ldo_bypass
Definition: gr55xx_sys.h:189
sys_device_uid_get
uint16_t sys_device_uid_get(uint8_t *p_device_uid)
Get the device UID information.
sys_lpclk_update_func_register
void sys_lpclk_update_func_register(void_func_t func_update_lpclk)
Register low power clock update function.
rf_trim_info_t::rssi_cali
int8_t rssi_cali
Definition: gr55xx_sys.h:166
sys_swd_disable
void sys_swd_disable(void)
Diable swd function.
sys_adc_trim_get
uint16_t sys_adc_trim_get(adc_trim_info_t *p_adc_trim)
Get the ADC trim information.
PACKAGE_GR5513BENDU
@ PACKAGE_GR5513BENDU
Definition: gr55xx_sys.h:127
link_rx_info_t::rx_total_cnt
uint32_t rx_total_cnt
Definition: gr55xx_sys.h:154
sys_sdk_verison_get
void sys_sdk_verison_get(sdk_version_t *p_version)
Get SDK version.
SYS_DEV_SRAM_64K
@ SYS_DEV_SRAM_64K
Definition: gr55xx_sys.h:112
adc_trim_info_t::offset_ext_1p0
uint16_t offset_ext_1p0
Definition: gr55xx_sys.h:183
rng_calibration
void rng_calibration(void)
RNG calibration function.
sys_device_lp_gain_offset_2m_get
uint16_t sys_device_lp_gain_offset_2m_get(uint8_t *p_offset)
Get the LP gain offset 2M information.
sys_trim_sum_get
uint16_t sys_trim_sum_get(uint16_t *p_trim_sum)
Get the trim checksum.
sys_device_sram_get
uint16_t sys_device_sram_get(sram_size_t *p_sram_size)
Get the RAM size information.
rtc_calibration
void rtc_calibration(void)
RTC calibration function.
sys_assert_cb_t::assert_param_cb
assert_param_cb_t assert_param_cb
Definition: gr55xx_sys.h:147
PACKAGE_GR5515IGND
@ PACKAGE_GR5515IGND
Definition: gr55xx_sys.h:123
link_rx_info_t
Link RX information definition.
Definition: gr55xx_sys.h:153
sys_swd_enable
void sys_swd_enable(void)
Enable swd function.
sys_nonret_usage_ratio_get
uint8_t sys_nonret_usage_ratio_get(void)
Get system non retention heap usage ratio.
adc_trim_info_t
ADC trim parameter information definition.
Definition: gr55xx_sys.h:172
rf_trim_info_t::tx_power
int8_t tx_power
Definition: gr55xx_sys.h:167
sdk_version_t::commit_id
uint32_t commit_id
Definition: gr55xx_sys.h:140
sdk_version_t::build
uint16_t build
Definition: gr55xx_sys.h:139
adc_trim_info_t::slope_int_1p2
uint16_t slope_int_1p2
Definition: gr55xx_sys.h:176
sys_lpclk_set
void sys_lpclk_set(uint32_t user_lpclk)
Set low power CLK frequency.
pmu_trim_info_t::dcdc_vout
uint8_t dcdc_vout
Definition: gr55xx_sys.h:193
SYS_DEV_SRAM_256K
@ SYS_DEV_SRAM_256K
Definition: gr55xx_sys.h:114
sys_assert_cb_t
Assert callbacks.
Definition: gr55xx_sys.h:145
pmu_trim_info_t::dig_ldo_64m
uint8_t dig_ldo_64m
Definition: gr55xx_sys.h:191
sys_assert_cb_register
void sys_assert_cb_register(sys_assert_cb_t *p_assert_cb)
Register assert callbacks.
sys_reverse_hword
uint16_t sys_reverse_hword(uint16_t value)
Reverse byte order (16 bit). For example, 0x1234 becomes 0x3412.
sys_regs_save
void sys_regs_save(volatile uint32_t *p_address, uint32_t value)
Save system registers.
sys_ble_heartbeat_period_get
uint16_t sys_ble_heartbeat_period_get(uint32_t *p_period_hus)
Get BLE Sleep HeartBeat Period.
sys_malloc
void * sys_malloc(uint32_t size)
Memory allocation.
sys_security_enable_status_check
uint32_t sys_security_enable_status_check(void)
Check the chip's security level.
link_rx_info_t::rx_sync_err_cnt
uint32_t rx_sync_err_cnt
Definition: gr55xx_sys.h:155
sys_lpper_get
uint32_t sys_lpper_get(void)
Get low power CLK period.
sys_us_2_lpcycles
uint32_t sys_us_2_lpcycles(uint32_t us)
Convert a duration in μs into a duration in lp cycles.
adc_trim_info_t::offset_int_1p6
uint16_t offset_int_1p6
Definition: gr55xx_sys.h:179
pmu_trim_info_t::dig_ldo_16m
uint8_t dig_ldo_16m
Definition: gr55xx_sys.h:192
gr55xx_fpb.h
sys_assert_cb_t::assert_err_cb
assert_err_cb_t assert_err_cb
Definition: gr55xx_sys.h:146
ble.h
include all ble sdk header files
PACKAGE_GR5515RGBD
@ PACKAGE_GR5515RGBD
Definition: gr55xx_sys.h:121
sys_ke_sleep_check
bool sys_ke_sleep_check(void)
Get status of ke_event list.