16#ifndef _IC_SPECIFICS_H
17#define _IC_SPECIFICS_H
59#define __IC_SPEC_SAFE_SNPRINTF(out_str, ...) \
62 _snprintf_s(out_str, sizeof(out_str), _TRUNCATE, __VA_ARGS__); \
70#define IS_580(dut_ic) (dut_ic == DUT_IC_DA14580)
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))
87#define IS_701(dut_ic) (dut_ic == DUT_IC_DA14701)
94#define IS_705(dut_ic) (dut_ic == DUT_IC_DA14705)
101#define IS_706(dut_ic) (dut_ic == DUT_IC_DA14706)
108#define IS_708(dut_ic) (dut_ic == DUT_IC_DA14708)
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"
125#define CFG_FW_PROD_TEST_70x "st_fw_da1470x.bin"
130#define CFG_FW_70x_FLASH_PROG "uartboot_da1470x.bin"
133#define DUT_IC_SLEEP_THRES_DA1470x 8000
137#define PULSE_IN_RX_STR "PULSE_IN_RX"
146#define IC_58x_GPIO_PORT_PIN_TO_ENUM(port, pin) (port * 10 + pin)
154#define IC_58x_GPIO_ENUM_TO_PORT(enum_val) ((int)floor((double)enum_val / 10))
162#define IC_58x_GPIO_ENUM_TO_PIN(enum_val) (enum_val % 10)
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)) )
180#define IC_58x_GPIO_W_OPTS_VALID(val) \
181 (IC_58x_GPIO_VALID(val) || \
182 (val == IC_58x_PULSE_IN_RX))
186#define GPIO_OFFSET_70x_PORT1 0x20
189#define GPIO_OFFSET_70x_PORT2 0x40
198#define IC_70x_GPIO_PORT_PIN_TO_ENUM(port, pin) \
199 (port * GPIO_OFFSET_70x_PORT1 + pin)
207#define IC_70x_GPIO_ENUM_TO_PORT(enum_val) \
208 ((int)floor((double)enum_val / GPIO_OFFSET_70x_PORT1))
216#define IC_70x_GPIO_ENUM_TO_PIN(enum_val) \
217 (enum_val % GPIO_OFFSET_70x_PORT1)
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))
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)))
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))
259#define IC_GPIO_ENUM_TO_PORT(dut_ic, val) \
260 ((uint8_t) (IS_70x(dut_ic) ? IC_70x_GPIO_ENUM_TO_PORT(val) : \
270#define IC_GPIO_ENUM_TO_PIN(dut_ic, val) \
271 ( (uint8_t) (IS_70x(dut_ic) ? IC_70x_GPIO_ENUM_TO_PIN(val) : \
288typedef enum __ic_spec_status
292 IC_SPEC_INTERNAL_ERROR,
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,
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,
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,
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,
328 IC_58x_INVALID_XTAL_GPIO = 48,
329 IC_58x_PULSE_IN_RX = 0xFE,
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,
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,
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,
358 IC_70x_LED1 = 0xF1, IC_70x_LED2 = 0xF2, IC_70x_LED3 = 0xF3,
359 IC_70x_PULSE_IN_RX = 0xFE,
426 else if (dut_ic == i)
448 return IC_SPEC_ERROR;
484 if (!str)
return IC_SPEC_ERROR;
529 return IC_SPEC_ERROR;
538 strcpy_s(file_name,
sizeof(CFG_FW_PROD_TEST_70x),
539 CFG_FW_PROD_TEST_70x);
562 return IC_SPEC_ERROR;
571 strcpy_s(file_name,
sizeof(CFG_FW_70x_FLASH_PROG), CFG_FW_70x_FLASH_PROG);
597 ret = IC_SPEC_SUCCESS;
604 ret = IC_SPEC_SUCCESS;
609 return IC_SPEC_INTERNAL_ERROR;
631 return IC_SPEC_ERROR;
636 if (gpio.
gpio_58x == IC_58x_PULSE_IN_RX)
638 _snprintf_s((
char *
const)str,
644 const char fmt[] =
"P%d_%d";
648 sze += (uint8_t)(gpio_pin >= 10);
650 _snprintf_s((
char *
const)str, (
const size_t)sze, _TRUNCATE,
651 (
char *
const)fmt, (uint8_t)gpio_port, (uint8_t)gpio_pin);
658 const char fmt[] =
"LED1";
659 _snprintf_s((
char *
const)str, (
const size_t)sze,
660 _TRUNCATE, (
char *
const)fmt);
662 else if (gpio.
gpio_70x == IC_70x_LED2)
664 const char fmt[] =
"LED2";
665 _snprintf_s((
char *
const)str, (
const size_t)sze,
666 _TRUNCATE, (
char *
const)fmt);
668 else if (gpio.
gpio_70x == IC_70x_LED3)
670 const char fmt[] =
"LED3";
671 _snprintf_s((
char *
const)str, (
const size_t)sze,
672 _TRUNCATE, (
char *
const)fmt);
674 else if (gpio.
gpio_70x == IC_70x_PULSE_IN_RX)
676 _snprintf_s((
char *
const)str,
682 const char fmt[] =
"P0_%d";
683 uint8_t gpio_pin = (uint8_t)
686 sze += (uint8_t)(gpio_pin >= 10);
688 _snprintf_s((
char *
const)str, (
const size_t)sze,
689 _TRUNCATE, (
char *
const)fmt, (uint8_t)gpio_pin);
694 return IC_SPEC_ERROR;
697 return IC_SPEC_SUCCESS;
716 ret = IC_SPEC_SUCCESS;
721 return IC_SPEC_INTERNAL_ERROR;
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.
enum __dut_ic _dut_ic
The Dialog BLE device IC selection.
__dut_ic
The Dialog BLE device IC selection.
enum __gpio_58x _gpio_58x
Values that represent the DA1458x GPIOs.
__gpio_gen
Values that represent a generic GPIO.
__gpio_58x
Values that represent the DA1458x GPIOs.
enum __gpio_70x _gpio_70x
Values that represent the DA1470x GPIOs.
__vbat_rst_mode
The available options for the VBAT/RST mode.
__inline bool is_ic_supported(_dut_ic dut_ic)
Query if the IC is supported by current PLT version.
__inline _ic_spec_status check_gpio(_dut_ic dut_ic, _ic_gpio gpio_sel)
Check if a GPIO port/pin configuration is valid.
__inline _ic_spec_status check_gpio_is_led(_dut_ic dut_ic, _ic_gpio gpio)
Return whether the selected GPIO in an LED.
__inline _ic_spec_status get_dut_ic_str(_dut_ic dut_ic, char *str)
Return the dut_ic string resolution.
__inline _ic_spec_status get_dut_ic_enum(_dut_ic *dut_ic, char *str)
Return the dut_ic enumeration value from the string equivalent.
__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.
__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.
__inline _ic_spec_status get_gpio_name_str(_dut_ic dut_ic, _ic_gpio gpio, char *str)
Return the selected GPIO in a string.
#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.
#define IC_70x_GPIO_IS_LED(enum_val)
A macro that checks if a DA1470x GPIO of type _gpio_70x is an LED GPIO.
#define DUT_IC_DA14701_STR
DA14701 string macro.
#define DUT_IC_DA14708_STR
DA14705 string macro.
#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.
#define PULSE_IN_RX_STR
A macro that defines the string used in XML for the XTAL trim pulse in UART RX pin.
#define IS_580(dut_ic)
A macro that checks if a device is DA14580 type (GU).
#define IC_70x_GPIO_W_OPTS_VALID(val)
A macro that checks if a GPIO is valid for DA1470x ICs.
#define IC_58x_GPIO_W_OPTS_VALID(val)
A macro that checks if a GPIO is valid for DA1458x device ICs.
#define IS_70x(dut_ic)
A macro that checks if a device is DA1470x type.
#define DUT_IC_DA14580_STR
DA14580 string macro.
#define DUT_IC_DA14705_STR
DA14705 string macro.
#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.
#define DUT_IC_DA14706_STR
DA14705 string macro.
union __ic_gpio _ic_gpio
GPIO selection based on IC.
GPIO selection based on IC.