온도센서 데이터 계산중, oled 온도 표시 중

master
imbis 4 months ago
parent 0b61bb811a
commit 84bac81255

@ -29,7 +29,8 @@ void App_Log_Prinf(LOG_LEVEL level, const char *func, const char *format, ...)
if(nowLogLevel >= level) if(nowLogLevel >= level)
{ {
va_list arg; va_list arg;
fprintf(stderr, "[%d][%s] ", millis(), func); //fprintf(stderr, "[%d][%s] ", millis(), func);
fprintf(stderr, "[%d] ", millis());
va_start(arg, format); va_start(arg, format);
vfprintf(stderr, format, arg); vfprintf(stderr, format, arg);
va_end(arg); va_end(arg);

@ -8,12 +8,13 @@
#define OLED_POWER_PORT PORT_0 #define OLED_POWER_PORT PORT_0
#define OLED_POWER_PIN PIN_4 #define OLED_POWER_PIN PIN_4
#define OLED_POWER_ON Gpio_Output_Set(OLED_POWER_PORT, OLED_POWER_PIN); #define OLED_POWER_ON Gpio_Output_Clear(OLED_POWER_PORT, OLED_POWER_PIN);
#define OLED_POWER_OFF Gpio_Output_Clear(OLED_POWER_PORT, OLED_POWER_PIN); #define OLED_POWER_OFF Gpio_Output_Set(OLED_POWER_PORT, OLED_POWER_PIN);
#define OLED_POWER_T Gpio_Output_Toggle(OLED_POWER_PORT, OLED_POWER_PIN); #define OLED_POWER_T Gpio_Output_Toggle(OLED_POWER_PORT, OLED_POWER_PIN);
#define OLED_POWER_ON_OFF_WAIT_TIME 100 #define OLED_POWER_OFF_WAIT_TIME 500
#define OLED_POWER_ON_WAIT_TIME 100
#define OLED_ERROR_PRINT_INTERVAL 1000 #define OLED_ERROR_PRINT_INTERVAL 1000
#define OLED_SHOW_LOG_WAIT_TIME 1000 #define OLED_SHOW_LOG_WAIT_TIME 1000
#define OLED_SHOW_LOG_INVERSE_WAIT_TIME 1000 #define OLED_SHOW_LOG_INVERSE_WAIT_TIME 1000
@ -24,9 +25,11 @@
static OLED_STEP oled_step; static OLED_STEP oled_step;
static OLED_STEP oled_pre_step; static OLED_STEP oled_pre_step;
static uint32_t oled_tickCount; static uint32_t oled_tickCount;
uint32_t oled_shift_index; static uint32_t oled_shift_index;
uint16_t oled_draw_temp; uint16_t oled_draw_before_temp;
static uint16_t oled_draw_temp;
static bool isDrawUpdate;
static void Oled_Process(void); static void Oled_Process(void);
@ -49,7 +52,7 @@ static void Oled_Next_Step(OLED_STEP nextStep);
bool Oled_Initialization(void) bool Oled_Initialization(void)
{ {
oled_step = OLED_STEP_INIT; oled_step = OLED_STEP_INIT;
oled_pre_step = OLED_STEP_INIT; oled_pre_step = OLED_STEP_INIT;
//Gpio_Set_Port_Output(OLED_POWER_PORT, OLED_POWER_PIN, GPIO_PAD_PULL_UP); //Gpio_Set_Port_Output(OLED_POWER_PORT, OLED_POWER_PIN, GPIO_PAD_PULL_UP);
//OLED_POWER_OFF; //OLED_POWER_OFF;
@ -75,7 +78,7 @@ static void Oled_Process(void)
break; break;
case OLED_STEP_POWER_OFF_WAIT: case OLED_STEP_POWER_OFF_WAIT:
if((millis() - oled_tickCount) >= OLED_POWER_ON_OFF_WAIT_TIME) if((millis() - oled_tickCount) >= OLED_POWER_OFF_WAIT_TIME)
{ {
Oled_Next_Step(OLED_STEP_POWER_ON); Oled_Next_Step(OLED_STEP_POWER_ON);
} }
@ -86,7 +89,7 @@ static void Oled_Process(void)
Oled_Next_Step(OLED_STEP_POWER_ON_WAIT); Oled_Next_Step(OLED_STEP_POWER_ON_WAIT);
break; break;
case OLED_STEP_POWER_ON_WAIT: case OLED_STEP_POWER_ON_WAIT:
if((millis() - oled_tickCount) >= OLED_POWER_ON_OFF_WAIT_TIME) if((millis() - oled_tickCount) >= OLED_POWER_ON_WAIT_TIME)
{ {
Oled_Next_Step(OLED_STEP_SET_INIT); Oled_Next_Step(OLED_STEP_SET_INIT);
} }
@ -154,16 +157,30 @@ static void Oled_Process(void)
SSD1306_Draw_Temperature(oled_draw_temp); SSD1306_Draw_Temperature(oled_draw_temp);
SSD1306_UpdateScreen (SSD1306_ADDR); SSD1306_UpdateScreen (SSD1306_ADDR);
oled_tickCount = millis(); oled_tickCount = millis();
oled_draw_temp = 0;
isDrawUpdate = true;
Oled_Next_Step(OLED_STEP_DRAW_TEMP); Oled_Next_Step(OLED_STEP_DRAW_TEMP);
break; break;
case OLED_STEP_DRAW_TEMP: case OLED_STEP_DRAW_TEMP:
if(isDrawUpdate == true)
{
isDrawUpdate = false;
SSD1306_Draw_Temperature(oled_draw_temp);
SSD1306_UpdateScreen (SSD1306_ADDR);
}
#if 0
if((millis() - oled_tickCount) >= OLED_UPDATE_TEMP_INTERVAL) if((millis() - oled_tickCount) >= OLED_UPDATE_TEMP_INTERVAL)
{ {
oled_tickCount = millis(); oled_tickCount = millis();
SSD1306_Draw_Temperature(oled_draw_temp); SSD1306_Draw_Temperature(oled_draw_temp);
SSD1306_UpdateScreen (SSD1306_ADDR); SSD1306_UpdateScreen (SSD1306_ADDR);
} }
#endif
break; break;
@ -186,6 +203,18 @@ static void Oled_Next_Step(OLED_STEP nextStep)
oled_step = nextStep; oled_step = nextStep;
} }
bool Oled_SetTemperature(uint16_t Temperature)
{
if(oled_step == OLED_STEP_DRAW_TEMP)
{
if(oled_draw_temp != Temperature)
{
isDrawUpdate = true;
oled_draw_temp = Temperature;
}
}
}

@ -33,6 +33,7 @@ typedef enum
bool Oled_Initialization(void); bool Oled_Initialization(void);
bool Oled_SetTemperature(uint16_t Temperature);

@ -38,19 +38,16 @@ bool App_Gpio_I2C_Read(uint8_t Address, uint8_t* pReadData, uint32_t RxSize);
int main(void) int main(void)
{ {
uint8_t i;
bool isAck;
ICC_Enable(); ICC_Enable();
SystemCoreClockSet(HIRC_96MHZ); SystemCoreClockSet(HIRC_96MHZ);
App_Uart_Initialization();
App_Uart_Initialization();
Gpio_Port_Initialization(); Gpio_Port_Initialization();
App_Gpio_I2C_Initialization(200000); App_Gpio_I2C_Initialization(200000);
I2C_Master_Initialization(TEMP_I2C_INSTANCE, I2C_FAST_MODE); I2C_Master_Initialization(TEMP_I2C_INSTANCE, I2C_FAST_MODE);
App_Led_Initialization(); App_Led_Initialization();
App_CLI_Initialization(); App_CLI_Initialization();
Oled_Initialization(); Oled_Initialization();
AK9757W_Initialization();
__enable_irq(); __enable_irq();
App_Led_OutputSet(APP_LED_1, APP_LED_MODE_TOGGLE, 100, 900); App_Led_OutputSet(APP_LED_1, APP_LED_MODE_TOGGLE, 100, 900);
@ -60,9 +57,9 @@ int main(void)
COMPLETE:
AK9757W_Initialization();
while(1) while(1)
{ {

@ -3,11 +3,13 @@
#include "app_i2c_master.h" #include "app_i2c_master.h"
#include "app_log.h" #include "app_log.h"
#include "sw_timer.h" #include "sw_timer.h"
#include "app_oled.h"
#define AK9757W_CHIPID_READ_WAIT_TIME 100
#define AK9757W_ERROR_PRINT_INTERVAL 1000 #define AK9757W_ERROR_PRINT_INTERVAL 1000
#define AK9757W_MEASUREMENT_INTERVAL 1000
@ -28,14 +30,18 @@ const uint8_t default_gir_oir_gts_ots_git_reg_data[] = {0x53, 0xE0, 0x94, 0x12,
static bool AK9757W_Check_CompanyCode(void); static bool AK9757W_Check_CompanyCode(void);
static bool AK9757W_Set_Operation_Mode(AK9757W_MODE mode); static bool AK9757W_Set_Operation_Mode(AK9757W_MODE mode);
static bool AK9757W_Set_ADC_Inverter(AK9757W_MODE mode); static bool AK9757W_Set_ADC_Inverter(AK9757W_MODE mode);
static bool AK9757W_Set_CNTL1_9_Parameter(void); static bool AK9757W_Set_CNTL1_9_Parameter(void);
static bool AK9757W_Set_FCOEF4_0_Parameter(void); static bool AK9757W_Set_FCOEF4_0_Parameter(void);
static bool AK9757W_Set_GCOEF4_0_Parameter(void); static bool AK9757W_Set_GCOEF4_0_Parameter(void);
static bool AK9757W_Set_XCOEF4_0_Parameter(void); static bool AK9757W_Set_XCOEF4_0_Parameter(void);
static bool AK9757W_Set_IR_TS_IT_Parameter(void); static bool AK9757W_Set_IR_TS_IT_Parameter(void);
static bool AK9757W_Calc_Parameter(void);
static bool AK9757W_Read_RawData(void);
static bool AK9757W_Process(void); static bool AK9757W_Process(void);
static void AK9757W_Next_Step(AK9757W_STEP nextStep); static void AK9757W_Next_Step(AK9757W_STEP nextStep);
static int16_t AK9757W_14BitTo16Bit(uint16_t Data);
static int16_t AK9757W_12BitTo16Bit(uint16_t Data);
static int8_t AK9757W_6BitTo8it(uint8_t Data);
@ -48,33 +54,10 @@ bool AK9757W_Initialization(void)
AK9757W_Handler.PreStep = STEP_INIT; AK9757W_Handler.PreStep = STEP_INIT;
AK9757W_Handler.Step = STEP_INIT; AK9757W_Handler.Step = STEP_INIT;
AK9757W_Handler.isMeasurementStart = true;
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1, AK9757W_Process); SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1, AK9757W_Process);
return true; return true;
#if 0
if(AK9757W_Check_CompanyCode() == false)
{
return false;
}
if(AK9757_Set_Mode(AK9757W_MODE_CONTINUOUS_MODE) == false)
{
return false;
}
Delay_ms(200);
if(AK9757_Get_SensorID() == false)
{
return false;
}
AK9757W_Handler.isInitComplete = true;
#endif
} }
@ -163,8 +146,43 @@ static bool AK9757W_Process(void)
AK9757W_Next_Step(STEP_ERROR); AK9757W_Next_Step(STEP_ERROR);
} }
else{ else{
AK9757W_Next_Step(STEP_CALC_PARAMETER);
}
break;
case STEP_CALC_PARAMETER:
AK9757W_Calc_Parameter();
AK9757W_Next_Step(STEP_WAIT_START);
break;
case STEP_WAIT_START:
if(pHandler->isMeasurementStart == true)
AK9757W_Next_Step(STEP_MEASUREMENT_START);
break;
case STEP_MEASUREMENT_START:
if(AK9757W_Set_Mode(AK9757W_MODE_CONTINUOUS_MODE) == false){
AK9757W_Next_Step(STEP_ERROR); AK9757W_Next_Step(STEP_ERROR);
} }
else{
pHandler->TickCount = millis();
AK9757W_Next_Step(STEP_MEASUREMENT);
}
break;
case STEP_MEASUREMENT:
if((millis() - pHandler->TickCount) >= AK9757W_MEASUREMENT_INTERVAL)
{
pHandler->TickCount = millis();
AK9757W_Read_RawData();
}
break;
case STEP_WAIT_STOP:
if(AK9757W_Set_Mode(AK9757W_MODE_STAND_BY_MODE) == false){
AK9757W_Next_Step(STEP_ERROR);
}
else{
pHandler->isMeasurementStart = false;
AK9757W_Next_Step(STEP_CALC_PARAMETER);
}
break; break;
@ -347,11 +365,204 @@ static bool AK9757W_Set_IR_TS_IT_Parameter(void)
} }
static bool AK9757W_Calc_Parameter(void)
{
int error;
uint8_t uint8_TempValue;
int8_t int8_TempValue;
uint16_t uint16_TempValue;
int16_t int16_TempValue;
uint8_t TxData;
uint8_t* pRxBuff;
TxData = AK9757W_REG_PARAMETER;
pRxBuff = &pHandler->IR_TS_IT_Info.IR_TS_IT_Buff[0];
error = I2C_Master_WriteRead(TEMP_I2C_ADDRESS, &TxData, 1, pRxBuff, 9);
if(error != E_NO_ERROR)
return false;
TxData = AK9757W_REG_RW_FCOEF4L;
pRxBuff = &pHandler->Fcoef_Info.FCOEF_Buff[0];
error = I2C_Master_WriteRead(TEMP_I2C_ADDRESS, &TxData, 1, pRxBuff, 14);
if(error != E_NO_ERROR)
return false;
TxData = AK9757W_REG_RW_GCOEF4L;
pRxBuff = &pHandler->Gcoef_Info.GCOEF_Buff[0];
error = I2C_Master_WriteRead(TEMP_I2C_ADDRESS, &TxData, 1, pRxBuff, 14);
if(error != E_NO_ERROR)
return false;
TxData = AK9757W_REG_RW_XCOEF4L;
pRxBuff = &pHandler->Xcoef_Info.XCOEF_Buff[0];
error = I2C_Master_WriteRead(TEMP_I2C_ADDRESS, &TxData, 1, pRxBuff, 14);
if(error != E_NO_ERROR)
return false;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pHandler->calc_gts = ((double)((int8_t)pHandler->IR_TS_IT_Info.IR_TS_IT.gts) * (double)TWO_POW_M10);
uint16_TempValue = (uint16_t)(pHandler->IR_TS_IT_Info.IR_TS_IT.ots_h << 8) | (uint16_t)pHandler->IR_TS_IT_Info.IR_TS_IT.ots_l;
pHandler->calc_ots = AK9757W_14BitTo16Bit(uint16_TempValue);
pHandler->calc_git = (double)((double)((int8_t)pHandler->IR_TS_IT_Info.IR_TS_IT.git) * (double)TWO_POW_M23);
uint16_TempValue = (uint16_t)(pHandler->IR_TS_IT_Info.IR_TS_IT.gir_h << 8) | pHandler->IR_TS_IT_Info.IR_TS_IT.gir_l;
pHandler->calc_gir = (double)((double)uint16_TempValue* (double)TWO_POW_M14);
uint16_TempValue = (uint16_t)(pHandler->IR_TS_IT_Info.IR_TS_IT.oir_h << 8) | pHandler->IR_TS_IT_Info.IR_TS_IT.oir_l;
pHandler->calc_oir = AK9757W_12BitTo16Bit(uint16_TempValue);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int16_TempValue = (pHandler->Fcoef_Info.FCOEF.fcoef4_h << 8) | pHandler->Fcoef_Info.FCOEF.fcoef4_l;
uint8_TempValue = pHandler->Fcoef_Info.FCOEF.fcoef4_ex;
pHandler->calc_FC4 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Fcoef_Info.FCOEF.fcoef3_h << 8) | pHandler->Fcoef_Info.FCOEF.fcoef3_l;
uint8_TempValue = pHandler->Fcoef_Info.FCOEF.fcoef3_ex;
pHandler->calc_FC3 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Fcoef_Info.FCOEF.fcoef2_h << 8) | pHandler->Fcoef_Info.FCOEF.fcoef2_l;
uint8_TempValue = pHandler->Fcoef_Info.FCOEF.fcoef2_ex & 0x3F;
pHandler->calc_FC2 = (double)int16_TempValue * pow(2, ((14+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Fcoef_Info.FCOEF.fcoef1_h << 8) | pHandler->Fcoef_Info.FCOEF.fcoef1_l;
uint8_TempValue = pHandler->Fcoef_Info.FCOEF.fcoef1_ex & 0x1F;
pHandler->calc_FC1 = (double)int16_TempValue * pow(2, ((14+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Fcoef_Info.FCOEF.fcoef0_h << 8) | pHandler->Fcoef_Info.FCOEF.fcoef0_l;
pHandler->calc_FC0 = (double)int16_TempValue;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int16_TempValue = (pHandler->Gcoef_Info.GCOEF.gcoef4_h << 8) | pHandler->Gcoef_Info.GCOEF.gcoef4_l;
uint8_TempValue = pHandler->Gcoef_Info.GCOEF.gcoef4_ex;
pHandler->calc_GC4 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Gcoef_Info.GCOEF.gcoef3_h << 8) | pHandler->Gcoef_Info.GCOEF.gcoef3_l;
uint8_TempValue = pHandler->Gcoef_Info.GCOEF.gcoef3_ex;
pHandler->calc_GC3 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Gcoef_Info.GCOEF.gcoef2_h << 8) | pHandler->Gcoef_Info.GCOEF.gcoef2_l;
uint8_TempValue = pHandler->Gcoef_Info.GCOEF.gcoef2_ex & 0x3F;
pHandler->calc_GC2 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Gcoef_Info.GCOEF.gcoef1_h << 8) | pHandler->Gcoef_Info.GCOEF.gcoef1_l;
uint8_TempValue = pHandler->Gcoef_Info.GCOEF.gcoef1_ex & 0x1F;
pHandler->calc_GC1 = (double)int16_TempValue * pow(2, ((14+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Gcoef_Info.GCOEF.gcoef0_h << 8) | pHandler->Gcoef_Info.GCOEF.gcoef0_l;
pHandler->calc_GC0 = (double)int16_TempValue * TWO_POW_M14;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int16_TempValue = (pHandler->Xcoef_Info.XCOEF.xcoef4_h << 8) | pHandler->Xcoef_Info.XCOEF.xcoef4_l;
uint8_TempValue = pHandler->Xcoef_Info.XCOEF.xcoef4_ex;
pHandler->calc_XC4 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Xcoef_Info.XCOEF.xcoef3_h << 8) | pHandler->Xcoef_Info.XCOEF.xcoef3_l;
uint8_TempValue = pHandler->Xcoef_Info.XCOEF.xcoef3_ex;
pHandler->calc_XC3 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Xcoef_Info.XCOEF.xcoef2_h << 8) | pHandler->Xcoef_Info.XCOEF.xcoef2_l;
uint8_TempValue = pHandler->Xcoef_Info.XCOEF.xcoef2_ex & 0x3F;
pHandler->calc_XC2 = (double)int16_TempValue * pow(2, ((15+uint8_TempValue) * -1));
int16_TempValue = (pHandler->Xcoef_Info.XCOEF.xcoef1_h << 8) | pHandler->Xcoef_Info.XCOEF.xcoef1_l;
uint8_TempValue = pHandler->Xcoef_Info.XCOEF.xcoef1_ex & 0x1F;
pHandler->calc_XC1 = (double)int16_TempValue * pow(2, ((14+uint8_TempValue) * -1));
uint16_TempValue = (pHandler->Xcoef_Info.XCOEF.xcoef0_h << 8) | pHandler->Xcoef_Info.XCOEF.xcoef0_l;
pHandler->calc_XC0 = (double)uint16_TempValue * TWO_POW_M10;
}
static bool AK9757W_Read_RawData(void)
{
int error;
uint8_t TxData = AK9757W_REG_RO_STATUS;
uint8_t RxBuff[7];
uint16_t uint16_TempValue;
int16_t int16_TempValue;
uint16_t ToutTemp;
error = I2C_Master_WriteRead(TEMP_I2C_ADDRESS, &TxData, 1, &RxBuff[0], 7);
if(error != E_NO_ERROR)
{
dbg_printf(LOG_LEVEL_DEBUG, "I2C W/R Error %d\r\n", error);
return false;
}
pHandler->RAWDATA.Status.Status = RxBuff[0];
pHandler->RAWDATA.RAW_TO = (RxBuff[2] << 8) | RxBuff[1];
pHandler->RAWDATA.RAW_TS = RxBuff[4] << 8 | RxBuff[3];
pHandler->RAWDATA.RAW_IR = RxBuff[6] << 8 | RxBuff[5];
dbg_printf(LOG_LEVEL_DEBUG, "s = %x, to=%d, ts=%d,ir=%d\r\n", RxBuff[0], pHandler->RAWDATA.RAW_TO, pHandler->RAWDATA.RAW_TS, pHandler->RAWDATA.RAW_IR);
Oled_SetTemperature(pHandler->RAWDATA.RAW_TO/10);
return true;
}
static int16_t AK9757W_14BitTo16Bit(uint16_t Data)
{
int16_t RetData = 0;
Data &= 0x3FFF;
if(Data & 0x2000)
Data |= 0xC000;
RetData |= Data;
return RetData;
}
static int16_t AK9757W_12BitTo16Bit(uint16_t Data)
{
int16_t RetData = 0;
Data &= 0x0FFF;
if(Data & 0x0800)
Data |= 0xF000;
RetData |= Data;
return RetData;
}
static int8_t AK9757W_6BitTo8it(uint8_t Data)
{
int8_t RetData = 0;
Data &= 0x3F;
if(Data & 0x20)
Data |= 0xC0;
RetData |= Data;
}
@ -402,4 +613,14 @@ static void AK9757W_Next_Step(AK9757W_STEP nextStep)
{ {
AK9757W_Handler.PreStep = AK9757W_Handler.Step; AK9757W_Handler.PreStep = AK9757W_Handler.Step;
AK9757W_Handler.Step = nextStep; AK9757W_Handler.Step = nextStep;
}
bool AK9757W_Start_Stop(bool isStartStop)
{
} }

@ -5,19 +5,9 @@
#include "board_config.h" #include "board_config.h"
#include "ak9757w_def.h" #include "ak9757w_def.h"
#define AK9757W_CHIPID_READ_WAIT_TIME 100
bool AK9757W_Initialization(void);
bool AK9757W_Initialization(void);
bool AK9757W_Start_Stop(bool isStartStop);
bool AK9757_Get_SensorID(void);
bool AK9757_Set_Mode(AK9757W_MODE mode);
bool AK9757_Set_AD_OutputDataTyte(AK9757W_IR_ADC_INVERT type);
#endif #endif

@ -95,18 +95,16 @@
#define AK9757W_REG_RW_XCOEF0L 0x51 // 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_XCOEF0H 0x52 // Calculation coefficient setting
#define AK9757W_REG_PARAMETER 0x53 // Correction parameter read address
#define AK9757W_REG_RW_GIRL 0x54 // IR gain Correction parameter 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_GIRH 0x55 // IR gain Correction parameter setting
#define AK9757W_REG_RW_OIRL 0x56 // IR offset 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_OIRH 0x57 // IR offset Correction parameter setting
#define AK9757W_REG_RW_GTS 0x58 // TS Gain 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_OTSL 0x59 // TS offset Correction parameter setting
#define AK9757W_REG_RW_OTSH 0x5A // 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_RW_GIT 0x5B // Temperature dependent ingredient of IR gain setting
#define AK9757W_REG_RO_CHIPID 0x5C // Chip ID #define AK9757W_REG_RO_CHIPID 0x5C // Chip ID
@ -187,7 +185,7 @@
#define TWO_POW_M10 0.000976562500000 #define TWO_POW_M10 0.000976562500000
#define TWO_POW_M23 0.000000119209290 #define TWO_POW_M23 0.000000119209290
#define TWO_POW_M13 0.000061035156250 #define TWO_POW_M14 0.000061035156250
@ -219,6 +217,15 @@ typedef enum _ak9757w_step
STEP_WRITE_GCOEF4_0, STEP_WRITE_GCOEF4_0,
STEP_WRITE_XCOEF4_0, STEP_WRITE_XCOEF4_0,
STEP_WRITE_IR_TS_IT, STEP_WRITE_IR_TS_IT,
STEP_CALC_PARAMETER,
STEP_WAIT_START,
STEP_MEASUREMENT_START,
STEP_WAIT_STOP,
STEP_MEASUREMENT,
STEP_WRITE_WAIT, STEP_WRITE_WAIT,
STEP_ERROR, STEP_ERROR,
@ -324,53 +331,27 @@ typedef union
uint8_t ots_l; uint8_t ots_l;
uint8_t ots_h; uint8_t ots_h;
uint8_t git; uint8_t git;
}XCOEF; }IR_TS_IT;
uint8_t IR_TS_IT_Buff[9]; uint8_t IR_TS_IT_Buff[9];
}IR_TS_IT_INFO; }IR_TS_IT_INFO;
#pragma pack(push, 1) typedef union
typedef struct
{ {
uint16_t FCOEF0; struct
uint16_t FCOEF1; {
uint8_t FCOEF1_Ex; uint8_t DRDY : 1;
uint16_t FCOEF2; uint8_t BFULL : 1;
uint8_t FCOEF2_Ex; uint8_t THL : 1;
uint16_t FCOEF3; uint8_t THH : 1;
uint8_t FCOEF3_Ex; uint8_t OVF : 1;
uint16_t FCOEF4; uint8_t Reserved : 3;
uint8_t FCOEF4_Ex; }Status_Bit;
uint8_t Status;
}AK9757W_STATUS;
uint16_t GCOEF0;
uint16_t GCOEF1;
uint8_t GCOEF1_Ex;
uint16_t GCOEF2;
uint8_t GCOEF2_Ex;
uint16_t GCOEF3;
uint8_t GCOEF3_Ex;
uint16_t GCOEF4;
uint8_t GCOEF4_Ex;
uint16_t XCOEF0;
uint16_t XCOEF1;
uint8_t XCOEF1_Ex;
uint16_t XCOEF2;
uint8_t XCOEF2_Ex;
uint16_t XCOEF3;
uint8_t XCOEF3_Ex;
uint16_t XCOEF4;
uint8_t XCOEF4_Ex;
uint8_t Reserved;
uint16_t GIR;
uint16_t OIR;
uint8_t GTS;
uint16_t OTS;
uint8_t GIT;
}TEMP_CAL_PARAMETER;
#pragma pack(pop)
typedef struct _ak9757w_handler typedef struct _ak9757w_handler
{ {
@ -381,8 +362,7 @@ typedef struct _ak9757w_handler
FCOEF_INFO Fcoef_Info; FCOEF_INFO Fcoef_Info;
GCOEF_INFO Gcoef_Info; GCOEF_INFO Gcoef_Info;
XCOEF_INFO Xcoef_Info; XCOEF_INFO Xcoef_Info;
IR_TS_IT_INFO IR_TS_IT_Info; IR_TS_IT_INFO IR_TS_IT_Info;
TEMP_CAL_PARAMETER Calculation_Parameter;
AK9757W_STEP PreStep; AK9757W_STEP PreStep;
AK9757W_STEP Step; AK9757W_STEP Step;
@ -390,10 +370,48 @@ typedef struct _ak9757w_handler
uint32_t TickCount; uint32_t TickCount;
double TS; double calc_gts;
double GIR; int16_t calc_ots;
double IR; double calc_git;
double calc_gir;
int16_t calc_oir;
struct
{
AK9757W_STATUS Status;
int16_t RAW_IR;
int16_t RAW_TS;
uint16_t RAW_TO;
}RAWDATA;
double calc_TS;
double calc_GIR;
double calc_IR;
double calc_FC4;
double calc_FC3;
double calc_FC2;
double calc_FC1;
double calc_FC0;
double calc_GC4;
double calc_GC3;
double calc_GC2;
double calc_GC1;
double calc_GC0;
double calc_XC4;
double calc_XC3;
double calc_XC2;
double calc_XC1;
double calc_XC0;
bool isMeasurementStart;
}AK9757W_HANDLER; }AK9757W_HANDLER;

File diff suppressed because one or more lines are too long

@ -152,41 +152,25 @@
<Bp> <Bp>
<Number>0</Number> <Number>0</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>327</LineNumber> <LineNumber>379</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>19268</Address> <Address>3906</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject> <SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess> <BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount> <BreakIfRCount>1</BreakIfRCount>
<Filename>..\Application\app_cli.c</Filename> <Filename>..\Application\sensor\ak9757w.c</Filename>
<ExecCommand></ExecCommand> <ExecCommand></ExecCommand>
<Expression>\\AKM_Temperature_Demo\../Application/app_cli.c\327</Expression> <Expression>\\AKM_Temperature_Demo\../Application/sensor/ak9757w.c\379</Expression>
</Bp> </Bp>
<Bp> <Bp>
<Number>1</Number> <Number>1</Number>
<Type>0</Type> <Type>0</Type>
<LineNumber>82</LineNumber> <LineNumber>487</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>9864</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Application\app_oled.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\AKM_Temperature_Demo\../Application/app_oled.c\82</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>283</LineNumber>
<EnabledFlag>1</EnabledFlag> <EnabledFlag>1</EnabledFlag>
<Address>4496</Address> <Address>5548</Address>
<ByteObject>0</ByteObject> <ByteObject>0</ByteObject>
<HtxType>0</HtxType> <HtxType>0</HtxType>
<ManyObjects>0</ManyObjects> <ManyObjects>0</ManyObjects>
@ -195,24 +179,24 @@
<BreakIfRCount>1</BreakIfRCount> <BreakIfRCount>1</BreakIfRCount>
<Filename>..\Application\sensor\ak9757w.c</Filename> <Filename>..\Application\sensor\ak9757w.c</Filename>
<ExecCommand></ExecCommand> <ExecCommand></ExecCommand>
<Expression>\\AKM_Temperature_Demo\../Application/sensor/ak9757w.c\283</Expression> <Expression>\\AKM_Temperature_Demo\../Application/sensor/ak9757w.c\487</Expression>
</Bp> </Bp>
</Breakpoint> </Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>pHandler</ItemText> <ItemText>RxBuff</ItemText>
</Ww> </Ww>
<Ww> <Ww>
<count>1</count> <count>1</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>default_cntl_reg_data</ItemText> <ItemText>ToutTemp,0x0A</ItemText>
</Ww> </Ww>
<Ww> <Ww>
<count>2</count> <count>2</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>RxBuff</ItemText> <ItemText>pHandler</ItemText>
</Ww> </Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow1> <MemoryWindow1>

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save