Production Line Tool v5.0
The DA1470x Production Line Tool Software Package
Loading...
Searching...
No Matches
ic_specifics.h
Go to the documentation of this file.
1
16#ifndef _IC_SPECIFICS_H
17#define _IC_SPECIFICS_H
18
19/*************************************************************************/
20/* INCLUDE FILES */
21/*************************************************************************/
22#include <stdint.h>
23#include <math.h>
24#include <stdlib.h>
25#include <stdio.h>
26#include <string.h>
27#include <windows.h>
28#include <strsafe.h>
29
30
59#define __IC_SPEC_SAFE_SNPRINTF(out_str, ...) \
60{ \
61 out_str[0] = '\0'; \
62 _snprintf_s(out_str, sizeof(out_str), _TRUNCATE, __VA_ARGS__); \
63}
64
70#define IS_580(dut_ic) (dut_ic == DUT_IC_DA14580)
71
77#define IS_70x(dut_ic) ((dut_ic == DUT_IC_DA14701) |\
78 (dut_ic == DUT_IC_DA14705) |\
79 (dut_ic == DUT_IC_DA14706) |\
80 (dut_ic == DUT_IC_DA14708))
81
87#define IS_701(dut_ic) (dut_ic == DUT_IC_DA14701)
88
94#define IS_705(dut_ic) (dut_ic == DUT_IC_DA14705)
95
101#define IS_706(dut_ic) (dut_ic == DUT_IC_DA14706)
102
108#define IS_708(dut_ic) (dut_ic == DUT_IC_DA14708)
109
111#define DUT_IC_DA14580_STR "DA14580"
113#define DUT_IC_DA14701_STR "DA14701"
115#define DUT_IC_DA14705_STR "DA14705"
117#define DUT_IC_DA14706_STR "DA14706"
119#define DUT_IC_DA14708_STR "DA14708"
120
125#define CFG_FW_PROD_TEST_70x "st_fw_da1470x.bin"
126
130#define CFG_FW_70x_FLASH_PROG "uartboot_da1470x.bin"
131
133#define DUT_IC_SLEEP_THRES_DA1470x 8000
134
137#define PULSE_IN_RX_STR "PULSE_IN_RX"
138
146#define IC_58x_GPIO_PORT_PIN_TO_ENUM(port, pin) (port * 10 + pin)
147
154#define IC_58x_GPIO_ENUM_TO_PORT(enum_val) ((int)floor((double)enum_val / 10))
155
162#define IC_58x_GPIO_ENUM_TO_PIN(enum_val) (enum_val % 10)
163
169#define IC_58x_GPIO_VALID(val) \
170 (((val >= IC_58x_P0_0) && (val <= IC_58x_P0_7)) || \
171 ((val >= IC_58x_P1_0) && (val <= IC_58x_P1_7)) || \
172 ((val >= IC_58x_P2_0) && (val <= IC_58x_P2_9)) || \
173 ((val >= IC_58x_P3_0) && (val <= IC_58x_P3_7)) )
174
180#define IC_58x_GPIO_W_OPTS_VALID(val) \
181 (IC_58x_GPIO_VALID(val) || \
182 (val == IC_58x_PULSE_IN_RX))
183
184
186#define GPIO_OFFSET_70x_PORT1 0x20
187
189#define GPIO_OFFSET_70x_PORT2 0x40
190
198#define IC_70x_GPIO_PORT_PIN_TO_ENUM(port, pin) \
199 (port * GPIO_OFFSET_70x_PORT1 + pin)
200
207#define IC_70x_GPIO_ENUM_TO_PORT(enum_val) \
208 ((int)floor((double)enum_val / GPIO_OFFSET_70x_PORT1))
209
216#define IC_70x_GPIO_ENUM_TO_PIN(enum_val) \
217 (enum_val % GPIO_OFFSET_70x_PORT1)
218
225#define IC_70x_GPIO_IS_LED(enum_val) \
226 ((enum_val == IC_70x_LED1) || \
227 (enum_val == IC_70x_LED2) || \
228 (enum_val == IC_70x_LED3))
229
235#define IC_70x_GPIO_VALID(val) \
236 (((val >= IC_70x_P0_0) && (val <= IC_70x_P0_31)) || \
237 ((val >= IC_70x_P1_0) && (val <= IC_70x_P1_31)) || \
238 ((val >= IC_70x_P2_0) && (val <= IC_70x_P2_15)))
239
245#define IC_70x_GPIO_W_OPTS_VALID(val) \
246 (IC_70x_GPIO_VALID(val) || \
247 (val == IC_70x_LED1) || \
248 (val == IC_70x_LED2) || \
249 (val == IC_70x_LED3) || \
250 (val == IC_70x_PULSE_IN_RX))
251
259#define IC_GPIO_ENUM_TO_PORT(dut_ic, val) \
260 ((uint8_t) (IS_70x(dut_ic) ? IC_70x_GPIO_ENUM_TO_PORT(val) : \
261 0xFF)) // Invalid DUT IC
262
270#define IC_GPIO_ENUM_TO_PIN(dut_ic, val) \
271 ( (uint8_t) (IS_70x(dut_ic) ? IC_70x_GPIO_ENUM_TO_PIN(val) : \
272 0xFF)) // Invalid DUT IC
288typedef enum __ic_spec_status
289{
290 IC_SPEC_SUCCESS = 0,
291 IC_SPEC_ERROR,
292 IC_SPEC_INTERNAL_ERROR,
294
296typedef enum __dut_ic
297{
305
307typedef enum __gpio_gen
308{
309 IC_GEN = 0x00, // Dummy entry
311
313typedef enum __gpio_58x
314{
315 IC_58x_P0_0 = 00, IC_58x_P0_1, IC_58x_P0_2, IC_58x_P0_3,
316 IC_58x_P0_4, IC_58x_P0_5, IC_58x_P0_6, IC_58x_P0_7,
317
318 IC_58x_P1_0 = 10, IC_58x_P1_1, IC_58x_P1_2, IC_58x_P1_3,
319 IC_58x_P1_4, IC_58x_P1_5, IC_58x_P1_6, IC_58x_P1_7,
320
321 IC_58x_P2_0 = 20, IC_58x_P2_1, IC_58x_P2_2, IC_58x_P2_3,
322 IC_58x_P2_4, IC_58x_P2_5, IC_58x_P2_6, IC_58x_P2_7,
323 IC_58x_P2_8, IC_58x_P2_9,
324
325 IC_58x_P3_0 = 30, IC_58x_P3_1, IC_58x_P3_2, IC_58x_P3_3,
326 IC_58x_P3_4, IC_58x_P3_5, IC_58x_P3_6, IC_58x_P3_7,
327
328 IC_58x_INVALID_XTAL_GPIO = 48,
329 IC_58x_PULSE_IN_RX = 0xFE,
331
333typedef enum __gpio_70x
334{
335 IC_70x_P0_0 = 00, IC_70x_P0_1, IC_70x_P0_2, IC_70x_P0_3,
336 IC_70x_P0_4, IC_70x_P0_5, IC_70x_P0_6, IC_70x_P0_7,
337 IC_70x_P0_8, IC_70x_P0_9, IC_70x_P0_10, IC_70x_P0_11,
338 IC_70x_P0_12, IC_70x_P0_13, IC_70x_P0_14, IC_70x_P0_15,
339 IC_70x_P0_16, IC_70x_P0_17, IC_70x_P0_18, IC_70x_P0_19,
340 IC_70x_P0_20, IC_70x_P0_21, IC_70x_P0_22, IC_70x_P0_23,
341 IC_70x_P0_24, IC_70x_P0_25, IC_70x_P0_26, IC_70x_P0_27,
342 IC_70x_P0_28, IC_70x_P0_29, IC_70x_P0_30, IC_70x_P0_31,
343
344 IC_70x_P1_0, IC_70x_P1_1, IC_70x_P1_2, IC_70x_P1_3,
345 IC_70x_P1_4, IC_70x_P1_5, IC_70x_P1_6, IC_70x_P1_7,
346 IC_70x_P1_8, IC_70x_P1_9, IC_70x_P1_10, IC_70x_P1_11,
347 IC_70x_P1_12, IC_70x_P1_13, IC_70x_P1_14, IC_70x_P1_15,
348 IC_70x_P1_16, IC_70x_P1_17, IC_70x_P1_18, IC_70x_P1_19,
349 IC_70x_P1_20, IC_70x_P1_21, IC_70x_P1_22, IC_70x_P1_23,
350 IC_70x_P1_24, IC_70x_P1_25, IC_70x_P1_26, IC_70x_P1_27,
351 IC_70x_P1_28, IC_70x_P1_29, IC_70x_P1_30, IC_70x_P1_31,
352
353 IC_70x_P2_0, IC_70x_P2_1, IC_70x_P2_2, IC_70x_P2_3,
354 IC_70x_P2_4, IC_70x_P2_5, IC_70x_P2_6, IC_70x_P2_7,
355 IC_70x_P2_8, IC_70x_P2_9, IC_70x_P2_10, IC_70x_P2_11,
356 IC_70x_P2_12, IC_70x_P2_13, IC_70x_P2_14, IC_70x_P2_15,
357
358 IC_70x_LED1 = 0xF1, IC_70x_LED2 = 0xF2, IC_70x_LED3 = 0xF3,
359 IC_70x_PULSE_IN_RX = 0xFE,
361
363typedef enum __vbat_rst_mode
364{
368 INVALID_VBAT_MODE,
370
390typedef union __ic_gpio
391{
417__inline bool is_ic_supported(_dut_ic dut_ic)
418{
419 int i = 0;
420 for (i = 0; i < INVALID_DUT_IC; i++)
421 {
422 if (dut_ic == DUT_IC_DA14580)
423 {
424 return false;
425 }
426 else if (dut_ic == i)
427 {
428 return true;
429 }
430 }
431 return false;
432}
433
442__inline _ic_spec_status get_dut_ic_str(_dut_ic dut_ic, char *str)
443{
444 _ic_spec_status ret = IC_SPEC_SUCCESS;
445
446 if (!str)
447 {
448 return IC_SPEC_ERROR;
449 }
450
451 switch (dut_ic)
452 {
453 case DUT_IC_DA14701:
454 strcpy_s(str, sizeof(DUT_IC_DA14701_STR), DUT_IC_DA14701_STR);
455 break;
456 case DUT_IC_DA14705:
457 strcpy_s(str, sizeof(DUT_IC_DA14705_STR), DUT_IC_DA14705_STR);
458 break;
459 case DUT_IC_DA14706:
460 strcpy_s(str, sizeof(DUT_IC_DA14706_STR), DUT_IC_DA14706_STR);
461 break;
462 case DUT_IC_DA14708:
463 strcpy_s(str, sizeof(DUT_IC_DA14708_STR), DUT_IC_DA14708_STR);
464 break;
465 default:
466 ret = IC_SPEC_ERROR;
467 break;
468 }
469 return ret;
470}
471
480__inline _ic_spec_status get_dut_ic_enum(_dut_ic *dut_ic, char *str)
481{
482 _ic_spec_status ret = IC_SPEC_SUCCESS;
483
484 if (!str) return IC_SPEC_ERROR;
485
486 if (!strcmp(str, DUT_IC_DA14580_STR))
487 {
488 *dut_ic = DUT_IC_DA14580;
489 }
490 else if (!strcmp(str, DUT_IC_DA14701_STR))
491 {
492 *dut_ic = DUT_IC_DA14701;
493 }
494 else if (!strcmp(str, DUT_IC_DA14705_STR))
495 {
496 *dut_ic = DUT_IC_DA14705;
497 }
498 else if (!strcmp(str, DUT_IC_DA14706_STR))
499 {
500 *dut_ic = DUT_IC_DA14706;
501 }
502 else if (!strcmp(str, DUT_IC_DA14708_STR))
503 {
504 *dut_ic = DUT_IC_DA14708;
505 }
506 else
507 {
508 ret = IC_SPEC_ERROR;
509 }
510
511 return ret;
512}
513
523 char *file_name)
524{
525 _ic_spec_status ret = IC_SPEC_SUCCESS;
526
527 if (!file_name)
528 {
529 return IC_SPEC_ERROR;
530 }
531
532 switch (dut_ic)
533 {
534 case DUT_IC_DA14701:
535 case DUT_IC_DA14705:
536 case DUT_IC_DA14706:
537 case DUT_IC_DA14708:
538 strcpy_s(file_name, sizeof(CFG_FW_PROD_TEST_70x),
539 CFG_FW_PROD_TEST_70x);
540 break;
541 default:
542 ret = IC_SPEC_ERROR;
543 break;
544 }
545 return ret;
546}
547
556__inline _ic_spec_status get_dut_ic_mem_prog_fw(_dut_ic dut_ic, char *file_name)
557{
558 _ic_spec_status ret = IC_SPEC_SUCCESS;
559
560 if (!file_name)
561 {
562 return IC_SPEC_ERROR;
563 }
564
565 switch (dut_ic)
566 {
567 case DUT_IC_DA14701:
568 case DUT_IC_DA14705:
569 case DUT_IC_DA14706:
570 case DUT_IC_DA14708:
571 strcpy_s(file_name, sizeof(CFG_FW_70x_FLASH_PROG), CFG_FW_70x_FLASH_PROG);
572 break;
573 default:
574 ret = IC_SPEC_ERROR;
575 break;
576 }
577 return ret;
578}
579
580
589__inline _ic_spec_status check_gpio(_dut_ic dut_ic, _ic_gpio gpio_sel)
590{
591 _ic_spec_status ret = IC_SPEC_ERROR;
592
593 if (IS_580(dut_ic)) // GU
594 {
596 {
597 ret = IC_SPEC_SUCCESS;
598 }
599 }
600 else if (IS_70x(dut_ic))
601 {
603 {
604 ret = IC_SPEC_SUCCESS;
605 }
606 }
607 else
608 {
609 return IC_SPEC_INTERNAL_ERROR;
610 }
611
612 return ret;
613}
614
625 char *str)
626{
627 size_t sze = 5;
628
629 if (!str)
630 {
631 return IC_SPEC_ERROR;
632 }
633
634 if (IS_580(dut_ic)) // GU
635 {
636 if (gpio.gpio_58x == IC_58x_PULSE_IN_RX)
637 {
638 _snprintf_s((char *const)str,
639 (const size_t)sizeof(PULSE_IN_RX_STR) + 1, _TRUNCATE,
640 (char *const)PULSE_IN_RX_STR);
641 }
642 else
643 {
644 const char fmt[] = "P%d_%d";
645 uint8_t gpio_port = (uint8_t)IC_58x_GPIO_ENUM_TO_PORT(gpio.gpio_58x);
646 uint8_t gpio_pin = (uint8_t)IC_58x_GPIO_ENUM_TO_PIN(gpio.gpio_58x);
647
648 sze += (uint8_t)(gpio_pin >= 10);
649
650 _snprintf_s((char *const)str, (const size_t)sze, _TRUNCATE,
651 (char *const)fmt, (uint8_t)gpio_port, (uint8_t)gpio_pin);
652 }
653 }
654 else if (IS_70x(dut_ic))
655 {
656 if (gpio.gpio_70x == IC_70x_LED1)
657 {
658 const char fmt[] = "LED1";
659 _snprintf_s((char *const)str, (const size_t)sze,
660 _TRUNCATE, (char *const)fmt);
661 }
662 else if (gpio.gpio_70x == IC_70x_LED2)
663 {
664 const char fmt[] = "LED2";
665 _snprintf_s((char *const)str, (const size_t)sze,
666 _TRUNCATE, (char *const)fmt);
667 }
668 else if (gpio.gpio_70x == IC_70x_LED3)
669 {
670 const char fmt[] = "LED3";
671 _snprintf_s((char *const)str, (const size_t)sze,
672 _TRUNCATE, (char *const)fmt);
673 }
674 else if (gpio.gpio_70x == IC_70x_PULSE_IN_RX)
675 {
676 _snprintf_s((char *const)str,
677 (const size_t)sizeof(PULSE_IN_RX_STR) + 1,
678 _TRUNCATE, (char *const)PULSE_IN_RX_STR);
679 }
680 else
681 {
682 const char fmt[] = "P0_%d";
683 uint8_t gpio_pin = (uint8_t)
685
686 sze += (uint8_t)(gpio_pin >= 10);
687
688 _snprintf_s((char *const)str, (const size_t)sze,
689 _TRUNCATE, (char *const)fmt, (uint8_t)gpio_pin);
690 }
691 }
692 else
693 {
694 return IC_SPEC_ERROR;
695 }
696
697 return IC_SPEC_SUCCESS;
698}
699
709{
710 _ic_spec_status ret = IC_SPEC_ERROR;
711
712 if (IS_70x(dut_ic))
713 {
715 {
716 ret = IC_SPEC_SUCCESS;
717 }
718 }
719 else
720 {
721 return IC_SPEC_INTERNAL_ERROR;
722 }
723
724 return ret;
725} // @defgroup ic_specific
730
731#endif // _IC_SPECIFICS_H
enum __gpio_gen _gpio_gen
Values that represent a generic GPIO.
enum __vbat_rst_mode _vbat_rst_mode
The available options for the VBAT/RST mode.
enum __ic_spec_status _ic_spec_status
Values that represent IC specific function status.
__gpio_70x
Values that represent the DA1470x GPIOs.
Definition: ic_specifics.h:334
enum __dut_ic _dut_ic
The Dialog BLE device IC selection.
__dut_ic
The Dialog BLE device IC selection.
Definition: ic_specifics.h:297
enum __gpio_58x _gpio_58x
Values that represent the DA1458x GPIOs.
__gpio_gen
Values that represent a generic GPIO.
Definition: ic_specifics.h:308
__gpio_58x
Values that represent the DA1458x GPIOs.
Definition: ic_specifics.h:314
enum __gpio_70x _gpio_70x
Values that represent the DA1470x GPIOs.
__vbat_rst_mode
The available options for the VBAT/RST mode.
Definition: ic_specifics.h:364
@ INVALID_DUT_IC
Definition: ic_specifics.h:303
@ DUT_IC_DA14701
Definition: ic_specifics.h:299
@ DUT_IC_DA14580
Definition: ic_specifics.h:298
@ DUT_IC_DA14706
Definition: ic_specifics.h:301
@ DUT_IC_DA14705
Definition: ic_specifics.h:300
@ DUT_IC_DA14708
Definition: ic_specifics.h:302
@ VBAT_AS_RST
Definition: ic_specifics.h:367
@ VBAT_ONLY
Definition: ic_specifics.h:365
@ VBAT_ON_RST
Definition: ic_specifics.h:366
__inline bool is_ic_supported(_dut_ic dut_ic)
Query if the IC is supported by current PLT version.
Definition: ic_specifics.h:417
__inline _ic_spec_status check_gpio(_dut_ic dut_ic, _ic_gpio gpio_sel)
Check if a GPIO port/pin configuration is valid.
Definition: ic_specifics.h:589
__inline _ic_spec_status check_gpio_is_led(_dut_ic dut_ic, _ic_gpio gpio)
Return whether the selected GPIO in an LED.
Definition: ic_specifics.h:708
__inline _ic_spec_status get_dut_ic_str(_dut_ic dut_ic, char *str)
Return the dut_ic string resolution.
Definition: ic_specifics.h:442
__inline _ic_spec_status get_dut_ic_enum(_dut_ic *dut_ic, char *str)
Return the dut_ic enumeration value from the string equivalent.
Definition: ic_specifics.h:480
__inline _ic_spec_status get_dut_ic_mem_prog_fw(_dut_ic dut_ic, char *file_name)
Returns the memory programming firmware file name for the given device IC.
Definition: ic_specifics.h:556
__inline _ic_spec_status get_dut_ic_prod_test_fw(_dut_ic dut_ic, char *file_name)
Returns the production firmware file name for the given device IC.
Definition: ic_specifics.h:522
__inline _ic_spec_status get_gpio_name_str(_dut_ic dut_ic, _ic_gpio gpio, char *str)
Return the selected GPIO in a string.
Definition: ic_specifics.h:624
#define IC_58x_GPIO_ENUM_TO_PORT(enum_val)
A macro that returns the port from a DA1458x GPIO port/pin combination, as shown in _gpio_58x.
Definition: ic_specifics.h:154
#define IC_70x_GPIO_IS_LED(enum_val)
A macro that checks if a DA1470x GPIO of type _gpio_70x is an LED GPIO.
Definition: ic_specifics.h:225
#define DUT_IC_DA14701_STR
DA14701 string macro.
Definition: ic_specifics.h:113
#define DUT_IC_DA14708_STR
DA14705 string macro.
Definition: ic_specifics.h:119
#define IC_58x_GPIO_ENUM_TO_PIN(enum_val)
A macro that returns the pin from a DA1458x GPIO port/pin combination, as shown in _gpio_58x.
Definition: ic_specifics.h:162
#define PULSE_IN_RX_STR
A macro that defines the string used in XML for the XTAL trim pulse in UART RX pin.
Definition: ic_specifics.h:137
#define IS_580(dut_ic)
A macro that checks if a device is DA14580 type (GU).
Definition: ic_specifics.h:70
#define IC_70x_GPIO_W_OPTS_VALID(val)
A macro that checks if a GPIO is valid for DA1470x ICs.
Definition: ic_specifics.h:245
#define IC_58x_GPIO_W_OPTS_VALID(val)
A macro that checks if a GPIO is valid for DA1458x device ICs.
Definition: ic_specifics.h:180
#define IS_70x(dut_ic)
A macro that checks if a device is DA1470x type.
Definition: ic_specifics.h:77
#define DUT_IC_DA14580_STR
DA14580 string macro.
Definition: ic_specifics.h:111
#define DUT_IC_DA14705_STR
DA14705 string macro.
Definition: ic_specifics.h:115
#define IC_70x_GPIO_ENUM_TO_PIN(enum_val)
A macro that returns the pin from a DA1470x GPIO port/pin combination, as shown in _gpio_70x.
Definition: ic_specifics.h:216
#define DUT_IC_DA14706_STR
DA14705 string macro.
Definition: ic_specifics.h:117
union __ic_gpio _ic_gpio
GPIO selection based on IC.
GPIO selection based on IC.
Definition: ic_specifics.h:391
_gpio_58x gpio_58x
Definition: ic_specifics.h:393
_gpio_gen gpio_gen
Definition: ic_specifics.h:392
_gpio_70x gpio_70x
Definition: ic_specifics.h:394