/** \file ak9757w_def.h */ #if !defined(AK9757W_DEF_H__4BA48BEA_F528_4C98_B828_6A11363D6764__INCLUDED_) #define AK9757W_DEF_H__4BA48BEA_F528_4C98_B828_6A11363D6764__INCLUDED_ #define AK9757W_DEVICE_ADDRESS 0x6C #define AK9757W_REG_RO_COMPANY_CODE 0x00 // Company Code #define AK9757W_REG_RO_DEVICE_ID 0x01 // Device ID #define AK9757W_REG_RO_INFORMATION1 0x02 // Information1 #define AK9757W_REG_RO_INFORMATION2 0x03 // Information2 #define AK9757W_REG_RO_STATUS 0x04 // Status #define AK9757W_REG_RO_TOUTL 0x05 // TOUT, TS, IR: data register #define AK9757W_REG_RO_TOUTH 0x06 // TOUT, TS, IR: data register #define AK9757W_REG_RO_TSL 0x07 // TOUT, TS, IR: data register #define AK9757W_REG_RO_TSH 0x08 // TOUT, TS, IR: data register #define AK9757W_REG_RO_IRL 0x09 // TOUT, TS, IR: data register #define AK9757W_REG_RO_IRH 0x0A // TOUT, TS, IR: data register #define AK9757W_REG_RO_STATUS2 0x0B // Status2 #define AK9757W_REG_RO_SBUF0L 0x0C // Streaming Buffer data #define AK9757W_REG_RO_SBUF0H 0x0D // Streaming Buffer data #define AK9757W_REG_RO_SBUF1L 0x0E // Streaming Buffer data #define AK9757W_REG_RO_SBUF1H 0x0F // Streaming Buffer data #define AK9757W_REG_RO_SBUF2L 0x10 // Streaming Buffer data #define AK9757W_REG_RO_SBUF2H 0x11 // Streaming Buffer data #define AK9757W_REG_RO_SBUF3L 0x12 // Streaming Buffer data #define AK9757W_REG_RO_SBUF3H 0x13 // Streaming Buffer data #define AK9757W_REG_RO_SBUF4L 0x14 // Streaming Buffer data #define AK9757W_REG_RO_SBUF4H 0x15 // Streaming Buffer data #define AK9757W_REG_RO_SBUF5L 0x16 // Streaming Buffer data #define AK9757W_REG_RO_SBUF5H 0x17 // Streaming Buffer data #define AK9757W_REG_RO_SBUF6L 0x18 // Streaming Buffer data #define AK9757W_REG_RO_SBUF6H 0x19 // Streaming Buffer data #define AK9757W_REG_RO_SBUF7L 0x1A // Streaming Buffer data #define AK9757W_REG_RO_SBUF7H 0x1B // Streaming Buffer data #define AK9757W_REG_RO_SBUF8L 0x1C // Streaming Buffer data #define AK9757W_REG_RO_SBUF8H 0x1D // Streaming Buffer data #define AK9757W_REG_RO_SBUF9L 0x1E // Streaming Buffer data #define AK9757W_REG_RO_SBUF9H 0x1F // Streaming Buffer data #define AK9757W_REG_RW_CNTL1 0x20 // Soft Reset #define AK9757W_REG_RW_CNTL2 0x21 // Streaming buffer control #define AK9757W_REG_RW_CNTL3 0x22 // I/V AMP, Temp. calc., ODR setting #define AK9757W_REG_RW_CNTL4 0x23 // Interrupt setting #define AK9757W_REG_RW_CNTL5 0x24 // Threshold judgment setting #define AK9757W_REG_RW_CNTL6 0x25 // Threshold Level setting low #define AK9757W_REG_RW_CNTL7 0x26 // Threshold Level setting high #define AK9757W_REG_RW_CNTL8 0x27 // ADC average number setting #define AK9757W_REG_RW_CNTL9 0x28 // Mode setting #define AK9757W_REG_RW_FCOEF4L 0x29 // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF4H 0x2A // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF4EX 0x2B // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF3L 0x2C // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF3H 0x2D // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF3EX 0x2E // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF2L 0x2F // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF2H 0x30 // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF2EX 0x31 // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF1L 0x32 // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF1H 0x33 // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF1EX 0x34 // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF0L 0x35 // Calculation coefficient setting #define AK9757W_REG_RW_FCOEF0H 0x36 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF4L 0x37 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF4H 0x38 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF4EX 0x39 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF3L 0x3A // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF3H 0x3B // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF3EX 0x3C // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF2L 0x3D // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF2H 0x3E // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF3EX 0x3F // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF1L 0x40 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF1H 0x41 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF1EX 0x42 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF0L 0x43 // Calculation coefficient setting #define AK9757W_REG_RW_GCOEF0H 0x44 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF4L 0x45 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF4H 0x46 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF4EX 0x47 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF3L 0x48 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF3H 0x49 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF3EX 0x4A // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF2L 0x4B // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF2H 0x4C // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF3EX 0x4D // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF1L 0x4E // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF1H 0x4F // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF1EX 0x50 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF0L 0x51 // Calculation coefficient setting #define AK9757W_REG_RW_XCOEF0H 0x52 // Calculation coefficient setting #define AK9757W_REG_RW_GIRL 0x54 // IR gain Correction parameter setting #define AK9757W_REG_RW_GIRH 0x55 // IR gain Correction parameter setting #define AK9757W_REG_RW_OIRL 0x56 // IR offset Correction parameter setting #define AK9757W_REG_RW_OIRH 0x57 // IR offset Correction parameter setting #define AK9757W_REG_RW_GTS 0x58 // TS Gain Correction parameter setting #define AK9757W_REG_RW_OTSL 0x59 // TS offset Correction parameter setting #define AK9757W_REG_RW_OTSH 0x5A // TS offset Correction parameter setting #define AK9757W_REG_RW_GIT 0x5B // Temperature dependent ingredient of IR gain setting #define AK9757W_REG_RO_CHIPID 0x5C // Chip ID /////////////////////////////////////////////////////////// #define AK9757W_COMPANY_CODE_VALUE 0x48 #define AK9757W_DEVICE_ID_VALUE 0x17 #define AK9757W_INFORMATION1_VALUE 0x00 #define AK9757W_INFORMATION2_VALUE 0x00 #define AK9757W_STATUS_DRDY_POS 0x00 #define AK9757W_STATUS_DRDY_MSK 0x01 #define AK9757W_STATUS_BFULL_POS 0x01 #define AK9757W_STATUS_BFULL_MSK 0x01 #define AK9757W_STATUS_THL_POS 0x02 #define AK9757W_STATUS_THL_MSK 0x01 #define AK9757W_STATUS_THH_POS 0x03 #define AK9757W_STATUS_THH_MSK 0x01 #define AK9757W_CNTL1_SRST_POS 0x00 #define AK9757W_CNTL1_SRST_MSK 0x01 #define AK9757W_CNTL2_BUFON_POS 0x00 #define AK9757W_CNTL2_BUFON_MSK 0x01 #define AK9757W_CNTL3_ODR_POS 0x00 #define AK9757W_CNTL3_ODR_MSK 0x03 #define AK9757W_CNTL3_CALC_POS 0x03 #define AK9757W_CNTL3_CALC_MSK 0x01 #define AK9757W_CNTL3_GAIN_POS 0x04 #define AK9757W_CNTL3_GAIN_MSK 0x07 #define AK9757W_CNTL3_IROFF_POS 0x07 #define AK9757W_CNTL3_IROFF_MSK 0x01 #define AK9757W_CNTL4_IDRDY_POS 0x00 #define AK9757W_CNTL4_IDRDY_MSK 0x01 #define AK9757W_CNTL4_IBFULL_POS 0x01 #define AK9757W_CNTL4_IBFULL_MSK 0x01 #define AK9757W_CNTL4_ITHL_POS 0x02 #define AK9757W_CNTL4_ITHL_MSK 0x01 #define AK9757W_CNTL4_ITHU_POS 0x03 #define AK9757W_CNTL4_ITHU_MSK 0x01 #define AK9757W_CNTL4_IOVF_POS 0x04 #define AK9757W_CNTL4_IOVF_MSK 0x01 #define AK9757W_CNTL4_ANG_POS 0x07 #define AK9757W_CNTL4_ANG_MSK 0x01 #define AK9757W_CNTL5_DNUM_POS 0x00 #define AK9757W_CNTL5_DNUM_MSK 0x0F #define AK9757W_CNTL5_DIFFON_POS 0x04 #define AK9757W_CNTL5_DIFFON_MSK 0x01 #define AK9757W_CNTL5_THSEL_POS 0x05 #define AK9757W_CNTL5_THSEL_MSK 0x01 #define AK9757W_CNTL5_TOUTLPF_POS 0x06 #define AK9757W_CNTL5_TOUTLPF_MSK 0x01 #define AK9757W_CNTL5_LPFON_POS 0x07 #define AK9757W_CNTL5_LPFON_MSK 0x01 #define AK9757W_CNTL8_AVN_POS 0x00 #define AK9757W_CNTL8_AVN_MSK 0x3F #define AK9757W_CNTL9_MODE_POS 0x00 #define AK9757W_CNTL9_MODE_MSK 0x01 #define AK9757W_CNTL9_IRINV_POS 0x04 #define AK9757W_CNTL9_IRINV_MSK 0x01 #define AK9757W_FCOEF2EX_FC2EX_POS 0x00 #define AK9757W_FCOEF2EX_FC2EX_MSK 0x3F #define AK9757W_FCOEF1EX_FC1EX_POS 0x00 #define AK9757W_FCOEF1EX_FC1EX_MSK 0x1F #define AK9757W_GCOEF2EX_GC2EX_POS 0x00 #define AK9757W_GCOEF2EX_GC2EX_MSK 0x3F #define AK9757W_GCOEF1EX_GC1EX_POS 0x00 #define AK9757W_GCOEF1EX_GC1EX_MSK 0x1F #define AK9757W_XCOEF2EX_GC2EX_POS 0x00 #define AK9757W_XCOEF2EX_GC2EX_MSK 0x3F #define AK9757W_XCOEF1EX_GC1EX_POS 0x00 #define AK9757W_XCOEF1EX_GC1EX_MSK 0x1F #define AK9757W_OIR_OIR_H_POS 0x00 #define AK9757W_OIR_OIR_H_MSK 0x0F #define AK9757W_OTS_OTS_H_POS 0x00 #define AK9757W_OTS_OTS_H_MSK 0x3F typedef enum _ak9757w_mode { AK9757W_MODE_STAND_BY_MODE = 0, AK9757W_MODE_CONTINUOUS_MODE = 1, }AK9757W_MODE; typedef enum _ak9757w_ir_adc_invert { AK9757W_ADC_NORMAL = 0, AK9757W_ADC_INVERT = 1, }AK9757W_IR_ADC_INVERT; typedef enum _ak9757w_step { STEP_INIT, STEP_CHECK_COMPANY, STEP_CHECK_ID_POWER_ON, STEP_CHECK_ID_POWER_ON_WAIT, STEP_CHECK_ID_READ, STEP_CHECK_ID_POWER_OFF, STEP_WRITE_CNTL1_9, STEP_ERROR, }AK9757W_STEP; typedef union { struct { uint8_t get_addr; uint8_t cntl1; uint8_t cntl2; uint8_t cntl3; uint8_t cntl4; uint8_t cntl5; uint8_t cntl6; uint8_t cntl7; uint8_t cntl8; uint8_t cntl9; }CNTL; uint8_t CNTL_Buff[10]; }CNTL_INFO; typedef struct _ak9757w_handler { bool isInitComplete; uint32_t SensorID; CNTL_INFO Cntl_Info; AK9757W_STEP Step; uint32_t TickCount; }AK9757W_HANDLER; #if 0 #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #define AK9757W_REG_ #endif #endif