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