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_GR5515I0NDA = 8,
129 PACKAGE_GR5515IENDU = 9,
130 } package_type_t;
137 typedef struct
138 {
139 uint8_t major;
140 uint8_t minor;
141 uint16_t build;
142 uint32_t commit_id;
143 }sdk_version_t;
144
146 typedef struct
147 {
148 assert_err_cb_t assert_err_cb;
149 assert_param_cb_t assert_param_cb;
150 assert_warn_cb_t assert_warn_cb;
151 }sys_assert_cb_t;
152
154 typedef struct
155 {
156 uint32_t rx_total_cnt;
157 uint32_t rx_sync_err_cnt;
158 uint32_t rx_crc_err_cnt;
159 uint32_t rx_other_err_cnt;
160 uint32_t rx_sn_err_cnt;
161 uint32_t rx_mic_err_cnt;
162 uint32_t rx_normal_cnt;
163 } link_rx_info_t;
164
166 typedef struct
167 {
168 int8_t rssi_cali;
169 int8_t tx_power;
170 } rf_trim_info_t;
171
173 typedef struct
174 {
175 uint16_t adc_temp;
176 uint16_t slope_int_0p8;
177 uint16_t offset_int_0p8;
178 uint16_t slope_int_1p2;
179 uint16_t offset_int_1p2;
180 uint16_t slope_int_1p6;
181 uint16_t offset_int_1p6;
182 uint16_t slope_int_2p0;
183 uint16_t offset_int_2p0;
184 uint16_t slope_ext_1p0;
185 uint16_t offset_ext_1p0;
186 } adc_trim_info_t;
187
189 typedef struct
190 {
191 uint8_t io_ldo_bypass;
192 uint8_t io_ldo_vout;
193 uint8_t dig_ldo_64m;
194 uint8_t dig_ldo_16m;
195 uint8_t dcdc_vout;
196 } pmu_trim_info_t;
197
210 void sys_app_printf(const char *format, ...);
211
219 void sys_delay_us(uint32_t us);
220
228 void sys_delay_ms(uint32_t ms);
229
239 void *sys_malloc(uint32_t size);
240
248 void sys_free(void *p_mem);
249
260 void sys_signal_handler_register(callback_t isr_handler);
261
271 void sys_sdk_verison_get(sdk_version_t *p_version);
272
281 void sys_context_save(void);
282
290 void restore_sys_context(void);
291
302 void sys_regs_save(volatile uint32_t *p_address, uint32_t value);
303
312 void sys_context_checksum_gen(void);
313
326 void sys_security_data_use_present(uint32_t addr, uint8_t *input, uint32_t size, uint8_t *output);
327
336 uint32_t sys_security_enable_status_check(void);
337
347 uint16_t sys_rf_trim_get(rf_trim_info_t *p_rf_trim);
348
358 uint16_t sys_adc_trim_get(adc_trim_info_t *p_adc_trim);
359
369 uint16_t sys_pmu_trim_get(pmu_trim_info_t *p_pmu_trim);
370
380 uint16_t sys_crystal_trim_get(uint16_t *p_crystal_trim);
381
389 void sys_firmware_jump(uint32_t fw_addr);
390
400 uint16_t sys_trim_sum_get(uint16_t *p_trim_sum);
401
411 uint16_t sys_device_addr_get(uint8_t *p_device_addr);
412
422 uint16_t sys_device_uid_get(uint8_t *p_device_uid);
423
433 uint16_t sys_device_lp_gain_offset_2m_get(uint8_t *p_offset);
434
444 uint16_t sys_device_sram_get(sram_size_t *p_sram_size);
445
455 uint16_t sys_device_package_get(package_type_t *p_package_type);
456
457
458 #if defined(GR5515_D)
459
471 uint16_t sys_get_efuse_io_ldo(uint16_t *io_ldo);
472
473 #endif
474
482 void sys_lpclk_set(uint32_t user_lpclk);
483
496 uint32_t sys_us_2_lpcycles(uint32_t us);
497
510 uint32_t sys_lpcycles_2_hus(uint32_t lpcycles, uint32_t *error_corr);
511
523 uint16_t sys_ble_heartbeat_period_set(uint32_t period_hus);
524
525
537 uint16_t sys_ble_heartbeat_period_get(uint32_t* p_period_hus);
538
550 void sys_max_msg_usage_ratio_set(uint8_t usage_ratio);
551
563 void sys_lld_max_msg_usage_ratio_set(uint8_t usage_ratio);
564
575 uint8_t sys_msg_usage_ratio_get(void);
576
587 uint8_t sys_env_usage_ratio_get(void);
588
599 uint8_t sys_attdb_usage_ratio_get(void);
600
611 uint8_t sys_nonret_usage_ratio_get(void);
612
623 uint8_t sys_link_quality_get(uint8_t conn_idx, link_rx_info_t* rx_info);
624
632 void sys_link_quality_clear(uint8_t conn_idx);
633
641 void sys_lpclk_update_func_register(void_func_t func_update_lpclk);
642
650 void sys_lpclk_update_func_with_return_register(int_func_t func_update_lpclk);
651
661 uint32_t sys_lpclk_get(void);
662
672 uint32_t sys_lpper_get(void);
673
681 void sys_assert_cb_register(sys_assert_cb_t *p_assert_cb);
682
689 bool sys_ke_sleep_check(void);
690
696 void sys_swd_enable(void);
697
703 void sys_swd_disable(void);
704
711 void rtc_calibration(void);
712
720 void rng_calibration(void);
721
728 uint32_t sys_reverse_word(uint32_t value);
729
736 uint16_t sys_reverse_hword(uint16_t value);
737
738
739
740
741
743 #endif
744
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:179
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:192
sdk_version_t::major
uint8_t major
Definition: gr55xx_sys.h:139
adc_trim_info_t::offset_int_2p0
uint16_t offset_int_2p0
Definition: gr55xx_sys.h:183
adc_trim_info_t::slope_int_1p6
uint16_t slope_int_1p6
Definition: gr55xx_sys.h:180
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:159
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:167
sdk_version_t::minor
uint8_t minor
Definition: gr55xx_sys.h:140
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:177
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:184
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:158
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:161
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:176
sys_assert_cb_t::assert_warn_cb
assert_warn_cb_t assert_warn_cb
Definition: gr55xx_sys.h:150
pmu_trim_info_t
PMU trim parameter information definition.
Definition: gr55xx_sys.h:190
SYS_DEV_SRAM_128K
@ SYS_DEV_SRAM_128K
Definition: gr55xx_sys.h:113
sdk_version_t
SDK version definition.
Definition: gr55xx_sys.h:138
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:162
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:182
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:160
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:175
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.
PACKAGE_GR5515I0NDA
@ PACKAGE_GR5515I0NDA
Definition: gr55xx_sys.h:128
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_GR5515IENDU
@ PACKAGE_GR5515IENDU
Definition: gr55xx_sys.h:129
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:191
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:168
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:156
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:185
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:149
PACKAGE_GR5515IGND
@ PACKAGE_GR5515IGND
Definition: gr55xx_sys.h:123
link_rx_info_t
Link RX information definition.
Definition: gr55xx_sys.h:155
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:174
rf_trim_info_t::tx_power
int8_t tx_power
Definition: gr55xx_sys.h:169
sdk_version_t::commit_id
uint32_t commit_id
Definition: gr55xx_sys.h:142
sdk_version_t::build
uint16_t build
Definition: gr55xx_sys.h:141
adc_trim_info_t::slope_int_1p2
uint16_t slope_int_1p2
Definition: gr55xx_sys.h:178
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:195
SYS_DEV_SRAM_256K
@ SYS_DEV_SRAM_256K
Definition: gr55xx_sys.h:114
sys_assert_cb_t
Assert callbacks.
Definition: gr55xx_sys.h:147
pmu_trim_info_t::dig_ldo_64m
uint8_t dig_ldo_64m
Definition: gr55xx_sys.h:193
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:157
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:181
pmu_trim_info_t::dig_ldo_16m
uint8_t dig_ldo_16m
Definition: gr55xx_sys.h:194
gr55xx_fpb.h
sys_assert_cb_t::assert_err_cb
assert_err_cb_t assert_err_cb
Definition: gr55xx_sys.h:148
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.