Unverified Commit 84dfde1c authored by mntmn's avatar mntmn
Browse files

add XADC block and die temperature register 0xe0 (celsius x 10)

parent a9e94b00
......@@ -29,6 +29,7 @@
#include "xil_cache.h"
#include "xclk_wiz.h"
#include "xil_exception.h"
#include "xadcps.h"
#include "gfx.h"
#include "ethernet.h"
......@@ -60,6 +61,24 @@ typedef u8 uint8_t;
// I2C controller instance
XIicPs Iic;
// XADC adc converter instance
XAdcPs Xadc;
int xadc_init() {
printf("xadc_init()...");
XAdcPs_Config* cfg;
cfg = XAdcPs_LookupConfig(XPAR_XADCPS_0_DEVICE_ID);
XAdcPs_CfgInitialize(&Xadc, cfg, cfg->BaseAddress);
int status = XAdcPs_SelfTest(&Xadc);
printf("xadc_init() done: %d", status);
return status;
}
float xadc_get_temperature() {
u16 raw = XAdcPs_GetAdcData(&Xadc, XADCPS_CH_TEMP);
return XAdcPs_RawToTemperature(raw);
}
int hdmi_ctrl_write_byte(u8 addr, u8 value) {
u8 buffer[2];
buffer[0] = addr;
......@@ -889,6 +908,8 @@ int main() {
disable_reset_out();
xadc_init();
// FIXME constant
framebuffer = (u32*) 0x00200000;
int need_req_ack = 0;
......@@ -1621,6 +1642,10 @@ int main() {
}
break;
}
case REG_ZZ_TEMPERATURE: {
data = ((int16_t)(xadc_get_temperature()*10.0)) << 16;
break;
}
}
if (z3) {
......
......@@ -142,7 +142,7 @@ enum zz_reg_offsets {
REG_ZZ_USB_CAPACITY = 0xDC,
REG_ZZ_UNUSED_REGDE = 0xDE,
REG_ZZ_UNUSED_REGE0 = 0xE0,
REG_ZZ_TEMPERATURE = 0xE0,
REG_ZZ_UNUSED_REGE2 = 0xE2,
REG_ZZ_UNUSED_REGE4 = 0xE4,
REG_ZZ_UNUSED_REGE6 = 0xE6,
......
Markdown is supported
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