Skip to content
Snippets Groups Projects
Commit a8ac461b authored by Christos Gentsos's avatar Christos Gentsos
Browse files

PMBus: add the READ_TEMPERATURE_n cmds, temp sensor -> ADC -> tmp1

parent b876cef4
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,7 @@ hal/src/hal_atomic.o \
hpl/adc/hpl_adc.o \
../../common/src/checksums.o \
../../common/src/flash_utils.o \
../../common/src/float_utils.o \
../../common/src/i2c_slave.o \
../src/i2c_impl.o
......
......@@ -18,6 +18,10 @@ void query_prp();
void query_cln();
uint8_t query_r;
extern uint16_t temp1;
extern uint16_t temp2;
extern uint16_t temp3;
extern uint32_t secondary_fw_start;
#define N_CMDS 12
......@@ -25,6 +29,9 @@ extern uint32_t secondary_fw_start;
static cmd_space_t cmds = {
N_CMDS,
(cmd_t[]){{0x1A, -1, (uint8_t *)&query_r, &query_prp, &query_cln},
{0x8D, 2, (uint8_t *)&temp1, (fp_t)NULL, (fp_t)NULL},
{0x8E, 2, (uint8_t *)&temp2, (fp_t)NULL, (fp_t)NULL},
{0x8F, 2, (uint8_t *)&temp3, (fp_t)NULL, (fp_t)NULL},
{0x99, -(int8_t)sizeof(MFR_ID), (uint8_t *)&MFR_ID, (fp_t)NULL, (fp_t)NULL},
{0x9A, -(int8_t)sizeof(MFR_MDL), (uint8_t *)&MFR_MDL, (fp_t)NULL, (fp_t)NULL},
{0x9B, -(int8_t)sizeof(MFR_REV), (uint8_t *)&MFR_REV, (fp_t)NULL, (fp_t)NULL},
......
......@@ -3,10 +3,15 @@
#include "usb_debug.h"
#include "checksums.h"
#include "flash_utils.h"
#include "float_utils.h"
#include "i2c_impl.h"
static uint16_t iter = 0;
uint16_t temp1;
uint16_t temp2;
uint16_t temp3;
static void mytimercallback(const struct timer_task *const timer_task)
{
uint16_t adc_val;
......@@ -15,6 +20,7 @@ static void mytimercallback(const struct timer_task *const timer_task)
for (int i = 0; i < 9; ++i)
adc_sync_read_channel(&ADC_0, 0, (uint8_t *)&adc_val, 2);
adc_temp = ((adc_val / 4095.0) - 0.6)/0.01;
temp1 = float_to_linear(adc_temp);
debug("slave iter %d, temp=%.1f", iter++, adc_temp);
gpio_toggle_pin_level(LED);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment