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