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

PMBus: implement the READ_POUT command

parent cfd4b63b
Branches
Tags
No related merge requests found
......@@ -17,10 +17,12 @@ const char MFR_SER[] = "123456789";
void page_chk();
uint8_t page;
void setvolt();
void setcurr();
void accvolt();
void acccurr();
void accpowr();
uint16_t curpage_volt;
uint16_t curpage_curr;
uint16_t curpage_powr;
void query_prp();
void query_cln();
......@@ -29,6 +31,7 @@ uint8_t query_r;
extern uint16_t temps[3];
extern uint16_t volts[3];
extern uint16_t currs[3];
extern uint16_t powrs[3];
extern uint32_t secondary_fw_start;
......@@ -38,11 +41,12 @@ static cmd_space_t cmds = {
N_CMDS,
(cmd_t[]){{0x00, 1, (uint8_t *)&page, (fp_t)NULL, &page_chk, (fp_t)NULL},
{0x1A, -1, (uint8_t *)&query_r, (fp_t)NULL, &query_prp, &query_cln},
{0x8B, 2, (uint8_t *)&curpage_volt, &setvolt, (fp_t)NULL, (fp_t)NULL},
{0x8C, 2, (uint8_t *)&curpage_curr, &setcurr, (fp_t)NULL, (fp_t)NULL},
{0x8B, 2, (uint8_t *)&curpage_volt, &accvolt, (fp_t)NULL, (fp_t)NULL},
{0x8C, 2, (uint8_t *)&curpage_curr, &acccurr, (fp_t)NULL, (fp_t)NULL},
{0x8D, 2, (uint8_t *)&temps[0], (fp_t)NULL, (fp_t)NULL, (fp_t)NULL},
{0x8E, 2, (uint8_t *)&temps[1], (fp_t)NULL, (fp_t)NULL, (fp_t)NULL},
{0x8F, 2, (uint8_t *)&temps[2], (fp_t)NULL, (fp_t)NULL, (fp_t)NULL},
{0x96, 2, (uint8_t *)&curpage_powr, &accpowr, (fp_t)NULL, (fp_t)NULL},
{0x99, -(int8_t)sizeof(MFR_ID), (uint8_t *)&MFR_ID, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL},
{0x9A, -(int8_t)sizeof(MFR_MDL), (uint8_t *)&MFR_MDL, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL},
{0x9B, -(int8_t)sizeof(MFR_REV), (uint8_t *)&MFR_REV, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL},
......@@ -173,18 +177,24 @@ void page_chk()
}
void setvolt()
void accvolt()
{
curpage_volt = volts[page];
}
void setcurr()
void acccurr()
{
curpage_curr = currs[page];
}
void accpowr()
{
curpage_powr = powrs[page];
}
void query_prp()
{
uint8_t query_cmd;
......
......@@ -13,6 +13,7 @@ static uint16_t iter = 0;
uint16_t temps[3];
uint16_t volts[3];
uint16_t currs[3];
uint16_t powrs[3];
static void mytimercallback(const struct timer_task *const timer_task)
{
......@@ -38,6 +39,7 @@ static void mytimercallback(const struct timer_task *const timer_task)
temps[i] = float_to_linear((adc_temps[i] - 0.6)/0.01);
volts[i] = float_to_linear(adc_volts[i]);
currs[i] = float_to_linear(adc_currs[i]);
powrs[i] = float_to_linear(adc_volts[i] * adc_currs[i]); // TODO: scale the ADC readings
}
debug("slave iter %d, temp val = %.3f (%.3f degC)", iter, adc_temps[0], (adc_temps[0] - 0.6)/0.01);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment