gr55xx_sys.h
Go to the documentation of this file.
1 /**
2 *******************************************************************************
3 *
4 * @file gr55xx_sys.h
5 *
6 * @brief GR55XX System API
7 *
8 *******************************************************************************
9 * @attention
10 #####Copyright (c) 2019 GOODIX
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of GOODIX nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 *****************************************************************************************
36 */
37
38 /**
39 @addtogroup SYSTEM
40 @{
41 */
42
43 /**
44 * @addtogroup SYS System SDK
45 * @{
46 * @brief Definitions and prototypes for the system SDK interface.
47 */
48
49
50
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_dfu.h"
57 #include "gr55xx_pwr.h"
58 #include "gr55xx_fpb.h"
59 #include "ble.h"
60
61 #include <stdint.h>
62 #include <stdio.h>
63 #include <stdbool.h>
64 #include <stdarg.h>
65
66 /** @addtogroup GR55XX_SYS_DEFINES Defines
67 * @{
68 */
69 #define SYS_INVALID_TIMER_ID 0xFF /**< Invalid system Timer ID. */
70 #define SYS_BD_ADDR_LEN BLE_GAP_ADDR_LEN /**< Length of Bluetoth Device Address. */
71 #define SYS_CHIP_UID_LEN 0x10 /**< Length of Bluetoth Chip UID. */
72 #define SYS_SET_BD_ADDR(BD_ADDR_ARRAY) nvds_put(0xC001, SYS_BD_ADDR_LEN, BD_ADDR_ARRAY) /**< NVDS put BD address. */
73 #define SYS_ROM_VERSION_ADDR 0x45000 /**< The rom version address. */
74 /** @} */
75
76 /**
77 * @defgroup GR55XX_SYS_TYPEDEF Typedefs
78 * @{
79 */
80 /**@brief The function pointers to register event callback. */
81 typedef void (*callback_t)(int);
82
83 /** @brief Timer callback type. */
84 typedef void (*timer_callback_t)(uint8_t timer_id);
85
86 /**@brief Printf callback type. */
87 typedef int (*vprintf_callback_t) (const char *fmt, va_list argp);
88
89 /**@brief Low power clock update function type. */
90 typedef void (*void_func_t)(void);
91
92 /**@brief Low power clock update function type with resturn. */
93 typedef int (*int_func_t)(void);
94
95 /**@brief Function type for saving user context before deep sleep. */
96 typedef void (*sys_context_func_t)(void);
97
98 /**@brief Error assert callback type. */
99 typedef void (*assert_err_cb_t)(const char *expr, const char *file, int line);
100
101 /**@brief Parameter assert callback type. */
102 typedef void (*assert_param_cb_t)(int param0, int param1, const char *file, int line);
103
104 /**@brief Warning assert callback type. */
105 typedef void (*assert_warn_cb_t)(int param0, int param1, const char *file, int line);
106 /** @} */
107
108 /** @addtogroup GR55XX_SYS_ENUMERATIONS Enumerations
109 * @{
110 */
111 /**@brief Definition of Device SRAM Size Enumerations. */
112 typedef enum
113 {
114 SYS_DEV_SRAM_64K = 0x02, /**< Supported 64K SRAM. */
115 SYS_DEV_SRAM_128K = 0x01, /**< Supported 128K SRAM. */
116 SYS_DEV_SRAM_256K = 0x00, /**< Supported 256K SRAM. */
117 } sram_size_t;
118
119 /**@brief package type. */
120 typedef enum
121 {
122 PACKAGE_NONE = 0, /**< Package unused. */
123 PACKAGE_GR5515RGBD = 1, /**< BGA68 package. */
124 PACKAGE_GR5515GGBD = 2, /**< BGA55 package. */
125 PACKAGE_GR5515IGND = 3, /**< QFN56 + 1024KB flash package. */
126 PACKAGE_GR5515I0ND = 4, /**< QFN56 + no flash package, support external high voltage flash only*/
127 PACKAGE_GR5513BEND = 5, /**< QFN40 + 128KB RAM + 512KB flash packet. */
128 PACKAGE_GR5515BEND = 6, /**< QFN40 + 256KB RAM + 512KB flash packet. */
129 PACKAGE_GR5513BENDU = 7, /**< QFN40 + 128KB RAM + 512KB flash packet @1.7V ~ 3.6V. */
130 PACKAGE_GR5515I0NDA = 8, /**< QFN56 + no flash package, support external high/low voltage flash */
131 PACKAGE_GR5515IENDU = 9, /**< QFN56 + 512KB flash package */
132 } package_type_t;
133 /** @} */
134
135 /** @addtogroup GR55XX_SYS_STRUCTURES Structures
136 * @{
137 */
138 /**@brief SDK version definition. */
139 typedef struct
140 {
141 uint8_t major; /**< Major version. */
142 uint8_t minor; /**< Minor version. */
143 uint16_t build; /**< Build number. */
144 uint32_t commit_id; /**< commit ID. */
145 }sdk_version_t;
146
147 /**@brief Assert callbacks.*/
148 typedef struct
149 {
150 assert_err_cb_t assert_err_cb; /**< Assert error type callback. */
151 assert_param_cb_t assert_param_cb; /**< Assert parameter error type callback. */
152 assert_warn_cb_t assert_warn_cb; /**< Assert warning type callback. */
153 }sys_assert_cb_t;
154
155 /**@brief Link RX information definition. */
156 typedef struct
157 {
158 uint32_t rx_total_cnt; /**< Counts of RX times. */
159 uint32_t rx_sync_err_cnt; /**< Counts of RX sync error times. */
160 uint32_t rx_crc_err_cnt; /**< Counts of RX crc error times. */
161 uint32_t rx_other_err_cnt; /**< Counts of RX other error times. */
162 uint32_t rx_sn_err_cnt; /**< Counts of sn CRC error times. */
163 uint32_t rx_mic_err_cnt; /**< Counts of mic CRC error times. */
164 uint32_t rx_normal_cnt; /**< Counts of RX normal times. */
165 } link_rx_info_t;
166
167 /**@brief RF trim parameter information definition. */
168 typedef struct
169 {
170 int8_t rssi_cali; /**< RSSI calibration. */
171 int8_t tx_power; /**< TX power. */
172 } rf_trim_info_t;
173
174 /**@brief ADC trim parameter information definition. */
175 typedef struct
176 {
177 uint16_t adc_temp; /**< ADC TEMP. */
178 uint16_t slope_int_0p8; /**< Internal reference 0.8v. */
179 uint16_t offset_int_0p8; /**< Internal reference 0.8v. */
180 uint16_t slope_int_1p2; /**< Internal reference 1.2v. */
181 uint16_t offset_int_1p2; /**< Internal reference 1.2v. */
182 uint16_t slope_int_1p6; /**< Internal reference 1.6v. */
183 uint16_t offset_int_1p6; /**< Internal reference 1.6v. */
184 uint16_t slope_int_2p0; /**< Internal reference 2.0v. */
185 uint16_t offset_int_2p0; /**< Internal reference 2.0v. */
186 uint16_t slope_ext_1p0; /**< External reference 1.0v. */
187 uint16_t offset_ext_1p0; /**< External reference 1.0v. */
188 } adc_trim_info_t;
189
190 /**@brief PMU trim parameter information definition. */
191 typedef struct
192 {
193 uint8_t io_ldo_bypass; /**< IO LDO bypass */
194 uint8_t io_ldo_vout; /**< IO LDO Vout. */
195 uint8_t dig_ldo_64m; /**< DIG LDO 64m. */
196 uint8_t dig_ldo_16m; /**< DIG LDO 16m */
197 uint8_t dcdc_vout; /**< DCDC Vout */
198 } pmu_trim_info_t;
199
200 /** @} */
201
202 /** @addtogroup GR55XX_SYS_FUNCTIONS Functions
203 * @{
204 */
205 /**
206 *****************************************************************************************
207 * @brief Output debug logs.
208 *
209 * @param[in] format: Pointer to the log information.
210 *****************************************************************************************
211 */
212 void sys_app_printf(const char *format, ...);
213
214 /**
215 *****************************************************************************************
216 * @brief Delay the function execution.
217 *
218 * @param[in] us: Microsecond.
219 *****************************************************************************************
220 */
221 void sys_delay_us(uint32_t us);
222
223 /**
224 *****************************************************************************************
225 * @brief Delay the function execution.
226 *
227 * @param[in] ms: Millisecond.
228 *****************************************************************************************
229 */
230 void sys_delay_ms(uint32_t ms);
231
232 /**
233 *****************************************************************************************
234 * @brief Memory allocation.
235 *
236 * @param[in] size: Requested memory size.
237 *
238 * @return Valid memory location if successful, else null.
239 *****************************************************************************************
240 */
241 void *sys_malloc(uint32_t size);
242
243 /**
244 *****************************************************************************************
245 * @brief Free allocated memory.
246 *
247 * @param[in] p_mem: Pointer to memory block.
248 *****************************************************************************************
249 */
250 void sys_free(void *p_mem);
251
252 /**
253 *****************************************************************************************
254 * @brief Register signal handler.
255 *
256 * @note This function is mainly used to register the upper-layer APP callback functions to the protocol layer,
257 * which will be invoked when there are event responses in the protocol layer.
258 *
259 * @param[in] isr_handler: callback function which to be registered.
260 *****************************************************************************************
261 */
262 void sys_signal_handler_register(callback_t isr_handler);
263
264 /**
265 *****************************************************************************************
266 * @brief Get SDK version.
267 *
268 * @note This function is mainly used to get the version of SDK.
269 *
270 * @param[out] p_version: The pointer to struct of @ref sdk_version_t.
271 *****************************************************************************************
272 */
273 void sys_sdk_verison_get(sdk_version_t *p_version);
274
275 /**
276 *****************************************************************************************
277 * @brief Save system context.
278 *
279 * @note This function is used to save system context before the system goes to deep sleep.
280 * Boot codes will be used to restore system context in the wakeup procedure.
281 *****************************************************************************************
282 */
283 void sys_context_save(void);
284
285 /**
286 *****************************************************************************************
287 * @brief Load system context.
288 *
289 * @note This function is used to load system context after the system goes to deep sleep.
290 *****************************************************************************************
291 */
292 void restore_sys_context(void);
293
294 /**
295 *****************************************************************************************
296 * @brief Save system registers.
297 *
298 * @note This function is used to save system register before the system goes to deep sleep.
299 *
300 * @param[in] p_address: The pointer to register address.
301 * @param[in] value: The register value to be saved, it will be restored when system wakes up.
302 *****************************************************************************************
303 */
304 void sys_regs_save(volatile uint32_t *p_address, uint32_t value);
305
306 /**
307 *****************************************************************************************
308 * @brief Generate checksum info for system context.
309 *
310 * @note This function is used to generate checksum for system context, it will be called
311 * before deep sleep in power management module.
312 *****************************************************************************************
313 */
314 void sys_context_checksum_gen(void);
315
316 /**
317 *****************************************************************************************
318 * @brief Encrypt and decrypt data using Present.
319 *
320 * @note This function is only used to encrypt and decrypt data that needs to be stored in Flash.
321 *
322 * @param[in] addr: Operation address (Flash address minus Flash start address).
323 * @param[in] input: Data before encryption and decryption.
324 * @param[in] size: Data size.
325 * @param[out] output: Data after encryption and decryption.
326 *****************************************************************************************
327 */
328 void sys_security_data_use_present(uint32_t addr, uint8_t *input, uint32_t size, uint8_t *output);
329
330 /**
331 *****************************************************************************************
332 * @brief Check the chip's security level.
333 *
334 * @return 0: Security is not supported.
335 * 1: Security is supported.
336 *****************************************************************************************
337 */
338 uint32_t sys_security_enable_status_check(void);
339
340 /**
341 *****************************************************************************************
342 * @brief Get the RF trim information.
343 *
344 * @param[out] p_rf_trim: The pointer to struct of @ref rf_trim_info_t.
345 * @return 0: Operation is OK.
346 * 1: the chip's parameter is incorrect.
347 *****************************************************************************************
348 */
349 uint16_t sys_rf_trim_get(rf_trim_info_t *p_rf_trim);
350
351 /**
352 *****************************************************************************************
353 * @brief Get the ADC trim information.
354 *
355 * @param[out] p_adc_trim: The pointer to struct of @ref adc_trim_info_t.
356 * @return 0: Operation is OK.
357 * 1: the chip's parameter is incorrect.
358 *****************************************************************************************
359 */
360 uint16_t sys_adc_trim_get(adc_trim_info_t *p_adc_trim);
361
362 /**
363 *****************************************************************************************
364 * @brief Get the PMU trim information.
365 *
366 * @param[out] p_pmu_trim: The pointer to struct of @ref pmu_trim_info_t.
367 * @return 0: Operation is OK.
368 * 1: the chip's parameter is incorrect.
369 *****************************************************************************************
370 */
371 uint16_t sys_pmu_trim_get(pmu_trim_info_t *p_pmu_trim);
372
373 /**
374 *****************************************************************************************
375 * @brief Get the crystal trim information.
376 *
377 * @param[out] p_crystal_trim: offset information for crystal.
378 * @return 0: Operation is OK.
379 * 1: the chip's parameter is incorrect.
380 *****************************************************************************************
381 */
382 uint16_t sys_crystal_trim_get(uint16_t *p_crystal_trim);
383
384 /**
385 *****************************************************************************************
386 * @brief app boot project turn on the encrypt clock.
387 *
388 *****************************************************************************************
389 */
390 void app_boot_turn_on_encrypt_clock(void);
391
392 /**
393 *****************************************************************************************
394 * @brief app boot project set the security clock.
395 *
396 *****************************************************************************************
397 */
398 void app_boot_security_clock_set(void);
399
400 /**
401 *****************************************************************************************
402 * @brief jump to app firmware. 69
403 *
404 * @param[in] p_boot_info: Firmware system firmware information 71
405 *****************************************************************************************
406 */
407 void sys_firmware_jump(dfu_boot_info_t *p_boot_info);
408
409 /**
410 *****************************************************************************************
411 * @brief Get the trim checksum.
412 *
413 * @param[out] p_trim_sum: The pointer to the buffer for trim checksum.
414 * @return 0: Operation is OK.
415 * 1: the chip's parameter is incorrect.
416 *****************************************************************************************
417 */
418 uint16_t sys_trim_sum_get(uint16_t *p_trim_sum);
419
420 /**
421 *****************************************************************************************
422 * @brief Get the device address information.
423 *
424 * @param[out] p_device_addr: Bluetooth address by default.
425 * @return 0: Operation is OK.
426 * 1: the chip's parameter is incorrect.
427 *****************************************************************************************
428 */
429 uint16_t sys_device_addr_get(uint8_t *p_device_addr);
430
431 /**
432 *****************************************************************************************
433 * @brief Get the device UID information.
434 *
435 * @param[out] p_device_uid: Device chip UID.
436 * @return 0: Operation is OK.
437 * 1: the chip's parameter is incorrect.
438 *****************************************************************************************
439 */
440 uint16_t sys_device_uid_get(uint8_t *p_device_uid);
441
442 /**
443 *****************************************************************************************
444 * @brief Get the LP gain offset 2M information.
445 *
446 * @param[out] p_offset: the offset of LP gain.
447 * @return 0: Operation is OK.
448 * 1: the chip's parameter is incorrect.
449 *****************************************************************************************
450 */
451 uint16_t sys_device_lp_gain_offset_2m_get(uint8_t *p_offset);
452
453 /**
454 *****************************************************************************************
455 * @brief Get the RAM size information.
456 *
457 * @param[out] p_sram_size: The pointer to enumeration of @ref sram_size_t.
458 * @return 0: Operation is OK.
459 * 1: the chip's parameter is incorrect.
460 *****************************************************************************************
461 */
462 uint16_t sys_device_sram_get(sram_size_t *p_sram_size);
463
464 /**
465 *****************************************************************************************
466 * @brief Get the chip's package type.
467 *
468 * @param[out] p_package_type: The pointer to enumeration of @ref package_type_t.
469 * @return 0: Operation is OK.
470 * 1: the chip's parameter is incorrect.
471 *****************************************************************************************
472 */
473 uint16_t sys_device_package_get(package_type_t *p_package_type);
474
475 /**
476 *****************************************************************************************
477 * @brief Get the chip's IO LDO voltage.
478 *
479 * This function is an API interface for special users.
480 *
481 * @param[out] io_ldo: The IO LDO voltage.
482 * @return 0: Operation is OK.
483 * 1: the chip's parameter is incorrect.
484 *****************************************************************************************
485 */
486 uint16_t sys_get_efuse_io_ldo(uint16_t *io_ldo);
487
488 /**
489 *****************************************************************************************
490 * @brief Set low power CLK frequency.
491 *
492 * @param[in] user_lpclk: CLK frequency.
493 *****************************************************************************************
494 */
495 void sys_lpclk_set(uint32_t user_lpclk);
496
497 /**
498 ****************************************************************************************
499 * @brief Convert a duration in us into a duration in lp cycles.
500 *
501 * The function converts a duration in us into a duration in lp cycles, according to the
502 * low power clock frequency (32768Hz or 32000Hz).
503 *
504 * @param[in] us: Duration in us.
505 *
506 * @return Duration in lpcycles.
507 ****************************************************************************************
508 */
509 uint32_t sys_us_2_lpcycles(uint32_t us);
510
511 /**
512 ****************************************************************************************
513 * @brief Convert a duration in lp cycles into a duration in half us.
514 *
515 * The function converts a duration in lp cycles into a duration in half us, according to the
516 * low power clock frequency (32768Hz or 32000Hz).
517 * @param[in] lpcycles: Duration in lp cycles.
518 * @param[in,out] error_corr: Insert and retrieve error created by truncating the LP Cycle Time to a half us (in half us).
519 *
520 * @return Duration in half us
521 ****************************************************************************************
522 */
523 uint32_t sys_lpcycles_2_hus(uint32_t lpcycles, uint32_t *error_corr);
524
525 /**
526 *****************************************************************************************
527 * @brief Reverse the policy for static address created by chip uuid .
528 * @note After sdk_v1.6.10, this policy has been updated.
529 *
530 *****************************************************************************************
531 */
532 void sys_ble_static_addr_policy_reverse(void);
533
534 /**
535 *****************************************************************************************
536 * @brief Set BLE Sleep HeartBeat Period.
537 * @note The BLE Sleep HeartBeat Period is used to Wakeup BLE Periodically when BLE is IDLE.
538 *
539 * @param[in] period_hus: The wake up duration of BLE when BLE is IDEL.
540 * Range 0x00000000-0xFFFFFFFF (in unit of us).
541 *
542 * @retval ::SDK_SUCCESS Operation is Success.
543 *****************************************************************************************
544 */
545 uint16_t sys_ble_heartbeat_period_set(uint32_t period_hus);
546
547
548 /**
549 *****************************************************************************************
550 * @brief Get BLE Sleep HeartBeat Period.
551 * @note The BLE Sleep HeartBeat Period is used to Wakeup BLE Periodically when BLE is IDLE.
552 *
553 * @param[in] p_period_hus: Pointer to the wake up duration.
554 * Range 0x00000000-0xFFFFFFFF (in unit of us).
555 *
556 * @retval ::SDK_SUCCESS Operation is Success.
557 *****************************************************************************************
558 */
559 uint16_t sys_ble_heartbeat_period_get(uint32_t* p_period_hus);
560
561 /**
562 ****************************************************************************************
563 * @brief Set system maximum usage ratio of message heap.
564 *
565 * The function will used to set message ratio of message heap.
566 * Valid ratio range is 50 - 100 percent in full message size.
567 *
568 * @param[in] usage_ratio: Usage ratio of message heap size.
569 *
570 ****************************************************************************************
571 */
572 void sys_max_msg_usage_ratio_set(uint8_t usage_ratio);
573
574 /**
575 ****************************************************************************************
576 * @brief Set system lld layer maximum usage ratio of message heap.
577 *
578 * The function will used to set message ratio of message heap.
579 * Valid ratio range is 50 - 100 percent in full message size.
580 *
581 * @param[in] usage_ratio: Usage ratio of message heap size.
582 *
583 ****************************************************************************************
584 */
585 void sys_lld_max_msg_usage_ratio_set(uint8_t usage_ratio);
586
587 /**
588 ****************************************************************************************
589 * @brief Get system message heap usage ratio.
590 *
591 * The function will used to get message ratio of message heap.
592 * This ratio is heap used percent in full message size.
593 *
594 * @return current heap used percent.
595 ****************************************************************************************
596 */
597 uint8_t sys_msg_usage_ratio_get(void);
598
599 /**
600 ****************************************************************************************
601 * @brief Get system environment heap usage ratio.
602 *
603 * The function will used to get environment ratio of environment heap.
604 * This ratio is heap used percent in full environment size.
605 *
606 * @return current heap used percent.
607 ****************************************************************************************
608 */
609 uint8_t sys_env_usage_ratio_get(void);
610
611 /**
612 ****************************************************************************************
613 * @brief Get system attriute database heap usage ratio.
614 *
615 * The function will used to get attriute database ratio of attriute database heap.
616 * This ratio is heap used percent in full attriute database size.
617 *
618 * @return current heap used percent.
619 ****************************************************************************************
620 */
621 uint8_t sys_attdb_usage_ratio_get(void);
622
623 /**
624 ****************************************************************************************
625 * @brief Get system non retention heap usage ratio.
626 *
627 * The function will used to get non retention ratio of non retention heap.
628 * This ratio is heap used percent in full non retention size.
629 *
630 * @return current heap used percent.
631 ****************************************************************************************
632 */
633 uint8_t sys_nonret_usage_ratio_get(void);
634
635 /**
636 ****************************************************************************************
637 * @brief Get link quality info
638 *
639 * @param[in] conn_idx: Connect index.
640 * @param[in,out] rx_info: RX detailed information.
641 *
642 * @return Current connect index link quality.
643 ****************************************************************************************
644 */
645 uint8_t sys_link_quality_get(uint8_t conn_idx, link_rx_info_t* rx_info);
646
647 /**
648 ****************************************************************************************
649 * @brief Clear link quality info.
650 *
651 * @param[in] conn_idx: Connect index.
652 ****************************************************************************************
653 */
654 void sys_link_quality_clear(uint8_t conn_idx);
655
656 /**
657 ****************************************************************************************
658 * @brief Register low power clock update function.
659 *
660 * @param[in] func_update_lpclk: function pointer to update_lpclk.
661 ****************************************************************************************
662 */
663 void sys_lpclk_update_func_register(void_func_t func_update_lpclk);
664
665 /**
666 ****************************************************************************************
667 * @brief Register low power clock update function with int return.
668 *
669 * @param[in] func_update_lpclk: function pointer to update_lpclk.
670 ****************************************************************************************
671 */
672 void sys_lpclk_update_func_with_return_register(int_func_t func_update_lpclk);
673
674 /**
675 ****************************************************************************************
676 * @brief Get low power CLK frequency.
677 *
678 * This function is used to get the low power clock frequency.
679 *
680 * @return Low power CLK frequency.
681 ****************************************************************************************
682 */
683 uint32_t sys_lpclk_get(void);
684
685 /**
686 ****************************************************************************************
687 * @brief Get low power CLK period.
688 *
689 * This function is used to get the low power CLK period.
690 *
691 * @return Low power CLK period.
692 ****************************************************************************************
693 */
694 uint32_t sys_lpper_get(void);
695
696 /**
697 *****************************************************************************************
698 * @brief Register assert callbacks.
699 *
700 * @param[in] p_assert_cb: Pointer to assert callbacks.
701 *****************************************************************************************
702 */
703 void sys_assert_cb_register(sys_assert_cb_t *p_assert_cb);
704
705 /**
706 ****************************************************************************************
707 * @brief Get status of ke_event list
708 * @return true: ke_event not busy, false : ke_event busy.
709 ****************************************************************************************
710 */
711 bool sys_ke_sleep_check(void);
712
713 /**
714 ****************************************************************************************
715 * @brief Enable swd function
716 ****************************************************************************************
717 */
718 void sys_swd_enable(void);
719
720 /**
721 ****************************************************************************************
722 * @brief Diable swd function
723 ****************************************************************************************
724 */
725 void sys_swd_disable(void);
726
727 /**
728 ****************************************************************************************
729 * @brief RTC calibration function.
730 ****************************************************************************************
731 */
732 void rtc_calibration(void);
733
734 /**
735 ****************************************************************************************
736 * @brief RNG calibration function.
737 * @note The function will call between platform_init_push and platform_init_pop.
738 ****************************************************************************************
739 */
740 void rng_calibration(void);
741
742 /**
743 ****************************************************************************************
744 * @brief Reverse byte order (32 bit). For example, 0x12345678 becomes 0x78563412.
745 * @return Byte Reversed value
746 ****************************************************************************************
747 */
748 uint32_t sys_reverse_word(uint32_t value);
749
750 /**
751 ****************************************************************************************
752 * @brief Reverse byte order (16 bit). For example, 0x1234 becomes 0x3412.
753 * @return Byte Reversed value
754 ****************************************************************************************
755 */
756 uint16_t sys_reverse_hword(uint16_t value);
757
758 /** @} */
759 #endif
760
761 /** @} */
762 /** @} */
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 us.
sram_size_t
sram_size_t
Definition of Device SRAM Size Enumerations.
Definition: gr55xx_sys.h:113
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:105
callback_t
void(* callback_t)(int)
The function pointers to register event callback.
Definition: gr55xx_sys.h:81
adc_trim_info_t::offset_int_1p2
uint16_t offset_int_1p2
Definition: gr55xx_sys.h:181
vprintf_callback_t
int(* vprintf_callback_t)(const char *fmt, va_list argp)
Printf callback type.
Definition: gr55xx_sys.h:87
pmu_trim_info_t::io_ldo_vout
uint8_t io_ldo_vout
Definition: gr55xx_sys.h:194
sdk_version_t::major
uint8_t major
Definition: gr55xx_sys.h:141
adc_trim_info_t::offset_int_2p0
uint16_t offset_int_2p0
Definition: gr55xx_sys.h:185
adc_trim_info_t::slope_int_1p6
uint16_t slope_int_1p6
Definition: gr55xx_sys.h:182
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:99
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.
app_boot_turn_on_encrypt_clock
void app_boot_turn_on_encrypt_clock(void)
app boot project turn on the encrypt clock.
link_rx_info_t::rx_other_err_cnt
uint32_t rx_other_err_cnt
Definition: gr55xx_sys.h:161
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:169
sdk_version_t::minor
uint8_t minor
Definition: gr55xx_sys.h:142
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:179
app_boot_security_clock_set
void app_boot_security_clock_set(void)
app boot project set the security clock.
PACKAGE_NONE
@ PACKAGE_NONE
Definition: gr55xx_sys.h:122
adc_trim_info_t::slope_ext_1p0
uint16_t slope_ext_1p0
Definition: gr55xx_sys.h:186
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_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:84
link_rx_info_t::rx_crc_err_cnt
uint32_t rx_crc_err_cnt
Definition: gr55xx_sys.h:160
PACKAGE_GR5513BEND
@ PACKAGE_GR5513BEND
Definition: gr55xx_sys.h:127
link_rx_info_t::rx_mic_err_cnt
uint32_t rx_mic_err_cnt
Definition: gr55xx_sys.h:163
sys_context_func_t
void(* sys_context_func_t)(void)
Function type for saving user context before deep sleep.
Definition: gr55xx_sys.h:96
PACKAGE_GR5515I0ND
@ PACKAGE_GR5515I0ND
Definition: gr55xx_sys.h:126
PACKAGE_GR5515BEND
@ PACKAGE_GR5515BEND
Definition: gr55xx_sys.h:128
adc_trim_info_t::slope_int_0p8
uint16_t slope_int_0p8
Definition: gr55xx_sys.h:178
sys_assert_cb_t::assert_warn_cb
assert_warn_cb_t assert_warn_cb
Definition: gr55xx_sys.h:152
pmu_trim_info_t
PMU trim parameter information definition.
Definition: gr55xx_sys.h:192
SYS_DEV_SRAM_128K
@ SYS_DEV_SRAM_128K
Definition: gr55xx_sys.h:115
sdk_version_t
SDK version definition.
Definition: gr55xx_sys.h:140
PACKAGE_GR5515GGBD
@ PACKAGE_GR5515GGBD
Definition: gr55xx_sys.h:124
link_rx_info_t::rx_normal_cnt
uint32_t rx_normal_cnt
Definition: gr55xx_sys.h:164
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:102
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.
dfu_boot_info_t
Boot information definition.
Definition: gr55xx_dfu.h:88
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:90
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:184
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:162
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.
sys_get_efuse_io_ldo
uint16_t sys_get_efuse_io_ldo(uint16_t *io_ldo)
Get the chip's IO LDO voltage.
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:177
int_func_t
int(* int_func_t)(void)
Low power clock update function type with resturn.
Definition: gr55xx_sys.h:93
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:130
sys_delay_ms
void sys_delay_ms(uint32_t ms)
Delay the function execution.
sys_firmware_jump
void sys_firmware_jump(dfu_boot_info_t *p_boot_info)
jump to app firmware. 69
sys_delay_us
void sys_delay_us(uint32_t us)
Delay the function execution.
PACKAGE_GR5515IENDU
@ PACKAGE_GR5515IENDU
Definition: gr55xx_sys.h:131
package_type_t
package_type_t
package type.
Definition: gr55xx_sys.h:121
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:193
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:170
sys_ble_static_addr_policy_reverse
void sys_ble_static_addr_policy_reverse(void)
Reverse the policy for static address created by chip uuid .
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:129
link_rx_info_t::rx_total_cnt
uint32_t rx_total_cnt
Definition: gr55xx_sys.h:158
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:114
adc_trim_info_t::offset_ext_1p0
uint16_t offset_ext_1p0
Definition: gr55xx_sys.h:187
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.
gr55xx_dfu.h
Device Firmware Update API.
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:151
PACKAGE_GR5515IGND
@ PACKAGE_GR5515IGND
Definition: gr55xx_sys.h:125
link_rx_info_t
Link RX information definition.
Definition: gr55xx_sys.h:157
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:176
rf_trim_info_t::tx_power
int8_t tx_power
Definition: gr55xx_sys.h:171
sdk_version_t::commit_id
uint32_t commit_id
Definition: gr55xx_sys.h:144
sdk_version_t::build
uint16_t build
Definition: gr55xx_sys.h:143
adc_trim_info_t::slope_int_1p2
uint16_t slope_int_1p2
Definition: gr55xx_sys.h:180
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:197
SYS_DEV_SRAM_256K
@ SYS_DEV_SRAM_256K
Definition: gr55xx_sys.h:116
sys_assert_cb_t
Assert callbacks.
Definition: gr55xx_sys.h:149
pmu_trim_info_t::dig_ldo_64m
uint8_t dig_ldo_64m
Definition: gr55xx_sys.h:195
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:159
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 us into a duration in lp cycles.
adc_trim_info_t::offset_int_1p6
uint16_t offset_int_1p6
Definition: gr55xx_sys.h:183
pmu_trim_info_t::dig_ldo_16m
uint8_t dig_ldo_16m
Definition: gr55xx_sys.h:196
gr55xx_fpb.h
sys_assert_cb_t::assert_err_cb
assert_err_cb_t assert_err_cb
Definition: gr55xx_sys.h:150
ble.h
include all ble sdk header files
PACKAGE_GR5515RGBD
@ PACKAGE_GR5515RGBD
Definition: gr55xx_sys.h:123
sys_ke_sleep_check
bool sys_ke_sleep_check(void)
Get status of ke_event list.