-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added heartbeat functionality #266
Changes from 6 commits
e6859f7
fb1b693
a8b7e53
d064f56
8a14bd5
3f726c0
05a9b02
31b424f
3fcf57c
4c99086
e05fa87
03f56cf
115e40c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ OBJECTS=isr.o \ | |
hdmi_in1.o \ | ||
hdmi_out0.o \ | ||
hdmi_out1.o \ | ||
heartbeat.o \ | ||
pattern.o \ | ||
edid.o \ | ||
pll.o \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
#include <generated/csr.h> | ||
#include <generated/mem.h> | ||
#include <hw/flags.h> | ||
#include <system.h> | ||
#include <time.h> | ||
|
||
#include "heartbeat.h" | ||
#include "processor.h" | ||
#include "hdmi_in0.h" | ||
#include "hdmi_in1.h" | ||
#include "pattern.h" | ||
|
||
static int heartbeat_status = 0; | ||
|
||
void hb_status(int val) | ||
{ | ||
if(val==1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, can't you just do void hb_status(bool new_status)
{
heartbeat_status = new_status;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was gonna be my next natural step. Corrected. |
||
heartbeat_status = 1; | ||
} | ||
else { | ||
heartbeat_status = 0; | ||
} | ||
} | ||
|
||
void hb_service(int source) | ||
{ | ||
static int last_event; | ||
static int counter; | ||
if (heartbeat_status==1) { | ||
if(elapsed(&last_event, identifier_frequency_read()/5)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your formatting here is all over the place. |
||
hb_fill(counter, source); | ||
if(counter==5) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably better to have a 1 bit counter here, pass it to hb_fill and select color in hb_fill. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good Idea. Changed counter variable to bool. |
||
counter = 6; //BLUE in color_bar[6] | ||
else | ||
counter = 5; //RED in color_bar[5] | ||
} | ||
} | ||
} | ||
|
||
void hb_fill(int color_v, int source) | ||
{ | ||
int addr, i, j; | ||
volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + pattern_framebuffer_base()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shenki What does the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
#ifdef CSR_HDMI_IN0_BASE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can probably just use hdmi_out0_fi_base0_read or hdmi_out1_fi_base0_read functions to get the framebuffer address. Not need to duplicate these #ifdef that are already in processor.c. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified this. This also fixed some irregular toggle in pattern source. And with some changes, also the hdmi_in sources. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to add the #ifdef preprocessor commands again, the firmware should compile for all possible boards, hence the travis-ci was giving errors. |
||
if (source == VIDEO_IN_HDMI_IN0) { | ||
framebuffer = (unsigned int *)(MAIN_RAM_BASE + hdmi_in0_framebuffer_base(hdmi_in0_fb_index)); | ||
} | ||
#endif | ||
#ifdef CSR_HDMI_IN1_BASE | ||
if (source == VIDEO_IN_HDMI_IN1) { | ||
framebuffer = (unsigned int *)(MAIN_RAM_BASE + hdmi_in1_framebuffer_base(hdmi_in1_fb_index)); | ||
} | ||
#endif | ||
if (source == VIDEO_IN_PATTERN) { | ||
framebuffer = (unsigned int *)(MAIN_RAM_BASE + pattern_framebuffer_base()); | ||
} | ||
/* | ||
8x8 pixel square at right bottom corner | ||
8 pixel = 4 memory locations in horizoantal | ||
8 pixel = 8 memory locations in vertical | ||
Toggles between the colors defined in color_bar array from pattern.c | ||
*/ | ||
addr = 0 + (processor_h_active/2)*(processor_v_active-8) + (processor_h_active/2) - 4; | ||
for (i=0; i<4; i++){ | ||
for (j=0; j<8; j++){ | ||
framebuffer[addr+i+(processor_h_active/2)*j] = color_bar[color_v]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not use color bar but something like that: uint32_t color;
if (counter == 0)
color = YCBCR422_BLUE;
else
color = YCBCR422_RED;
[...]
framebuffer[addr+i+(processor_h_active/2)*j] = color;
[...] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Corrected. |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef __HEARTBEAT_H | ||
#define __HEARTBEAT_H | ||
|
||
void hb_status(int val); | ||
void hb_service(int source) ; | ||
void hb_fill(int color_v, int source); | ||
|
||
#endif /* __HEARTBEAT_H */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a bool for heartbeat_status rather than an int?