gr533x_sys_sdk.h
Go to the documentation of this file.
1 /**
2 *******************************************************************************
3 *
4 * @file gr533x_sys.h
5 *
6 * @brief GR533X 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 __GR533X_SYS_SDK_H__
52 #define __GR533X_SYS_SDK_H__
53
54 #include "gr533x_sys_cfg.h"
55 #include "gr533x_nvds.h"
56 #include "gr533x_pwr.h"
57 #include "gr5xx_fpb.h"
58
59 #include <stdint.h>
60 #include <stdio.h>
61 #include <stdbool.h>
62 #include <stdarg.h>
63
64 /** @addtogroup GR533X_SYS_DEFINES Defines
65 * @{
66 */
67 #define SYS_BOOT_SETTING_PATTERN 0x474F4F44
68 #define SYS_BOOT_SETTING_RSV_MAGIC 0xFFFFFFFF
69 #define SYS_BOOT_SETTING_SWD_ENABLE 0xFF
70 #define SYS_BOOT_SETTING_SWD_DISABLE 0xA5
71 #define SYS_SCA_SETTING_ADDR 0x0027F000
72 #define SYS_INVALID_TIMER_ID 0xFF /**< Invalid system Timer ID. */
73 #define SYS_BD_ADDR_LEN BLE_GAP_ADDR_LEN /**< Length of Bluetoth Device Address. */
74 #define SYS_CHIP_UID_LEN 0x10 /**< Length of Bluetoth Chip UID. */
75 #define SYS_SET_BD_ADDR(BD_ADDR_ARRAY) nvds_put(0xC001, SYS_BD_ADDR_LEN, BD_ADDR_ARRAY) /**< NVDS put BD address. */
76 #define SYS_ROM_VERSION_ADDR ((uint32_t)(0x200)) /**< The rom version address. */
77 /** @} */
78
79 /**
80 * @defgroup GR533X_SYS_TYPEDEF Typedefs
81 * @{
82 */
83 /**@brief The function pointers to register event callback. */
84 typedef void (*callback_t)(int);
85
86 /** @brief Timer callback type. */
87 typedef void (*timer_callback_t)(uint8_t timer_id);
88
89 /**@brief Printf callback type. */
90 typedef int (*vprintf_callback_t) (const char *fmt, va_list argp);
91
92 /**@brief raw log callback type. */
93 typedef uint16_t (*raw_log_send_cb_t) (uint8_t *p_data, uint16_t length);
94
95 /**@brief Low power clock update function type. */
96 typedef void (*void_func_t)(void);
97
98 /**@brief Low power clock update function type. */
99 typedef int32_t (*int_func_t)(void);
100
101 /**@brief Function type for saving user context before deep sleep. */
102 typedef void (*sys_context_func_t)(void);
103
104 /**@brief Error assert callback type. */
105 typedef void (*assert_err_cb_t)(const char *expr, const char *file, int line);
106
107 /**@brief Parameter assert callback type. */
108 typedef void (*assert_param_cb_t)(int param0, int param1, const char *file, int line);
109
110 /**@brief Warning assert callback type. */
111 typedef void (*assert_warn_cb_t)(int param0, int param1, const char *file, int line);
112 /** @} */
113
114 /** @addtogroup GR533X_SYS_ENUMERATIONS Enumerations
115 * @{*/
116 /**@brief Definition of Device SRAM Size Enumerations. */
117 typedef enum
118 {
119 SYS_DEV_SRAM_48K = 0x30, /**< Supported 48K SRAM. */
120 SYS_DEV_SRAM_64K = 0x40, /**< Supported 64K SRAM. */
121 SYS_DEV_SRAM_80K = 0x50, /**< Supported 80K SRAM. */
122 SYS_DEV_SRAM_96K = 0x60, /**< Supported 96K SRAM. */
123 } sram_size_t;
124
125 /**@brief package type. */
126 typedef enum
127 {
128 PACKAGE_NONE = 0xFFFF, /**< Package unused. */
129 PACKAGE_GR5332CENI = 0x0200, /**< (QFN48, 85Centigrade, 512KB Flash, 96K SRAM). */
130 PACKAGE_GR5332CENE = 0x0201, /**< (QFN48, 105Centigrade, 512KB Flash, 96K SRAM). */
131 PACKAGE_GR5332AENI = 0x0202, /**< (QFN32, 85Centigrade, 512KB Flash, 96K SRAM). */
132 PACKAGE_GR5332AENE = 0x0203, /**< (QFN32, 105Centigrade, 512KB Flash, 96K SRAM). */
133 PACKAGE_GR5331CENI = 0x0204, /**< (QFN48, 85Centigrade, 512KB Flash, 96K SRAM). */
134 PACKAGE_GR5331AENI = 0x0205, /**< (QFN32, 85Centigrade, 512KB Flash, 96K SRAM). */
135 PACKAGE_GR5330ACNI = 0x0206, /**< (QFN32, 85Centigrade, 256B Flash, 64K SRAM). */
136 PACKAGE_GR5330AENI = 0x0207, /**< (QFN32, 85Centigrade, 512B Flash, 64K SRAM). */
137 PACKAGE_GR5331DEBI = 0x0208, /**< (BGA45, 85Centigrade, 512B Flash, 96K SRAM). */
138 } package_type_t;
139
140 /**@brief package type. */
141 typedef enum
142 {
143 HW_VERSION_B2 = 0x4232, /**< hw version B2. */
144 HW_VERSION_B3 = 0x4233, /**< hw version B3. */
145 } hw_version_type_t;
146
147 /** @} */
148
149 /** @addtogroup GR533X_SYS_STRUCTURES Structures
150 * @{ */
151 /**@brief SDK version definition. */
152 typedef struct
153 {
154 uint8_t major; /**< Major version. */
155 uint8_t minor; /**< Minor version. */
156 uint16_t build; /**< Build number. */
157 uint32_t commit_id; /**< commit ID. */
158 }sdk_version_t;
159
160 /**@brief Assert callbacks.*/
161 typedef struct
162 {
163 assert_err_cb_t assert_err_cb; /**< Assert error type callback. */
164 assert_param_cb_t assert_param_cb; /**< Assert parameter error type callback. */
165 assert_warn_cb_t assert_warn_cb; /**< Assert warning type callback. */
166 }sys_assert_cb_t;
167
168 /**@brief RF trim parameter information definition. */
169 typedef struct
170 {
171 int8_t rssi_cali; /**< RSSI calibration. */
172 int8_t tx_power; /**< TX power. */
173 } rf_trim_info_t;
174
175 /**@brief ADC trim parameter information definition. */
176 typedef struct
177 {
178 uint16_t adc_temp; /**< ADC TEMP. */
179 uint16_t adc_temp_ref; /**< ADC Reference temperature*/
180 uint16_t adc_vbat_div; /**< ADC internal resistance ratio*/
181 uint16_t slope_int_0p8; /**< Internal reference 0.8v. */
182 uint16_t offset_int_0p8; /**< Internal reference 0.8v. */
183 uint16_t slope_int_1p2; /**< Internal reference 1.2v. */
184 uint16_t offset_int_1p2; /**< Internal reference 1.2v. */
185 uint16_t slope_int_1p6; /**< Internal reference 1.6v. */
186 uint16_t offset_int_1p6; /**< Internal reference 1.6v. */
187 uint16_t slope_int_2p0; /**< Internal reference 2.0v. */
188 uint16_t offset_int_2p0; /**< Internal reference 2.0v. */
189 uint16_t slope_ext_1p0; /**< External reference 1.0v. */
190 uint16_t offset_ext_1p0; /**< External reference 1.0v. */
191 uint8_t cali_mode; /**< ADC calibration mode. */
192 } adc_trim_info_t;
193
194
195
196 /**@brief PMU trim parameter information definition. */
197 typedef struct
198 {
199 uint8_t io_ldo_vout; /**< IO LDO Vout, trim step is about 13mV. */
200 uint8_t dig_ldo_1p05_coarse; /**< DIG LDO 64m Coarse Code, trim step is about 100mV. */
201 uint8_t dig_ldo_1p05_fine; /**< DIG LDO 64m Fine Code, trim step is about 30mV. */
202 uint8_t dig_ldo_0p9_coarse; /**< DIG LDO 16m Coarse Code, trim step is about 100mV. */
203 uint8_t dig_ldo_0p9_fine; /**< DIG LDO 16m Fine Code, trim step is about 30mV. */
204 uint8_t dcdc_vout1p15; /**< DCDC 64m Vout, trim step is about 25mV. */
205 uint8_t dcdc_vout1p05; /**< DCDC 16m Vout, trim step is about 25mV. */
206 uint8_t sys_ldo_1p15; /**< SYSLDO 64m Vout, Trim step is about 30mV. */
207 uint8_t sys_ldo_1p05; /**< SYSLDO 16m Vout, Trim step is about 30mV. */
208 } pmu_trim_info_t;
209
210 /**@brief Ringo trim information definition. */
211 typedef struct
212 {
213 uint16_t ringo_dig_0p9; /**< Ringo Value with digital core 0.9V. */
214 uint16_t ringo_dig_1p05; /**< Ringo Value with digital core 1.05V. */
215 } ringo_trim_info_t;
216
217 /**@brief Warm boot timing parameters(unit: us). */
218 typedef struct
219 {
220 uint16_t fast_ldo_prep; /**< Fast ldo prep. */
221 uint16_t hf_osc_prep; /**< HF Osc prep. */
222 uint16_t dcdc_prep; /**< DCDC prep. */
223 uint16_t dig_ldo_prep; /**< Dig ldo prep. */
224 uint16_t xo_prep; /**< XO prep. */
225 uint16_t pll_prep; /**< PLL prep. */
226 uint16_t pll_lock; /**< PLL lock. */
227 uint16_t pwr_sw_prep; /**< PWR sw prep. */
228 } boot_timing_params_t;
229
230 typedef struct __attribute((packed))
231 {
232 uint32_t pattern;
233 uint32_t load_addr;
234 uint32_t run_addr;
235 uint32_t bin_size;
236 uint32_t fw_check_sum;
237 uint8_t check_image;
238 uint8_t boot_delay;
239 uint8_t swd_control;
240 uint8_t check_sec;
241 uint8_t pad_size;
242 uint8_t comments[20];
243 uint8_t reserved[15];
244 uint32_t setting_check_sum;
245 } sys_boot_setting_t;
246
247 /** @} */
248
249 /** @addtogroup GR533X_SYS_FUNCTIONS Functions
250 * @{ */
251 /**
252 *****************************************************************************************
253 * @brief Malloc size memery.
254 *
255 * @param[in] size: memery size.
256 *****************************************************************************************
257 */
258 void *sys_malloc(uint32_t size);
259
260 /**
261 *****************************************************************************************
262 * @brief free memery.
263 *
264 * @param[in] mem_ptr: memery to be free.
265 *****************************************************************************************
266 */
267 void sys_free(void *mem_ptr);
268
269
270 /**
271 *****************************************************************************************
272 * @brief Output debug logs.
273 *
274 * @param[in] format: Pointer to the log information.
275 *****************************************************************************************
276 */
277 void sys_app_printf(const char *format, ...);
278
279 /**
280 *****************************************************************************************
281 * @brief Delay the function execution.
282 *
283 * @param[in] us: Microsecond.
284 *****************************************************************************************
285 */
286 void delay_us(uint32_t us);
287
288 /**
289 *****************************************************************************************
290 * @brief Delay the function execution.
291 *
292 * @param[in] ms: Millisecond.
293 *****************************************************************************************
294 */
295 void delay_ms(uint32_t ms);
296
297 /**
298 *****************************************************************************************
299 * @brief Register signal handler.
300 *
301 * @note This function is mainly used to register the upper-layer APP callback functions to the protocol layer,
302 * which will be invoked when there are event responses in the protocol layer.
303 *****************************************************************************************
304 */
305 void sys_signal_handler_register(callback_t isr_handler);
306
307 /**
308 *****************************************************************************************
309 * @brief Get SDK version.
310 *
311 * @note This function is mainly used to get the version of SDK.
312 *
313 * @param[out] p_version: The pointer to struct of @ref sdk_version_t.
314 *****************************************************************************************
315 */
316 void sys_sdk_verison_get(sdk_version_t *p_version);
317
318 /**
319 *****************************************************************************************
320 * @brief Save system context.
321 *
322 * @note This function is used to save system context before the system goes to deep sleep.
323 * Boot codes will be used to restore system context in the wakeup procedure.
324 *****************************************************************************************
325 */
326 void sys_context_save(void);
327
328 /**
329 *****************************************************************************************
330 * @brief Load system context.
331 *
332 * @note This function is used to load system context after the system goes to deep sleep.
333 *****************************************************************************************
334 */
335 void restore_sys_context(void);
336
337 /**
338 *****************************************************************************************
339 * @brief Encrypt and decrypt data using Present.
340 *
341 * @note This function is only used to encrypt and decrypt data that needs to be stored in Flash.
342 *
343 * @param[in] addr: Operation address (Flash address minus Flash start address).
344 * @param[in] input: Data before encryption and decryption.
345 * @param[in] size: Data size.
346 * @param[out] output: Data after encryption and decryption.
347 *****************************************************************************************
348 */
349 void sys_security_data_use_present(uint32_t addr, uint8_t *input, uint32_t size, uint8_t *output);
350
351 /**
352 *****************************************************************************************
353 * @brief Get the RF trim information.
354 *
355 * @param[out] p_rf_trim: The pointer to struct of @ref rf_trim_info_t.
356 *
357 * @return Result of get.
358 *****************************************************************************************
359 */
360 uint16_t sys_rf_trim_get(rf_trim_info_t *p_rf_trim);
361
362 /**
363 *****************************************************************************************
364 * @brief Get the ADC trim information.
365 *
366 * @param[out] p_adc_trim: The pointer to struct of @ref adc_trim_info_t.
367 *
368 * @return Result of get.
369 *****************************************************************************************
370 */
371 uint16_t sys_adc_trim_get(adc_trim_info_t *p_adc_trim);
372
373 /**
374 *****************************************************************************************
375 * @brief Get the PMU trim information.
376 *
377 * @param[out] p_pmu_trim: The pointer to struct of @ref pmu_trim_info_t.
378 *
379 * @return Result of get.
380 *****************************************************************************************
381 */
382 uint16_t sys_pmu_trim_get(pmu_trim_info_t *p_pmu_trim);
383
384 /**
385 *****************************************************************************************
386 * @brief Get the crystal trim information.
387 *
388 * @param[out] p_crystal_trim: offset information for crystal.
389 *
390 * @return Result of get.
391 *****************************************************************************************
392 */
393 uint16_t sys_crystal_trim_get(uint16_t *p_crystal_trim);
394
395 /**
396 *****************************************************************************************
397 * @brief Get the trim checksum.
398 *
399 * @param[out] p_trim_sum: The pointer to the buffer for trim checksum.
400 *
401 * @return Result of get.
402 *****************************************************************************************
403 */
404 uint16_t sys_trim_sum_get(uint16_t *p_trim_sum);
405
406 /**
407 *****************************************************************************************
408 * @brief Get the device address information.
409 *
410 * @param[out] p_device_addr: Bluetooth address by default.
411 *
412 * @return Result of get.
413 *****************************************************************************************
414 */
415 uint16_t sys_device_addr_get(uint8_t *p_device_addr);
416
417 /**
418 *****************************************************************************************
419 * @brief Get the HW version information.
420 *
421 * @param[out] p_hw_version: The pointer to the buffer for hw version.
422 *
423 * @return Result of get.
424 *****************************************************************************************
425 */
426 uint16_t sys_hw_version_get(hw_version_type_t *p_hw_version);
427 bool sys_hw_version_is_B3(void);
428
429 /**
430 *****************************************************************************************
431 * @brief Get the device UID information.
432 *
433 * @param[out] p_device_uid: Device chip UID.
434 *
435 * @return Result of get.
436 *****************************************************************************************
437 */
438 uint16_t sys_device_uid_get(uint8_t *p_device_uid);
439
440 /**
441 *****************************************************************************************
442 * @brief Get the LP gain offset 2M information.
443 *
444 * @param[out] p_offset: the offset of LP gain.
445 *
446 * @return Result of get.
447 *****************************************************************************************
448 */
449 uint16_t sys_device_lp_gain_offset_2m_get(uint8_t *p_offset);
450
451 /**
452 *****************************************************************************************
453 * @brief Get the RAM size information.
454 *
455 * @param[out] p_sram_size: The pointer to enumeration of @ref sram_size_t.
456 *
457 * @return Result of get.
458 *****************************************************************************************
459 */
460 uint16_t sys_device_sram_get(sram_size_t *p_sram_size);
461
462 /**
463 *****************************************************************************************
464 * @brief Get the chip's package type.
465 *
466 * @param[out] p_package_type: The pointer to enumeration of @ref package_type_t.
467 *
468 * @return Result of get.
469 *****************************************************************************************
470 */
471 uint16_t sys_device_package_get(package_type_t *p_package_type);
472 bool sys_device_is_PACKAGE_GR5331DEBI(void);
473
474 /**
475 *****************************************************************************************
476 * @brief Get the chip ringo trim value.
477 *
478 * @param[out] p_ringo_trim: The pointer to ringo trim value @ref ringo_trim_info_t.
479 *
480 * @return Result of get.
481 *****************************************************************************************
482 */
483 uint16_t sys_ringo_trim_get(ringo_trim_info_t *p_ringo_trim);
484
485 /**
486 *****************************************************************************************
487 * @brief Set low power CLK frequency.
488 *
489 * @param[in] user_lpclk: CLK frequency.
490 *****************************************************************************************
491 */
492 void sys_lpclk_set(uint32_t user_lpclk);
493
494 /**
495 ****************************************************************************************
496 * @brief Convert a duration in μs into a duration in lp cycles.
497 *
498 * The function converts a duration in μs into a duration in lp cycles, according to the
499 * low power clock frequency (32768Hz or 32000Hz).
500 *
501 * @param[in] us: Duration in μs.
502 *
503 * @return Duration in lpcycles.
504 ****************************************************************************************
505 */
506 uint32_t sys_us_2_lpcycles(uint32_t us);
507
508 /**
509 ****************************************************************************************
510 * @brief Convert a duration in lp cycles into a duration in half μs.
511 *
512 * The function converts a duration in lp cycles into a duration in half μs, according to the
513 * low power clock frequency (32768Hz or 32000Hz).
514 * @param[in] lpcycles: Duration in lp cycles.
515 * @param[in,out] error_corr: Insert and retrieve error created by truncating the LP Cycle Time to a half μs (in half μs).
516 *
517 * @return Duration in half μs
518 ****************************************************************************************
519 */
520 uint32_t sys_lpcycles_2_hus(uint32_t lpcycles, uint32_t *error_corr);
521
522 /**
523 *****************************************************************************************
524 * @brief Set BLE Sleep HeartBeat Period.
525 * @note The BLE Sleep HeartBeat Period is used to Wakeup BLE Periodically when BLE is IDLE.
526 *
527 * @param[in] period_hus: The wake up duration of BLE when BLE is IDEL.
528 * Range 0x00000000-0xFFFFFFFF (in unit of μs).
529 *
530 * @return Result of set.
531 *****************************************************************************************
532 */
533 uint16_t sys_ble_heartbeat_period_set(uint32_t period_hus);
534
535
536 /**
537 *****************************************************************************************
538 * @brief Get BLE Sleep HeartBeat Period.
539 * @note The BLE Sleep HeartBeat Period is used to Wakeup BLE Periodically when BLE is IDLE.
540 *
541 * @param[in] p_period_hus: Pointer to the wake up duration.
542 * Range 0x00000000-0xFFFFFFFF (in unit of μs).
543 *
544 * @return Result of get.
545 *****************************************************************************************
546 */
547 uint16_t sys_ble_heartbeat_period_get(uint32_t* p_period_hus);
548
549 /**
550 ****************************************************************************************
551 * @brief Set system maximum usage ratio of message heap.
552 *
553 * The function will used to set message ratio of message heap.
554 * Valid ratio range is 50 - 100 percent in full message size.
555 *
556 * @param[in] usage_ratio: Usage ratio of message heap size.
557 ****************************************************************************************
558 */
559 void sys_max_msg_usage_ratio_set(uint8_t usage_ratio);
560
561 /**
562 ****************************************************************************************
563 * @brief Set system lld layer 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 void sys_lld_max_msg_usage_ratio_set(uint8_t usage_ratio);
572
573 /**
574 ****************************************************************************************
575 * @brief Get system message heap usage ratio.
576 *
577 * The function will used to get message ratio of message heap.
578 * This ratio is heap used percent in full message size.
579 *
580 * @return current heap used percent.
581 ****************************************************************************************
582 */
583 uint8_t sys_msg_usage_ratio_get(void);
584
585 /**
586 ****************************************************************************************
587 * @brief Get system environment heap usage ratio.
588 *
589 * The function will used to get environment ratio of environment heap.
590 * This ratio is heap used percent in full environment size.
591 *
592 * @return current heap used percent.
593 ****************************************************************************************
594 */
595 uint8_t sys_env_usage_ratio_get(void);
596
597 /**
598 ****************************************************************************************
599 * @brief Get system attriute database heap usage ratio.
600 *
601 * The function will used to get attriute database ratio of attriute database heap.
602 * This ratio is heap used percent in full attriute database size.
603 *
604 * @return current heap used percent.
605 ****************************************************************************************
606 */
607 uint8_t sys_attdb_usage_ratio_get(void);
608
609 /**
610 ****************************************************************************************
611 * @brief Get system non retention heap usage ratio.
612 *
613 * The function will used to get non retention ratio of non retention heap.
614 * This ratio is heap used percent in full non retention size.
615 *
616 * @return current heap used percent.
617 ****************************************************************************************
618 */
619 uint8_t sys_nonret_usage_ratio_get(void);
620
621 /**
622 ****************************************************************************************
623 * @brief Get low power CLK frequency.
624 *
625 * This function is used to get the low power clock frequency.
626 *
627 * @return Low power CLK frequency.
628 ****************************************************************************************
629 */
630 uint32_t sys_lpclk_get(void);
631
632 /**
633 ****************************************************************************************
634 * @brief Get low power CLK period.
635 *
636 * This function is used to get the low power CLK period.
637 *
638 * @return Low power CLK period.
639 ****************************************************************************************
640 */
641 uint32_t sys_lpper_get(void);
642
643 /**
644 *****************************************************************************************
645 * @brief Register assert callbacks.
646 *
647 * @param[in] p_assert_cb: Pointer to assert callbacks.
648 *****************************************************************************************
649 */
650 void sys_assert_cb_register(sys_assert_cb_t *p_assert_cb);
651
652 /**
653 ****************************************************************************************
654 * @brief Get status of ke_event list
655 *
656 * @return true: ke_event not busy, false : ke_event busy.
657 ****************************************************************************************
658 */
659 bool sys_ke_sleep_check(void);
660
661 /**
662 ****************************************************************************************
663 * @brief Enable swd function
664 ****************************************************************************************
665 */
666 void sys_swd_enable(void);
667
668 /**
669 ****************************************************************************************
670 * @brief Diable swd function
671 ****************************************************************************************
672 */
673 void sys_swd_disable(void);
674
675 /**
676 ****************************************************************************************
677 * @brief Set g_io_ldo_use_3p3_v function
678 ****************************************************************************************
679 */
680 void set_io_ldo_use_3p3_v(bool flag);
681
682 /**
683 ****************************************************************************************
684 * @brief Set ble exchange memory base address
685 * @param[in] address: base address of ble exchange memory buffer.
686 ****************************************************************************************
687 */
688 void ble_stack_em_base_init(uint32_t address);
689
690 /**
691 ****************************************************************************************
692 * @brief Set ble exchange memory buffer address common offset
693 * @param[in] offset: Offset of ble exchange memory buffer.
694 ****************************************************************************************
695 */
696 void ble_em_addr_offset_set(uint16_t offset);
697
698 /**
699 ****************************************************************************************
700 * @brief Register the callback function of the extended llcp process
701 *
702 * @param[in] conn_idx: Connect index.
703 * @param[in] interval: Connect interval (unit: 312.5 us)
704 * @param[in] latency: Connect latency (unit of connection event)
705 * @param[in] superv_to: Link supervision timeout (unit of 10 ms)
706 *
707 * @return Error status.
708 ****************************************************************************************
709 */
710 uint8_t sys_sdk_ultra_conn_update(uint8_t conn_idx, uint16_t interval, uint16_t latency, uint16_t superv_to);
711
712 /**
713 *****************************************************************************************
714 * @brief jump to app firmware.
715 *
716 * @param[in] fw_addr: Firmware run address
717 * @param[in] fw_bin_size: Firmware bin size
718 *****************************************************************************************
719 */
720 void sys_firmware_jump(uint32_t fw_addr, uint32_t fw_bin_size);
721
722 /** @} */
723 #endif
724
725 /** @} */
726 /** @} */
sys_ringo_trim_get
uint16_t sys_ringo_trim_get(ringo_trim_info_t *p_ringo_trim)
Get the chip ringo trim value.
boot_timing_params_t::pwr_sw_prep
uint16_t pwr_sw_prep
Definition: gr533x_sys_sdk.h:227
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_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.
pmu_trim_info_t::sys_ldo_1p05
uint8_t sys_ldo_1p05
Definition: gr533x_sys_sdk.h:207
PACKAGE_GR5330ACNI
@ PACKAGE_GR5330ACNI
Definition: gr533x_sys_sdk.h:135
adc_trim_info_t::offset_int_1p2
uint16_t offset_int_1p2
Definition: gr533x_sys_sdk.h:184
pmu_trim_info_t::io_ldo_vout
uint8_t io_ldo_vout
Definition: gr533x_sys_sdk.h:199
sdk_version_t::major
uint8_t major
Definition: gr533x_sys_sdk.h:154
adc_trim_info_t::offset_int_2p0
uint16_t offset_int_2p0
Definition: gr533x_sys_sdk.h:188
adc_trim_info_t::slope_int_1p6
uint16_t slope_int_1p6
Definition: gr533x_sys_sdk.h:185
gr533x_pwr.h
GR533X Platform Power Manager Module API.
sys_sdk_ultra_conn_update
uint8_t sys_sdk_ultra_conn_update(uint8_t conn_idx, uint16_t interval, uint16_t latency, uint16_t superv_to)
Register the callback function of the extended llcp process.
sys_device_addr_get
uint16_t sys_device_addr_get(uint8_t *p_device_addr)
Get the device address information.
restore_sys_context
void restore_sys_context(void)
Load system context.
PACKAGE_NONE
@ PACKAGE_NONE
Definition: gr533x_sys_sdk.h:128
sys_app_printf
void sys_app_printf(const char *format,...)
Output debug logs.
sys_device_package_get
uint16_t sys_device_package_get(package_type_t *p_package_type)
Get the chip's package type.
rf_trim_info_t
RF trim parameter information definition.
Definition: gr533x_sys_sdk.h:170
sys_hw_version_get
uint16_t sys_hw_version_get(hw_version_type_t *p_hw_version)
Get the HW version information.
hw_version_type_t
hw_version_type_t
package type.
Definition: gr533x_sys_sdk.h:142
gr533x_sys_cfg.h
Define the chip configuration.
sdk_version_t::minor
uint8_t minor
Definition: gr533x_sys_sdk.h:155
sys_hw_version_is_B3
bool sys_hw_version_is_B3(void)
sys_ble_heartbeat_period_set
uint16_t sys_ble_heartbeat_period_set(uint32_t period_hus)
Set BLE Sleep HeartBeat Period.
sys_pmu_trim_get
uint16_t sys_pmu_trim_get(pmu_trim_info_t *p_pmu_trim)
Get the PMU trim information.
sys_nonret_usage_ratio_get
uint8_t sys_nonret_usage_ratio_get(void)
Get system non retention heap usage ratio.
adc_trim_info_t::offset_int_0p8
uint16_t offset_int_0p8
Definition: gr533x_sys_sdk.h:182
__attribute
struct __attribute((packed))
Definition: gr533x_sys_sdk.h:230
assert_err_cb_t
void(* assert_err_cb_t)(const char *expr, const char *file, int line)
Error assert callback type.
Definition: gr533x_sys_sdk.h:105
timer_callback_t
void(* timer_callback_t)(uint8_t timer_id)
Timer callback type.
Definition: gr533x_sys_sdk.h:87
adc_trim_info_t::slope_ext_1p0
uint16_t slope_ext_1p0
Definition: gr533x_sys_sdk.h:189
sys_trim_sum_get
uint16_t sys_trim_sum_get(uint16_t *p_trim_sum)
Get the trim checksum.
PACKAGE_GR5331AENI
@ PACKAGE_GR5331AENI
Definition: gr533x_sys_sdk.h:134
sys_lpper_get
uint32_t sys_lpper_get(void)
Get low power CLK period.
sys_device_uid_get
uint16_t sys_device_uid_get(uint8_t *p_device_uid)
Get the device UID information.
package_type_t
package_type_t
package type.
Definition: gr533x_sys_sdk.h:127
raw_log_send_cb_t
uint16_t(* raw_log_send_cb_t)(uint8_t *p_data, uint16_t length)
raw log callback type.
Definition: gr533x_sys_sdk.h:93
ringo_trim_info_t
Ringo trim information definition.
Definition: gr533x_sys_sdk.h:212
sys_device_is_PACKAGE_GR5331DEBI
bool sys_device_is_PACKAGE_GR5331DEBI(void)
PACKAGE_GR5332AENI
@ PACKAGE_GR5332AENI
Definition: gr533x_sys_sdk.h:131
SYS_DEV_SRAM_48K
@ SYS_DEV_SRAM_48K
Definition: gr533x_sys_sdk.h:119
boot_timing_params_t
Warm boot timing parameters(unit: us).
Definition: gr533x_sys_sdk.h:219
sys_msg_usage_ratio_get
uint8_t sys_msg_usage_ratio_get(void)
Get system message heap usage ratio.
adc_trim_info_t::slope_int_0p8
uint16_t slope_int_0p8
Definition: gr533x_sys_sdk.h:181
boot_timing_params_t::dig_ldo_prep
uint16_t dig_ldo_prep
Definition: gr533x_sys_sdk.h:223
sys_assert_cb_t::assert_warn_cb
assert_warn_cb_t assert_warn_cb
Definition: gr533x_sys_sdk.h:165
sys_env_usage_ratio_get
uint8_t sys_env_usage_ratio_get(void)
Get system environment heap usage ratio.
SYS_DEV_SRAM_64K
@ SYS_DEV_SRAM_64K
Definition: gr533x_sys_sdk.h:120
sys_rf_trim_get
uint16_t sys_rf_trim_get(rf_trim_info_t *p_rf_trim)
Get the RF trim information.
pmu_trim_info_t
PMU trim parameter information definition.
Definition: gr533x_sys_sdk.h:198
sdk_version_t
SDK version definition.
Definition: gr533x_sys_sdk.h:153
sys_device_sram_get
uint16_t sys_device_sram_get(sram_size_t *p_sram_size)
Get the RAM size information.
assert_param_cb_t
void(* assert_param_cb_t)(int param0, int param1, const char *file, int line)
Parameter assert callback type.
Definition: gr533x_sys_sdk.h:108
SYS_DEV_SRAM_96K
@ SYS_DEV_SRAM_96K
Definition: gr533x_sys_sdk.h:122
boot_timing_params_t::pll_lock
uint16_t pll_lock
Definition: gr533x_sys_sdk.h:226
PACKAGE_GR5331DEBI
@ PACKAGE_GR5331DEBI
Definition: gr533x_sys_sdk.h:137
PACKAGE_GR5330AENI
@ PACKAGE_GR5330AENI
Definition: gr533x_sys_sdk.h:136
SYS_DEV_SRAM_80K
@ SYS_DEV_SRAM_80K
Definition: gr533x_sys_sdk.h:121
pmu_trim_info_t::sys_ldo_1p15
uint8_t sys_ldo_1p15
Definition: gr533x_sys_sdk.h:206
sys_signal_handler_register
void sys_signal_handler_register(callback_t isr_handler)
Register signal handler.
adc_trim_info_t::slope_int_2p0
uint16_t slope_int_2p0
Definition: gr533x_sys_sdk.h:187
sys_swd_disable
void sys_swd_disable(void)
Diable swd function.
set_io_ldo_use_3p3_v
void set_io_ldo_use_3p3_v(bool flag)
Set g_io_ldo_use_3p3_v function.
sys_adc_trim_get
uint16_t sys_adc_trim_get(adc_trim_info_t *p_adc_trim)
Get the ADC trim information.
delay_us
void delay_us(uint32_t us)
Delay the function execution.
adc_trim_info_t::adc_vbat_div
uint16_t adc_vbat_div
Definition: gr533x_sys_sdk.h:180
sys_firmware_jump
void sys_firmware_jump(uint32_t fw_addr, uint32_t fw_bin_size)
jump to app firmware.
sys_context_func_t
void(* sys_context_func_t)(void)
Function type for saving user context before deep sleep.
Definition: gr533x_sys_sdk.h:102
sys_sdk_verison_get
void sys_sdk_verison_get(sdk_version_t *p_version)
Get SDK version.
HW_VERSION_B2
@ HW_VERSION_B2
Definition: gr533x_sys_sdk.h:143
sram_size_t
sram_size_t
Definition of Device SRAM Size Enumerations.
Definition: gr533x_sys_sdk.h:118
adc_trim_info_t::adc_temp
uint16_t adc_temp
Definition: gr533x_sys_sdk.h:178
pmu_trim_info_t::dcdc_vout1p05
uint8_t dcdc_vout1p05
Definition: gr533x_sys_sdk.h:205
sys_free
void sys_free(void *mem_ptr)
free memery.
pmu_trim_info_t::dig_ldo_1p05_coarse
uint8_t dig_ldo_1p05_coarse
Definition: gr533x_sys_sdk.h:200
rf_trim_info_t::rssi_cali
int8_t rssi_cali
Definition: gr533x_sys_sdk.h:171
sys_us_2_lpcycles
uint32_t sys_us_2_lpcycles(uint32_t us)
Convert a duration in μs into a duration in lp cycles.
ringo_trim_info_t::ringo_dig_0p9
uint16_t ringo_dig_0p9
Definition: gr533x_sys_sdk.h:213
sys_swd_enable
void sys_swd_enable(void)
Enable swd function.
sys_context_save
void sys_context_save(void)
Save system context.
delay_ms
void delay_ms(uint32_t ms)
Delay the function execution.
sys_lpclk_set
void sys_lpclk_set(uint32_t user_lpclk)
Set low power CLK frequency.
PACKAGE_GR5332CENI
@ PACKAGE_GR5332CENI
Definition: gr533x_sys_sdk.h:129
int_func_t
int32_t(* int_func_t)(void)
Low power clock update function type.
Definition: gr533x_sys_sdk.h:99
sys_lpclk_get
uint32_t sys_lpclk_get(void)
Get low power CLK frequency.
pmu_trim_info_t::dig_ldo_1p05_fine
uint8_t dig_ldo_1p05_fine
Definition: gr533x_sys_sdk.h:201
adc_trim_info_t::offset_ext_1p0
uint16_t offset_ext_1p0
Definition: gr533x_sys_sdk.h:190
vprintf_callback_t
int(* vprintf_callback_t)(const char *fmt, va_list argp)
Printf callback type.
Definition: gr533x_sys_sdk.h:90
HW_VERSION_B3
@ HW_VERSION_B3
Definition: gr533x_sys_sdk.h:144
sys_assert_cb_register
void sys_assert_cb_register(sys_assert_cb_t *p_assert_cb)
Register assert callbacks.
sys_boot_setting_t
sys_boot_setting_t
Definition: gr533x_sys_sdk.h:245
boot_timing_params_t::hf_osc_prep
uint16_t hf_osc_prep
Definition: gr533x_sys_sdk.h:221
sys_lpcycles_2_hus
uint32_t sys_lpcycles_2_hus(uint32_t lpcycles, uint32_t *error_corr)
Convert a duration in lp cycles into a duration in half μs.
sys_ke_sleep_check
bool sys_ke_sleep_check(void)
Get status of ke_event list.
sys_assert_cb_t::assert_param_cb
assert_param_cb_t assert_param_cb
Definition: gr533x_sys_sdk.h:164
void_func_t
void(* void_func_t)(void)
Low power clock update function type.
Definition: gr533x_sys_sdk.h:96
assert_warn_cb_t
void(* assert_warn_cb_t)(int param0, int param1, const char *file, int line)
Warning assert callback type.
Definition: gr533x_sys_sdk.h:111
adc_trim_info_t
ADC trim parameter information definition.
Definition: gr533x_sys_sdk.h:177
rf_trim_info_t::tx_power
int8_t tx_power
Definition: gr533x_sys_sdk.h:172
sdk_version_t::commit_id
uint32_t commit_id
Definition: gr533x_sys_sdk.h:157
pmu_trim_info_t::dig_ldo_0p9_fine
uint8_t dig_ldo_0p9_fine
Definition: gr533x_sys_sdk.h:203
boot_timing_params_t::xo_prep
uint16_t xo_prep
Definition: gr533x_sys_sdk.h:224
PACKAGE_GR5332AENE
@ PACKAGE_GR5332AENE
Definition: gr533x_sys_sdk.h:132
ble_em_addr_offset_set
void ble_em_addr_offset_set(uint16_t offset)
Set ble exchange memory buffer address common offset.
sdk_version_t::build
uint16_t build
Definition: gr533x_sys_sdk.h:156
adc_trim_info_t::slope_int_1p2
uint16_t slope_int_1p2
Definition: gr533x_sys_sdk.h:183
ble_stack_em_base_init
void ble_stack_em_base_init(uint32_t address)
Set ble exchange memory base address.
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.
pmu_trim_info_t::dig_ldo_0p9_coarse
uint8_t dig_ldo_0p9_coarse
Definition: gr533x_sys_sdk.h:202
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.
PACKAGE_GR5331CENI
@ PACKAGE_GR5331CENI
Definition: gr533x_sys_sdk.h:133
adc_trim_info_t::adc_temp_ref
uint16_t adc_temp_ref
Definition: gr533x_sys_sdk.h:179
sys_assert_cb_t
Assert callbacks.
Definition: gr533x_sys_sdk.h:162
sys_malloc
void * sys_malloc(uint32_t size)
Malloc size memery.
boot_timing_params_t::fast_ldo_prep
uint16_t fast_ldo_prep
Definition: gr533x_sys_sdk.h:220
boot_timing_params_t::pll_prep
uint16_t pll_prep
Definition: gr533x_sys_sdk.h:225
callback_t
void(* callback_t)(int)
The function pointers to register event callback.
Definition: gr533x_sys_sdk.h:84
adc_trim_info_t::cali_mode
uint8_t cali_mode
Definition: gr533x_sys_sdk.h:191
sys_crystal_trim_get
uint16_t sys_crystal_trim_get(uint16_t *p_crystal_trim)
Get the crystal trim information.
gr533x_nvds.h
NVDS API.
sys_attdb_usage_ratio_get
uint8_t sys_attdb_usage_ratio_get(void)
Get system attriute database heap usage ratio.
adc_trim_info_t::offset_int_1p6
uint16_t offset_int_1p6
Definition: gr533x_sys_sdk.h:186
sys_assert_cb_t::assert_err_cb
assert_err_cb_t assert_err_cb
Definition: gr533x_sys_sdk.h:163
pmu_trim_info_t::dcdc_vout1p15
uint8_t dcdc_vout1p15
Definition: gr533x_sys_sdk.h:204
sys_ble_heartbeat_period_get
uint16_t sys_ble_heartbeat_period_get(uint32_t *p_period_hus)
Get BLE Sleep HeartBeat Period.
boot_timing_params_t::dcdc_prep
uint16_t dcdc_prep
Definition: gr533x_sys_sdk.h:222
PACKAGE_GR5332CENE
@ PACKAGE_GR5332CENE
Definition: gr533x_sys_sdk.h:130
ringo_trim_info_t::ringo_dig_1p05
uint16_t ringo_dig_1p05
Definition: gr533x_sys_sdk.h:214