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