|
|
@ -14,10 +14,12 @@ int fputc(int ch, FILE *stream) { |
|
|
|
void Hardware::hardwareinit() { |
|
|
|
debug_light_init(); |
|
|
|
can_init(); |
|
|
|
temperature_init(); |
|
|
|
} |
|
|
|
void Hardware::periodicJob() { |
|
|
|
debug_light_periodicJob(); |
|
|
|
can_periodicJob(); |
|
|
|
temperature_periodicJob(); |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
@ -102,4 +104,49 @@ void Hardware::can_periodicJob() { |
|
|
|
can_send(m_can.tdata, 8); |
|
|
|
// 查询接收can消息,并通过UART1 打印接收到的CAN消息报文
|
|
|
|
can_receive(m_can.adata, 8); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 温度 * |
|
|
|
*******************************************************************************/ |
|
|
|
void Hardware::temperature_init() { |
|
|
|
m_temperature.tmp117[0].initializate(&hi2c1, TMP117::ID0); |
|
|
|
m_temperature.tmp117[1].initializate(&hi2c1, TMP117::ID1); |
|
|
|
m_temperature.tmp117[2].initializate(&hi2c1, TMP117::ID2); |
|
|
|
m_temperature.tmp117[3].initializate(&hi2c1, TMP117::ID3); |
|
|
|
} |
|
|
|
|
|
|
|
TMP117 *Hardware::temperature_get_tmp117(int off) { |
|
|
|
if (off < 0 || off > 3) { |
|
|
|
ZASSERT(0); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
return &m_temperature.tmp117[off]; |
|
|
|
} |
|
|
|
float Hardware::temperature_get_temp(int off) { |
|
|
|
if (off < 0 || off > 3) { |
|
|
|
ZASSERT(0); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
return m_temperature.tmp117[off].getTemperature(); |
|
|
|
} |
|
|
|
|
|
|
|
void Hardware::temperature_periodicJob() { |
|
|
|
if (testHardwareFlag) { |
|
|
|
/**
|
|
|
|
* @brief 周期打印温度 |
|
|
|
*/ |
|
|
|
static uint32_t lastcall; |
|
|
|
if (hasPassedMS(lastcall) > 1000) { |
|
|
|
lastcall = getTicket(); |
|
|
|
for (size_t i = 0; i < 4; i++) { |
|
|
|
float temp = m_temperature.tmp117[i].getTemperature(); |
|
|
|
if (m_temperature.tmp117[i].getLastCallStatus() == HAL_OK) { |
|
|
|
ZLOGI(TAG, "tmp117_%d:%f", i, temp); |
|
|
|
} else { |
|
|
|
ZLOGI(TAG, "tmp117_%d:read fail", i); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |