663 lines
28 KiB
C
663 lines
28 KiB
C
/*******************************************************************************
|
|
* @file measurements.h
|
|
* @author CandyPops Co.
|
|
* @version V1.0.0
|
|
* @date 2022-09-05
|
|
* @brief
|
|
******************************************************************************/
|
|
|
|
#ifndef _MEASUREMENTS_H__
|
|
#define _MEASUREMENTS_H__
|
|
|
|
#include "sdk_common.h"
|
|
|
|
#include <stdbool.h>
|
|
#include "nrf.h"
|
|
#include "nrf_drv_gpiote.h"
|
|
|
|
#define trig_r NRF_GPIO_PIN_MAP(0,18)
|
|
#define trig_r_CONFIG() nrf_gpio_cfg_output(trig_r)
|
|
#define trig_SW(x) if(x == true) nrf_gpio_pin_set(trig_r);\
|
|
else if(x == false) nrf_gpio_pin_clear(trig_r)
|
|
/* For NIR LED */
|
|
|
|
//#define LIGHT_ON1 NRF_GPIO_PIN_MAP(0,28)
|
|
//#define LIGHT_ON2 NRF_GPIO_PIN_MAP(0,29)
|
|
//#define LIGHT_ON3 NRF_GPIO_PIN_MAP(0,31)
|
|
//#define LIGHT_ON4 NRF_GPIO_PIN_MAP(0,19)
|
|
//may work below.
|
|
//#define VCSEL_SW1 NRF_GPIO_PIN_MAP(1,1)
|
|
//#define VCSEL_SW2 NRF_GPIO_PIN_MAP(1,2)
|
|
//#define VCSEL_SW3 NRF_GPIO_PIN_MAP(1,3)
|
|
|
|
|
|
|
|
#define LIGHT_ON NRF_GPIO_PIN_MAP(0,22)
|
|
#define NIR_PART_SEL NRF_GPIO_PIN_MAP(1,7)
|
|
|
|
#define NIRLED_SEL0 NRF_GPIO_PIN_MAP(1,4)
|
|
#define NIRLED_SEL1 NRF_GPIO_PIN_MAP(1,5)
|
|
|
|
#define NIR_WAV_SEL0 NRF_GPIO_PIN_MAP(1,1)
|
|
#define NIR_WAV_SEL1 NRF_GPIO_PIN_MAP(1,2)
|
|
#define NIR_WAV_SEL2 NRF_GPIO_PIN_MAP(1,3)
|
|
|
|
|
|
|
|
//#define LED_CONFIG() nrf_gpio_cfg(LIGHT_ON1, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);\
|
|
// nrf_gpio_cfg(LIGHT_ON2, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);\
|
|
// nrf_gpio_cfg(LED_SEL_SW1, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);\
|
|
// nrf_gpio_cfg(LED_SEL_SW2, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);\
|
|
// nrf_gpio_cfg(LED_SEL_SW3, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);\
|
|
// nrf_gpio_cfg(LED_INDIV_SEL_SW1, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);\
|
|
// nrf_gpio_cfg(LED_INDIV_SEL_SW2, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);\
|
|
// nrf_gpio_cfg(LED_INDIV_SEL_SW3, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_CONNECT,NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_S0D1,NRF_GPIO_PIN_NOSENSE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LED_CONFIG() nrf_gpio_cfg_output(LIGHT_ON);\
|
|
nrf_gpio_cfg_output(NIR_PART_SEL);\
|
|
nrf_gpio_cfg_output(NIRLED_SEL0);\
|
|
nrf_gpio_cfg_output(NIRLED_SEL1);\
|
|
nrf_gpio_cfg_output(NIR_WAV_SEL0);\
|
|
nrf_gpio_cfg_output(NIR_WAV_SEL1);\
|
|
nrf_gpio_cfg_output(NIR_WAV_SEL2)
|
|
|
|
|
|
// Macros for LEDs 0 to 5 ( LIGHT_ON -->0)
|
|
#define LED0() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED1() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED2() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED3() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED4() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED5() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
// Macros for LEDs 10 to 15 ( LIGHT_ON -->0)
|
|
#define LED6() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED7() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED8() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED9() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED10() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED11() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
// Macros for LEDs 20 to 25 ( LIGHT_ON -->0)
|
|
#define LED12() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED13() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED14() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED15() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED16() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED17() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
// Macros for LEDs 30 to 35 ( LIGHT_ON -->0)
|
|
#define LED18() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED19() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED20() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED21() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED22() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED23() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
|
|
|
|
|
|
// Macros for LEDs 40 to 45 ( LIGHT_ON -->0)
|
|
#define LED24() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED25() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED26() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED27() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED28() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED29() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
|
|
// Macros for LEDs 50 to 55 ( LIGHT_ON -->0)
|
|
#define LED30() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED31() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED32() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED33() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED34() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED35() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
|
|
// Macros for LEDs 60 to 65 ( LIGHT_ON -->0)
|
|
#define LED36() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED37() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED38() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED39() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED40() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED41() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_clear(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
|
|
|
|
|
|
// Macros for LEDs 70 to 75 ( LIGHT_ON -->0)
|
|
#define LED42() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
#define LED43() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED44() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED45() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL2)
|
|
|
|
|
|
#define LED46() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
#define LED47() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_set(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_clear(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
|
|
#define LED_ALLOFF() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
|
|
#define LED99() nrf_gpio_pin_clear(LIGHT_ON); \
|
|
nrf_gpio_pin_clear(NIR_PART_SEL); \
|
|
nrf_gpio_pin_set(NIRLED_SEL0); \
|
|
nrf_gpio_pin_set(NIRLED_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL0); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL1); \
|
|
nrf_gpio_pin_set(NIR_WAV_SEL2)
|
|
|
|
|
|
/*
|
|
#define LED23() nrf_gpio_pin_set(LIGHT_ON1);\
|
|
nrf_gpio_pin_set(LIGHT_ON2);\
|
|
nrf_gpio_pin_set(LIGHT_ON3);\
|
|
nrf_gpio_pin_clear(LIGHT_ON4);\
|
|
nrf_gpio_pin_clear(VCSEL_SW1);\
|
|
nrf_gpio_pin_clear(VCSEL_SW2);\
|
|
nrf_gpio_pin_set(VCSEL_SW3)
|
|
|
|
#define LED24() nrf_gpio_pin_set(LIGHT_ON1);\
|
|
nrf_gpio_pin_set(LIGHT_ON2);\
|
|
nrf_gpio_pin_set(LIGHT_ON3);\
|
|
nrf_gpio_pin_clear(LIGHT_ON4);\
|
|
nrf_gpio_pin_set(VCSEL_SW1);\
|
|
nrf_gpio_pin_clear(VCSEL_SW2);\
|
|
nrf_gpio_pin_set(VCSEL_SW3)
|
|
|
|
|
|
|
|
#define LED_ALLOFF() nrf_gpio_pin_clear(LIGHT_ON1);\
|
|
nrf_gpio_pin_clear(LIGHT_ON2);\
|
|
nrf_gpio_pin_clear(LIGHT_ON3);\
|
|
nrf_gpio_pin_clear(LIGHT_ON4);\
|
|
nrf_gpio_pin_set(VCSEL_SW1);\
|
|
nrf_gpio_pin_set(VCSEL_SW2);\
|
|
nrf_gpio_pin_set(VCSEL_SW3)
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* For Photo Diode */
|
|
|
|
//#define MUX_EN_RDATA1 NRF_GPIO_PIN_MAP(1,6)
|
|
//#define MUX_EN_RDATA2 NRF_GPIO_PIN_MAP(1,5)
|
|
//#define MUX_EN_RDATA3 NRF_GPIO_PIN_MAP(1,4)
|
|
//
|
|
//#define RDATA_SW1 NRF_GPIO_PIN_MAP(0,23)
|
|
//#define RDATA_SW2 NRF_GPIO_PIN_MAP(0,22)
|
|
//#define RDATA_SW3 NRF_GPIO_PIN_MAP(0,21)
|
|
|
|
#define PD_SEL0 NRF_GPIO_PIN_MAP(1,12)
|
|
#define PD_SEL1 NRF_GPIO_PIN_MAP(1,11)
|
|
//#define PD_SEL3 NRF_GPIO_PIN_MAP(1,10) no use
|
|
|
|
#define PD_CONFIG() nrf_gpio_cfg_output(PD_SEL0);\
|
|
nrf_gpio_cfg_output(PD_SEL1)
|
|
|
|
#define PD0() nrf_gpio_pin_clear(PD_SEL0);\
|
|
nrf_gpio_pin_clear(PD_SEL1)
|
|
|
|
#define PD1() nrf_gpio_pin_set(PD_SEL0);\
|
|
nrf_gpio_pin_clear(PD_SEL1)
|
|
|
|
#define MOD() nrf_gpio_pin_clear(PD_SEL0);\
|
|
nrf_gpio_pin_set(PD_SEL1)
|
|
#define MOD2() nrf_gpio_pin_set(PD_SEL0);\
|
|
nrf_gpio_pin_set(PD_SEL1)
|
|
/*
|
|
#define PD4() nrf_gpio_pin_clear(MUX_EN_RDATA1);\
|
|
nrf_gpio_pin_set(MUX_EN_RDATA2);\
|
|
nrf_gpio_pin_set(MUX_EN_RDATA3);\
|
|
nrf_gpio_pin_set(RDATA_SW1);\
|
|
nrf_gpio_pin_set(RDATA_SW2);\
|
|
nrf_gpio_pin_clear(RDATA_SW3);\
|
|
nrf_gpio_pin_clear(PD_SEL1);\
|
|
nrf_gpio_pin_clear(PD_SEL2);\
|
|
nrf_gpio_pin_clear(PD_SEL3)
|
|
|
|
#define PD5() nrf_gpio_pin_clear(MUX_EN_RDATA1);\
|
|
nrf_gpio_pin_set(MUX_EN_RDATA2);\
|
|
nrf_gpio_pin_set(MUX_EN_RDATA3);\
|
|
nrf_gpio_pin_clear(RDATA_SW1);\
|
|
nrf_gpio_pin_clear(RDATA_SW2);\
|
|
nrf_gpio_pin_set(RDATA_SW3);\
|
|
nrf_gpio_pin_clear(PD_SEL1);\
|
|
nrf_gpio_pin_clear(PD_SEL2);\
|
|
nrf_gpio_pin_clear(PD_SEL3)
|
|
|
|
|
|
|
|
|
|
#define PD_ALLOFF() nrf_gpio_pin_clear(MUX_EN_RDATA1);\
|
|
nrf_gpio_pin_clear(MUX_EN_RDATA2);\
|
|
nrf_gpio_pin_clear(MUX_EN_RDATA3);\
|
|
nrf_gpio_pin_clear(RDATA_SW1);\
|
|
nrf_gpio_pin_clear(RDATA_SW2);\
|
|
nrf_gpio_pin_clear(RDATA_SW3);\
|
|
nrf_gpio_pin_set(PD_SEL1);\
|
|
nrf_gpio_pin_set(PD_SEL2);\
|
|
nrf_gpio_pin_set(PD_SEL3)
|
|
*/
|
|
#define PD_ALLOFF() nrf_gpio_pin_set(PD_SEL0);\
|
|
nrf_gpio_pin_set(PD_SEL1)
|
|
|
|
|
|
/* For IC_NZP */ // No USE for 3.0
|
|
//#define VCSEL_EN_PIN NRF_GPIO_PIN_MAP(1,7)
|
|
//#define VCSEL_CONFIG() nrf_gpio_cfg_output(VCSEL_EN_PIN)
|
|
//#define VCSEL_SW(x) if(x == true) nrf_gpio_pin_set(VCSEL_EN_PIN);\
|
|
// else if(x == false) nrf_gpio_pin_clear(VCSEL_EN_PIN)
|
|
|
|
|
|
/* For AGC SW FSA5157L6X */
|
|
#define GAIN_SW_PIN NRF_GPIO_PIN_MAP(0,20)
|
|
#define GAIN_SW_CONFIG() nrf_gpio_cfg_output(GAIN_SW_PIN)
|
|
#define AGC_GAIN_SW(x) if(x == true) nrf_gpio_pin_set(GAIN_SW_PIN);\
|
|
else if(x == false) nrf_gpio_pin_clear(GAIN_SW_PIN)
|
|
|
|
|
|
|
|
|
|
void led_pd_gain_array_printout(void);
|
|
ret_code_t led_on(uint8_t led_index);
|
|
ret_code_t led_off(uint8_t led_index);
|
|
ret_code_t led_pd_matching_value_set(uint8_t led_index);
|
|
|
|
|
|
|
|
ret_code_t led_pd_mod_set(uint16_t mod_gain);
|
|
ret_code_t pd_on(uint8_t pd_index);
|
|
ret_code_t pd_off(uint8_t pd_index);
|
|
int16_t led_power_read(uint8_t led_index);
|
|
void led_power_read_48(uint16_t *data);
|
|
ret_code_t led_power_save_mem(uint8_t led_index, int16_t led_power);
|
|
ret_code_t led_power_save_mem_6(uint8_t led_index, int16_t led_power);
|
|
ret_code_t led_power_save_mem_48( uint8_t *led_power);
|
|
ret_code_t led_power_set(uint8_t led_index);
|
|
ret_code_t pd_gain_set(uint8_t activated_led); //version B change 2025.04.27
|
|
ret_code_t imm_gain_set(uint16_t imm_dac); //version B add 2025.05.07
|
|
ret_code_t led_select(uint8_t led_index);
|
|
ret_code_t pd_select(uint8_t pd_index);
|
|
void led_power_span(uint8_t led_index);
|
|
void mea_send_loop(void * p_context); /* For x ms */
|
|
void mea_send_timer_start(void);
|
|
void mea_send_timer_stop(void);
|
|
void mea_send_timer_init(void);
|
|
#endif //_MEASUREMENTS_H__
|
|
|